langgraph

Par mkurman · zorai

LangGraph — orchestrez des agents LLM sous forme de graphes avec état. Coordination multi-agents, état persistant, human-in-the-loop, streaming, checkpointing et flux de contrôle conditionnel. Construisez des workflows d'agents complexes.

npx skills add https://github.com/mkurman/zorai --skill langgraph

Aperçu

LangGraph construit des workflows d'agent multi-étapes et stateful sous forme de graphes. Supporte le routage conditionnel, les points de contrôle human-in-the-loop, l'état persistant, le streaming et l'orchestration multi-agent. La conception basée sur des graphes permet un comportement d'agent complexe et contrôlable.

Installation

uv pip install langgraph

Graphe simple

from typing import TypedDict
from langgraph.graph import StateGraph, END

class AgentState(TypedDict):
    messages: list
    next_step: str

def research(state):
    return {"messages": state["messages"], "next_step": "write"}

def write(state):
    return {"messages": state["messages"], "next_step": "review"}

def review(state):
    return {"messages": state["messages"], "next_step": "__end__"}

graph = StateGraph(AgentState)
graph.add_node("research", research)
graph.add_node("write", write)
graph.add_node("review", review)
graph.set_entry_point("research")
graph.add_edge("research", "write")
graph.add_conditional_edges("write", lambda s: s["next_step"])
graph.add_edge("review", END)
app = graph.compile()

result = app.invoke({"messages": [], "next_step": ""})

Références

Skills similaires