mnemosyne-langchain
LangChain and LangGraph integration for the Mnemosyne memory substrate. MnemosyneChatHistory, MnemosyneRetriever, and MnemosyneMemory classes, with hybrid BM25+vector recall, per-session thread tracking, automatic redaction, and TTL support.
Install
pip install mnemosyne-langchain
# or with the type stubs for full IDE support:
pip install "mnemosyne-langchain[langchain]"
Quick start
import os
from mnemosyne_langchain import MnemosyneChatHistory, MnemosyneRetriever, MnemosyneMemory
os.environ["MNEMOSYNE_API_KEY"] = "mn_..."
# Standalone chat history
history = MnemosyneChatHistory(session_id="alice-1", container_tag="default")
history.add_user_message("Hello!")
history.add_ai_message("Hi, how can I help?")
for m in history.messages:
print(m)
# Retriever
retriever = MnemosyneRetriever(container_tag="default")
docs = retriever.invoke("Python best practices")
for d in docs:
print(d.page_content, d.metadata)
# Full memory object
memory = MnemosyneMemory(session_id="alice-1")
vars = memory.load_memory_variables({"input": "what did I ask before?"})
print(vars)
memory.save_context({"input": "thanks!"}, {"output": "you're welcome"})
memory.clear()
With a LangChain chain
from langchain_openai import ChatOpenAI
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from mnemosyne_langchain import MnemosyneMemory
llm = ChatOpenAI(model="gpt-4")
prompt = PromptTemplate(
input_variables=["history", "context", "input"],
template="Context:\n{context}\n\nHistory:\n{history}\n\nUser: {input}\nAssistant:",
)
memory = MnemosyneMemory(session_id="alice-1", k=3)
chain = LLMChain(llm=llm, prompt=prompt, memory=memory)
chain.invoke({"input": "remind me what we discussed about caching"})
License
MIT © Geass Labs
Metadata
Release files for mnemosyne-langchain 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mnemosyne_langchain-0.1.0.tar.gz | 5.6 kB | Without provenance | Details for mnemosyne_langchain-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mnemosyne_langchain-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mnemosyne_langchain-0.1.0-py3-none-any.whl |
Total release size: 12.2 kB
Release files / mnemosyne_langchain-0.1.0.tar.gz
| Download URL | mnemosyne_langchain-0.1.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d58c613a1e57c8034c7c77777186db4bd754e6ea2d25515f3ebc78376565fe8
|
|
BLAKE2b-256 checksum How to use checksums |
7848af43d90eddae343b9cb02da87ac6c1746e7d091535b401ab20d0cc794791
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / mnemosyne_langchain-0.1.0-py3-none-any.whl
| Download URL | mnemosyne_langchain-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2c3b5c35f4edff2bdd109ad663825123ef9a93fa101514c59f783d345133f20
|
|
BLAKE2b-256 checksum How to use checksums |
19245b3bb19a3f2cc1ec949e9b33abcc8a339bad80e80d0f8c5d01224f6442cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for mnemosyne-langchain 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.