import { BaseChain } from "../chains/base.js"; import { LLMChain, LLMChainInput } from "../chains/llm_chain.js"; import { BaseLanguageModelInterface } from "@langchain/core/language_models/base"; import { BaseCallbackConfig, Callbacks } from "@langchain/core/callbacks/manager"; import { ChainValues } from "@langchain/core/utils/types"; import { AgentStep } from "@langchain/core/agents"; //#region src/evaluation/base.d.ts /** * Base input for evaluators. */ interface LLMEvalChainInput extends LLMChainInput {} type ExtractLLMCallOptions = LanguageModelInterface extends BaseLanguageModelInterface ? CallOptions : never; /** * The type of the output of an evaluation evaluator. */ type EvalOutputType = Record; /** * Base llm chain class for evaluators. */ declare abstract class LLMEvalChain extends LLMChain { requiresInput?: boolean; requiresReference?: boolean; skipInputWarning?: string; skipReferenceWarning?: string; /** * Check if the evaluation arguments are valid. * @param reference The reference label. * @param input The input string. * @throws {Error} If the evaluator requires an input string but none is provided, or if the evaluator requires a reference label but none is provided. */ checkEvaluationArgs(reference?: string, input?: string): void; } /** * Base chain class for evaluators. */ declare abstract class EvalChain extends BaseChain { requiresInput?: boolean; requiresReference?: boolean; skipInputWarning?: string; skipReferenceWarning?: string; /** * Check if the evaluation arguments are valid. * @param reference The reference label. * @param input The input string. * @throws {Error} If the evaluator requires an input string but none is provided, or if the evaluator requires a reference label but none is provided. */ checkEvaluationArgs(reference?: string, input?: string): void; } /** * @field prediction The output string from the model. * @field reference The expected output / reference string. * @field input The input string. */ interface StringEvaluatorArgs { prediction: string; reference?: string; input?: string; } /** * @field prediction The output string from the first model. * @field predictionB The output string from the second model. */ interface PairwiseStringEvaluatorArgs { prediction: string; predictionB: string; } /** * @field The input string. * @field prediction The output string from the first model. * @field predictionB The output string from the second model. * @field reference The expected output / reference string. */ interface LLMPairwiseStringEvaluatorArgs { input: string; prediction: string; predictionB: string; reference?: string; } /** * Args for AgentTrajectoryEvaluator * @field input The input to the agent. * @field prediction The final predicted response. * @field reference The reference answer. * @field agentTrajectory The intermediate steps forming the agent trajectory. */ interface LLMTrajectoryEvaluatorArgs { input: string; prediction: string; reference?: string; agentTrajectory: AgentStep[]; } /** * Grade, tag, or otherwise evaluate predictions relative to their inputs * and/or reference labels */ declare abstract class LLMStringEvaluator extends LLMEvalChain { /** * The name of the evaluation. */ evaluationName?: string; /** * Evaluate Chain or LLM output, based on optional input and label. * @returns The evaluation results containing the score or value. It is recommended that the dictionary contain the following keys: * - score: the score of the evaluation, if applicable. * - value: the string value of the evaluation, if applicable. * - reasoning: the reasoning for the evaluation, if applicable. * @param args * @param callOptions * @param config */ abstract _evaluateStrings(args: StringEvaluatorArgs & ExtractLLMCallOptions, config?: Callbacks | BaseCallbackConfig): Promise; /** * Evaluate Chain or LLM output, based on optional input and label. * @returns The evaluation results containing the score or value. It is recommended that the dictionary contain the following keys: * - score: the score of the evaluation, if applicable. * - value: the string value of the evaluation, if applicable. * - reasoning: the reasoning for the evaluation, if applicable. * @param args * @param callOptions * @param config */ evaluateStrings(args: StringEvaluatorArgs & ExtractLLMCallOptions, config?: Callbacks | BaseCallbackConfig): Promise; } /** * Grade, tag, or otherwise evaluate predictions relative to their inputs * and/or reference labels */ declare abstract class StringEvaluator extends EvalChain { /** * The name of the evaluation. */ evaluationName?: string; /** * Evaluate Chain or LLM output, based on optional input and label. * @returns The evaluation results containing the score or value. It is recommended that the dictionary contain the following keys: * - score: the score of the evaluation, if applicable. * - value: the string value of the evaluation, if applicable. * - reasoning: the reasoning for the evaluation, if applicable. * @param args * @param config */ abstract _evaluateStrings(args: StringEvaluatorArgs, config?: Callbacks | BaseCallbackConfig): Promise; /** * Evaluate Chain or LLM output, based on optional input and label. * @returns The evaluation results containing the score or value. It is recommended that the dictionary contain the following keys: * - score: the score of the evaluation, if applicable. * - value: the string value of the evaluation, if applicable. * - reasoning: the reasoning for the evaluation, if applicable. * @param args * @param config */ evaluateStrings(args: StringEvaluatorArgs, config?: Callbacks | BaseCallbackConfig): Promise; } /** * Compare the output of two models (or two outputs of the same model). */ declare abstract class PairwiseStringEvaluator extends EvalChain { /** * The name of the evaluation. */ evaluationName?: string; /** * Evaluate the output string pairs. * @param args * @param config * @return A dictionary containing the preference, scores, and/or other information. */ abstract _evaluateStringPairs(args: PairwiseStringEvaluatorArgs, config?: Callbacks | BaseCallbackConfig): Promise; /** * Evaluate the output string pairs. * @param args * @param config * @return A dictionary containing the preference, scores, and/or other information. */ evaluateStringPairs(args: PairwiseStringEvaluatorArgs, config?: Callbacks | BaseCallbackConfig): Promise; } /** * Compare the output of two models (or two outputs of the same model). */ declare abstract class LLMPairwiseStringEvaluator extends LLMEvalChain { /** * The name of the evaluation. */ evaluationName?: string; /** * Evaluate the output string pairs. * @param args * @param callOptions * @param config * @return A dictionary containing the preference, scores, and/or other information. */ abstract _evaluateStringPairs(args: LLMPairwiseStringEvaluatorArgs, callOptions?: ExtractLLMCallOptions, config?: Callbacks | BaseCallbackConfig): Promise; /** * Evaluate the output string pairs. * @param args * @param callOptions * @param config * @return A dictionary containing the preference, scores, and/or other information. */ evaluateStringPairs(args: LLMPairwiseStringEvaluatorArgs, callOptions?: ExtractLLMCallOptions, config?: Callbacks | BaseCallbackConfig): Promise; } /** * Interface for evaluating agent trajectories. */ declare abstract class AgentTrajectoryEvaluator extends LLMEvalChain { requiresInput: boolean; /** * The name of the evaluation. */ evaluationName?: string; /** * Evaluate a trajectory. * @return The evaluation result. * @param args * @param callOptions * @param config */ abstract _evaluateAgentTrajectory(args: LLMTrajectoryEvaluatorArgs, callOptions?: ExtractLLMCallOptions, config?: Callbacks | BaseCallbackConfig): Promise; /** * Evaluate a trajectory. * @return The evaluation result. * @param args * @param callOptions * @param config */ evaluateAgentTrajectory(args: LLMTrajectoryEvaluatorArgs, callOptions?: ExtractLLMCallOptions, config?: Callbacks | BaseCallbackConfig): Promise; } //#endregion export { AgentTrajectoryEvaluator, EvalOutputType, ExtractLLMCallOptions, LLMEvalChainInput, LLMPairwiseStringEvaluator, LLMPairwiseStringEvaluatorArgs, LLMStringEvaluator, LLMTrajectoryEvaluatorArgs, PairwiseStringEvaluator, PairwiseStringEvaluatorArgs, StringEvaluator, StringEvaluatorArgs }; //# sourceMappingURL=base.d.ts.map