Metadata-Version: 2.5
Name: getmnemo-langchain
Version: 0.2.0
Summary: LangChain adapter for Mnemo — drop-in BaseMemory and Retriever backed by the Mnemo SDK.
Project-URL: Homepage, https://github.com/ledgermem/getmnemo-langchain
Project-URL: Issues, https://github.com/ledgermem/getmnemo-langchain/issues
Project-URL: Source, https://github.com/ledgermem/getmnemo-langchain
Author-email: Mnemo <founders@mnemohq.com>
License: MIT
License-File: LICENSE
Keywords: getmnemo,langchain,llm,memory,rag,retriever
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: getmnemo<0.3,>=0.2
Requires-Dist: langchain-core<1.0,>=0.3
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Description-Content-Type: text/markdown

# getmnemo-langchain

LangChain adapter for [Mnemo Memory](https://mnemohq.com) — drop-in conversational memory and retriever backed by the [getmnemo](https://pypi.org/project/getmnemo/) SDK.

## Install

```bash
pip install getmnemo-langchain
```

Requires `getmnemo>=0.2`.

## Quickstart

```python
from getmnemo import Mnemo
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI

from langchain_getmnemo import MnemoMemory

mem_client = Mnemo(api_key="prfly_live_...", default_container_tag="user:jane")
chain = ConversationChain(
    llm=ChatOpenAI(model="gpt-4o-mini"),
    memory=MnemoMemory(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?"}))
```

Every call is scoped to a container — a `"<type>:<id>"` string such as
`"user:jane"`. Set it once on the client (`default_container_tag=`) or per
component (`container_tag=`):

```python
memory = MnemoMemory(client=mem_client, container_tag="user:jane")
```

## Retriever for RAG

```python
from langchain_getmnemo import MnemoRetriever

retriever = MnemoRetriever(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

- `MnemoMemory` — implements `langchain_core.memory.BaseMemory`. Auto-saves every user / AI turn and rehydrates the top-K relevant prior turns by semantic search. An optional `namespace` partitions threads that share one container.
- `MnemoRetriever` — implements `langchain_core.retrievers.BaseRetriever`. Returns LangChain `Document` objects with the memory's metadata plus `score`, `memory_id`, and (for document-derived hits) `document_id`.

## License

MIT — see [LICENSE](./LICENSE).
