"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.callAIReview = void 0;
var tslib_1 = require("tslib");
var axios_1 = require("axios");
var host = process.env.PEPSICO_AI_HOST;
var apiKey = process.env.PEPSICO_AI_API_KEY;
var callAIReview = function (ctx, approvalId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
    var now, result, data, error_1;
    return tslib_1.__generator(this, function (_a) {
        switch (_a.label) {
            case 0:
                _a.trys.push([0, 3, , 5]);
                now = new Date().getTime();
                console.log('[调用 AI review API] 开始:', "".concat(host, "/api/v1/review"), {
                    approval_id: approvalId
                }, new Date());
                return [4, axios_1.default.post("".concat(host, "/api/v1/review"), {
                        approval_id: approvalId
                    }, {
                        headers: {
                            'X-API-Key': apiKey
                        }
                    })];
            case 1:
                result = _a.sent();
                data = result.data;
                console.log("[\u8C03\u7528 AI review API]-".concat(approvalId), data, "\u8017\u65F6:", new Date().getTime() - now);
                return [4, ctx.logger.info("[\u8C03\u7528 AI review API]-".concat(approvalId), data)];
            case 2:
                _a.sent();
                return [2, data];
            case 3:
                error_1 = _a.sent();
                console.error("[\u8C03\u7528 AI review API]-".concat(approvalId), error_1.message, new Date());
                return [4, ctx.logger.error("[\u8C03\u7528 AI review API]-".concat(approvalId), error_1.message)];
            case 4:
                _a.sent();
                return [3, 5];
            case 5: return [2];
        }
    });
}); };
exports.callAIReview = callAIReview;
//# sourceMappingURL=AI.js.map