Metadata-Version: 2.4
Name: mnemosyne-langchain
Version: 0.1.0
Summary: LangChain and LangGraph integration for the Mnemosyne memory substrate. BaseChatMessageHistory, BaseMemory, and BaseRetriever adapters with hybrid BM25+vector recall, per-session thread tracking, automatic redaction, TTL support.
Author-email: Mashle Burneded <mashle@geasslabs.xyz>
Maintainer-email: Geass Labs <team@geasslabs.xyz>
License: MIT License
        
        Copyright (c) 2026 Geass Labs
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://mnemosyne.geasslabs.xyz
Project-URL: Documentation, https://docs.geasslabs.xyz/mnemosyne-langchain
Project-URL: Repository, https://github.com/synet-systems/mnemosyne/tree/main/packages/mnemosyne-langchain
Project-URL: Issues, https://github.com/synet-systems/mnemosyne/issues
Project-URL: Changelog, https://github.com/synet-systems/mnemosyne/blob/main/packages/mnemosyne-langchain/CHANGELOG.md
Keywords: mnemosyne,ai,llm,memory,agent,langchain,framework-adapter
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE-MIT
License-File: NOTICE
Requires-Dist: mnemosyne-sdk>=0.1.0
Requires-Dist: httpx>=0.27.0
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == "langchain"
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: respx>=0.21.0; extra == "dev"
Requires-Dist: ruff>=0.5.0; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: langchain>=0.1.0; extra == "dev"
Dynamic: license-file

# mnemosyne-langchain

[![PyPI version](https://img.shields.io/pypi/v/mnemosyne-langchain.svg)](https://pypi.org/project/mnemosyne-langchain/)
[![Python versions](https://img.shields.io/pypi/pyversions/mnemosyne-langchain.svg)](https://pypi.org/project/mnemosyne-langchain/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)

> 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

```bash
pip install mnemosyne-langchain
# or with the type stubs for full IDE support:
pip install "mnemosyne-langchain[langchain]"
```

## Quick start

```python
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

```python
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](https://geasslabs.xyz)
