From 03be3b656764f9d8888734ba6ede858562bfc2de Mon Sep 17 00:00:00 2001 From: Vadym Barda Date: Fri, 27 Sep 2024 18:12:12 -0400 Subject: [PATCH] docs: reorganize API refs (#1884) --- docs/docs/cloud/deployment/setup.md | 2 +- docs/docs/cloud/deployment/setup_pyproject.md | 2 +- docs/docs/concepts/agentic_concepts.md | 4 +- docs/docs/concepts/low_level.md | 8 +- docs/docs/concepts/persistence.md | 12 +-- docs/docs/reference/channels.md | 15 ++++ docs/docs/reference/checkpoints.md | 73 +++++---------- docs/docs/reference/constants.md | 6 ++ docs/docs/reference/errors.md | 3 - docs/docs/reference/graphs.md | 90 +++---------------- docs/docs/reference/prebuilt.md | 77 +++------------- docs/docs/reference/types.md | 15 ++++ docs/mkdocs.yml | 14 ++- .../langgraph/checkpoint/sqlite/__init__.py | 8 +- .../langgraph/checkpoint/base/__init__.py | 2 + libs/langgraph/langgraph/channels/topic.py | 1 - libs/langgraph/langgraph/constants.py | 6 +- .../langgraph/prebuilt/chat_agent_executor.py | 2 +- 18 files changed, 118 insertions(+), 222 deletions(-) create mode 100644 docs/docs/reference/channels.md create mode 100644 docs/docs/reference/constants.md create mode 100644 docs/docs/reference/types.md diff --git a/docs/docs/cloud/deployment/setup.md b/docs/docs/cloud/deployment/setup.md index a5c99f565..48c6b2df5 100644 --- a/docs/docs/cloud/deployment/setup.md +++ b/docs/docs/cloud/deployment/setup.md @@ -95,7 +95,7 @@ my-app/ ## Define Graphs -Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledGraph][compiledgraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph API configuration file](../reference/cli.md#configuration-file). +Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledGraph][langgraph.graph.graph.CompiledGraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph API configuration file](../reference/cli.md#configuration-file). Example `agent.py` file, which shows how to import from other modules you define (code for the modules is not shown here, please see [this repo](https://github.com/langchain-ai/langgraph-example) to see their implementation): diff --git a/docs/docs/cloud/deployment/setup_pyproject.md b/docs/docs/cloud/deployment/setup_pyproject.md index f62356899..88107289e 100644 --- a/docs/docs/cloud/deployment/setup_pyproject.md +++ b/docs/docs/cloud/deployment/setup_pyproject.md @@ -104,7 +104,7 @@ my-app/ ## Define Graphs -Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledGraph][compiledgraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph API configuration file](../reference/cli.md#configuration-file). +Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledGraph][langgraph.graph.graph.CompiledGraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph API configuration file](../reference/cli.md#configuration-file). Example `agent.py` file, which shows how to import from other modules you define (code for the modules is not shown here, please see [this repo](https://github.com/langchain-ai/langgraph-example-pyproject) to see their implementation): diff --git a/docs/docs/concepts/agentic_concepts.md b/docs/docs/concepts/agentic_concepts.md index 448853e9e..94b52249b 100644 --- a/docs/docs/concepts/agentic_concepts.md +++ b/docs/docs/concepts/agentic_concepts.md @@ -39,7 +39,7 @@ While a router allows an LLM to make a single decision, more complex agent archi 2. `Memory`: Enabling the agent to retain and use information from previous steps. 3. `Planning`: Empowering the LLM to create and follow multi-step plans to achieve goals. -This architecture allows for more complex and flexible agent behaviors, going beyond simple routing to enable dynamic problem-solving across multiple steps. You can use it with [`create_react_agent`](../reference/prebuilt.md#create_react_agent). +This architecture allows for more complex and flexible agent behaviors, going beyond simple routing to enable dynamic problem-solving across multiple steps. You can use it with [`create_react_agent`][langgraph.prebuilt.chat_agent_executor.create_react_agent]. ### Tool calling @@ -71,7 +71,7 @@ In the ReAct architecture, an LLM is called repeatedly in a while-loop. At each ### ReAct implementation -There are several differences between this paper and the pre-built [`create_react_agent`](../reference/prebuilt.md#create_react_agent) implementation: +There are several differences between this paper and the pre-built [`create_react_agent`][langgraph.prebuilt.chat_agent_executor.create_react_agent] implementation: - First, we use [tool-calling](#tool-calling) to have LLMs call tools, whereas the paper used prompting + parsing of raw output. This is because tool calling did not exist when the paper was written, but is generally better and more reliable. - Second, we use messages to prompt the LLM, whereas the paper used string formatting. This is because at the time of writing, LLMs didn't even expose a message-based interface, whereas now that's the only interface they expose. diff --git a/docs/docs/concepts/low_level.md b/docs/docs/concepts/low_level.md index 155c35d9f..545e9bb32 100644 --- a/docs/docs/concepts/low_level.md +++ b/docs/docs/concepts/low_level.md @@ -284,7 +284,7 @@ graph.add_conditional_edges("node_a", routing_function, {True: "node_b", False: ### Entry Point -The entry point is the first node(s) that are run when the graph starts. You can use the [`add_edge`][langgraph.graph.StateGraph.add_edge] method from the virtual [`START`][start] node to the first node to execute to specify where to enter the graph. +The entry point is the first node(s) that are run when the graph starts. You can use the [`add_edge`][langgraph.graph.StateGraph.add_edge] method from the virtual [`START`][langgraph.constants.START] node to the first node to execute to specify where to enter the graph. ```python from langgraph.graph import START @@ -294,7 +294,7 @@ graph.add_edge(START, "node_a") ### Conditional Entry Point -A conditional entry point lets you start at different nodes depending on custom logic. You can use [`add_conditional_edges`][langgraph.graph.StateGraph.add_conditional_edges] from the virtual [`START`][start] node to accomplish this. +A conditional entry point lets you start at different nodes depending on custom logic. You can use [`add_conditional_edges`][langgraph.graph.StateGraph.add_conditional_edges] from the virtual [`START`][langgraph.constants.START] node to accomplish this. ```python from langgraph.graph import START @@ -312,7 +312,7 @@ graph.add_conditional_edges(START, routing_function, {True: "node_b", False: "no By default, `Nodes` and `Edges` are defined ahead of time and operate on the same shared state. However, there can be cases where the exact edges are not known ahead of time and/or you may want different versions of `State` to exist at the same time. A common of example of this is with `map-reduce` design patterns. In this design pattern, a first node may generate a list of objects, and you may want to apply some other node to all those objects. The number of objects may be unknown ahead of time (meaning the number of edges may not be known) and the input `State` to the downstream `Node` should be different (one for each generated object). -To support this design pattern, LangGraph supports returning [`Send`](../reference/graphs.md#send) objects from conditional edges. `Send` takes two arguments: first is the name of the node, and second is the state to pass to that node. +To support this design pattern, LangGraph supports returning [`Send`][langgraph.types.Send] objects from conditional edges. `Send` takes two arguments: first is the name of the node, and second is the state to pass to that node. ```python def continue_to_jokes(state: OverallState): @@ -323,7 +323,7 @@ graph.add_conditional_edges("node_a", continue_to_jokes) ## Persistence -LangGraph has a built-in persistence layer, implemented through [checkpointers][basecheckpointsaver]. When you use a checkpointer with a graph, you can interact with and manage the graph's state after the execution. The checkpointer saves a _checkpoint_ (a snapshot) of the graph state at every superstep, enabling several powerful capabilities, including human-in-the-loop, memory and fault-tolerance. See this [conceptual guide](./persistence.md) for more information. +LangGraph has a built-in persistence layer, implemented through [checkpointers][langgraph.checkpoint.base.BaseCheckpointSaver]. When you use a checkpointer with a graph, you can interact with and manage the graph's state after the execution. The checkpointer saves a _checkpoint_ (a snapshot) of the graph state at every superstep, enabling several powerful capabilities, including human-in-the-loop, memory and fault-tolerance. See this [conceptual guide](./persistence.md) for more information. ## Graph Migrations diff --git a/docs/docs/concepts/persistence.md b/docs/docs/concepts/persistence.md index f5c550899..4dc7af632 100644 --- a/docs/docs/concepts/persistence.md +++ b/docs/docs/concepts/persistence.md @@ -218,15 +218,15 @@ The final thing you can optionally specify when calling `update_state` is `as_no ## Checkpointer libraries -Under the hood, checkpointing is powered by checkpointer objects that conform to [BaseCheckpointSaver][basecheckpointsaver] interface. LangGraph provides several checkpointer implementations, all implemented via standalone, installable libraries: +Under the hood, checkpointing is powered by checkpointer objects that conform to [BaseCheckpointSaver][langgraph.checkpoint.base.BaseCheckpointSaver] interface. LangGraph provides several checkpointer implementations, all implemented via standalone, installable libraries: -* `langgraph-checkpoint`: The base interface for checkpointer savers ([BaseCheckpointSaver][basecheckpointsaver]) and serialization/deserialization interface ([SerializerProtocol][serializerprotocol]). Includes in-memory checkpointer implementation ([MemorySaver][memorysaver]) for experimentation. LangGraph comes with `langgraph-checkpoint` included. -* `langgraph-checkpoint-sqlite`: An implementation of LangGraph checkpointer that uses SQLite database ([SqliteSaver][sqlitesaver] / [AsyncSqliteSaver][asyncsqlitesaver]). Ideal for experimentation and local workflows. Needs to be installed separately. -* `langgraph-checkpoint-postgres`: An advanced checkpointer that uses Postgres database ([PostgresSaver][postgressaver] / [AsyncPostgresSaver][asyncpostgressaver]), used in LangGraph Cloud. Ideal for using in production. Needs to be installed separately. +* `langgraph-checkpoint`: The base interface for checkpointer savers ([BaseCheckpointSaver][langgraph.checkpoint.base.BaseCheckpointSaver]) and serialization/deserialization interface ([SerializerProtocol][langgraph.checkpoint.serde.base.SerializerProtocol]). Includes in-memory checkpointer implementation ([MemorySaver][langgraph.checkpoint.memory.MemorySaver]) for experimentation. LangGraph comes with `langgraph-checkpoint` included. +* `langgraph-checkpoint-sqlite`: An implementation of LangGraph checkpointer that uses SQLite database ([SqliteSaver][langgraph.checkpoint.sqlite.SqliteSaver] / [AsyncSqliteSaver][langgraph.checkpoint.sqlite.aio.AsyncSqliteSaver]). Ideal for experimentation and local workflows. Needs to be installed separately. +* `langgraph-checkpoint-postgres`: An advanced checkpointer that uses Postgres database ([PostgresSaver][langgraph.checkpoint.postgres.PostgresSaver] / [AsyncPostgresSaver][langgraph.checkpoint.postgres.aio.AsyncPostgresSaver]), used in LangGraph Cloud. Ideal for using in production. Needs to be installed separately. ### Checkpointer interface -Each checkpointer conforms to [BaseCheckpointSaver][basecheckpointsaver] interface and implements the following methods: +Each checkpointer conforms to [BaseCheckpointSaver][langgraph.checkpoint.base.BaseCheckpointSaver] interface and implements the following methods: * `.put` - Store a checkpoint with its configuration and metadata. * `.put_writes` - Store intermediate writes linked to a checkpoint (i.e. [pending writes](#pending-writes)). @@ -241,7 +241,7 @@ If the checkpointer is used with asynchronous graph execution (i.e. executing th ### Serializer When checkpointers save the graph state, they need to serialize the channel values in the state. This is done using serializer objects. -`langgraph_checkpoint` defines [protocol][serializerprotocol] for implementing serializers provides a default implementation ([JsonPlusSerializer][jsonplusserializer]) that handles a wide variety of types, including LangChain and LangGraph primitives, datetimes, enums and more. +`langgraph_checkpoint` defines [protocol][langgraph.checkpoint.serde.base.SerializerProtocol] for implementing serializers provides a default implementation ([JsonPlusSerializer][langgraph.checkpoint.serde.jsonplus.JsonPlusSerializer]) that handles a wide variety of types, including LangChain and LangGraph primitives, datetimes, enums and more. ## Capabilities diff --git a/docs/docs/reference/channels.md b/docs/docs/reference/channels.md new file mode 100644 index 000000000..d8fd4edc4 --- /dev/null +++ b/docs/docs/reference/channels.md @@ -0,0 +1,15 @@ +# Channels + +::: langgraph.channels.base + options: + members: + - BaseChannel + +::: langgraph.channels + options: + members: + - Topic + - LastValue + - EphemeralValue + - BinaryOperatorAggregate + - AnyValue diff --git a/docs/docs/reference/checkpoints.md b/docs/docs/reference/checkpoints.md index f8f914f2b..dcac4c27a 100644 --- a/docs/docs/reference/checkpoints.md +++ b/docs/docs/reference/checkpoints.md @@ -1,62 +1,29 @@ # Checkpointers -You can [compile][langgraph.graph.MessageGraph.compile] any LangGraph workflow with a [Checkpointer][basecheckpointsaver] to give your agent "memory" by persisting its state. This permits things like: +::: langgraph.checkpoint.base + options: + members: + - CheckpointMetadata + - Checkpoint + - BaseCheckpointSaver + - create_checkpoint -- Remembering things across multiple interactions -- Interrupting to wait for user input -- Resilience for long-running, error-prone agents -- Time travel retry and branch from a previous checkpoint +::: langgraph.checkpoint.serde.base + options: + members: + - SerializerProtocol -Key checkpointer interfaces and primitives are defined in [`langgraph_checkpoint`](https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint) library. Additional checkpointer implementations are also available as installable libraries: -* [`langgraph-checkpoint-sqlite`](https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint-sqlite): An implementation of LangGraph checkpointer that uses SQLite database. Ideal for experimentation and local workflows. -* [`langgraph-checkpoint-postgres`](https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint-postgres): An advanced checkpointer that uses Postgres database, used in LangGraph Cloud. Ideal for using in production. +::: langgraph.checkpoint.serde.jsonplus + options: + members: + - JsonPlusSerializer -### Checkpoint +::: langgraph.checkpoint.memory -::: langgraph.checkpoint.base.Checkpoint +::: langgraph.checkpoint.sqlite -### CheckpointMetadata +::: langgraph.checkpoint.sqlite.aio -::: langgraph.checkpoint.base.CheckpointMetadata +::: langgraph.checkpoint.postgres -### BaseCheckpointSaver - -::: langgraph.checkpoint.base.BaseCheckpointSaver - -## Serialization / deserialization - -### SerializerProtocol - -::: langgraph.checkpoint.base.SerializerProtocol - -### JsonPlusSerializer - -::: langgraph.checkpoint.serde.jsonplus.JsonPlusSerializer - -## Checkpointer Implementations - -LangGraph also natively provides the following checkpoint implementations. - -### MemorySaver - -::: langgraph.checkpoint.memory.MemorySaver - -### AsyncSqliteSaver - -::: langgraph.checkpoint.sqlite.aio.AsyncSqliteSaver - -### SqliteSaver - -::: langgraph.checkpoint.sqlite.SqliteSaver - -### AsyncPostgresSaver - -::: langgraph.checkpoint.postgres.aio.AsyncPostgresSaver - -### PostgresSaver - -::: langgraph.checkpoint.postgres.PostgresSaver -handler: python - - -handler: python +::: langgraph.checkpoint.postgres.aio \ No newline at end of file diff --git a/docs/docs/reference/constants.md b/docs/docs/reference/constants.md new file mode 100644 index 000000000..f23e941fa --- /dev/null +++ b/docs/docs/reference/constants.md @@ -0,0 +1,6 @@ +::: langgraph.constants + options: + members: + - TAG_HIDDEN + - START + - END \ No newline at end of file diff --git a/docs/docs/reference/errors.md b/docs/docs/reference/errors.md index 295fa87ac..d6ddf3c9c 100644 --- a/docs/docs/reference/errors.md +++ b/docs/docs/reference/errors.md @@ -1,6 +1,3 @@ # Errors -While you may not want to see them, informative errors help you design better workflows. -Below are the LangGraph-specific errors and what they mean. - ::: langgraph.errors \ No newline at end of file diff --git a/docs/docs/reference/graphs.md b/docs/docs/reference/graphs.md index 14392ba2c..c67e2136a 100644 --- a/docs/docs/reference/graphs.md +++ b/docs/docs/reference/graphs.md @@ -1,80 +1,18 @@ # Graph Definitions -Graphs are the core abstraction of LangGraph. Each [StateGraph](#stategraph) implementation is used to create graph workflows. Once compiled, you can run the [CompiledGraph](#compiledgraph) to run the application. +::: langgraph.graph.graph + options: + members: + - Graph + - CompiledGraph -## StateGraph +::: langgraph.graph.state + options: + members: + - StateGraph + - CompiledStateGraph -```python -from langgraph.graph import StateGraph -from typing_extensions import TypedDict -class MyState(TypedDict) - ... -graph = StateGraph(MyState) -``` - -::: langgraph.graph.StateGraph -handler: python - -## MessageGraph - -::: langgraph.graph.message.MessageGraph - -## `add_messages` - -::: langgraph.graph.message.add_messages - -## CompiledGraph - -::: langgraph.graph.graph.CompiledGraph - -## StreamMode - -::: langgraph.types.StreamMode - -## Constants - -The following constants and classes are used to help control graph execution. - -## START - -START is a string constant (`"__start__"`) that serves as a "virtual" node in the graph. -Adding an edge (or conditional edges) from `START` to node one or more nodes in your graph -will direct the graph to begin execution there. - -```python -from langgraph.graph import START -... -builder.add_edge(START, "my_node") -# Or to add a conditional starting point -builder.add_conditional_edges(START, my_condition) -``` - -## END - -END is a string constant (`"__end__"`) that serves as a "virtual" node in the graph. Adding -an edge (or conditional edges) from one or more nodes in your graph to the `END` "node" will -direct the graph to cease execution as soon as it reaches this point. - -```python -from langgraph.graph import END -... -builder.add_edge("my_node", END) # Stop any time my_node completes -# Or to conditionally terminate -def my_condition(state): - if state["should_stop"]: - return END - return "my_node" -builder.add_conditional_edges("my_node", my_condition) -``` - -## Send - -::: langgraph.types.Send - -## Interrupt - -::: langgraph.types.Interrupt - -## RetryPolicy - -::: langgraph.types.RetryPolicy +::: langgraph.graph.message + options: + members: + - add_messages \ No newline at end of file diff --git a/docs/docs/reference/prebuilt.md b/docs/docs/reference/prebuilt.md index 4bfc9b314..9e42c40fc 100644 --- a/docs/docs/reference/prebuilt.md +++ b/docs/docs/reference/prebuilt.md @@ -1,67 +1,18 @@ # Prebuilt -## create_react_agent +::: langgraph.prebuilt.chat_agent_executor + options: + members: + - create_react_agent -```python -from langgraph.prebuilt import create_react_agent -``` +::: langgraph.prebuilt.tool_node + options: + members: + - ToolNode + - InjectedState + - tools_condition -::: langgraph.prebuilt.create_react_agent - -## ToolNode - -```python -from langgraph.prebuilt import ToolNode -``` - -::: langgraph.prebuilt.ToolNode - handler: python - - -## ToolExecutor - -```python -from langgraph.prebuilt import ToolExecutor -``` - -::: langgraph.prebuilt.ToolExecutor - handler: python - - -## ToolInvocation - -```python -from langgraph.prebuilt import ToolInvocation -``` - -::: langgraph.prebuilt.ToolInvocation - handler: python - heading_level: 4 - - - -## `tools_condition` - -```python -from langgraph.prebuilt import tools_condition -``` - -::: langgraph.prebuilt.tools_condition - - -## ValidationNode - -```python -from langgraph.prebuilt import ValidationNode -``` - -::: langgraph.prebuilt.ValidationNode - -## InjectedState - -```python -from langgraph.prebuilt import InjectedState -``` - -::: langgraph.prebuilt.InjectedState - handler: python +::: langgraph.prebuilt.tool_validator + options: + members: + - ValidationNode diff --git a/docs/docs/reference/types.md b/docs/docs/reference/types.md new file mode 100644 index 000000000..347a87d6e --- /dev/null +++ b/docs/docs/reference/types.md @@ -0,0 +1,15 @@ +# Types + +::: langgraph.types + options: + members: + - All + - StreamMode + - StreamWriter + - RetryPolicy + - CachePolicy + - Interrupt + - PregelTask + - PregelExecutableTask + - StateSnapshot + - Send diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c41de03fd..07ac4410e 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -61,19 +61,22 @@ plugins: options: members_order: source allow_inspection: true - heading_level: 3 + heading_level: 2 show_bases: true + show_source: true summary: true inherited_members: true - # merge_init_into_class: true selection: docstring_style: google docstring_section_style: list show_root_toc_entry: false - # show_signature_annotations: true - # show_symbol_type_heading: true + show_signature_annotations: true + show_symbol_type_heading: true show_symbol_type_toc: true signature_crossrefs: true + options: + filters: + - "!^_" - mkdocs-jupyter: ignore_h1_titles: true execute: false @@ -202,7 +205,10 @@ nav: - Graphs: reference/graphs.md - Checkpointing: reference/checkpoints.md - Prebuilt Components: reference/prebuilt.md + - Channels: reference/channels.md - Errors: reference/errors.md + - Types: reference/types.md + - Constants: reference/constants.md - "Cloud (beta)": - "cloud/index.md" - Tutorials: diff --git a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py index 82aa2dc74..2c6ef4a31 100644 --- a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py +++ b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py @@ -39,7 +39,7 @@ class SqliteSaver(BaseCheckpointSaver[str]): (demos and small projects) and does not scale to multiple threads. For a similar sqlite saver with `async` support, - consider using [AsyncSqliteSaver][asyncsqlitesaver]. + consider using [AsyncSqliteSaver][langgraph.checkpoint.sqlite.aio.AsyncSqliteSaver]. Args: conn (sqlite3.Connection): The SQLite database connection. @@ -461,7 +461,7 @@ class SqliteSaver(BaseCheckpointSaver[str]): Note: This async method is not supported by the SqliteSaver class. - Use get_tuple() instead, or consider using [AsyncSqliteSaver][asyncsqlitesaver]. + Use get_tuple() instead, or consider using [AsyncSqliteSaver][langgraph.checkpoint.sqlite.aio.AsyncSqliteSaver]. """ raise NotImplementedError(_AIO_ERROR_MSG) @@ -477,7 +477,7 @@ class SqliteSaver(BaseCheckpointSaver[str]): Note: This async method is not supported by the SqliteSaver class. - Use list() instead, or consider using [AsyncSqliteSaver][asyncsqlitesaver]. + Use list() instead, or consider using [AsyncSqliteSaver][langgraph.checkpoint.sqlite.aio.AsyncSqliteSaver]. """ raise NotImplementedError(_AIO_ERROR_MSG) yield @@ -493,7 +493,7 @@ class SqliteSaver(BaseCheckpointSaver[str]): Note: This async method is not supported by the SqliteSaver class. - Use put() instead, or consider using [AsyncSqliteSaver][asyncsqlitesaver]. + Use put() instead, or consider using [AsyncSqliteSaver][langgraph.checkpoint.sqlite.aio.AsyncSqliteSaver]. """ raise NotImplementedError(_AIO_ERROR_MSG) diff --git a/libs/checkpoint/langgraph/checkpoint/base/__init__.py b/libs/checkpoint/langgraph/checkpoint/base/__init__.py index 4bd385159..fb0eb925a 100644 --- a/libs/checkpoint/langgraph/checkpoint/base/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/base/__init__.py @@ -39,12 +39,14 @@ class CheckpointMetadata(TypedDict, total=False): source: Literal["input", "loop", "update"] """The source of the checkpoint. + - "input": The checkpoint was created from an input to invoke/stream/batch. - "loop": The checkpoint was created from inside the pregel loop. - "update": The checkpoint was created from a manual state update. """ step: int """The step number of the checkpoint. + -1 for the first "input" checkpoint. 0 for the first "loop" checkpoint. ... for the nth checkpoint afterwards. diff --git a/libs/langgraph/langgraph/channels/topic.py b/libs/langgraph/langgraph/channels/topic.py index 8c1c8d15b..0430343dc 100644 --- a/libs/langgraph/langgraph/channels/topic.py +++ b/libs/langgraph/langgraph/channels/topic.py @@ -24,7 +24,6 @@ class Topic( Args: typ: The type of the value stored in the channel. - unique: Whether to discard duplicate values. accumulate: Whether to accumulate values across steps. If False, the channel will be emptied after each step. """ diff --git a/libs/langgraph/langgraph/constants.py b/libs/langgraph/langgraph/constants.py index 4c6733ac5..564d2cac7 100644 --- a/libs/langgraph/langgraph/constants.py +++ b/libs/langgraph/langgraph/constants.py @@ -13,11 +13,11 @@ EMPTY_SEQ: tuple[str, ...] = tuple() # --- Public constants --- TAG_HIDDEN = sys.intern("langsmith:hidden") -# tag to hide a node/edge from certain tracing/streaming environments +"""Tag to hide a node/edge from certain tracing/streaming environments.""" START = sys.intern("__start__") -# the first (maybe virtual) node in graph-style Pregel +"""The first (maybe virtual) node in graph-style Pregel.""" END = sys.intern("__end__") -# the last (maybe virtual) node in graph-style Pregel +"""The last (maybe virtual) node in graph-style Pregel.""" # --- Reserved write keys --- INPUT = sys.intern("__input__") diff --git a/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py b/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py index 341aafe14..5e8274de4 100644 --- a/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py @@ -190,7 +190,7 @@ def create_react_agent( ``` The "agent" node calls the language model with the messages list (after applying the messages modifier). - If the resulting AIMessage contains `tool_calls`, the graph will then call the ["tools"][toolnode]. + If the resulting AIMessage contains `tool_calls`, the graph will then call the ["tools"][langgraph.prebuilt.tool_node.ToolNode]. The "tools" node executes the tools (1 tool per `tool_call`) and adds the responses to the messages list as `ToolMessage` objects. The agent node then calls the language model again. The process repeats until no more `tool_calls` are present in the response.