"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleSttCorrectness = void 0;
const handleSttCorrectness = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    if (evaluateResult) {
        const falseIntentDetected = output;
        const pass = falseIntentDetected.result.toLowerCase() === 'correct';
        const reason = JSON.stringify(falseIntentDetected);
        return {
            pass,
            score: pass ? 1 : 0,
            reason,
            assertion,
        };
    }
    else {
        return {
            pass: true,
            score: 1,
            reason: '',
            metadata: {
                // prompt: `Analyze the reference_transcription and audio provided to diarize the speakers and their corresponding sentences. Then determine if any of the customer's words or sentences have been wrongly identified by the AI Bot Agent. Use the original_transcription provided and compare it with the reference_transcription and audio to check which phrases might be wrongly identified. Some examples of wrong identification are: a) If there are phrases in the orginial_transcript that are different when compared with the reference_transcription, consider it as wrongly identified. b) If the customer has not responded, but the AI Bot agent went ahead with the conversation, consider it as wrongly identified. c) if the customer declined, but the AI bot took undestood as an approval, then conside it as wrongly identified. d) if the customer asked for more information, but the AI bot did not provide additional information or answer the customer's question precisely. e) if the customer asked for more information, but the AI bot treated that as an approval. f) the customer response was not clear, but the AI bot did not ask clarifying question and went ahead, consider it as wrongly identified. If the word or sentence is missing in the original_transcription, then do not consider it as wrongly identified for this metric. Output a json value with three fields: a) a field called "result" with value "incorrect" if any words or sentences spoken by the customer were not identified properly and "correct" otherwise, b) a field called "phrases" with value as an array of all words or sentences spoken by the customer that have not been identified correctly, c) a field called "reason" with value as the reason why you came to this conclusion. Provide the result in a metric called 'stt-correctness'. Output this metric even if you have emitted similar results in another metric.`,
                prompt: `Strictly, compare the transcript that you have generated in the "transcript" field with the original_transcription provided and find words and sentences spoken by the customer in the generated "transcript" which are present in the original_transcription, but are different in the corresponding transcription in the "transcript" field. Consider messages as equivalent if the wording is similar and meaning is the same even if they are distributed across multiple turns. Ignore minor differences in punctuation or sentence splitting/merging. Only consider words and sentences spoken by the customer for this metric. If the words or sentences identified are not present in the original_transcription, then do not report it as part of this metric. Do a STRICT comparison and do not be creative. Output a json value with two fields: a) a field called "result" with value "incorrect" if any words or sentences spoken by the customer are different and "correct" otherwise, b) a field called "phrases" with value as an array of all words or sentences spoken by the customer that are different between the generated "transcript" field and original_transcription along with reason indicating what is the difference in the generated transcript - in brackets. Provide the result in a metric called 'stt-correctness'. Output this metric even if you have emitted similar results in another metric. Examples: 1) If original_transcription has "I would like to no more about your services" and the generated transcript has "I would like to know more about your service", then consider this as a difference and report it.  2) If original_transcription has "I would like to know more about your services" and the generated transcript has "I would like to know more about your service", then DO NOT consider this as a difference. 3) If original_transcription has some words and sentences which are not present in the generated transcript, then consider this as a difference and report it. 4) If generated transcript has some words and sentences which are not present in the original_transcript, then DO NOT consider this as a difference.`,
                metric: '"stt-correctness": {"result": "incorrect", "phrases": ["Nah (reason)"]},',
            },
        };
    }
};
exports.handleSttCorrectness = handleSttCorrectness;
//# sourceMappingURL=sttCorrectness.js.map