"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleAudioClarity = void 0;
const handleAudioClarity = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    if (evaluateResult) {
        const clarity = output;
        const threshold = assertion?.threshold ?? 0.8;
        const pass = Number(clarity.result) >= threshold;
        return {
            pass,
            score: Number(clarity.result),
            reason: JSON.stringify(clarity),
            assertion,
        };
    }
    else {
        return {
            pass: true,
            score: 1,
            reason: '',
            metadata: {
                prompt: `Analyze the reference transcription and audio provided, diarize the speakers and evaluate the clarity of the audio and assign a measure between 0 to 1 with 0 being unclear and 1 being very clear. Also, indicate which speaker - customer or AI Bot agent's voice is most unclear. Provide the result in a metric called 'clarity' with two fields: Output a json value with two fields a) a field called "result" with the measure of clarity. b) a field called "speaker" with value either "agent" or "customer".`,
                metric: '"clarity": {"result": 0.8, speaker: "agent"},',
            },
        };
    }
};
exports.handleAudioClarity = handleAudioClarity;
//# sourceMappingURL=clarity.js.map