"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LangflowProvider = void 0;
const http_1 = require("../http");
const logger_1 = __importDefault(require("../../logger"));
class LangflowProvider {
    constructor(config, options = {}) {
        this.config = options.config || {};
        this.providerConfig = config;
        // Create HttpProvider with Langflow-specific configuration
        // Assuming Langflow uses similar structure to Dify
        const httpProviderConfig = {
            url: `${config.url}/api/v1/run/${config.flowId}?stream=false`,
            method: 'POST',
            headers: {
                'x-api-key': config.apiKey,
                'Content-Type': 'application/json',
            },
            body: {
                input_value: '{{prompt}}',
                output_type: 'chat',
                input_type: 'chat',
            },
            transformResponse: options?.config?.transformResponse || 'json.outputs?.[0]?.outputs?.[0]?.results?.message?.text || json.output || json',
        };
        this.httpProvider = new http_1.HttpProvider(httpProviderConfig.url, {
            ...options,
            config: httpProviderConfig,
        });
    }
    id() {
        return `langflow:${this.providerConfig.url}`;
    }
    async callApi(prompt, context) {
        logger_1.default.debug(`[Langflow Provider]: Calling API with url: ${this.providerConfig.url}`);
        return this.httpProvider.callApi(prompt, context);
    }
}
exports.LangflowProvider = LangflowProvider;
//# sourceMappingURL=langflow.js.map