(ctx context.Context)
| 113 | } |
| 114 | |
| 115 | func 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 | |
| 137 | func mockTranslate(in string) string { |
| 138 | return "快速的棕色狐狸跳过了懒狗" |
no test coverage detected