功能那么强大,代码如此简单
npx skills add https://github.com/smallnest/langgraphgo --skill feature-builderCLI를 사용하여 이 스킬을 설치하고 작업 공간에서 SKILL.md 워크플로 사용을 시작하세요.

Abbreviated as
lango, 中文:懒狗
Website: http://lango.rpcx.io
🔀 Forked from paulnegz/langgraphgo - Enhanced with streaming, visualization, observability, and production-ready features.
This fork aims for feature parity with the Python LangGraph library, adding support for parallel execution, persistence, advanced state management, pre-built agents, and human-in-the-loop workflows.
Real-world applications built with LangGraphGo:
| Insight | NoteX |
|---|---|
![]() |
![]() |
Insight - An AI-powered knowledge management and insight generation platform that uses LangGraphGo to build intelligent analysis workflows, helping users extract key insights from massive amounts of information.
NoteX - An intelligent note-taking and knowledge organization tool that leverages AI for automatic categorization, tag extraction, and content association, making knowledge management more efficient.
go get github.com/smallnest/langgraphgo
Note: This repository uses Git submodules for the showcases directory. When cloning, use one of the following methods:
# Method 1: Clone with submodules
git clone --recurse-submodules https://github.com/smallnest/langgraphgo
# Method 2: Clone first, then initialize submodules
git clone https://github.com/smallnest/langgraphgo
cd langgraphgo
git submodule update --init --recursive
Core Runtime:
RunnableConfig.langchaingo.Persistence & Reliability:
Advanced Capabilities:
AppendReducer).AddMessages).updates, values, messages).ReAct, CreateAgent, and Supervisor agent factories.Developer Experience:
UpdateState), and resume.Tavily and Exa search tools.package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
ctx := context.Background()
model, _ := openai.New()
// 1. Create Graph
g := graph.NewStateGraph[map[string]any]()
// 2. Add Nodes
g.AddNode("generate", "generate", func(ctx context.Context, state map[string]any) (map[string]any, error) {
input, ok := state["input"].(string)
if !ok {
return nil, fmt.Errorf("invalid input")
}
response, err := model.Call(ctx, input)
if err != nil {
return nil, err
}
state["output"] = response
return state, nil
})
// 3. Define Edges
g.AddEdge("generate", graph.END)
g.SetEntryPoint("generate")
// 4. Compile
runnable, _ := g.Compile()
// 5. Invoke
initialState := map[string]any{
"input": "Hello, LangGraphGo!",
}
result, _ := runnable.Invoke(ctx, initialState)
fmt.Println(result)
}
This project includes 90+ comprehensive examples organized into categories:
LangGraphGo automatically executes nodes in parallel when they share the same starting node. Results are merged using the graph's state merger or schema.
g.AddEdge("start", "branch_a")
g.AddEdge("start", "branch_b")
// branch_a and branch_b run concurrently
Pause execution to allow for human approval or input.
config := &graph.Config{
InterruptBefore: []string{"human_review"},
}
// Execution stops before "human_review" node
state, err := runnable.InvokeWithConfig(ctx, input, config)
// Resume execution
resumeConfig := &graph.Config{
ResumeFrom: []string{"human_review"},
}
runnable.InvokeWithConfig(ctx, state, resumeConfig)
Quickly create complex agents using factory functions.
// Create a ReAct agent
agent, err := prebuilt.CreateReactAgent(model, tools)
// Create an agent with options
agent, err := prebuilt.CreateAgent(model, tools, prebuilt.WithSystemMessage("System prompt"))
// Create a Supervisor agent
supervisor, err := prebuilt.CreateSupervisor(model, agents)
Generate code that calls tools directly, reducing API round-trips and token usage.
// Create a PTC agent
agent, err := ptc.CreatePTCAgent(ptc.PTCAgentConfig{
Model: model,
Tools: toolList,
Language: ptc.LanguagePython, // or ptc.LanguageGo
ExecutionMode: ptc.ModeDirect, // Subprocess (default) or ModeServer
MaxIterations: 10,
})
// LLM generates code that calls tools programmatically
result, err := agent.Invoke(ctx, initialState)
See the PTC README for detailed documentation.
exporter := runnable.GetGraph()
fmt.Println(exporter.DrawMermaid()) // Generates Mermaid flowchart
go test ./... -v
This project is open for contributions! if you are interested in being a contributor please create feature issues first, then submit PRs..
MIT License - see original repository for details.