"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleSttAccuracy = void 0;
const dedent_1 = __importDefault(require("dedent"));
const defaults_1 = require("../../providers/defaults");
const handleSttAccuracy = async ({ assertion, renderedValue, prompt, output, outputAudio, test, evaluateResult, workspaceId, }) => {
    const textProvider = (await (0, defaults_1.getDefaultProviders)(undefined, workspaceId)).audioProvider; //TODO: Hardcoded for now
    const promptSteps = (0, dedent_1.default) `
          You are a helpful assistant that checks for the accuracy of transcription of audio. You will be provided with the audio and the transcription below. Analyze the audio and transcript for the customer part of the conversation and determined the accuracy.

          transcription: ${output}

          Provide a score between 0 and 1 depicting the accuracy of the audio transcription. Only provide a number for the score in the output.
          `;
    const llmprompt = [
        {
            role: 'user',
            content: [
                { type: 'text', text: promptSteps },
                { type: 'input_audio', input_audio: { data: outputAudio?.data, format: outputAudio?.format } },
            ],
        },
    ];
    const promptText = JSON.stringify(llmprompt);
    const resp = await textProvider.callApi(promptText);
    const result = resp.output;
    const pass = assertion?.threshold ? result >= assertion?.threshold : result >= 0.8;
    return {
        assertion,
        pass,
        score: result,
        reason: resp.output,
        tokensUsed: resp.tokenUsage,
    };
};
exports.handleSttAccuracy = handleSttAccuracy;
//# sourceMappingURL=sttAcccuracy.js.map