What is LangGraph?
LangGraph is an open-source framework for building stateful, controllable AI agent workflows as graphs. You describe your app as nodes (steps) and edges (how to move between steps), with a shared, typed state flowing through the graph. It’s designed for agents and multi-step LLM apps where you need loops, branching, tool use, memory, human-in-the-loop, and reliability.
Core ideas:
-
StateGraph: declare the shape of the shared state. Each node outputs a partial update (a diff). LangGraph applies it to the state—no in-place mutation.
-
Nodes & Edges: register node functions and connect them with edges; use conditional edges for branching; special START and END markers define entry/exit.
-
Persistence (checkpointers): when compiled with a checkpointer, the graph saves a checkpoint each super-step into a thread, enabling resumability, memory, time-travel, fault tolerance, and human review.
-
Helpful built-ins & optional platform: quickstarts and message-centric state helpers in the docs to get started fast, plus an optional LangGraph Platform to deploy and operate long-running, stateful agent workflows.
The smallest possible example (Python)
This is a literal “hello world” graph: one node that replies, wired from START → node → END.
code
This mirrors the official quickstart, just with explicit prints. The key parts to notice are StateGraph(MessagesState), add_node, add_edge(START, ...), add_edge(..., END), and compile().
No comments:
Post a Comment