MCPcopy
hub / github.com/micro/go-micro / ExampleVerify

Function ExampleVerify

flow/example_verify_test.go:11–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9)
10
11func ExampleVerify() {
12 generate := func(_ context.Context, in flow.State) (flow.State, error) {
13 if strings.Contains(in.String(), "feedback") {
14 in.Data = []byte(`{"answer":"include a source"}`)
15 return in, nil
16 }
17 in.Data = []byte(`{"answer":"draft"}`)
18 return in, nil
19 }
20 grader := func(_ context.Context, out flow.State) (bool, string, error) {
21 return strings.Contains(out.String(), "source"), "add a source", nil
22 }
23
24 out, _ := flow.Verify(generate, grader, flow.VerifyMaxAttempts(2))(context.Background(), flow.State{})
25 fmt.Println(strings.Contains(out.String(), `"verification_passed":true`))
26 // Output: true
27}
28
29func ExampleAnalyze() {
30 runs := []flow.Run{{

Callers

nothing calls this directly

Calls 3

VerifyFunction · 0.92
VerifyMaxAttemptsFunction · 0.92
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…