"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleCallCategory = void 0;
const invariant_1 = __importDefault(require("../../util/invariant"));
const handleCallCategory = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    (0, invariant_1.default)(typeof renderedValue === 'string' || Array.isArray(renderedValue), 'Call category assertion type must have a string or array of strings value');
    let input = [];
    if (Array.isArray(renderedValue)) {
        input = renderedValue;
    }
    else {
        input = [renderedValue];
    }
    if (evaluateResult) {
        const result = typeof output === 'string' ? output.toLowerCase() : '';
        const pass = input.includes(result);
        return {
            pass,
            score: pass ? 1 : 0,
            reason: result,
            assertion,
        };
    }
    else {
        return {
            pass: true,
            score: 1,
            reason: '',
            metadata: {
                prompt: `Determine the call category and classify it as [${input}]. Provide the result in a metric called 'call-category'.`,
                metric: '"call-category": "order related",',
            },
        };
    }
};
exports.handleCallCategory = handleCallCategory;
//# sourceMappingURL=callCategory.js.map