MenteDB integration for LangChain and LangGraph
Project description
mentedb-langchain
MenteDB integration for LangChain and LangGraph. Gives your agents persistent, cognitive memory that goes beyond simple vector retrieval.
Installation
pip install mentedb-langchain
Components
MenteDBMemory
A LangChain compatible memory backend that stores conversation context in MenteDB. Unlike buffer or summary memory, MenteDBMemory uses hybrid search (vector similarity, tag filtering, temporal decay) to assemble the most relevant context for each turn.
from mentedb_langchain import MenteDBMemory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI
memory = MenteDBMemory(
data_dir="./agent-memory",
agent_id="my-agent",
token_budget=4096,
)
chain = ConversationChain(
llm=ChatOpenAI(),
memory=memory,
)
chain.predict(input="What database should I use for time series data?")
chain.predict(input="Tell me more about that recommendation")
MenteDBRetriever
A LangChain compatible retriever that uses MenteDB hybrid search. Supports optional tag filtering and agent scoping to narrow results.
from mentedb_langchain import MenteDBRetriever
from langchain.chains import RetrievalQA
from langchain_openai import ChatOpenAI
retriever = MenteDBRetriever(
data_dir="./agent-memory",
k=10,
tags=["backend", "architecture"],
)
chain = RetrievalQA.from_chain_type(
llm=ChatOpenAI(),
retriever=retriever,
)
chain.invoke("What were the key decisions about our database migration?")
MenteDBChatHistory
Persistent chat history with cognitive tracking. MenteDB stores messages alongside reasoning trajectories, knowledge gaps, and contradiction signals so the agent's memory improves over time.
from mentedb_langchain import MenteDBChatHistory
history = MenteDBChatHistory(
session_id="session-123",
data_dir="./agent-memory",
)
history.add_user_message("What database should I use?")
history.add_ai_message("I recommend PostgreSQL for your use case.")
messages = history.messages
Usage with LangGraph
MenteDB works naturally with LangGraph. Use MenteDBMemory as a checkpointer or context source within graph nodes:
from mentedb_langchain import MenteDBMemory
memory = MenteDBMemory(data_dir="./graph-memory", agent_id="planner")
def plan_node(state):
context = memory.load_memory_variables({"input": state["task"]})
# Use context to inform planning
return {**state, "context": context}
def reflect_node(state):
memory.save_context(
inputs={"input": state["task"]},
outputs={"output": state["result"]},
)
return state
Configuration
All components accept data_dir to specify where MenteDB stores its data. For multi agent setups, use agent_id to isolate each agent's memory space.
| Parameter | Default | Description |
|---|---|---|
data_dir |
./mentedb-data |
Path to the MenteDB data directory |
agent_id |
None |
Optional agent identifier for memory isolation |
token_budget |
4096 |
Maximum tokens for assembled context (MenteDBMemory) |
k |
10 |
Number of results to return (MenteDBRetriever) |
tags |
None |
Tag filter for retrieval (MenteDBRetriever) |
License
Apache 2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mentedb_langchain-0.8.2.tar.gz.
File metadata
- Download URL: mentedb_langchain-0.8.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b75b7f20347223ed986aaa9c09ca4d04b16a54192a3c4b7a57e1082e31110e2f
|
|
| MD5 |
242b2f3f19508197a9bd85673c8b4c1a
|
|
| BLAKE2b-256 |
c10da9b3c1799a1235f74d9531b15c212d3c58ad3e6e707447b29863faf99ff1
|
Provenance
The following attestation bundles were made for mentedb_langchain-0.8.2.tar.gz:
Publisher:
publish-sdks.yml on nambok/mentedb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mentedb_langchain-0.8.2.tar.gz -
Subject digest:
b75b7f20347223ed986aaa9c09ca4d04b16a54192a3c4b7a57e1082e31110e2f - Sigstore transparency entry: 1391834942
- Sigstore integration time:
-
Permalink:
nambok/mentedb@93328744456ceae043319d9c8898fe5f02d22443 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nambok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdks.yml@93328744456ceae043319d9c8898fe5f02d22443 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file mentedb_langchain-0.8.2-py3-none-any.whl.
File metadata
- Download URL: mentedb_langchain-0.8.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e6addc9d22e58001f01c8d33fc2e28383fdc2c4e7419f6dec35a13ba646afa8
|
|
| MD5 |
1f74aeafb6312ed75fb4220b93b259f8
|
|
| BLAKE2b-256 |
29ef49317242e74ff0b1d11c7e8c59dd52d62ee3bc96e5aaafac412e89ecfba9
|
Provenance
The following attestation bundles were made for mentedb_langchain-0.8.2-py3-none-any.whl:
Publisher:
publish-sdks.yml on nambok/mentedb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mentedb_langchain-0.8.2-py3-none-any.whl -
Subject digest:
0e6addc9d22e58001f01c8d33fc2e28383fdc2c4e7419f6dec35a13ba646afa8 - Sigstore transparency entry: 1391834948
- Sigstore integration time:
-
Permalink:
nambok/mentedb@93328744456ceae043319d9c8898fe5f02d22443 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nambok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdks.yml@93328744456ceae043319d9c8898fe5f02d22443 -
Trigger Event:
workflow_dispatch
-
Statement type: