LangChain Integration
The langchain-dakera package provides drop-in LangChain components backed by Dakera — persistent agent memory and server-side RAG with no local embedding model.
Quick Start
pip install langchain-dakera
Requires Python ≥ 3.10 and a running Dakera server.
from langchain_dakera import DakeraMemory, DakeraVectorStore
# Persistent conversation memory
memory = DakeraMemory(
api_url="http://localhost:3300",
api_key="dk-mykey",
agent_id="my-agent",
)
# RAG vector store — server handles embedding
vectorstore = DakeraVectorStore(
api_url="http://localhost:3300",
api_key="dk-mykey",
namespace="my-docs",
)
Features
- DakeraMemory —
BaseMemoryimplementation with semantic recall - DakeraVectorStore —
VectorStorefor RAG (server-side embeddings) - DakeraSessionManager — conversation session lifecycle
- DakeraKnowledgeGraph — entity-relationship graph operations
- DakeraEntityExtractor — automatic entity extraction from text
- DakeraNamespaceManager — multi-tenant namespace isolation
- DakeraAgentTools — LangChain tools wrapping Dakera operations
Examples
Conversation chain with persistent memory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI
from langchain_dakera import DakeraMemory
memory = DakeraMemory(
api_url="http://localhost:3300",
api_key="dk-mykey",
agent_id="chat-agent",
recall_k=5,
importance=0.7,
)
chain = ConversationChain(
llm=ChatOpenAI(model="gpt-4o"),
memory=memory,
)
response = chain.predict(input="My name is Alice and I'm building a chatbot.")
# Later session — memory persists across restarts
response = chain.predict(input="What was I building?")
# "You mentioned you were building a chatbot."
RAG with server-side embeddings
from langchain.chains import RetrievalQA
from langchain_openai import ChatOpenAI
from langchain_dakera import DakeraVectorStore
vectorstore = DakeraVectorStore(
api_url="http://localhost:3300",
api_key="dk-mykey",
namespace="my-docs",
)
qa_chain = RetrievalQA.from_chain_type(
llm=ChatOpenAI(model="gpt-4o"),
retriever=vectorstore.as_retriever(search_kwargs={"k": 4}),
)
answer = qa_chain.run("How does Dakera handle memory decay?")
Document indexing
from langchain_community.document_loaders import DirectoryLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_dakera import DakeraVectorStore
loader = DirectoryLoader("./docs", glob="**/*.md")
docs = loader.load()
splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50)
chunks = splitter.split_documents(docs)
vectorstore = DakeraVectorStore(
api_url="http://localhost:3300",
api_key="dk-mykey",
namespace="my-docs",
)
vectorstore.add_documents(chunks)
API Reference
DakeraMemory options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_url | str | — | Dakera server URL |
api_key | str | "" | API key |
agent_id | str | — | Agent identifier for memory namespacing |
recall_k | int | 5 | Memories to surface per turn |
min_importance | float | 0.0 | Minimum importance threshold |
importance | float | 0.7 | Importance assigned to stored memories |
memory_key | str | "history" | Key injected into the prompt |
input_key | str | first key | Input key used as recall query |
DakeraVectorStore options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_url | str | — | Dakera server URL |
api_key | str | "" | API key |
namespace | str | — | Vector namespace to read/write |
embedding_model | str | namespace default | Server-side embedding model override |
Configuration
export DAKERA_API_URL=http://localhost:3300
export DAKERA_API_KEY=dk-your-key
Both DakeraMemory and DakeraVectorStore read from these environment variables when api_url and api_key are not passed explicitly.