import { ModelProviderUISection } from '../../config/types.js';
import { ProviderConstructor } from '../base/provider.js';
import OpenAIProvider from './openai/index.js';
import OllamaProvider from './ollama/index.js';
import TimewebProvider from './timeweb/index.js';
import GeminiProvider from './gemini/index.js';
import TransformersProvider from './transformers/index.js';
import GroqProvider from './groq/index.js';
import LemonadeProvider from './lemonade/index.js';
import AnthropicProvider from './anthropic/index.js';
import LMStudioProvider from './lmstudio/index.js';

export const providers: Record<string, ProviderConstructor<any>> = {
  openai: OpenAIProvider,
  ollama: OllamaProvider,
  timeweb: TimewebProvider,
  gemini: GeminiProvider,
  transformers: TransformersProvider,
  groq: GroqProvider,
  lemonade: LemonadeProvider,
  anthropic: AnthropicProvider,
  lmstudio: LMStudioProvider,
};

export const getModelProvidersUIConfigSection =
  (): ModelProviderUISection[] => {
    return Object.entries(providers).map(([k, p]) => {
      const configFields = p.getProviderConfigFields();
      const metadata = p.getProviderMetadata();

      return {
        fields: configFields,
        key: k,
        name: metadata.name,
      };
    });
  };
