eino-guide
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEino Framework Guide
Eino框架指南
Eino (pronounced "i know") is a Go framework for building LLM applications.
Eino(发音为"i know")是一款用于构建LLM应用的Go框架。
Core Concepts
核心概念
Component
组件
Standardized interfaces for AI capabilities. Each interface has multiple interchangeable implementations.
| Component | What It Does | Key Interface |
|---|---|---|
| ChatModel | LLM inference (generate / stream) | |
| Tool | Functions the model can call | |
| Embedding | Text to vector | |
| Retriever | Vector/keyword search | |
| Indexer | Store documents with vectors | |
| ChatTemplate | Prompt formatting with variables | |
| Document Loader/Transformer | Load and process documents | |
| Callback Handler | Observability and tracing | |
Implementations live in (OpenAI, Claude, Gemini, Ark, Ollama, Milvus, Redis, Elasticsearch, etc.).
eino-ext-> Use for selecting, configuring, and using components.
/eino-componentAI能力的标准化接口。每个接口都有多个可互换的实现。
| 组件 | 功能 | 核心接口 |
|---|---|---|
| ChatModel | LLM推理(生成/流式输出) | |
| Tool | 模型可调用的函数 | |
| Embedding | 文本转向量 | |
| Retriever | 向量/关键词搜索 | |
| Indexer | 存储带向量的文档 | |
| ChatTemplate | 带变量的Prompt格式化 | |
| Document Loader/Transformer | 加载和处理文档 | |
| Callback Handler | 可观测性与链路追踪 | |
实现代码位于中(支持OpenAI、Claude、Gemini、Ark、Ollama、Milvus、Redis、Elasticsearch等)。
eino-ext-> 如需选择、配置和使用组件,请使用。
/eino-componentOrchestration (Compose)
编排(Compose)
Three APIs for wiring components into executable pipelines. All compile to a with four execution modes (Invoke, Stream, Collect, Transform).
Runnable[I, O]| API | Topology | When to Use |
|---|---|---|
| Graph | Directed graph, supports cycles | Complex flows with branching, loops (e.g., ReAct pattern) |
| Chain | Linear sequential | Simple pipelines (e.g., template -> model) |
| Workflow | DAG with field-level mapping | Parallel branches with struct field routing |
The compose layer handles type checking, stream conversion between nodes, concurrency, callback injection, and option distribution automatically.
-> Use for building graphs, chains, workflows, streaming, callbacks, and state management.
/eino-compose三个用于将组件组装为可执行流水线的API。全部会编译为,支持四种执行模式(Invoke、Stream、Collect、Transform)。
Runnable[I, O]| API | 拓扑结构 | 使用场景 |
|---|---|---|
| Graph | 有向图,支持循环 | 含分支、循环的复杂流程(例如ReAct模式) |
| Chain | 线性顺序 | 简单流水线(例如模板 -> 模型) |
| Workflow | 支持字段级映射的DAG | 带结构体字段路由的并行分支 |
编排层会自动处理类型检查、节点间的流转换、并发、回调注入和选项分发。
-> 如需构建图、链、工作流、流式处理、回调和状态管理,请使用。
/eino-composeADK (Agent Development Kit)
ADK(Agent开发套件)
High-level abstractions for building AI agents. Encapsulates the model-tool-loop pattern.
| Concept | What It Does |
|---|---|
| ChatModelAgent | ReAct-style agent: model generates, calls tools, loops until done |
| DeepAgent | Pre-built agent with filesystem backend, tool search, summarization |
| Runner | Executes agents, manages checkpoints, emits event streams |
| Middleware (Handlers) | Intercept and extend agent behavior (filesystem, summarization, plan-task, etc.) |
| Interrupt/Resume | Human-in-the-loop: pause agent, get user input, resume from checkpoint |
| AgentAsTool | Wrap an agent as a tool callable by another agent |
-> Use for building agents, configuring middleware, runners, and human-in-the-loop.
/eino-agent用于构建AI Agent的高层抽象,封装了模型-工具-循环模式。
| 概念 | 功能 |
|---|---|
| ChatModelAgent | ReAct风格Agent:模型生成内容、调用工具、循环直到任务完成 |
| DeepAgent | 预构建Agent,支持文件系统后端、工具搜索、摘要生成 |
| Runner | 执行Agent、管理检查点、输出事件流 |
| Middleware (Handlers) | 拦截并扩展Agent行为(文件系统、摘要、规划任务等) |
| Interrupt/Resume | 人在回路:暂停Agent、获取用户输入、从检查点恢复执行 |
| AgentAsTool | 将Agent包装为工具,可供其他Agent调用 |
-> 如需构建Agent、配置中间件、运行器和人在回路能力,请使用。
/eino-agentSchema
Schema
Shared data types used across all layers:
- -- Conversation message (system/user/assistant/tool roles, content, tool calls)
schema.Message - -- Document with content, metadata, and vector embeddings
schema.Document - -- Tool description with JSON schema parameters
schema.ToolInfo - -- Generic streaming reader (always
schema.StreamReader[T])defer stream.Close()
所有层共用的共享数据类型:
- -- 会话消息(系统/用户/助手/工具角色、内容、工具调用)
schema.Message - -- 包含内容、元数据和向量嵌入的文档
schema.Document - -- 带JSON schema参数的工具描述
schema.ToolInfo - -- 通用流式读取器(始终执行
schema.StreamReader[T])defer stream.Close()
Repositories
代码仓库
| Repository | Role |
|---|---|
| Core: interfaces, schema, compose engine, ADK, callbacks |
| Implementations: model providers, vector stores, tools, callback handlers |
| 仓库 | 作用 |
|---|---|
| 核心库:接口、Schema、编排引擎、ADK、回调 |
| 实现库:模型提供商、向量存储、工具、回调处理器 |
Packages at a Glance
包速览
eino (core):
| Package | Contains |
|---|---|
| Message, Document, ToolInfo, StreamReader |
| ChatModel interfaces |
| Tool interfaces (BaseTool, InvokableTool, StreamableTool, Enhanced variants) |
| Embedder interface |
| Retriever interface |
| Indexer interface |
| Loader, Transformer interfaces |
| ChatTemplate interface |
| Graph, Chain, Workflow, ToolsNode, Runnable, state, checkpoint |
| Handler interface, global/per-run registration |
| Agent, Runner, ChatModelAgent, middleware, interrupt/resume |
| DeepAgent preset |
eino-ext (implementations):
| Package | Contains |
|---|---|
| ChatModel implementations (openai, claude, gemini, ark, ollama, deepseek, qwen, etc.) |
| Embedding implementations (openai, ark, ollama, etc.) |
| Retriever implementations (redis, milvus2, es8, qdrant) |
| Indexer implementations (redis, milvus2, es8, qdrant) |
| Tool implementations (mcp, googlesearch, duckduckgo, bingsearch, etc.) |
| Callback handlers (cozeloop, apmplus, langfuse, langsmith) |
| Local filesystem Backend for DeepAgent |
eino(核心库):
| 包 | 包含内容 |
|---|---|
| Message、Document、ToolInfo、StreamReader |
| ChatModel 接口 |
| Tool 接口(BaseTool、InvokableTool、StreamableTool、增强变体) |
| Embedder 接口 |
| Retriever 接口 |
| Indexer 接口 |
| Loader、Transformer 接口 |
| ChatTemplate 接口 |
| Graph、Chain、Workflow、ToolsNode、Runnable、状态、检查点 |
| Handler 接口、全局/单次运行注册 |
| Agent、Runner、ChatModelAgent、中间件、中断/恢复 |
| DeepAgent 预设 |
eino-ext(实现库):
| 包 | 包含内容 |
|---|---|
| ChatModel 实现(openai、claude、gemini、ark、ollama、deepseek、qwen等) |
| Embedding 实现(openai、ark、ollama等) |
| Retriever 实现(redis、milvus2、es8、qdrant) |
| Indexer 实现(redis、milvus2、es8、qdrant) |
| Tool 实现(mcp、googlesearch、duckduckgo、bingsearch等) |
| 回调处理器(cozeloop、apmplus、langfuse、langsmith) |
| DeepAgent 用的本地文件系统后端 |
Choosing Your Approach
方案选择
| Scenario | Approach | Skill |
|---|---|---|
| Single model call (generate or stream) | Use ChatModel directly | |
| Multi-turn agent with tools | ChatModelAgent + Runner | |
| Production agent with filesystem, tool search | DeepAgent | |
| Linear pipeline (template -> model) | Chain | |
| Complex flow with branching or loops | Graph | |
| Parallel branches with field mapping | Workflow | |
| RAG (embed + index + retrieve) | Indexer + Retriever + Embedding | |
| Agent with human approval | Interrupt/Resume + Runner | |
| Observability and tracing | Callback handlers | |
| 场景 | 方案 | 技能 |
|---|---|---|
| 单次模型调用(生成或流式输出) | 直接使用ChatModel | |
| 带工具的多轮Agent | ChatModelAgent + Runner | |
| 带文件系统、工具搜索的生产级Agent | DeepAgent | |
| 线性流水线(模板 -> 模型) | Chain | |
| 带分支或循环的复杂流程 | Graph | |
| 带字段映射的并行分支 | Workflow | |
| RAG(嵌入 + 索引 + 检索) | Indexer + Retriever + Embedding | |
| 需人工审批的Agent | Interrupt/Resume + Runner | |
| 可观测性与链路追踪 | 回调处理器 | |
Reference Files
参考文件
- -- Core data types shared across all layers: Message, Document, ToolInfo, StreamReader
reference/schema.md - -- Runnable[I, O] interface, four execution modes, runtime options
reference/runnable.md - -- Three complete working examples (ChatModel, Agent+Runner, Chain)
reference/quick-start.md
- -- 所有层共用的核心数据类型:Message、Document、ToolInfo、StreamReader
reference/schema.md - -- Runnable[I, O]接口、四种执行模式、运行时选项
reference/runnable.md - -- 三个完整可运行示例(ChatModel、Agent+Runner、Chain)
reference/quick-start.md
Instructions to Agent
给Agent的指令
- Route to the appropriate skill (,
/eino-component,/eino-compose) when the question is specific. Consult the "Choosing Your Approach" table./eino-agent - Always provide Go code examples using real import paths from and
github.com/cloudwego/eino.github.com/cloudwego/eino-ext - For component implementation details, always read the provider's reference file before generating code. Do not assume constructor or config naming conventions.
- Prefer ADK (ChatModelAgent + Runner) for agent use cases over manually building ReAct loops with compose graphs.
- When showing streaming code, always include .
defer stream.Close()
- 当问题具体时,路由到合适的技能(、
/eino-component、/eino-compose),请参考“方案选择”表格。/eino-agent - 始终提供使用和
github.com/cloudwego/eino真实导入路径的Go代码示例。github.com/cloudwego/eino-ext - 对于组件实现细节,生成代码前请务必阅读提供商的参考文件,不要假设构造函数或配置的命名规则。
- Agent使用场景优先选择ADK(ChatModelAgent + Runner),而不是用编排图手动构建ReAct循环。
- 展示流式代码时,始终包含。
defer stream.Close()