"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.evalTestCases = evalTestCases;
const createLanguageModel_1 = require("../createLanguageModel");
const createTestTextSimilarity_1 = require("./createTestTextSimilarity");
const evaluateScenario_1 = require("./evaluateScenario");
const textSimilaryPrompt_1 = require("./textSimilaryPrompt");
async function evalTestCases(autopilotApplication) {
    const { testCases } = autopilotApplication.intelligence.config;
    const { config: assistantConfig } = autopilotApplication.intelligence;
    const voice = {
        say: async (_) => { }
    };
    const evaluationReports = [];
    for (const scenario of testCases?.scenarios ?? []) {
        const languageModel = (0, createLanguageModel_1.createLanguageModel)({
            voice,
            assistantConfig: autopilotApplication.intelligence.config,
            knowledgeBase: {
                load: async () => { },
                queryKnowledgeBase: async (query) => query
            },
            telephonyContext: scenario.telephonyContext
        });
        const testTextSimilarity = (0, createTestTextSimilarity_1.createTestTextSimilarity)({
            provider: assistantConfig.testCases?.evalsLanguageModel?.provider,
            model: assistantConfig.testCases?.evalsLanguageModel?.model ?? "",
            apiKey: assistantConfig.testCases?.evalsLanguageModel?.apiKey
        }, assistantConfig.testCases?.evalsSystemPrompt || textSimilaryPrompt_1.textSimilaryPrompt);
        const evaluationReport = await (0, evaluateScenario_1.evaluateScenario)({
            assistantConfig,
            scenario,
            languageModel,
            testTextSimilarity
        });
        evaluationReports.push(evaluationReport);
    }
    return evaluationReports;
}
