Skip to content

Commit

Permalink
BREAKING: remove langgraph checkpointer (#52)
Browse files Browse the repository at this point in the history
Breaking change, removing langgraph checkpointer since the langgraph
checkpointer interface changed (so was a breaking change anyway).
  • Loading branch information
eyurtsev authored May 18, 2024
1 parent 9912f54 commit d5b7756
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 1,565 deletions.
91 changes: 0 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,97 +25,6 @@ pip install -U langchain-postgres

## Usage

### PostgresSaver (LangGraph Checkpointer)

The LangGraph checkpointer can be used to add memory to your LangGraph application.

`PostgresSaver` is an implementation of the checkpointer saver using
Postgres as the backend.

Currently, only the psycopg3 driver is supported.

Sync usage:

```python
from psycopg_pool import ConnectionPool
from langchain_postgres import (
PostgresSaver, PickleCheckpointSerializer
)

pool = ConnectionPool(
# Example configuration
conninfo="postgresql://langchain:langchain@localhost:6024/langchain",
max_size=20,
)

PostgresSaver.create_tables(pool)

checkpointer = PostgresSaver(
serializer=PickleCheckpointSerializer(),
sync_connection=pool,
)

# Set up the langgraph workflow with the checkpointer
workflow = ... # Fill in with your workflow
app = workflow.compile(checkpointer=checkpointer)

# Use with the sync methods of `app` (e.g., `app.stream())

pool.close() # Remember to close the connection pool.
```

Async usage:

```python
from psycopg_pool import AsyncConnectionPool
from langchain_postgres import (
PostgresSaver, PickleCheckpointSerializer
)

pool = AsyncConnectionPool(
# Example configuration
conninfo="postgresql://langchain:langchain@localhost:6024/langchain",
max_size=20,
)

# Create the tables in postgres (only needs to be done once)
await PostgresSaver.acreate_tables(pool)

checkpointer = PostgresSaver(
serializer=PickleCheckpointSerializer(),
async_connection=pool,
)

# Set up the langgraph workflow with the checkpointer
workflow = ... # Fill in with your workflow
app = workflow.compile(checkpointer=checkpointer)

# Use with the async methods of `app` (e.g., `app.astream()`)

await pool.close() # Remember to close the connection pool.
```

#### Testing

If testing with the postgres checkpointer it may be useful to both create and
drop the tables before and after the tests.

```python
from psycopg_pool import ConnectionPool
from langchain_postgres import (
PostgresSaver
)
with ConnectionPool(
# Example configuration
conninfo="postgresql://langchain:langchain@localhost:6024/langchain",
max_size=20,
) as conn:
PostgresSaver.create_tables(conn)
PostgresSaver.drop_tables(conn)
# Run your unit tests with langgraph
```


### ChatMessageHistory

The chat message history abstraction helps to persist chat message history
Expand Down
Loading

0 comments on commit d5b7756

Please sign in to comment.