MCPcopy
hub / github.com/cloudwego/eino

github.com/cloudwego/eino @v0.9.12 sqlite

repository ↗ · DeepWiki ↗ · release v0.9.12 ↗
5,198 symbols 25,350 edges 338 files 1,478 documented · 28%
README

Eino

coverage Release WebSite License Go Report Card OpenIssue ClosedIssue Stars Forks

English | 中文

简介

Eino['aino] 是一个 Go 语言的 LLM 应用开发框架,借鉴了 LangChain、Google ADK 等开源项目,按照 Go 的惯例设计。

Eino 提供: - 组件ChatModelToolRetrieverChatTemplate 等可复用模块,官方实现覆盖 OpenAI、Ollama 等 - 智能体开发套件(ADK):支持工具调用、多智能体协同、上下文管理、中断/恢复等人机交互,以及开箱即用的智能体模式 - 编排:把组件组装成图或工作流,既能独立运行,也能作为工具给智能体调用 - 示例:常见模式和实际场景的可运行代码

快速上手

ChatModelAgent

配置好 ChatModel,加上工具(可选),就能跑起来:

chatModel, _ := openai.NewChatModel(ctx, &openai.ChatModelConfig{
    Model:  "gpt-4o",
    APIKey: os.Getenv("OPENAI_API_KEY"),
})

agent, _ := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
    Model: chatModel,
})

runner := adk.NewRunner(ctx, adk.RunnerConfig{Agent: agent})
iter := runner.Query(ctx, "Hello, who are you?")
for {
    event, ok := iter.Next()
    if !ok {
        break
    }
    fmt.Println(event.Message.Content)
}

加工具让智能体有更多能力:

agent, _ := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
    Model: chatModel,
    ToolsConfig: adk.ToolsConfig{
        ToolsNodeConfig: compose.ToolsNodeConfig{
            Tools: []tool.BaseTool{weatherTool, calculatorTool},
        },
    },
})

智能体内部自动处理 ReAct 循环,自己判断什么时候调工具、什么时候回复。

ChatModelAgent 示例 · 文档

DeepAgent

复杂任务用 DeepAgent,它会把问题拆成步骤,分派给子智能体,并追踪进度:

deepAgent, _ := deep.New(ctx, &deep.Config{
    ChatModel: chatModel,
    SubAgents: []adk.Agent{researchAgent, codeAgent},
    ToolsConfig: adk.ToolsConfig{
        ToolsNodeConfig: compose.ToolsNodeConfig{
            Tools: []tool.BaseTool{shellTool, pythonTool, webSearchTool},
        },
    },
})

runner := adk.NewRunner(ctx, adk.RunnerConfig{Agent: deepAgent})
iter := runner.Query(ctx, "Analyze the sales data in report.csv and generate a summary chart")

DeepAgent 可以配置成:协调多个专业智能体、跑 shell 命令、执行 Python、搜索网络。

DeepAgent 示例 · 文档

编排

需要精确控制执行流程时,用 compose 搭图或工作流:

graph := compose.NewGraph[*Input, *Output]()
graph.AddLambdaNode("validate", validateFn)
graph.AddChatModelNode("generate", chatModel)
graph.AddLambdaNode("format", formatFn)

graph.AddEdge(compose.START, "validate")
graph.AddEdge("validate", "generate")
graph.AddEdge("generate", "format")
graph.AddEdge("format", compose.END)

runnable, _ := graph.Compile(ctx)
result, _ := runnable.Invoke(ctx, input)

编排出来的流程可以包装成工具给智能体用,把确定性流程和自主决策结合起来:

tool, _ := graphtool.NewInvokableGraphTool(graph, "data_pipeline", "Process and validate data")

agent, _ := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
    Model: chatModel,
    ToolsConfig: adk.ToolsConfig{
        ToolsNodeConfig: compose.ToolsNodeConfig{
            Tools: []tool.BaseTool{tool},
        },
    },
})

这样你可以写出精确可控的业务流程,再让智能体决定什么时候调用。

GraphTool 示例 · 编排文档

主要特性

组件生态

Eino 定义了组件抽象(ChatModel、Tool、Retriever、Embedding 等),官方实现覆盖 OpenAI、Claude、Gemini、Ark、Ollama、Elasticsearch 等。

eino-ext

流式处理

Eino 在编排中自动处理流式:拼接、装箱、合并、复制。组件只需实现有业务意义的流式范式,框架处理剩下的。

文档

回调切面

在固定切点(OnStart、OnEnd、OnError、OnStartWithStreamInput、OnEndWithStreamOutput)注入日志、追踪、指标,适用于组件、图、智能体。

文档

中断/恢复

任何智能体或工具都能暂停等待人工输入,从检查点恢复。框架处理状态持久化和路由。

文档 · 示例

框架结构

Eino 框架包含:

  • Eino(本仓库):类型定义、流处理机制、组件抽象、编排、智能体实现、切面机制

  • EinoExt:组件实现、回调处理器、使用示例、评估器、提示优化器

  • Eino Devops:可视化开发和调试

  • EinoExamples:示例应用和最佳实践

文档

依赖

  • Go 1.18 及以上

代码规范

本仓库使用 golangci-lint,本地检查:

golangci-lint run ./...

规则: - 导出的函数、接口、package 等需要 GoDoc 注释 - 代码格式符合 gofmt -s - import 顺序符合 goimports(std -> third party -> local)

安全

如果你在该项目中发现潜在的安全问题,或你认为可能发现了安全问题,请通过我们的安全中心漏洞报告邮箱通知字节跳动安全团队。

不要创建公开的 GitHub Issue。

联系我们

    LarkGroup

开源许可证

本项目基于 Apache-2.0 许可证 开源。

Extension points exported contracts — how you extend this code

Typer (Interface)
Typer provides a human-readable type name for a component implementation. When implemented, the component's full displa [13 …
components/types.go
ChatTemplate (Interface)
ChatTemplate formats a variables map into a list of messages for a ChatModel. Format substitutes the values from vs int [7 …
components/prompt/interface.go
BaseModel (Interface)
BaseModel is the generic base model interface parameterized by message type M. It exposes two modes of interaction: - [B [52 …
components/model/interface.go
Retriever (Interface)
go:generate mockgen -destination ../../internal/mock/components/retriever/retriever_mock.go --package retriever -source [8 …
components/retriever/interface.go
BaseTool (Interface)
BaseTool provides the metadata that a ChatModel uses to decide whether and how to call a tool. Info returns a [schema.To [76 …
components/tool/interface.go
TypedAgent (Interface)
TypedAgent is the base agent interface parameterized by message type. For M = *schema.Message, the full ADK feature set [39 …
adk/interface.go
TypedAgentHub (Interface)
TypedAgentHub provides agent instances for context mode (fork/fork_with_context) execution. [20 implementers]
adk/middlewares/skill/skill.go
MessagesTemplate (Interface)
MessagesTemplate is the interface for messages template. It's used to render a template to a list of messages. e.g. ch [7 …
schema/message.go

Core symbols most depended-on inside this repo

Run
called by 1876
adk/interface.go
AssistantMessage
called by 645
schema/message.go
UserMessage
called by 575
schema/message.go
Next
called by 510
adk/utils.go
Send
called by 488
adk/utils.go
Close
called by 483
schema/stream.go
Error
called by 412
adk/cancel.go
EXPECT
called by 379
internal/mock/components/model/ChatModel_mock.go

Shape

Function 2,486
Method 1,508
Struct 975
FuncType 91
Interface 73
TypeAlias 65

Languages

Go100%

Modules by API surface

adk/turn_loop_test.go206 symbols
schema/agentic_message.go109 symbols
adk/turn_loop.go101 symbols
adk/cancel_test.go90 symbols
adk/middlewares/filesystem/filesystem_test.go79 symbols
schema/message.go76 symbols
adk/agent_tool_test.go73 symbols
compose/tool_node.go71 symbols
adk/handler_test.go71 symbols
schema/stream.go68 symbols
adk/chatmodel.go68 symbols
adk/wrappers_test.go67 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

github.com/bahlo/generic-list-gov0.2.0 · 1×
github.com/bmatcuk/doublestar/v4v4.10.0 · 1×
github.com/bytedance/gopkgv0.1.3 · 1×
github.com/bytedance/sonicv1.15.0 · 1×
github.com/bytedance/sonic/loaderv0.5.0 · 1×
github.com/cloudwego/base64xv0.1.6 · 1×
github.com/eino-contrib/jsonschemav1.0.3 · 1×
github.com/goph/emperrorv0.17.2 · 1×

For agents

$ claude mcp add eino \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact