1
1
---
2
2
Description : " "
3
- date : " 2025-02-19 "
3
+ date : " 2025-03-28 "
4
4
lastmod : " "
5
5
tags : []
6
6
title : ' Eino: Chain/Graph 编排介绍'
@@ -131,7 +131,7 @@ func main() {
131
131
132
132
ctx := context.Background ()
133
133
134
- callbacks.InitCallbackHandlers ([]callbacks. Handler { &loggerCallbacks{} })
134
+ callbacks.AppendGlobalHandlers ( &loggerCallbacks{})
135
135
136
136
// 1. create an instance of ChatTemplate as 1st Graph Node
137
137
systemTpl := ` 你是一名房产经纪人,结合用户的薪酬和工作,使用 user_info API,为其提供相关的房产信息。邮箱是必须的`
@@ -301,9 +301,9 @@ Graph 可以有 graph 自身的“全局”状态,在创建 Graph 时传入 Wi
301
301
``` go
302
302
// compose/generic_graph.go
303
303
304
- // type GenLocalState[S any] func(ctx ** context**._Context_ ) (state S)
304
+ // type GenLocalState[S any] func(ctx context.Context ) (state S)
305
305
306
- func WithGenLocalState [S any](gls _GenLocalState_ [S]) _NewGraphOption _ {
306
+ func WithGenLocalState [S any](gls GenLocalState [S]) NewGraphOption {
307
307
// --snip--
308
308
}
309
309
```
@@ -313,14 +313,14 @@ Add node 时添加 Pre/Post Handler 来处理 State:
313
313
``` go
314
314
// compose/graph_add_node_options.go
315
315
316
- // type StatePreHandler[I, S any] func(ctx ** context**._Context_ , in I, state S) (I, error)
317
- // type StatePostHandler[O, S any] func(ctx ** context**._Context_ , out O, state S) (O, error)
316
+ // type StatePreHandler[I, S any] func(ctx context.Context , in I, state S) (I, error)
317
+ // type StatePostHandler[O, S any] func(ctx context.Context , out O, state S) (O, error)
318
318
319
- func WithStatePreHandler [I, S any](pre _StatePreHandler_ [I, S ]) _GraphAddNodeOpt _ {
319
+ func WithStatePreHandler [I, S any](pre StatePreHandler [I, S ]) GraphAddNodeOpt {
320
320
// --snip--
321
321
}
322
322
323
- func WithStatePostHandler [O, S any](post _StatePostHandler_ [O, S ]) _GraphAddNodeOpt _ {
323
+ func WithStatePostHandler [O, S any](post StatePostHandler [O, S ]) GraphAddNodeOpt {
324
324
// --snip--
325
325
}
326
326
```
@@ -331,7 +331,7 @@ func WithStatePostHandler[O, S any](post _StatePostHandler_[O, S]) _GraphAddNode
331
331
// flow/agent/react/react.go
332
332
333
333
var msg *schema.Message
334
- err = compose.ProcessState [*state](ctx**, ** func (_ context.Context **, ** state *state) error {
334
+ err = compose.ProcessState [*state](ctx, func (_ context.Context , state *state) error {
335
335
for i := range msgs {
336
336
if msgs[i] != nil && msgs[i].ToolCallID == state.ReturnDirectlyToolCallID {
337
337
msg = msgs[i]
@@ -396,7 +396,7 @@ func main() {
396
396
}
397
397
398
398
_ = sg.AddLambdaNode (nodeOfL1, l1,
399
- compose.WithStatePreHandler (l1StateToInput), compose.WithStatePostHandler (l1StateToOutput))
399
+ compose.WithStatePreHandler (l1StateToInput), compose.WithStatePostHandler (l1StateToOutput))
400
400
401
401
l2 := compose.StreamableLambda (func (ctx context.Context , input string ) (output *schema.StreamReader [string ], err error ) {
402
402
outStr := " StreamableLambda: " + input
0 commit comments