UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

47 lines (40 loc) 1.52 kB
import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; import type { ChatModelCard } from '@/types/llm'; export interface ZeroOneModelCard { id: string; } export const LobeZeroOneAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.lingyiwanwu.com/v1', debug: { chatCompletion: () => process.env.DEBUG_ZEROONE_CHAT_COMPLETION === '1', }, models: async ({ client }) => { const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels'); const modelsPage = await client.models.list() as any; const modelList: ZeroOneModelCard[] = modelsPage.data; return modelList .map((model) => { const knownModel = LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.toLowerCase() === m.id.toLowerCase()); return { contextWindowTokens: knownModel?.contextWindowTokens ?? undefined, displayName: knownModel?.displayName ?? undefined, enabled: knownModel?.enabled || false, functionCall: model.id.toLowerCase().includes('fc') || knownModel?.abilities?.functionCall || false, id: model.id, reasoning: knownModel?.abilities?.reasoning || false, vision: model.id.toLowerCase().includes('vision') || knownModel?.abilities?.vision || false, }; }) .filter(Boolean) as ChatModelCard[]; }, provider: ModelProvider.ZeroOne, });