"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleMultiModalCommon = void 0;
const path_1 = __importDefault(require("path"));
const matchers_1 = require("../../matchers");
const defaults_1 = require("../../providers/defaults");
const pythonUtils_1 = require("../../python/pythonUtils");
const utils_1 = require("./utils");
const handleMultiModalCommon = async ({ assertion, outputString, test, context, workspaceId, }) => {
    const modelProvider = await (0, matchers_1.getAndCheckProvider)('text', test.options?.provider, (await (0, defaults_1.getDefaultProviders)(undefined, workspaceId)).gradingProvider, assertion.type);
    const output = (0, utils_1.getImageContent)(outputString);
    if (!output) {
        return {
            assertion,
            pass: false,
            score: 0,
            reason: 'Missing trusys.output or output not valid JSON.',
        };
    }
    const pythonScriptPath = path_1.default.join(__dirname, '..', 'python', 'multimodal', `${assertion.type}.py`);
    const pythonScriptOutput = await (0, pythonUtils_1.runPython)(pythonScriptPath, 'get_assert', [
        output,
        context,
    ]);
    return {
        assertion,
        ...pythonScriptOutput
    };
};
exports.handleMultiModalCommon = handleMultiModalCommon;
//# sourceMappingURL=multimodalCommon.js.map