Skip to content

Commit c898743

Browse files
authored
feat(go): added Evaluate() function to genkit (#3480)
1 parent 5b4c3f7 commit c898743

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

go/genkit/genkit.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,35 @@ func LookupEvaluator(g *Genkit, name string) ai.Evaluator {
864864
return ai.LookupEvaluator(g.reg, name)
865865
}
866866

867+
// Evaluate performs an evaluation request using a flexible set of options
868+
// provided via [ai.EvaluatorOption] arguments. It's a convenient way to run
869+
// evaluations using registered evaluators without directly calling the
870+
// evaluator instance.
871+
//
872+
// Example:
873+
//
874+
// dataset := []*ai.Example{
875+
// {
876+
// Input: "What is the capital of France?",
877+
// Reference: "Paris",
878+
// },
879+
// }
880+
//
881+
// resp, err := genkit.Evaluate(ctx, g,
882+
// ai.WithEvaluator("myEvaluator"),
883+
// ai.WithDataset(dataset),
884+
// )
885+
// if err != nil {
886+
// log.Fatalf("Evaluate failed: %v", err)
887+
// }
888+
//
889+
// for _, result := range *resp {
890+
// fmt.Printf("Evaluation result: %+v\n", result)
891+
// }
892+
func Evaluate(ctx context.Context, g *Genkit, opts ...ai.EvaluatorOption) (*ai.EvaluatorResponse, error) {
893+
return ai.Evaluate(ctx, g.reg, opts...)
894+
}
895+
867896
// LoadPromptDir loads all `.prompt` files from the specified directory `dir`
868897
// into the registry, associating them with the given `namespace`.
869898
// Files starting with `_` are treated as partials and are not registered as

0 commit comments

Comments
 (0)