Skip to content

Commit ce65333

Browse files
feat(eino): update docs and optimize mermaid rendering (#1501)
1 parent 9741625 commit ce65333

File tree

24 files changed

+926
-173
lines changed

24 files changed

+926
-173
lines changed

assets/js/mermaid.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,31 @@
22
{{ if .enable }}
33
(function($) {
44
var needMermaid = false;
5+
function parseFrontMatter(text) {
6+
var m = text.match(/^\s*---\s*[\r\n]([\s\S]*?)[\r\n]---\s*[\r\n]?/);
7+
if (!m) return { cfg: null, body: text };
8+
var yamlStr = m[1];
9+
var doc = null;
10+
try {
11+
if (window.jsyaml && typeof window.jsyaml.load === 'function') {
12+
doc = window.jsyaml.load(yamlStr);
13+
} else {
14+
doc = JSON.parse(yamlStr);
15+
}
16+
} catch (e) {
17+
console.warn('Mermaid front matter parse failed, fallback to global settings:', e);
18+
return { cfg: null, body: text.replace(m[0], '') };
19+
}
20+
var cfg = doc && typeof doc === 'object' && doc.config ? doc.config : doc;
21+
return { cfg: cfg, body: text.replace(m[0], '') };
22+
}
23+
524
function preprocessMermaid(text) {
6-
var fm = text.match(/^\s*---\s*\n([\s\S]*?)\n---\s*\n?/);
25+
var fm = parseFrontMatter(text);
726
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], '');
27+
var body = fm.body;
28+
if (fm.cfg && typeof fm.cfg === 'object' && Object.keys(fm.cfg).length > 0) {
29+
directive = '%%{init: ' + JSON.stringify(fm.cfg) + '}%%\n';
3630
}
3731
var isV10 = typeof mermaid !== 'undefined' && mermaid.version && parseInt(mermaid.version.split('.')[0], 10) >= 10;
3832
body = body.replace(/<br\s*\/?>(?![^`]*`)/gi, '\\n');

content/en/docs/eino/Eino: Cookbook.md

Lines changed: 230 additions & 0 deletions
Large diffs are not rendered by default.

content/en/docs/eino/FAQ.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
Description: ""
3-
date: "2026-01-20"
3+
date: "2026-01-30"
44
lastmod: ""
55
tags: []
66
title: FAQ
7-
weight: 6
7+
weight: 7
88
---
99

1010
# 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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ date: "2025-07-21"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Core Modules'
7-
weight: 3
7+
weight: 4
88
---
99

1010
Eino’s core modules include the following parts:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2026-01-20"
3+
date: "2026-01-30"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Callback Manual'
@@ -155,7 +155,7 @@ Inject Handlers at graph runtime through `compose.WithCallbacks`, these Handlers
155155

156156
Inject Handlers to a specific Node of the top-level Graph through `compose.WithCallbacks(...).DesignateNode(...)`. When this Node itself is a nested Graph, it will be injected into this nested Graph itself and its internal Nodes.
157157

158-
Inject Handlers to a specific Node of an internally nested Graph through `compose.WithCallbacks(...).DesignateNodeForPath(...)`.
158+
Inject Handlers to a specific Node of an internally nested Graph through `compose.WithCallbacks(...).DesignateNodeWithPath(...)`.
159159

160160
### Injecting Handlers Outside Graph
161161

content/en/docs/eino/core_modules/chain_and_graph_orchestration/stream_programming_essentials.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2026-01-20"
3+
date: "2026-01-30"
44
lastmod: ""
55
tags: []
66
title: Eino Streaming Essentials

content/en/docs/eino/core_modules/components/retriever_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2026-01-20"
3+
date: "2026-01-30"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Retriever Guide'

content/en/docs/eino/core_modules/components/tools_node_guide/how_to_create_a_tool.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2026-01-20"
3+
date: "2026-01-30"
44
lastmod: ""
55
tags: []
66
title: How to Create a Tool
@@ -41,7 +41,7 @@ type StreamableTool interface {
4141

4242
## ToolInfo Representations
4343

44-
In LLM function-call flows, the model must understand whether generated parameters satisfy constraints. Eino supports two representations: `params map[string]*ParameterInfo` and `*openapi3.Schema`.
44+
In LLM function-call flows, the model must understand whether generated parameters satisfy constraints. Based on developer habits and domain standards, Eino provides two representations: `params map[string]*ParameterInfo` and `JSON Schema`.
4545

4646
### 1) `map[string]*ParameterInfo`
4747

@@ -77,26 +77,27 @@ map[string]*schema.ParameterInfo{
7777
}
7878
```
7979

80-
### 2) JSON Schema (2020-12)
80+
### 2) JSON Schema
8181

82-
JSON Schema’s constraint system is rich. In practice, you usually generate it from struct tags or helper functions.
82+
Another common way to represent parameter constraints is `JSON Schema`: [https://json-schema.org/draft/2020-12](https://json-schema.org/draft/2020-12).
8383

84-
#### `GoStruct2ParamsOneOf`
84+
The JSON Schema standard provides very rich ways to constrain parameters. In practice, developers generally don't construct this structure themselves, but use methods to generate it.
8585

86-
Describe constraints via Go tags on a struct and generate `ParamsOneOf`:
86+
#### Using GoStruct2ParamsOneOf
87+
88+
Eino provides a way to describe parameter constraints through go tags in structs, and provides the GoStruct2ParamsOneOf method to generate parameter constraints for a struct:
8789

8890
```go
8991
func GoStruct2ParamsOneOf[T any](opts ...Option) (*schema.ParamsOneOf, error)
9092
```
9193

92-
Supported tags:
94+
The tags used to extract parameter field names and descriptions from T are as follows:
9395

94-
- `jsonschema_description:"xxx"` [recommended] or `jsonschema:"description=xxx"`
95-
- Note: descriptions often include commas; tag commas separate fields and cannot be escaped. Prefer `jsonschema_description`.
96-
- `jsonschema:"enum=xxx,enum=yyy,enum=zzz"`
97-
- `jsonschema:"required"`
98-
- `json:"xxx,omitempty"``omitempty` implies not required
99-
- Customize via `utils.WithSchemaModifier`
96+
- jsonschema_description:"xxx" [recommended] or jsonschema:"description=xxx"
97+
- Descriptions often contain commas, and commas in tags are separators for different fields and cannot be escaped. It's strongly recommended to use the separate jsonschema_description tag.
98+
- jsonschema:"enum=xxx,enum=yyy,enum=zzz"
99+
- Fields are required by default; json:"xxx,omitempty" => use json tag's omitempty to indicate not required
100+
- Use utils.WithSchemaModifier to implement custom parsing methods
100101

101102
Example:
102103

@@ -109,7 +110,7 @@ import (
109110
)
110111

111112
type User struct {
112-
Name string `json:"name" jsonschema_description=the name of the user jsonschema:"required"`
113+
Name string `json:"name,omitempty" jsonschema_description=the name of the user`
113114
Age int `json:"age" jsonschema_description:"the age of the user"`
114115
Gender string `json:"gender" jsonschema:"enum=male,enum=female"`
115116
}
@@ -119,7 +120,7 @@ func main() {
119120
}
120121
```
121122

122-
You usually won't call this directly; prefer `utils.GoStruct2ToolInfo()` or `utils.InferTool()`.
123+
This method is generally not called by developers directly; instead, use `utils.GoStruct2ToolInfo()` to build ToolInfo, or use `utils.InferTool()` directly to build a tool. See the "Converting local functions to tools" section below for details.
123124

124125
## Ways to Implement a Tool
125126

@@ -238,9 +239,9 @@ import (
238239
)
239240

240241
type User struct {
241-
Name string `json:"name" jsonschema:"required,description=the name of the user"`
242-
Age int `json:"age" jsonschema:"description=the age of the user"`
243-
Gender string `json:"gender" jsonschema:"enum=male,enum=female"`
242+
Name string `json:"name" jsonschema:"description=the name of the user"`
243+
Age int `json:"age,omitempty" jsonschema:"description=the age of the user"`
244+
Gender string `json:"gender,omitempty" jsonschema:"enum=male,enum=female"`
244245
}
245246

246247
type Result struct {
@@ -256,9 +257,9 @@ func createTool() (tool.InvokableTool, error) {
256257
}
257258
```
258259

259-
#### `InferOptionableTool`
260+
#### Using InferOptionableTool
260261

261-
Eino’s Option mechanism passes dynamic runtime parameters. Details: `Eino: CallOption capabilities and conventions` at `/docs/eino/core_modules/chain_and_graph_orchestration/call_option_capabilities`. The same mechanism applies to custom tools.
262+
The Option mechanism is a mechanism provided by Eino for passing dynamic parameters at runtime. For details, see [Eino: CallOption Capabilities and Conventions](/docs/eino/core_modules/chain_and_graph_orchestration/call_option_capabilities). This mechanism also applies to custom tools.
262263

263264
When you need custom option parameters, use `InferOptionableTool`:
264265

@@ -310,10 +311,7 @@ func useInInvoke() {
310311

311312
### Approach 3 — Use tools from eino-ext
312313

313-
Beyond custom tools, the `eino-ext` project provides many ready-to-use implementations: `Googlesearch`, `DuckDuckGoSearch`, `wikipedia`, `httprequest`, etc. See implementations at https://github.com/cloudwego/eino-ext/tree/main/components/tool and docs:
314-
315-
- Tool — Googlesearch: `/docs/eino/ecosystem_integration/tool/tool_googlesearch`
316-
- Tool — DuckDuckGoSearch: `/docs/eino/ecosystem_integration/tool/tool_duckduckgo_search`
314+
Beyond custom tools that need to be implemented yourself, the eino-ext project has many general-purpose tool implementations that can be used out of the box, such as [Tool - Googlesearch](/docs/eino/ecosystem_integration/tool/tool_googlesearch), [Tool - DuckDuckGoSearch](/docs/eino/ecosystem_integration/tool/tool_duckduckgo_search), wikipedia, httprequest, etc. See various implementations at [https://github.com/cloudwego/eino-ext/tree/main/components/tool](https://github.com/cloudwego/eino-ext/tree/main/components/tool).
317315

318316
### Approach 4 — Use MCP protocol
319317

content/en/docs/eino/core_modules/eino_adk/agent_quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2026-01-20"
3+
date: "2026-01-30"
44
lastmod: ""
55
tags: []
66
title: 'Eino ADK: Quickstart'

content/en/docs/eino/core_modules/flow_integration_components/react_agent_manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2026-01-20"
3+
date: "2026-01-30"
44
lastmod: ""
55
tags: []
66
title: 'Eino: ReAct Agent Manual'

0 commit comments

Comments
 (0)