Metadata-Version: 2.4
Name: maximem-synap-langchain
Version: 0.2.0
Summary: Synap memory integration for LangChain
Author: Synap Team
License-Expression: Apache-2.0
Keywords: synap,memory,langchain,ai,context
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: maximem-synap>=0.2.0
Requires-Dist: maximem-synap-integrations-common>=0.1.0
Requires-Dist: langchain-core>=0.3
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: langchain>=0.2; extra == "dev"

# maximem-synap-langchain

Synap memory integration for [LangChain](https://python.langchain.com/).

## Install

```bash
pip install maximem-synap-langchain
```

Requires `langchain-core>=0.3`, `maximem-synap>=0.2.0`.

## What's in the box

- **`SynapChatMessageHistory`** — `BaseChatMessageHistory` for use with `RunnableWithMessageHistory`. Persists conversation turns to Synap's short-term + long-term memory.
- **`SynapRetriever`** — `BaseRetriever` for RAG pipelines. Returns typed memory items (memories, entities, triples, chunks) via `sdk.fetch`.
- **`SynapSearchTool` / `SynapStoreTool`** — Agent tools for explicit memory read/write inside a tool-using LangChain agent.
- **`SynapCallbackHandler`** — Zero-config callback that auto-records LLM input/output as conversation turns.
- **`create_synap_node`** — Helper that builds a LangGraph-compatible node which injects retrieved Synap context into graph state.

## Quickstart

```python
from langchain_core.runnables.history import RunnableWithMessageHistory
from maximem_synap import MaximemSynapSDK
from synap_langchain import SynapChatMessageHistory

sdk = MaximemSynapSDK(api_key="sk-...")

def get_history(session_id: str) -> SynapChatMessageHistory:
    return SynapChatMessageHistory(sdk, user_id=session_id, customer_id="acme")

chain_with_memory = RunnableWithMessageHistory(
    chain,
    get_history,
    input_messages_key="input",
    history_messages_key="history",
)
```

## License

Apache-2.0
