mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-19 14:15:44 +02:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d98eec6e91 | ||
|
|
659586947d | ||
|
|
c303ef2a2b | ||
|
|
ff92beb88a | ||
|
|
dce73fde66 |
@@ -59,6 +59,7 @@ _MANUAL = {
|
||||
"human_in_the_loop/time-travel.ipynb",
|
||||
"human_in_the_loop/edit-graph-state.ipynb",
|
||||
"human_in_the_loop/wait-user-input.ipynb",
|
||||
"human_in_the_loop/review-tool-calls.ipynb",
|
||||
"node-retries.ipynb",
|
||||
],
|
||||
"tutorials": [
|
||||
|
||||
@@ -38,6 +38,7 @@ These guides cover common examples of that.
|
||||
- [How to edit graph state](human_in_the_loop/edit-graph-state.ipynb)
|
||||
- [How to wait for user input](human_in_the_loop/wait-user-input.ipynb)
|
||||
- [How to view and update past graph state](human_in_the_loop/time-travel.ipynb)
|
||||
- [Review tool calls](human_in_the_loop/review-tool-calls.ipynb)
|
||||
|
||||
## Streaming
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ nav:
|
||||
- Wait for user input: how-tos/human_in_the_loop/wait-user-input.ipynb
|
||||
- View and update past graph state: how-tos/human_in_the_loop/time-travel.ipynb
|
||||
- Edit graph state: how-tos/human_in_the_loop/edit-graph-state.ipynb
|
||||
- Review tool calls: how-tos/human_in_the_loop/review-tool-calls.ipynb
|
||||
- Streaming:
|
||||
- Stream full state: how-tos/stream-values.ipynb
|
||||
- Stream state updates: how-tos/stream-updates.ipynb
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1053
-839
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,9 @@ Implementation of LangGraph CheckpointSaver that uses Postgres.
|
||||
> [!IMPORTANT]
|
||||
> When using Postgres checkpointers for the first time, make sure to call `.setup()` method on them to create required tables. See example below.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> When manually creating Postgres connections and passing them to `PostgresSaver` or `AsyncPostgresSaver`, make sure to include `autocommit=True` and `row_factory=dict_row` (`from psycopg.rows import dict_row`). See a full example in this [how-to guide](https://langchain-ai.github.io/langgraph/how-tos/persistence_postgres/).
|
||||
|
||||
```python
|
||||
from langgraph.checkpoint.postgres import PostgresSaver
|
||||
|
||||
@@ -95,4 +98,4 @@ async with AsyncPostgresSaver.from_conn_string(DB_URI) as checkpointer:
|
||||
|
||||
# list checkpoints
|
||||
[c async for c in checkpointer.alist(read_config)]
|
||||
```
|
||||
```
|
||||
|
||||
@@ -66,11 +66,10 @@ class AsyncPostgresSaver(BasePostgresSaver):
|
||||
async with self.lock:
|
||||
async with self.conn.cursor(binary=True) as cur:
|
||||
try:
|
||||
version = (
|
||||
await cur.execute(
|
||||
"SELECT v FROM checkpoint_migrations ORDER BY v DESC LIMIT 1"
|
||||
)
|
||||
).fetchone()["v"]
|
||||
results = await cur.execute(
|
||||
"SELECT v FROM checkpoint_migrations ORDER BY v DESC LIMIT 1"
|
||||
)
|
||||
version = (await results.fetchone())["v"]
|
||||
except UndefinedTable:
|
||||
version = -1
|
||||
for v, migration in zip(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "langgraph-checkpoint-postgres"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
description = "Library with a Postgres implementation of LangGraph checkpoint saver."
|
||||
authors = []
|
||||
license = "MIT"
|
||||
|
||||
@@ -27,11 +27,15 @@ CHECKPOINT_NAMESPACE_SEPARATOR = "|"
|
||||
class Send:
|
||||
"""A message or packet to send to a specific node in the graph.
|
||||
|
||||
The `Send` class is used within a `StateGraph`'s conditional edges to dynamically
|
||||
route states to different nodes based on certain conditions. This enables
|
||||
creating "map-reduce" like workflows, where a node can be invoked multiple times
|
||||
in parallel on different states, and the results can be aggregated back into the
|
||||
main graph's state.
|
||||
The `Send` class is used within a `StateGraph`'s conditional edges to
|
||||
dynamically invoke a node with a custom state at the next step.
|
||||
|
||||
Importantly, the sent state can differ from the core graph's state,
|
||||
allowing for flexible and dynamic workflow management.
|
||||
|
||||
One such example is a "map-reduce" workflow where your graph invokes
|
||||
the same node multiple times in parallel with different states,
|
||||
before aggregating the results back into the main graph's state.
|
||||
|
||||
Attributes:
|
||||
node (str): The name of the target node to send the message to.
|
||||
@@ -55,6 +59,8 @@ class Send:
|
||||
>>> builder.add_conditional_edges(START, continue_to_jokes)
|
||||
>>> builder.add_edge("generate_joke", END)
|
||||
>>> graph = builder.compile()
|
||||
>>>
|
||||
>>> # Invoking with two subjects results in a generated joke for each
|
||||
>>> graph.invoke({"subjects": ["cats", "dogs"]})
|
||||
{'subjects': ['cats', 'dogs'], 'jokes': ['Joke about cats', 'Joke about dogs']}
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user