|
| 1 | +import * as React from 'react'; |
| 2 | + |
| 3 | +import type { DModelsService, DModelsServiceId } from '~/common/stores/llms/llms.service.types'; |
| 4 | + |
| 5 | +import { findModelVendor, ModelVendorId } from '../vendors/vendors.registry'; |
| 6 | + |
| 7 | + |
| 8 | +// direct imports for all vendor setup components - NOTE: we could lazy load if this becomes a performance issue |
| 9 | +import { AlibabaServiceSetup } from '../vendors/alibaba/AlibabaServiceSetup'; |
| 10 | +import { AnthropicServiceSetup } from '../vendors/anthropic/AnthropicServiceSetup'; |
| 11 | +import { AzureServiceSetup } from '../vendors/azure/AzureServiceSetup'; |
| 12 | +import { DeepseekAIServiceSetup } from '../vendors/deepseek/DeepseekAIServiceSetup'; |
| 13 | +import { GeminiServiceSetup } from '../vendors/gemini/GeminiServiceSetup'; |
| 14 | +import { GroqServiceSetup } from '../vendors/groq/GroqServiceSetup'; |
| 15 | +import { LMStudioServiceSetup } from '../vendors/lmstudio/LMStudioServiceSetup'; |
| 16 | +import { LocalAIServiceSetup } from '../vendors/localai/LocalAIServiceSetup'; |
| 17 | +import { MistralServiceSetup } from '../vendors/mistral/MistralServiceSetup'; |
| 18 | +import { OllamaServiceSetup } from '../vendors/ollama/OllamaServiceSetup'; |
| 19 | +import { OpenAIServiceSetup } from '../vendors/openai/OpenAIServiceSetup'; |
| 20 | +import { OpenPipeServiceSetup } from '../vendors/openpipe/OpenPipeServiceSetup'; |
| 21 | +import { OpenRouterServiceSetup } from '../vendors/openrouter/OpenRouterServiceSetup'; |
| 22 | +import { PerplexityServiceSetup } from '../vendors/perplexity/PerplexityServiceSetup'; |
| 23 | +import { TogetherAIServiceSetup } from '../vendors/togetherai/TogetherAIServiceSetup'; |
| 24 | +import { XAIServiceSetup } from '../vendors/xai/XAIServiceSetup'; |
| 25 | + |
| 26 | + |
| 27 | +/** |
| 28 | + * Hardcoded mapping with the setup components for each vendor. |
| 29 | + * NOTE: we do it here to only depend on this file (even lazily) and avoid to import all the Components (UI) |
| 30 | + * code on vendor definitions (which must be lightweight as it impacts boot time). |
| 31 | + */ |
| 32 | +const vendorSetupComponents: Record<ModelVendorId, React.ComponentType<{ serviceId: DModelsServiceId }>> = { |
| 33 | + alibaba: AlibabaServiceSetup, |
| 34 | + anthropic: AnthropicServiceSetup, |
| 35 | + azure: AzureServiceSetup, |
| 36 | + deepseek: DeepseekAIServiceSetup, |
| 37 | + googleai: GeminiServiceSetup, |
| 38 | + groq: GroqServiceSetup, |
| 39 | + lmstudio: LMStudioServiceSetup, |
| 40 | + localai: LocalAIServiceSetup, |
| 41 | + mistral: MistralServiceSetup, |
| 42 | + ollama: OllamaServiceSetup, |
| 43 | + openai: OpenAIServiceSetup, |
| 44 | + openpipe: OpenPipeServiceSetup, |
| 45 | + openrouter: OpenRouterServiceSetup, |
| 46 | + perplexity: PerplexityServiceSetup, |
| 47 | + togetherai: TogetherAIServiceSetup, |
| 48 | + xai: XAIServiceSetup, |
| 49 | +} as const; |
| 50 | + |
| 51 | + |
| 52 | +export function LLMVendorSetup(props: { service: DModelsService }) { |
| 53 | + const vendor = findModelVendor(props.service.vId); |
| 54 | + if (!vendor) |
| 55 | + return 'Configuration issue: Vendor not found for Service ' + props.service.id; |
| 56 | + |
| 57 | + const SetupComponent = vendorSetupComponents[vendor.id]; |
| 58 | + if (!SetupComponent) |
| 59 | + return 'Configuration issue: Setup component not found for vendor ' + vendor.id; |
| 60 | + |
| 61 | + return <SetupComponent key={props.service.id} serviceId={props.service.id} />; |
| 62 | +} |
0 commit comments