Skip to content

Commit d6c5c08

Browse files
feat(eino): sync zh documents
Change-Id: I43a526ceaff63339e9dee705f0d55c5d6695d2f9
1 parent becca19 commit d6c5c08

File tree

277 files changed

+3561
-6026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+3561
-6026
lines changed

assets/js/mermaid.js

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,77 @@
22
{{ if .enable }}
33
(function($) {
44
var needMermaid = false;
5-
$('.language-mermaid').parent().replaceWith(function() {
5+
function preprocessMermaid(text) {
6+
var fm = text.match(/^\s*---\s*\n([\s\S]*?)\n---\s*\n?/);
7+
var directive = '';
8+
var body = text;
9+
if (fm) {
10+
var yaml = fm[1];
11+
var obj = {};
12+
var current = null;
13+
yaml.split('\n').forEach(function(line) {
14+
var l = line.trim();
15+
if (!l) return;
16+
if (/^[\w-]+\s*:\s*$/.test(l)) {
17+
current = l.replace(/:\s*$/, '').trim();
18+
obj[current] = obj[current] || {};
19+
return;
20+
}
21+
var m = l.match(/^(\w[\w-]*)\s*:\s*(.*)$/);
22+
if (m) {
23+
var k = m[1];
24+
var v = m[2].trim();
25+
v = v.replace(/^['"]|['"]$/g, '');
26+
if (current) {
27+
obj[current][k] = v;
28+
} else {
29+
obj[k] = v;
30+
}
31+
}
32+
});
33+
var cfg = obj.config || obj;
34+
directive = '%%{init: ' + JSON.stringify(cfg) + '}%%\n';
35+
body = text.replace(fm[0], '');
36+
}
37+
body = body.replace(/<br\s*\/?>(?![^`]*`)/gi, '\\n');
38+
body = body.split('\n').map(function(line) {
39+
var m = line.match(/^\s*([A-Za-z0-9_]+)\s*@\{\s*([^}]*)\s*\}\s*$/);
40+
if (m) {
41+
var id = m[1];
42+
var props = m[2];
43+
var lm = props.match(/label\s*:\s*("[^"]*"|'[^']*'|[^,]+)/);
44+
var label = lm ? lm[1].replace(/^['"]|['"]$/g, '') : id;
45+
return id + '["' + label + '"]';
46+
}
47+
return line;
48+
}).join('\n');
49+
return directive + body;
50+
}
51+
52+
function isMermaidLike(text) {
53+
var t = text.trim();
54+
return /^%%\{init:/.test(t) || /^---\s*/.test(t) || /^(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|gantt|pie)\b/.test(t);
55+
}
56+
57+
var toReplace = [];
58+
$('pre > code.language-mermaid').each(function() { toReplace.push($(this)); });
59+
$('pre > code').each(function() {
60+
var $c = $(this);
61+
if ($c.hasClass('language-mermaid')) return;
62+
if (isMermaidLike($c.text())) toReplace.push($c);
63+
});
64+
65+
toReplace.forEach(function($code) {
666
needMermaid = true;
7-
return $('<pre class="mermaid">').text($(this).text());
67+
var raw = $code.text();
68+
var processed = preprocessMermaid(raw);
69+
var $wrapper = $code.closest('div[class*=language-]');
70+
var $new = $('<pre class="mermaid">').text(processed);
71+
if ($wrapper.length) {
72+
$wrapper.replaceWith($new);
73+
} else {
74+
$code.parent().replaceWith($new);
75+
}
876
});
977

1078
if (!needMermaid) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
Description: ""
3+
date: "2025-07-21"
4+
lastmod: ""
5+
tags: []
6+
title: 'Eino: 贡献规范'
7+
weight: 0
8+
---
9+
10+
Eino 代码的贡献形式:
11+
12+
1. 贡献代码的同学以 Fork PR 的形式提交代码
13+
1. 提交 PR 时,请写清楚贡献代码的前因后果
14+
2. Eino Maintainers 会定期 Review 提交的 PR,并在 PR 中的 Conversion 讨论代码内容
15+
3. 代码达到合入条件后,由 Eino Maintainers 触发单测并合入。
16+
17+
# 组件贡献
18+
19+
Eino 组件的实现一般会在 Eino-Ext 仓库中的特定目录下,新建一个 Go Sub Module,独立开发和维护。
20+
21+
- 必须包含中英文的 README
22+
- 必须包含丰富准确的 Examples
23+
- 必须包含 callback.Handler 的切面点位的注入

content/zh/docs/eino/FAQ.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
Description: ""
3+
date: "2025-12-01"
4+
lastmod: ""
5+
tags: []
6+
title: FAQ
7+
weight: 0
8+
---
9+
10+
# Q: cannot use openapi3.TypeObject (untyped string constant "object") as *openapi3.Types value in struct literal,cannot use types (variable of type string) as *openapi3.Types value in struct literal
11+
12+
检查 github.com/getkin/kin-openapi 依赖版本不能超过 v0.118.0
13+
14+
# Q: Agent 流式调用时不会进入 ToolsNode 节点。或流式效果丢失,表现为非流式。
15+
16+
- 先更新 eino 版本到最新
17+
18+
不同的模型在流式模式下输出工具调用的方式可能不同: 某些模型(如 OpenAI) 会直接输出工具调用;某些模型 (如 Claude) 会先输出文本,然后再输出工具调用。因此需要使用不同的方法来判断,这个字段用来指定判断模型流式输出中是否包含工具调用的函数。
19+
20+
ReAct Agent 的 Config 中有一个 StreamToolCallChecker 字段,如未填写,Agent 会使用“非空包”是否包含工具调用判断:
21+
22+
```go
23+
**func **firstChunkStreamToolCallChecker(_ context.Context, sr *schema.StreamReader[*schema.Message]) (bool, error) {
24+
**defer **sr.Close()
25+
26+
**for **{
27+
msg, err := sr.Recv()
28+
**if **err == io.EOF {
29+
**return **false, nil
30+
}
31+
**if **err != nil {
32+
**return **false, err
33+
}
34+
35+
**if **len(msg.ToolCalls) > 0 {
36+
**return **true, nil
37+
}
38+
39+
**if **len(msg.Content) == 0 { // skip empty chunks at the front
40+
**continue**
41+
** **}
42+
43+
**return **false, nil
44+
}
45+
}
46+
```
47+
48+
上述默认实现适用于:模型输出的 Tool Call Message 中只有 Tool Call。
49+
50+
默认实现不适用的情况:在输出 Tool Call 前,有非空的 content chunk。此时,需要自定义 tool Call checker 如下:
51+
52+
```
53+
_toolCallChecker := func(ctx context.Context, sr *schema.StreamReader[*schema.Message]) (bool, error) {_
54+
_ defer sr.Close()_
55+
_ for {_
56+
_ msg, err := sr.Recv()_
57+
_ if err != nil {_
58+
_ if errors.Is(err, io.EOF) {_
59+
_ // finish_
60+
_ break_
61+
_ }_
62+
63+
_ return false, err_
64+
_ }_
65+
66+
_ if len(msg.ToolCalls) > 0 {_
67+
_ return true, nil_
68+
_ }_
69+
_ }_
70+
_ return false, nil_
71+
}
72+
```
73+
74+
上面这个自定义 StreamToolCallChecker,在模型常规输出 answer 时,需要判断**所有包**是否包含 ToolCall,从而导致“流式判断”的效果丢失。如果希望尽可能保留“流式判断”效果,解决这一问题的建议是:
75+
76+
> 💡
77+
> 尝试添加 prompt 来约束模型在工具调用时不额外输出文本,例如:“如果需要调用 tool,直接输出 tool,不要输出文本”。
78+
>
79+
> 不同模型受 prompt 影响可能不同,实际使用时需要自行调整 prompt 并验证效果。
80+
81+
# Q: [github.com/bytedance/sonic/loader](http://github.com/bytedance/sonic/loader): invalid reference to runtime.lastmoduledatap
82+
83+
老版本 sonic 不兼容 go1.24,更新版本大于 v1.13.2 即可
84+
85+
# Q: Tool Input 反序列化失败:failed to invoke tool call {tool_call_id}: unmarshal input fail
86+
87+
目前模型一般不会产生非法 json 输出,可以先确认下反序列化失败原因是什么,大概率是模型输出超长截断导致。
88+
89+
# Q: Eino 如何实现批处理节点? 类似 Coze 中的批处理节点
90+
91+
Eino 目前不支持批处理,可选方法有两种
92+
93+
1. 每次请求按需动态构建 graph,额外成本不高。 这种方法需要注意 Chain Parallel 要求其中并行节点数量大于一,
94+
2. 自定义批处理节点,节点内自行批处理任务
95+
96+
# Q: fornax sdk 中发生 panic / panic 栈中存在 fornax sdk
97+
98+
先把 Fornax sdk 和 eino 版本升级到最新试下
99+
100+
# Q: eino 支持把模型结构化输出吗
101+
102+
分两步,第一步要求模型输出结构化数据,有三个方法:
103+
104+
1. 部分模型支持直接配置(比如 openai 的 response format),可以看下模型配置里有没有。
105+
2. 通过 tool call 功能获得
106+
3. 写 prompt 要求模型
107+
108+
得到模型结构化输出后,可以用 schema.NewMessageJSONParser 把 message 转换成你需要的 struct
109+
110+
# Q:图片识别场景中报错:One or more parameters specified in the request are not valid
111+
112+
检查模型是否支持图片输入(doubao 系列只有带 vision 的模型才支持)
113+
114+
# Q: 如何获取模型(chat model)输出的 Reasoning Content/推理/深度思考 内容:
115+
116+
如果模型封装支持输出 Reasoning Content/推理/深度思考 内容,这些内容会储存到模型输出的 Message 的 Extra 字段,在封装目录下会提供类似 GetReasoningContent/GetThinking 函数,用这些方法可以从 message 中获取到。
117+
118+
# Q:报错中包含"context deadline exceeded" "timeout" "context canceled"
119+
120+
超时或者 ctx 被框架服务框架或人为取消,调整超时或者排查代码即可。 如果觉得模型等组件返回时间过长不符合预期,可以直接去找服务提供方,eino 只做透传,不需要提 eino oncall
121+
122+
# Q:想要在子图中获取父图的 State 怎么做
123+
124+
如果父图和子图存在 state ,子图的 state 会覆盖父图的 state 。因此,需要自定义 context key ,在调用子图前,调用 compose.ProcessState() 方法先获取父图的 state ,将父图 state 传入到自定义的 context key 中。
125+
126+
# Q: eino-ext 支持的 Model 模型的如何适配多模特的输入输出 ?
127+
128+
eino-ext 支持的多模态输入输出场景,可以查阅 [https://www.cloudwego.io/zh/docs/eino/ecosystem_integration/chat_model](https://www.cloudwego.io/zh/docs/eino/ecosystem_integration/chat_model) 对应模型的 Examples 示例;
129+
130+
# Q: 使用最新的多模态支持字段 UserInputMultiContent 输入多模态数据,但模型侧好像没有我传入的多模态数据或者多模态输入时,读不到 multicontent 的内容
131+
132+
最新版本的 Eino 引入 UserInputMultiContent 与 AssistantGenMultiContent 分别表达用户侧输入的多模态数据与模型侧返回的多模态数据,其中 eino-ext 中的 chatmodel 实现都已经做了适配,如果发现模型侧没有收到多模态信息,可以尝试升级下我们使用的模型的包。go get 到最新版本再次尝试运行看是否问题得到解决。
133+
134+
# Q: 升级到 0.6.x 版本后,有不兼容问题
135+
136+
根据先前社区公告规划 [Migration from OpenAPI 3.0 Schema Object to JSONSchema in Eino · cloudwego/eino · Discussion #397](https://github.com/cloudwego/eino/discussions/397),已发布 eino V0.6.1 版本。重要更新内容为移除了 getkin/kin-openapi 依赖以及所有 OpenAPI 3.0 相关代码。
137+
138+
eino-ext 部分 module 报错 undefined: schema.NewParamsOneOfByOpenAPIV3 等问题,升级报错的 eino-ext module 到最新版本即可。
139+
140+
如果 schema 改造比较复杂,可以使用 [JSONSchema 转换方法](https://bytedance.larkoffice.com/wiki/ZMaawoQC4iIjNykzahwc6YOknXf)文档中的工具方法辅助转换。
141+
142+
# Q: context canceled / context deadline exceeded
143+
144+
调用 eino 时传入的 ctx 被取消/超时了,与框架无关。

content/zh/docs/eino/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
Description: Eino 是基于 Go 的 AI 应用开发框架
3-
date: "2025-03-18"
2+
Description: Eino 是基于 Golang 的 AI 应用开发框架
3+
date: "2025-11-20"
44
lastmod: ""
55
linktitle: Eino
66
menu:

content/zh/docs/eino/core_modules/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2025-02-10"
3+
date: "2025-07-21"
44
lastmod: ""
55
tags: []
66
title: 'Eino: 核心模块'

content/zh/docs/eino/core_modules/chain_and_graph_orchestration/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2025-02-10"
3+
date: "2025-07-21"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Chain & Graph & Workflow 编排功能'
@@ -45,7 +45,7 @@ Eino 对「编排」有着这样的洞察:
4545
- 详细信息参考:[Eino: Callback 用户手册](/zh/docs/eino/core_modules/chain_and_graph_orchestration/callback_manual)
4646
- 提供了 call option 的机制,**扩展性**是快速迭代中的系统最基本的诉求
4747
- 详细信息参考:[Eino: CallOption 能力与规范](/zh/docs/eino/core_modules/chain_and_graph_orchestration/call_option_capabilities)
48-
- 提供了 “类型对齐” 的开发方式的强化,降低开发者心智负担,把 Go**类型安全**特性发挥出来
48+
- 提供了 “类型对齐” 的开发方式的强化,降低开发者心智负担,把 golang**类型安全**特性发挥出来
4949
- 详细信息参考:[Eino: 编排的设计理念](/zh/docs/eino/core_modules/chain_and_graph_orchestration/orchestration_design_principles)
5050
- 提供了 “**流的自动转换**” 能力,让 “流” 在「编排系统的复杂性来源榜」中除名
5151
- 详细信息参考:[Eino 流式编程要点](/zh/docs/eino/core_modules/chain_and_graph_orchestration/stream_programming_essentials)

content/zh/docs/eino/core_modules/chain_and_graph_orchestration/call_option_capabilities.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
Description: ""
3-
date: "2025-01-22"
3+
date: "2025-11-20"
44
lastmod: ""
55
tags: []
66
title: 'Eino: CallOption 能力与规范'
7-
weight: 5
7+
weight: 6
88
---
99

1010
**CallOption**: 对 Graph 编译产物进行调用时,直接传递数据给特定的一组节点(Component、Implementation、Node)的渠道
@@ -296,6 +296,7 @@ compiledGraph.Invoke(ctx, input, WithCallbacks(handler))
296296

297297
// 只对特定类型节点生效的 call option
298298
compiledGraph.Invoke(ctx, input, WithChatModelOption(WithTemperature(0.5))
299+
compiledGraph.Invoke(ctx, input, WithToolOption(WithXXX("xxx"))
299300

300301
// 只对特定节点生效的 call option
301302
compiledGraph.Invoke(ctx, input, WithCallbacks(handler).DesignateNode("node_1"))

content/zh/docs/eino/core_modules/chain_and_graph_orchestration/callback_manual.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
Description: ""
3-
date: "2025-03-18"
3+
date: "2025-12-01"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Callback 用户手册'
7-
weight: 4
7+
weight: 5
88
---
99

1010
## 解决的问题
@@ -94,7 +94,7 @@ type RunInfo struct {
9494
- 有接口的 Component:是啥接口,就是啥
9595
- Lambda:固定值 Lambda
9696
- Graph Node: 用内部的 Component/Lambda/Graph 的值。
97-
- Graph 自身:固定值 Graph / Chain. (之前曾有 StateGraph / StateChain ,现已整合到 Graph / Chain 中)
97+
- Graph 自身:固定值 Graph / Chain / Workflow. (之前曾有 StateGraph / StateChain ,现已整合到 Graph / Chain 中)
9898

9999
### Callback Input & Output
100100

content/zh/docs/eino/core_modules/chain_and_graph_orchestration/chain_graph_introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2025-03-28"
3+
date: "2025-12-01"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Chain/Graph 编排介绍'

content/zh/docs/eino/core_modules/chain_and_graph_orchestration/interrupt_checkpoint.md renamed to content/zh/docs/eino/core_modules/chain_and_graph_orchestration/checkpoint_interrupt.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
---
22
Description: ""
3-
date: "2025-08-07"
3+
date: "2025-11-20"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Interrupt & CheckPoint使用手册'
7-
weight: 6
7+
weight: 7
88
---
99

10+
> 💡
11+
> 注意:v0.3.26 版本中因为代码编写错误导致 CheckPoint 的序列化内容产生 break,新接入 CheckPoint 使用 v0.3.26 以后的版本,建议直接使用最新。
12+
>
13+
> eino 提供了兼容分支,使用了 checkpoint 且版本低于 v0.3.26 的业务在升级 eino 时可以先升级到兼容分支,老数据淘汰后再升级到主干。
14+
>
15+
> 因为兼容分支会引入额外的性能开销并且一般来说业务 agent checkpoint 有不太长的有效期,所以分支没有合入主干。
16+
1017
# 介绍
1118

1219
使用 Interrupt & CheckPoint 功能,可以实现在指定位置暂停 Graph 执行并在之后断点续传,如果是 StateGraph,还可以在断点续传前修改 State。
@@ -236,7 +243,7 @@ g.AddAnyGraph("node1", subGraph, WithGraphCompileOptions(
236243
WithInterruptAfterNodes([]string{"node2"}),
237244
))
238245

239-
g.Compile(ctx, WithCheckPointer(cp))
246+
g.Compile(ctx, WithCheckPointStore(cp))
240247
```
241248

242249
如果在子图中 interrupt,resume 时修改的 state 应为子图 state。TODO,说明下 StateModifier 中 Path 使用

0 commit comments

Comments
 (0)