LangChain integration
langchain-dakera (0.3.0) connects LangChain applications in Python to a Dakera server: DakeraMemory stores and recalls conversation turns as agent memories, and DakeraVectorStore is a LangChain vector store whose embeddings are computed by the server, so no local embedding model is needed. This page is for Python developers adding Dakera to a LangChain project.
Quick start
pip install langchain-dakera
Requires Python ≥ 3.10, dakera>=0.13.1 (installed automatically) and a running Dakera server. Works with Dakera server v0.12.0 and v0.11.108.
from langchain_dakera import DakeraMemory, DakeraVectorStore
# Persistent conversation memory
memory = DakeraMemory(
api_url="http://localhost:3000",
api_key="dk-mykey",
agent_id="my-agent",
)
# RAG vector store — server handles embedding
vectorstore = DakeraVectorStore(
api_url="http://localhost:3000",
api_key="dk-mykey",
namespace="my-docs",
)
Features
- DakeraMemory — conversation memory with semantic recall (
load_memory_variables/save_context); a LangChainBaseMemorywhenlangchain-core0.x is installed - 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 memory
from langchain_dakera import DakeraMemory
memory = DakeraMemory(
api_url="http://localhost:3000",
api_key="dk-mykey",
agent_id="chat-agent",
recall_k=5,
importance=0.7,
)
# Store a turn (saved as "Human: …\nAI: …")
memory.save_context(
{"input": "My name is Alice and I'm building a chatbot."},
{"output": "Nice to meet you, Alice."},
)
# Later, even after a restart: recall what is relevant to the new input
context = memory.load_memory_variables({"input": "What was I building?"})
print(context["history"])
DakeraMemory subclasses langchain_core.memory.BaseMemory, which exists in langchain-core 0.x only. With langchain-core 0.x you can pass it as memory= to a legacy chain such as ConversationChain; with 1.x, call load_memory_variables and save_context yourself as above.
Retrieval with server-side embeddings
from langchain_dakera import DakeraVectorStore
vectorstore = DakeraVectorStore(
api_url="http://localhost:3000",
api_key="dk-mykey",
namespace="my-docs",
)
retriever = vectorstore.as_retriever(search_kwargs={"k": 4})
docs = retriever.invoke("How does Dakera handle memory decay?")
# Pass docs to your LLM prompt; each Document carries score and id in metadata
Document indexing
from langchain_community.document_loaders import DirectoryLoader
from langchain_text_splitters 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:3000",
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 |
memory_type | str | "episodic" | Type of stored memories |
tags | list[str] | [] | Tags added to stored memories |
ttl_seconds | int | None | TTL of stored memories |
session_id | str | None | Session to store memories under |
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 | None | Accepted but not used in 0.3.0: the server embeds with the namespace's model |
Configuration
The package does not read environment variables. To keep the URL and key out of source code, read them yourself:
import os
from langchain_dakera import DakeraMemory
memory = DakeraMemory(
api_url=os.environ["DAKERA_API_URL"],
api_key=os.environ.get("DAKERA_API_KEY", ""),
agent_id="my-agent",
)
Links
LangChain + Dakera in production
Persistent agent memory and server-side retrieval for LangChain, with recall, importance-weighted decay and the knowledge graph running on your own Dakera server.
Other Python integrations: CrewAI · LlamaIndex · AutoGen · LangChain.js (TypeScript)