@@ -864,6 +864,35 @@ func LookupEvaluator(g *Genkit, name string) ai.Evaluator {
864
864
return ai .LookupEvaluator (g .reg , name )
865
865
}
866
866
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
+
867
896
// LoadPromptDir loads all `.prompt` files from the specified directory `dir`
868
897
// into the registry, associating them with the given `namespace`.
869
898
// Files starting with `_` are treated as partials and are not registered as
0 commit comments