Documentation Index
Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
Use this file to discover all available pages before exploring further.
Install
pip install maximem-synap-langchain
What’s included
synap-langchain provides four drop-in components:
| Class | Purpose |
|---|
SynapChatMessageHistory | Persistent chat history via BaseChatMessageHistory |
SynapCallbackHandler | Auto-records every LLM turn via LangChain callbacks |
SynapRetriever | Semantic retriever that returns Synap memories as Document objects |
SynapSearchTool, SynapStoreTool | Agent-callable tools for explicit memory read/write |
SynapChatMessageHistory
Plug into RunnableWithMessageHistory to give any chain persistent memory across sessions.
from langchain_core.runnables.history import RunnableWithMessageHistory
from synap_langchain import SynapChatMessageHistory
def get_history(session_id: str):
return SynapChatMessageHistory(
sdk=sdk,
conversation_id=session_id,
user_id="alice",
customer_id="acme", # optional
)
chain_with_history = RunnableWithMessageHistory(
base_chain,
get_session_history=get_history,
)
response = await chain_with_history.ainvoke(
{"question": "What did we discuss last time?"},
config={"configurable": {"session_id": "conv-123"}},
)
SynapCallbackHandler
Attach to any chain or agent to automatically ingest every conversation turn without changing your application logic.
from synap_langchain import SynapCallbackHandler
handler = SynapCallbackHandler(
sdk=sdk,
conversation_id="conv-123",
user_id="alice",
)
response = await chain.ainvoke(
{"question": "Remind me of my project deadlines."},
config={"callbacks": [handler]},
)
Failures during ingestion are logged at ERROR level and do not raise — your chain always completes.
SynapRetriever
Use as a standard LangChain retriever in RAG pipelines or ConversationalRetrievalChain.
from synap_langchain import SynapRetriever
retriever = SynapRetriever(
sdk=sdk,
user_id="alice",
customer_id="acme",
max_results=8,
mode="fast", # or "accurate"
)
docs = await retriever.aget_relevant_documents("project deadlines")
# Each doc: page_content = memory text, metadata = {"confidence": 0.92, "type": "fact", ...}
Give agents explicit control over memory read and write.
from langchain.agents import AgentExecutor, create_tool_calling_agent
from synap_langchain import SynapSearchTool, SynapStoreTool
tools = [
SynapSearchTool(sdk=sdk, user_id="alice", customer_id="acme"),
SynapStoreTool(sdk=sdk, user_id="alice", customer_id="acme"),
]
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
Next steps
LangGraph
Checkpointer and store for LangGraph state graphs.
SDK Ingestion
Direct ingestion API for custom pipelines.