MCPcopy Create free account
hub / github.com/cloudwego/eino-examples / buildGraph

Function buildGraph

compose/graph/state/state_graph.go:115–135  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

113}
114
115func buildGraph(ctx context.Context) (compose.Runnable[string, string], error) {
116 genState := func(ctx context.Context) *translateState { return &translateState{} }
117
118 g := compose.NewGraph[string, string](compose.WithGenLocalState(genState))
119
120 g.AddLambdaNode(nodeTranslate, newTranslateNode(),
121 compose.WithStatePreHandler(roundIncrement))
122
123 g.AddLambdaNode(nodeReview, newReviewNode(),
124 compose.WithStatePostHandler(saveHistory))
125
126 g.AddBranch(nodeReview, compose.NewGraphBranch(
127 qualityBranch,
128 map[string]bool{compose.END: true, nodeTranslate: true},
129 ))
130
131 g.AddEdge(compose.START, nodeTranslate)
132 g.AddEdge(nodeTranslate, nodeReview)
133
134 return g.Compile(ctx, compose.WithMaxRunSteps(10))
135}
136
137func mockTranslate(in string) string {
138 return "快速的棕色狐狸跳过了懒狗"

Callers 1

mainFunction · 0.85

Calls 3

newTranslateNodeFunction · 0.85
newReviewNodeFunction · 0.85
CompileMethod · 0.65

Tested by

no test coverage detected