"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BflCardChatProvider = void 0;
const time_1 = require("../../../util/time");
class BflCardChatProvider {
    constructor(options = {}) {
        this.options = options;
        this.id = options.id ? () => options.id : this.id;
        this.label = options.label;
        this.config = options.config;
        this.delay = options.delay;
    }
    id() {
        return 'output:transform:bfl:cardChat';
    }
    toString() {
        return '[BFL Card Chat Provider]';
    }
    async callApi(input, options, context) {
        if (this.delay && this.delay > 0) {
            await (0, time_1.sleep)(this.delay);
        }
        let inputJson = {};
        try {
            inputJson = JSON.parse(input);
        }
        catch { }
        const messages = inputJson.messages || [];
        const conversation = [];
        for (const message of messages) {
            //if(message.user_message){
            conversation.push({
                role: 'user',
                content: message.user_message,
            });
            //}
            //if (message.bot_response && message.bot_response.length > 0) {
            const bot_message = message.bot_response.join(" ");
            //if (bot_message.trim() !== '') {
            conversation.push({
                role: 'assistant',
                content: bot_message,
            });
            //}
            //}
        }
        // Create a complete ProviderResponse object
        const response = {
            output: conversation,
            raw: conversation,
            cost: 0,
            cached: false,
            tokenUsage: {
                total: 0,
                prompt: 0,
                completion: 0,
            },
            isRefusal: false,
            metadata: context?.metadata || {},
        };
        return response;
    }
}
exports.BflCardChatProvider = BflCardChatProvider;
//# sourceMappingURL=cardChat.js.map