UNPKG

@yk1028-test/ai-chat-supporter

Version:

AI Chat Supporter - TypeScript library for intelligent chat processing with LangChain integration

68 lines 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProviderFactory = exports.BaseLLMProvider = void 0; // 기본 LLM 제공자 추상 클래스 class BaseLLMProvider { constructor(config) { this.config = {}; this.isConfigured = false; if (config) { this.config = { ...config }; } } async configure(config) { if (config) { this.config = { ...this.config, ...config }; } await this.initializeProvider(); this.isConfigured = true; } // 설정 정보 조회 getConfig() { return { ...this.config }; } // 설정 상태 확인 isReady() { return this.isConfigured; } } exports.BaseLLMProvider = BaseLLMProvider; // 제공자 팩토리 클래스 (LangChain 통합) class ProviderFactory { // 제공자 클래스 등록 static register(name, providerClass) { this.providers.set(name.toLowerCase(), providerClass); } // 제공자 인스턴스 생성 static createProvider(name, config) { const ProviderClass = this.providers.get(name.toLowerCase()); if (!ProviderClass) { throw new Error(`지원하지 않는 제공자: ${name}`); } return new ProviderClass(config); } // 등록된 제공자 목록 조회 static getRegisteredProviders() { return Array.from(this.providers.keys()); } // 제공자 등록 해제 static unregister(name) { return this.providers.delete(name.toLowerCase()); } // 모든 제공자 등록 해제 static clear() { this.providers.clear(); } // 하위 호환성을 위한 기존 메서드 static create(name) { try { return this.createProvider(name, {}); } catch { return null; } } } exports.ProviderFactory = ProviderFactory; ProviderFactory.providers = new Map(); //# sourceMappingURL=base.js.map