"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KnowhowGenericClient = void 0;
const KnowhowClient_1 = require("../services/KnowhowClient");
const envUrl = KnowhowClient_1.KNOWHOW_API_URL;
class KnowhowGenericClient {
    baseUrl;
    client;
    constructor(baseUrl = envUrl, jwt) {
        this.baseUrl = baseUrl;
        this.setKey(jwt);
    }
    setKey(jwt) {
        this.client = new KnowhowClient_1.KnowhowSimpleClient(this.baseUrl, jwt);
    }
    async createChatCompletion(options) {
        const response = await this.client.createChatCompletion(options);
        return response.data;
    }
    async createEmbedding(options) {
        const response = await this.client.createEmbedding(options);
        return response.data;
    }
    async getModels(type = "all") {
        const response = await this.client.getModels(type);
        return (response.data?.data?.map((model) => ({
            id: model.id,
            modality: [model.type],
        })) || []);
    }
    async createAudioTranscription(options) {
        const response = await this.client.createAudioTranscription(options);
        return response.data;
    }
    async createAudioGeneration(options) {
        const response = await this.client.createAudioGeneration(options);
        const data = response.data;
        return {
            ...data,
            audio: data.audio ? Buffer.from(data.audio, "base64") : data.audio,
        };
    }
    async createImageGeneration(options) {
        const response = await this.client.createImageGeneration(options);
        return response.data;
    }
    async createVideoGeneration(options) {
        const response = await this.client.createVideoGeneration(options);
        return response.data;
    }
    async getVideoStatus(options) {
        const response = await this.client.getVideoStatus(options);
        return response.data;
    }
    async downloadVideo(options) {
        const response = await this.client.downloadVideo(options);
        return {
            data: Buffer.from(response.data),
            mimeType: response.headers?.["content-type"] || "video/mp4",
        };
    }
    async uploadFile(options) {
        const response = await this.client.uploadFile(options);
        return response.data;
    }
    async downloadFile(options) {
        const response = await this.client.downloadFile(options);
        return {
            data: Buffer.from(response.data),
            mimeType: response.headers?.["content-type"] ||
                "application/octet-stream",
        };
    }
}
exports.KnowhowGenericClient = KnowhowGenericClient;
//# sourceMappingURL=knowhow.js.map