Skip to content

Commit aea58cb

Browse files
authored
docs: eino graph update (#1293)
1 parent 5e69687 commit aea58cb

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2025-02-21"
3+
date: "2025-03-28"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Chain/Graph Orchestration Introduction'
@@ -131,7 +131,7 @@ func main() {
131131

132132
ctx := context.Background()
133133

134-
callbacks.InitCallbackHandlers([]callbacks.Handler{&loggerCallbacks{}})
134+
callbacks.AppendGlobalHandlers(&loggerCallbacks{})
135135

136136
// 1. create an instance of ChatTemplate as 1st Graph Node
137137
systemTpl := `你是一名房产经纪人,结合用户的薪酬和工作,使用 user_info API,为其提供相关的房产信息。邮箱是必须的`
@@ -301,9 +301,9 @@ Graph can own a 'global' state, created by using the WithGenLocalState Option du
301301
```go
302302
// compose/generic_graph.go
303303

304-
// type GenLocalState[S any] func(ctx **context**._Context_) (state S)
304+
// type GenLocalState[S any] func(ctx context.Context) (state S)
305305

306-
func WithGenLocalState[S any](gls _GenLocalState_[S]) _NewGraphOption _{
306+
func WithGenLocalState[S any](gls GenLocalState[S]) NewGraphOption {
307307
// --snip--
308308
}
309309
```
@@ -313,14 +313,14 @@ When adding nodes, add Pre/Post Handlers to process this State:
313313
```go
314314
// compose/graph_add_node_options.go
315315

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)
318318

319-
func WithStatePreHandler[I, S any](pre _StatePreHandler_[I, S]) _GraphAddNodeOpt _{
319+
func WithStatePreHandler[I, S any](pre StatePreHandler[I, S]) GraphAddNodeOpt {
320320
// --snip--
321321
}
322322

323-
func WithStatePostHandler[O, S any](post _StatePostHandler_[O, S]) _GraphAddNodeOpt _{
323+
func WithStatePostHandler[O, S any](post StatePostHandler[O, S]) GraphAddNodeOpt {
324324
// --snip--
325325
}
326326
```
@@ -331,7 +331,7 @@ Within nodes, use `ProcessState` to process State by passing in a function that
331331
// flow/agent/react/react.go
332332

333333
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 {
335335
for i := range msgs {
336336
if msgs[i] != nil && msgs[i].ToolCallID == state.ReturnDirectlyToolCallID {
337337
msg = msgs[i]

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Description: ""
3-
date: "2025-02-19"
3+
date: "2025-03-28"
44
lastmod: ""
55
tags: []
66
title: 'Eino: Chain/Graph 编排介绍'
@@ -131,7 +131,7 @@ func main() {
131131

132132
ctx := context.Background()
133133

134-
callbacks.InitCallbackHandlers([]callbacks.Handler{&loggerCallbacks{}})
134+
callbacks.AppendGlobalHandlers(&loggerCallbacks{})
135135

136136
// 1. create an instance of ChatTemplate as 1st Graph Node
137137
systemTpl := `你是一名房产经纪人,结合用户的薪酬和工作,使用 user_info API,为其提供相关的房产信息。邮箱是必须的`
@@ -301,9 +301,9 @@ Graph 可以有 graph 自身的“全局”状态,在创建 Graph 时传入 Wi
301301
```go
302302
// compose/generic_graph.go
303303

304-
// type GenLocalState[S any] func(ctx **context**._Context_) (state S)
304+
// type GenLocalState[S any] func(ctx context.Context) (state S)
305305

306-
func WithGenLocalState[S any](gls _GenLocalState_[S]) _NewGraphOption _{
306+
func WithGenLocalState[S any](gls GenLocalState[S]) NewGraphOption {
307307
// --snip--
308308
}
309309
```
@@ -313,14 +313,14 @@ Add node 时添加 Pre/Post Handler 来处理 State:
313313
```go
314314
// compose/graph_add_node_options.go
315315

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)
318318

319-
func WithStatePreHandler[I, S any](pre _StatePreHandler_[I, S]) _GraphAddNodeOpt _{
319+
func WithStatePreHandler[I, S any](pre StatePreHandler[I, S]) GraphAddNodeOpt {
320320
// --snip--
321321
}
322322

323-
func WithStatePostHandler[O, S any](post _StatePostHandler_[O, S]) _GraphAddNodeOpt _{
323+
func WithStatePostHandler[O, S any](post StatePostHandler[O, S]) GraphAddNodeOpt {
324324
// --snip--
325325
}
326326
```
@@ -331,7 +331,7 @@ func WithStatePostHandler[O, S any](post _StatePostHandler_[O, S]) _GraphAddNode
331331
// flow/agent/react/react.go
332332

333333
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 {
335335
for i := range msgs {
336336
if msgs[i] != nil && msgs[i].ToolCallID == state.ReturnDirectlyToolCallID {
337337
msg = msgs[i]
@@ -396,7 +396,7 @@ func main() {
396396
}
397397

398398
_ = sg.AddLambdaNode(nodeOfL1, l1,
399-
compose.WithStatePreHandler(l1StateToInput), compose.WithStatePostHandler(l1StateToOutput))
399+
compose.WithStatePreHandler(l1StateToInput), compose.WithStatePostHandler(l1StateToOutput))
400400

401401
l2 := compose.StreamableLambda(func(ctx context.Context, input string) (output *schema.StreamReader[string], err error) {
402402
outStr := "StreamableLambda: " + input

0 commit comments

Comments
 (0)