"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleInterruption = void 0;
const handleInterruption = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    if (!renderedValue) {
        renderedValue = 'Yes';
    }
    if (evaluateResult) {
        const result = output;
        const pass = renderedValue.toString().toLowerCase() === result.result.toString().toLowerCase();
        return {
            pass,
            score: pass ? 1 : 0,
            reason: pass ? result.result : result.reason || '',
            assertion,
        };
    }
    else {
        return {
            pass: true,
            score: 1,
            reason: '',
            metadata: {
                prompt: `Analyze the transcript that you have generated in the "transcript" field and the audio to identify whether the AI Bot agent is able to handle interruptions by the customer. If the customer interrupts while the AI Bot agent is speaking, then the AI Bot agent should stop and address the customer query. If the customer interruption is minor (like hmm, ok etc.), then the AI bot should continue with the conversation without stopping. Overall the conversation should be coherent and fluent without too many repetitions by the AI Bot for it to quialify as proper interruption handling. Output a json value with two fields: a) a field called "result" with value "Yes" if the agent handled the interuption properly and "No" otherwise, b) a field called "reason" with value as the reason why you came to this conclusion. If the customer did not interrupt at all during the conversation, then the result should be "Yes". Provide the result in a metric called 'interruption-handling'.`,
                metric: '"interruption-handling": {"result": "No", "reason": ["The customer interrupted, but the agent ignored it and continued speaking."]},',
            },
        };
    }
};
exports.handleInterruption = handleInterruption;
//# sourceMappingURL=interruption.js.map