LangChain adapter for Mnemo — drop-in BaseMemory and Retriever backed by the Mnemo SDK.
Project description
ledgermem-langchain
LangChain adapter for LedgerMem — drop-in conversational memory and retriever backed by the LedgerMem SDK.
Install
pip install ledgermem-langchain
Quickstart
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI
from ledgermem import LedgerMem
from langchain_ledgermem import LedgerMemMemory
mem_client = LedgerMem(api_key="lm_...", workspace_id="ws_...")
chain = ConversationChain(
llm=ChatOpenAI(model="gpt-4o-mini"),
memory=LedgerMemMemory(client=mem_client, top_k=5),
)
print(chain.invoke({"input": "Remember that my favourite framework is FastAPI."}))
print(chain.invoke({"input": "What is my favourite framework?"}))
Retriever for RAG
from langchain_ledgermem import LedgerMemRetriever
retriever = LedgerMemRetriever(client=mem_client, top_k=8)
docs = retriever.invoke("show me what I said about deployments")
for doc in docs:
print(doc.metadata.get("score"), doc.page_content)
What you get
LedgerMemMemory— implementslangchain_core.memory.BaseMemory. Auto-saves every user / AI turn and rehydrates the top-K relevant prior turns by semantic search.LedgerMemRetriever— implementslangchain_core.retrievers.BaseRetriever. Returns LangChainDocumentobjects with score andmemory_idin metadata.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
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 getmnemo_langchain-0.1.0.tar.gz.
File metadata
- Download URL: getmnemo_langchain-0.1.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38bec11fd5e810256cbcbb00e5712826cd4191dfe292a69930c1a7f99f4897b6
|
|
| MD5 |
e9bda62dc9ced1c9979723faa83f3bea
|
|
| BLAKE2b-256 |
2f686bda224ac9887313c8c4e9a0518cead06fa2f1036d613fbca1b63612f806
|
File details
Details for the file getmnemo_langchain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: getmnemo_langchain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
932dd0b2a99d5173c5c5163dc7d5308ca6999c20fda405f83e1d05876a9cc710
|
|
| MD5 |
a84639376db436ec6da1ca194c957260
|
|
| BLAKE2b-256 |
d43aef92e67e5d31570fb65fc1f08357ac967bcdeed4876e141d5f3f43bb6cc5
|