"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleAgentResponseTime = void 0;
const handleAgentResponseTime = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    if (evaluateResult) {
        const result = output;
        const threshold = assertion.threshold ?? 2;
        const pass = Number(result.max) <= threshold;
        if (!pass) {
            result.reason = `Maximum response time ${result.max} exceeds threshold ${threshold}`;
        }
        return {
            pass,
            score: Number(result.average),
            reason: JSON.stringify(result) || '',
            assertion,
        };
    }
    else {
        return {
            pass: true,
            score: 1,
            reason: '',
            metadata: {
                prompt: `Measure the average and maximum agent response time between customer query and AI Bot agent reply in seconds. Output a json value with two fields: a) "average" with the average response time, b) "max" with the max response time. Provide the result in a metric called 'agent-response-time'.`,
                metric: '"agent-response-time": {"average": 2.5, "max": 3},',
            },
        };
    }
};
exports.handleAgentResponseTime = handleAgentResponseTime;
//# sourceMappingURL=responseTime.js.map