"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleRepetition = void 0;
const handleRepetition = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    if (!renderedValue) {
        renderedValue = 'No';
    }
    if (evaluateResult) {
        const result = output;
        const pass = renderedValue.toString().toLowerCase() === result.result.toString().toLowerCase();
        return {
            pass,
            score: pass ? 1 : 0,
            reason: pass ? result.result : JSON.stringify(result.reason) || '',
            assertion,
        };
    }
    else {
        return {
            pass: true,
            score: 1,
            reason: '',
            metadata: {
                prompt: `Analyze the transcript that you have generated and the audio to identify if the AI Bot agent asked the same question to the customer again repeatedly even though the customer has already provided an answer to the question. Identify questions as repetitions even if the sentences do not exactly match, but have similar meaning and even if they are asked by the AI Bot at different points of the conversation and the customer has already answered it earlier. Do not consider the AI Bot questions as repetition if the Bot is providing additional information to the customer before repeating the question. Important: Do not consider the Bot questions as repetition if the customer has not answered the question. Output a json value with two fields: a) a field called "result" with value "yes" if the agent repeatedly asked a question and "no" otherwise, b) a field called "reason" with value as array of the words or sentences that were repeatedly asked. Provide the result in a metric called 'repetition'.`,
                metric: '"repetition": {"result": "yes", "reason": "The AI agent repeatedly asked for the customer name."},',
            },
        };
    }
};
exports.handleRepetition = handleRepetition;
//# sourceMappingURL=repetition.js.map