import { z, Action } from '@genkit-ai/core'; import { Registry } from '@genkit-ai/core/registry'; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ declare const ATTR_PREFIX = "genkit"; declare const SPAN_STATE_ATTR: string; declare const BaseDataPointSchema: z.ZodObject<{ input: z.ZodUnknown; output: z.ZodOptional; context: z.ZodOptional>; reference: z.ZodOptional; testCaseId: z.ZodOptional; traceIds: z.ZodOptional>; }, "strip", z.ZodTypeAny, { input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; testCaseId?: string | undefined; traceIds?: string[] | undefined; }, { input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; testCaseId?: string | undefined; traceIds?: string[] | undefined; }>; declare const BaseEvalDataPointSchema: z.ZodObject<{ input: z.ZodUnknown; output: z.ZodOptional; context: z.ZodOptional>; reference: z.ZodOptional; traceIds: z.ZodOptional>; } & { testCaseId: z.ZodString; }, "strip", z.ZodTypeAny, { testCaseId: string; input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; traceIds?: string[] | undefined; }, { testCaseId: string; input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; traceIds?: string[] | undefined; }>; type BaseEvalDataPoint = z.infer; /** Enum that indicates if an evaluation has passed or failed */ declare enum EvalStatusEnum { UNKNOWN = "UNKNOWN", PASS = "PASS", FAIL = "FAIL" } declare const ScoreSchema: z.ZodObject<{ id: z.ZodOptional; score: z.ZodOptional>; status: z.ZodOptional>; error: z.ZodOptional; details: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "strip", z.ZodTypeAny, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }>; declare const EVALUATOR_METADATA_KEY_DISPLAY_NAME = "evaluatorDisplayName"; declare const EVALUATOR_METADATA_KEY_DEFINITION = "evaluatorDefinition"; declare const EVALUATOR_METADATA_KEY_IS_BILLED = "evaluatorIsBilled"; type Score = z.infer; type BaseDataPoint = z.infer; type Dataset = Array>; declare const EvalResponseSchema: z.ZodObject<{ sampleIndex: z.ZodOptional; testCaseId: z.ZodString; traceId: z.ZodOptional; spanId: z.ZodOptional; evaluation: z.ZodUnion<[z.ZodObject<{ id: z.ZodOptional; score: z.ZodOptional>; status: z.ZodOptional>; error: z.ZodOptional; details: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "strip", z.ZodTypeAny, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }>, z.ZodArray; score: z.ZodOptional>; status: z.ZodOptional>; error: z.ZodOptional; details: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "strip", z.ZodTypeAny, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }>, "many">]>; }, "strip", z.ZodTypeAny, { testCaseId: string; evaluation: { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; } | { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }[]; sampleIndex?: number | undefined; traceId?: string | undefined; spanId?: string | undefined; }, { testCaseId: string; evaluation: { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; } | { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }[]; sampleIndex?: number | undefined; traceId?: string | undefined; spanId?: string | undefined; }>; type EvalResponse = z.infer; declare const EvalResponsesSchema: z.ZodArray; testCaseId: z.ZodString; traceId: z.ZodOptional; spanId: z.ZodOptional; evaluation: z.ZodUnion<[z.ZodObject<{ id: z.ZodOptional; score: z.ZodOptional>; status: z.ZodOptional>; error: z.ZodOptional; details: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "strip", z.ZodTypeAny, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }>, z.ZodArray; score: z.ZodOptional>; status: z.ZodOptional>; error: z.ZodOptional; details: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>>; }, "strip", z.ZodTypeAny, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }, { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }>, "many">]>; }, "strip", z.ZodTypeAny, { testCaseId: string; evaluation: { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; } | { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectOutputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }[]; sampleIndex?: number | undefined; traceId?: string | undefined; spanId?: string | undefined; }, { testCaseId: string; evaluation: { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; } | { status?: "UNKNOWN" | "PASS" | "FAIL" | undefined; id?: string | undefined; score?: string | number | boolean | undefined; error?: string | undefined; details?: z.objectInputType<{ reasoning: z.ZodOptional; }, z.ZodTypeAny, "passthrough"> | undefined; }[]; sampleIndex?: number | undefined; traceId?: string | undefined; spanId?: string | undefined; }>, "many">; type EvalResponses = z.infer; type EvaluatorFn = (input: z.infer, evaluatorOptions?: z.infer) => Promise; type EvaluatorAction = Action & { __dataPointType?: DataPoint; __configSchema?: CustomOptions; }; declare const EvalRequestSchema: z.ZodObject<{ dataset: z.ZodArray; context: z.ZodOptional>; reference: z.ZodOptional; testCaseId: z.ZodOptional; traceIds: z.ZodOptional>; }, "strip", z.ZodTypeAny, { input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; testCaseId?: string | undefined; traceIds?: string[] | undefined; }, { input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; testCaseId?: string | undefined; traceIds?: string[] | undefined; }>, "many">; evalRunId: z.ZodString; options: z.ZodUnknown; }, "strip", z.ZodTypeAny, { dataset: { input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; testCaseId?: string | undefined; traceIds?: string[] | undefined; }[]; evalRunId: string; options?: unknown; }, { dataset: { input?: unknown; output?: unknown; context?: unknown[] | undefined; reference?: unknown; testCaseId?: string | undefined; traceIds?: string[] | undefined; }[]; evalRunId: string; options?: unknown; }>; interface EvaluatorParams { evaluator: EvaluatorArgument; dataset: Dataset; evalRunId?: string; options?: z.infer; } /** * Creates evaluator action for the provided {@link EvaluatorFn} implementation. */ declare function defineEvaluator(registry: Registry, options: { name: string; displayName: string; definition: string; dataPointType?: DataPoint; configSchema?: EvaluatorOptions; isBilled?: boolean; }, runner: EvaluatorFn): EvaluatorAction; type EvaluatorArgument = string | EvaluatorAction | EvaluatorReference; /** * A veneer for interacting with evaluators. */ declare function evaluate(registry: Registry, params: EvaluatorParams): Promise; declare const EvaluatorInfoSchema: z.ZodObject<{ /** Friendly label for this evaluator */ label: z.ZodOptional; metrics: z.ZodArray; }, "strip", z.ZodTypeAny, { metrics: string[]; label?: string | undefined; }, { metrics: string[]; label?: string | undefined; }>; type EvaluatorInfo = z.infer; interface EvaluatorReference { name: string; configSchema?: CustomOptions; info?: EvaluatorInfo; } /** * Helper method to configure a {@link EvaluatorReference} to a plugin. */ declare function evaluatorRef(options: EvaluatorReference): EvaluatorReference; export { ATTR_PREFIX, type BaseDataPoint, BaseDataPointSchema, type BaseEvalDataPoint, BaseEvalDataPointSchema, type Dataset, EVALUATOR_METADATA_KEY_DEFINITION, EVALUATOR_METADATA_KEY_DISPLAY_NAME, EVALUATOR_METADATA_KEY_IS_BILLED, type EvalResponse, EvalResponseSchema, type EvalResponses, EvalResponsesSchema, EvalStatusEnum, type EvaluatorAction, type EvaluatorArgument, type EvaluatorFn, type EvaluatorInfo, EvaluatorInfoSchema, type EvaluatorParams, type EvaluatorReference, SPAN_STATE_ATTR, type Score, ScoreSchema, defineEvaluator, evaluate, evaluatorRef };