Metadata-Version: 2.4
Name: oliviadb-langgraph
Version: 0.1.2
Summary: LangGraph checkpointer and store backed by OliviaDB
License-Expression: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: oliviadb>=0.1.0
Requires-Dist: langgraph<2,>=1.2
Requires-Dist: langgraph-checkpoint<5,>=4.3
Provides-Extra: test
Requires-Dist: langgraph-checkpoint-conformance==0.0.2; extra == "test"

<!-- SPDX-License-Identifier: Apache-2.0 -->
# oliviadb-langgraph

[LangGraph](https://www.langchain.com/langgraph) persistence in [OliviaDB](https://olivia-db.com/):
a checkpointer (`OliviaDBSaver`: thread state, channel blobs, pending writes) and a store
(`OliviaDBStore`: long-term memories with TTL, filters and ranked search). Tested with
langgraph 1.2.24 and langgraph-checkpoint 4.3.2 (all five base capabilities of
langgraph-checkpoint-conformance).

## Install

```sh
pip install oliviadb-langgraph
```

Python 3.10 or later.

## Example

A server from the core image (`docker run -d -p 8443:8443 -v oliviadb-data:/data
ghcr.io/oliviadb/oliviadb`), its API key in `OLIVIADB_API_KEY` and its certificate in
`oliviadb-ca.pem` (`docker cp <container>:/data/tls/server.pem oliviadb-ca.pem`):

```python
import os
from typing import TypedDict

from langgraph.graph import END, START, StateGraph
from oliviadb import OliviaDbClient
from oliviadb_langgraph import OliviaDBSaver, OliviaDBStore


class State(TypedDict):
    text: str
    reply: str


client = OliviaDbClient("https://localhost:8443", api_key=os.environ["OLIVIADB_API_KEY"], ca_file="oliviadb-ca.pem")
graph = StateGraph(State)
graph.add_node("echo", lambda state: {"reply": state["text"]})
graph.add_edge(START, "echo")
graph.add_edge("echo", END)
app = graph.compile(
    checkpointer=OliviaDBSaver(client, root=("langgraph", "support")),
    store=OliviaDBStore(client, root=("langgraph", "support", "store")),
)
print(app.invoke({"text": "hello"}, {"configurable": {"thread_id": "demo"}})["reply"])
```

## Links

* Documentation: <https://docs.olivia-db.com/>
* Repository: <https://github.com/OliviaDB/oliviadb-python> (`adapters/langgraph`)

Licence: Apache-2.0.
