From 334451a9fcbbc46bdace262dcbc0ac60ace21a0e Mon Sep 17 00:00:00 2001 From: isaac hershenson Date: Fri, 8 Nov 2024 12:10:09 -0800 Subject: [PATCH] forgot to add a file --- js/src/evaluation/llm_evaluator.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/js/src/evaluation/llm_evaluator.ts b/js/src/evaluation/llm_evaluator.ts index 4f1ffa27..431bd1ab 100644 --- a/js/src/evaluation/llm_evaluator.ts +++ b/js/src/evaluation/llm_evaluator.ts @@ -141,7 +141,6 @@ interface LLMEvaluatorParams { mapVariables?: (run: Run, example?: Example) => Record; modelName?: string; modelProvider?: string; - reasoningKey?: string; } export class LLMEvaluator implements RunEvaluator { @@ -150,7 +149,6 @@ export class LLMEvaluator implements RunEvaluator { scoreConfig: ScoreConfig; scoreSchema: Record; runnable: any; - reasoningKey: string; constructor() {} @@ -188,7 +186,7 @@ export class LLMEvaluator implements RunEvaluator { } else { this.prompt = ChatPromptTemplate.fromMessages(promptTemplate); } - + // Initialize the chat model with structured output const chatModel = await initChatModel(modelName, { modelProvider: modelProvider, @@ -273,9 +271,9 @@ export class LLMEvaluator implements RunEvaluator { output: Record, runId: string ): EvaluationResult { + const explanation = this.scoreConfig.reasoningKey ? output[this.scoreConfig.reasoningKey] : undefined; if ("choices" in this.scoreConfig) { const value = output.value; - const explanation = output[this.reasoningKey]; return { key: this.scoreConfig.key, value, @@ -284,7 +282,6 @@ export class LLMEvaluator implements RunEvaluator { }; } else { const score = output.score; - const explanation = output[this.reasoningKey]; return { key: this.scoreConfig.key, score,