"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleSentiment = void 0;
const invariant_1 = __importDefault(require("../../util/invariant"));
const handleSentiment = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    if (evaluateResult) {
        (0, invariant_1.default)(typeof renderedValue === 'string' || Array.isArray(renderedValue), 'Sentiment assertion type must have a string or array of strings value');
        let input = [];
        if (Array.isArray(renderedValue)) {
            input = renderedValue;
        }
        else {
            input = [renderedValue];
        }
        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: `Analyze the sentiment of the audio and classify it as one of ['positive', 'neutral', 'negative']. Provide the result in a metric called 'sentiment'.`,
                metric: '"sentiment": "positive",',
            },
        };
    }
};
exports.handleSentiment = handleSentiment;
//# sourceMappingURL=sentiment.js.map