UNPKG

aquanet-bot-lib

Version:

A library for building aquaculture chatbots with LLM integration

36 lines (35 loc) 1.12 kB
import { LLMProviders } from '../types/llm'; import { DeepSeekProvider } from './providers/deepseek'; export class LLMFactory { static getProvider(config) { const key = `${config.provider}-${config.model}`; if (!this.providers.has(key)) { this.providers.set(key, this.createProvider(config)); } return this.providers.get(key); } static createProvider(config) { switch (config.provider) { case LLMProviders.DEEPSEEK: return new DeepSeekProvider(config); default: throw new Error(`Unsupported LLM provider: ${config.provider}`); } } static removeProvider(provider, model) { const key = `${provider}-${model}`; this.providers.delete(key); } static clearProviders() { this.providers.clear(); } static isProviderSupported(provider) { return Object.values(LLMProviders).includes(provider); } } Object.defineProperty(LLMFactory, "providers", { enumerable: true, configurable: true, writable: true, value: new Map() });