"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowiseProvider = void 0;
const http_1 = require("../http");
const logger_1 = __importDefault(require("../../logger"));
class FlowiseProvider {
    constructor(config, options = {}) {
        this.config = options.config || {};
        this.providerConfig = config;
        // Create HttpProvider with Flowise-specific configuration
        const httpProviderConfig = {
            url: `${this.providerConfig.url}/api/v1/prediction/${this.providerConfig.workflowId}`,
            method: 'POST',
            headers: {
                Authorization: `Bearer ${this.providerConfig.apiKey}`,
                'Content-Type': 'application/json',
            },
            body: {
                question: '{{prompt}}',
            },
            transformResponse: options.config?.transformResponse || 'json.output || json.text || json',
        };
        this.httpProvider = new http_1.HttpProvider(httpProviderConfig.url, {
            ...options,
            config: httpProviderConfig,
        });
    }
    id() {
        return `flowise:${this.providerConfig.workflowId}`;
    }
    async callApi(prompt, context) {
        logger_1.default.debug(`[Flowise Provider]: Calling API with workflowId: ${this.providerConfig.workflowId}`);
        return this.httpProvider.callApi(prompt, context);
    }
}
exports.FlowiseProvider = FlowiseProvider;
//# sourceMappingURL=flowise.js.map