mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-22 01:25:06 +02:00
docs: reorganize API refs (#1884)
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user