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.

51 lines (42 loc) 1.62 kB
import type { ChatModelCard } from '@lobechat/types'; import { ModelProvider } from 'model-bank'; import { OpenAICompatibleFactoryOptions, createOpenAICompatibleRuntime, } from '../../core/openaiCompatibleFactory'; export interface JinaModelCard { id: string; } export const params = { baseURL: 'https://deepsearch.jina.ai/v1', debug: { chatCompletion: () => process.env.DEBUG_JINA_CHAT_COMPLETION === '1', }, models: async ({ client }) => { const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank'); const reasoningKeywords = ['deepsearch']; const modelsPage = (await client.models.list()) as any; const modelList: JinaModelCard[] = 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: knownModel?.abilities?.functionCall || false, id: model.id, reasoning: reasoningKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) || knownModel?.abilities?.reasoning || false, vision: knownModel?.abilities?.vision || false, }; }) .filter(Boolean) as ChatModelCard[]; }, provider: ModelProvider.Jina, } satisfies OpenAICompatibleFactoryOptions; export const LobeJinaAI = createOpenAICompatibleRuntime(params);