"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProxyLlmProvider = void 0;
const common_1 = require("@nestjs/common");
const openrouter_llm_provider_1 = require("./openrouter-llm.provider");
const zai_llm_provider_1 = require("./zai-llm.provider");
const alibaba_llm_provider_1 = require("./alibaba-llm.provider");
const ollama_llm_provider_1 = require("./ollama-llm.provider");
const openai_llm_provider_1 = require("./openai-llm.provider");
let ProxyLlmProvider = class ProxyLlmProvider {
    constructor(openRouterProvider, zaiProvider, alibabaProvider, ollamaProvider, openaiProvider) {
        this.openRouterProvider = openRouterProvider;
        this.zaiProvider = zaiProvider;
        this.alibabaProvider = alibabaProvider;
        this.ollamaProvider = ollamaProvider;
        this.openaiProvider = openaiProvider;
    }
    async getModels() {
        const openRouterModels = await this.openRouterProvider.getModels();
        const zaiModels = await this.zaiProvider.getModels();
        const alibabaModels = await this.alibabaProvider.getModels();
        const ollamaModels = await this.ollamaProvider.getModels();
        const openaiModels = await this.openaiProvider.getModels();
        return [
            ...ollamaModels,
            ...alibabaModels,
            ...zaiModels,
            ...openRouterModels,
            ...openaiModels,
        ];
    }
    async generateContent(request) {
        const { modelId } = request;
        if (modelId?.startsWith('ollama/')) {
            return this.ollamaProvider.generateContent(request);
        }
        if (modelId?.startsWith('alibaba/')) {
            return this.alibabaProvider.generateContent(request);
        }
        if (modelId?.startsWith('zai/')) {
            return this.zaiProvider.generateContent(request);
        }
        if (modelId?.startsWith('openai/')) {
            return this.openaiProvider.generateContent(request);
        }
        if (modelId && modelId.includes('/')) {
            return this.openRouterProvider.generateContent(request);
        }
        throw new Error(`Unknown model provider for model ID: "${modelId}". Model IDs must be prefixed with a provider (e.g., ollama/, openrouter/, zai/, alibaba/, openai/).`);
    }
};
exports.ProxyLlmProvider = ProxyLlmProvider;
exports.ProxyLlmProvider = ProxyLlmProvider = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [openrouter_llm_provider_1.OpenRouterLlmProvider,
        zai_llm_provider_1.ZaiLlmProvider,
        alibaba_llm_provider_1.AlibabaLlmProvider,
        ollama_llm_provider_1.OllamaLlmProvider,
        openai_llm_provider_1.OpenaiLlmProvider])
], ProxyLlmProvider);
//# sourceMappingURL=proxy-llm.provider.js.map