mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-25 00:52:25 +02:00
This PR removes the following changes: * notebooks that were converted to markdown * mkdocs.yml file to reference the ipython notebooks rather than the markdown files * Makefile install vercel reverted * hooks for markdown-exec * notebook conversion jinja2 templates (for converting notebooks to markdown exec format)
20 KiB
20 KiB
In [1]:
%%capture --no-stderr
%pip install -U langgraphIn [1]:
from typing_extensions import TypedDict
class State(TypedDict):
value_1: str
value_2: intIn [2]:
def step_1(state: State):
return {"value_1": "a"}
def step_2(state: State):
current_value_1 = state["value_1"]
return {"value_1": f"{current_value_1} b"}
def step_3(state: State):
return {"value_2": 10}In [ ]:
from langgraph.graph import START, StateGraph
graph_builder = StateGraph(State)
# Add nodes
graph_builder.add_node(step_1)
graph_builder.add_node(step_2)
graph_builder.add_node(step_3)
# Add edges
graph_builder.add_edge(START, "step_1")
graph_builder.add_edge("step_1", "step_2")
graph_builder.add_edge("step_2", "step_3")In [4]:
graph = graph_builder.compile()In [5]:
from IPython.display import Image, display
display(Image(graph.get_graph().draw_mermaid_png()))In [6]:
graph.invoke({"value_1": "c"})Out [6]:
{'value_1': 'a b', 'value_2': 10}In [7]:
# highlight-next-line
graph_builder = StateGraph(State).add_sequence([step_1, step_2, step_3])
graph_builder.add_edge(START, "step_1")
graph = graph_builder.compile()
graph.invoke({"value_1": "c"})Out [7]:
{'value_1': 'a b', 'value_2': 10}