string_evaluator.d.ts 1.0 KB

123456789101112131415161718192021222324252627282930
  1. import { Example, Run, ScoreType, ValueType } from "../schemas.js";
  2. import { EvaluationResult, RunEvaluator } from "./evaluator.js";
  3. export interface GradingFunctionResult {
  4. key?: string;
  5. score?: ScoreType;
  6. value?: ValueType;
  7. comment?: string;
  8. correction?: Record<string, unknown>;
  9. }
  10. export interface GradingFunctionParams {
  11. input: string;
  12. prediction: string;
  13. answer?: string;
  14. }
  15. export interface StringEvaluatorParams {
  16. evaluationName?: string;
  17. inputKey?: string;
  18. predictionKey?: string;
  19. answerKey?: string;
  20. gradingFunction: (params: GradingFunctionParams) => Promise<GradingFunctionResult>;
  21. }
  22. export declare class StringEvaluator implements RunEvaluator {
  23. protected evaluationName?: string;
  24. protected inputKey: string;
  25. protected predictionKey: string;
  26. protected answerKey?: string;
  27. protected gradingFunction: (params: GradingFunctionParams) => Promise<GradingFunctionResult>;
  28. constructor(params: StringEvaluatorParams);
  29. evaluateRun(run: Run, example?: Example): Promise<EvaluationResult>;
  30. }