// providers/ai-provider.factory.ts
import {Injectable} from '@nestjs/common';
import {OpenAIProvider} from './openai.provider';
import {DeepSeekProvider} from './deepseek.provider';
import {IAIProvider} from '../interfaces/ai-provider.interface';
import {GrokProvider} from "./grok.provider";

export type ProviderName = 'openai' | 'deepseek' | 'grok';

@Injectable()
export class AIProviderFactory {
    constructor(
        private readonly openai: OpenAIProvider,
        private readonly deepseek: DeepSeekProvider,
        private readonly grok: GrokProvider,
    ) {
    }

    get(name: ProviderName): IAIProvider {
        switch (name) {
            case 'openai':
                return this.openai;
            case 'deepseek':
                return this.deepseek;
            case 'grok':
                return this.grok;
            default:
                throw new Error(`Unknown AI provider: ${name}`);
        }
    }

    getGrok(): GrokProvider {
        return this.grok;
    }
}
