When using eino debugging plugin, in the input box, you need to specify the concrete type of 'any' in map[string]any. For example, you can input the following data for debugging: { "name": { "_value": "alice", "_eino_go_type": "string" }, "score": { "_value": "99", "_eino_go_type": "int"
(ctx context.Context)
| 83 | //} |
| 84 | |
| 85 | func RegisterAnyInputGraph(ctx context.Context) { |
| 86 | g := compose.NewGraph[map[string]any, string]() |
| 87 | |
| 88 | _ = g.AddLambdaNode("node_1", compose.InvokableLambda(func(ctx context.Context, input map[string]any) (output string, err error) { |
| 89 | for k, v := range input { |
| 90 | switch v := v.(type) { |
| 91 | case string: |
| 92 | output += k + ":" + v + "," |
| 93 | case int: |
| 94 | output += k + ":" + fmt.Sprintf("%d", v) |
| 95 | default: |
| 96 | return "", fmt.Errorf("unsupported type: %T", v) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | return output, nil |
| 101 | })) |
| 102 | |
| 103 | _ = g.AddLambdaNode("node_2", compose.InvokableLambda(func(ctx context.Context, input string) (output string, err error) { |
| 104 | return input + " process by node_2,", nil |
| 105 | })) |
| 106 | |
| 107 | _ = g.AddEdge(compose.START, "node_1") |
| 108 | |
| 109 | _ = g.AddEdge("node_1", "node_2") |
| 110 | |
| 111 | _ = g.AddEdge("node_2", compose.END) |
| 112 | |
| 113 | r, err := g.Compile(ctx) |
| 114 | if err != nil { |
| 115 | logs.Errorf("compile graph failed, err=%v", err) |
| 116 | return |
| 117 | } |
| 118 | |
| 119 | message, err := r.Invoke(ctx, map[string]any{"name": "bob", "score": 100}) |
| 120 | if err != nil { |
| 121 | logs.Errorf("invoke graph failed, err=%v", err) |
| 122 | return |
| 123 | } |
| 124 | |
| 125 | logs.Infof("eino any input graph output is: %v", message) |
| 126 | } |