Skip to content

Commit 6b628ca

Browse files
authored
docs(Eino):Comply with new version of api (#1310)
1 parent 1ccbec9 commit 6b628ca

File tree

2 files changed

+35
-25
lines changed

2 files changed

+35
-25
lines changed

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ func main() {
5050

5151
// Initialize the required tools
5252
tools := compose.ToolsNodeConfig{
53-
InvokableTools: []tool.InvokableTool{mytool},
54-
StreamableTools: []tool.StreamableTool{myStreamTool},
53+
Tools: []tool.BaseTool{
54+
mytool,
55+
...
56+
},
5557
}
5658

5759
// Create an agent
58-
agent, err := react.NewAgent(ctx, react.AgentConfig{
59-
Model: toolableChatModel,
60+
agent, err := react.NewAgent(ctx, &react.AgentConfig{
61+
ToolCallingModel: toolableChatModel,
6062
ToolsConfig: tools,
6163
...
6264
})
@@ -99,20 +101,20 @@ func openaiExample() {
99101
})
100102

101103
agent, err := react.NewAgent(ctx, react.AgentConfig{
102-
Model: chatModel,
104+
ToolCallingModel: chatModel,
103105
ToolsConfig: ...,
104106
})
105107
}
106108

107109
func arkExample() {
108-
arkModel, err := ark.NewChatModel(context.Background(), ark.ChatModelConfig{
110+
arkModel, err := ark.NewChatModel(context.Background(), &ark.ChatModelConfig{
109111
APIKey: os.Getenv("ARK_API_KEY"),
110112
Model: os.Getenv("ARK_MODEL"),
111113
BaseURL: os.Getenv("ARK_BASE_URL"),
112114
})
113115

114-
agent, err := react.NewAgent(ctx, react.AgentConfig{
115-
Model: arkModel,
116+
agent, err := react.NewAgent(ctx, &react.AgentConfig{
117+
ToolCallingModel: arkModel,
116118
ToolsConfig: ...,
117119
})
118120
}
@@ -172,7 +174,10 @@ userInfoTool := utils.NewTool(
172174
})
173175

174176
toolConfig := &compose.ToolsNodeConfig{
175-
InvokableTools: []tool.InvokableTool{invokeTool},
177+
Tools: []tool.BaseTool{
178+
mytool,
179+
...
180+
},
176181
}
177182
```
178183

@@ -227,7 +232,7 @@ Similarly, if you want the Agent to run up to 10 loops (10 ChatModel + 9 Tools),
227232
```go
228233
func main() {
229234
agent, err := react.NewAgent(ctx, &react.AgentConfig{
230-
Model: toolableChatModel,
235+
ToolCallingModel: toolableChatModel,
231236
ToolsConfig: tools,
232237
MaxStep: 20,
233238
}
@@ -240,7 +245,7 @@ If you wish for the Agent to directly return the Tool's Response ToolMessage aft
240245

241246
```go
242247
a, err = NewAgent(ctx, &AgentConfig{
243-
Model: cm,
248+
ToolCallingModel: cm,
244249
ToolsConfig: compose.ToolsNodeConfig{
245250
Tools: []tool.BaseTool{fakeTool, fakeStreamTool},
246251
},
@@ -377,7 +382,7 @@ Agent can be embedded as a Lambda into other Graphs:
377382

378383
```go
379384
agent, _ := NewAgent(ctx, &AgentConfig{
380-
Model: cm,
385+
ToolCallingModel: cm,
381386
ToolsConfig: compose.ToolsNodeConfig{
382387
Tools: []tool.BaseTool{fakeTool, &fakeStreamToolGreetForTest{}},
383388
},

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ func main() {
4848

4949
// 初始化所需的 tools
5050
tools := compose.ToolsNodeConfig{
51-
InvokableTools: []tool.InvokableTool{mytool},
52-
StreamableTools: []tool.StreamableTool{myStreamTool},
51+
Tools: []tool.BaseTool{
52+
mytool,
53+
...
54+
},
5355
}
5456

5557
// 创建 agent
56-
agent, err := react.NewAgent(ctx, react.AgentConfig{
57-
Model: toolableChatModel,
58+
agent, err := react.NewAgent(ctx, &react.AgentConfig{
59+
ToolCallingModel: toolableChatModel,
5860
ToolsConfig: tools,
5961
...
6062
}
@@ -96,8 +98,8 @@ func openaiExample() {
9698
Model: "{{model name which support tool call}}",
9799
})
98100

99-
agent, err := react.NewAgent(ctx, react.AgentConfig{
100-
Model: chatModel,
101+
agent, err := react.NewAgent(ctx, &react.AgentConfig{
102+
ToolCallingModel: chatModel,
101103
ToolsConfig: ...,
102104
})
103105
}
@@ -109,8 +111,8 @@ func arkExample() {
109111
BaseURL: os.Getenv("ARK_BASE_URL"),
110112
})
111113

112-
agent, err := react.NewAgent(ctx, react.AgentConfig{
113-
Model: arkModel,
114+
agent, err := react.NewAgent(ctx, &react.AgentConfig{
115+
ToolCallingModel: arkModel,
114116
ToolsConfig: ...,
115117
})
116118
}
@@ -170,7 +172,10 @@ userInfoTool := utils.NewTool(
170172
})
171173

172174
toolConfig := &compose.ToolsNodeConfig{
173-
InvokableTools: []tool.InvokableTool{invokeTool},
175+
Tools: []tool.BaseTool{
176+
mytool,
177+
...
178+
},
174179
}
175180
```
176181

@@ -193,7 +198,7 @@ import (
193198

194199
func main() {
195200
agent, err := react.NewAgent(ctx, &react.AgentConfig{
196-
Model: toolableChatModel,
201+
ToolCallingModel: toolableChatModel,
197202
ToolsConfig: tools,
198203

199204
MessageModifier: func(ctx context.Context, input []*schema.Message) []*schema.Message {
@@ -225,7 +230,7 @@ func main() {
225230
```go
226231
func main() {
227232
agent, err := react.NewAgent(ctx, &react.AgentConfig{
228-
Model: toolableChatModel,
233+
ToolCallingModel: toolableChatModel,
229234
ToolsConfig: tools,
230235
MaxStep: 20,
231236
}
@@ -238,7 +243,7 @@ func main() {
238243

239244
```go
240245
a, err = NewAgent(ctx, &AgentConfig{
241-
Model: cm,
246+
ToolCallingModel: cm,
242247
ToolsConfig: compose.ToolsNodeConfig{
243248
Tools: []tool.BaseTool{fakeTool, fakeStreamTool},
244249
},
@@ -377,7 +382,7 @@ Agent 可作为 Lambda 嵌入到其他的 Graph 中:
377382

378383
```go
379384
agent, _ := NewAgent(ctx, &AgentConfig{
380-
Model: cm,
385+
ToolCallingModel: cm,
381386
ToolsConfig: compose.ToolsNodeConfig{
382387
Tools: []tool.BaseTool{fakeTool, &fakeStreamToolGreetForTest{}},
383388
},

0 commit comments

Comments
 (0)