mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-15 04:00:09 +00:00
♻️ refactor: refactor the model-bank package from src/config/aiModels (#8983)
* move * refactor with model banks * refactor with model banks * refactor @/config/aiModels to model-bank * refactor @/config/aiModels to model-bank * fix model bank exports * clean * add test workflow * try again * fix * add exports tests * fix model bank alias * Update tsconfig.json * fix import issue * clean unused code * fix tests
This commit is contained in:
@@ -7,7 +7,7 @@ permissions:
|
||||
|
||||
jobs:
|
||||
# Package tests - using each package's own test script
|
||||
test-packages:
|
||||
test-intenral-packages:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -41,6 +41,41 @@ jobs:
|
||||
files: ./packages/${{ matrix.package }}/coverage/lcov.info
|
||||
flags: packages/${{ matrix.package }}
|
||||
|
||||
test-packages:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
package: [model-bank]
|
||||
|
||||
name: Test package ${{ matrix.package }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Test ${{ matrix.package }} package with coverage
|
||||
run: bun run --filter ${{ matrix.package }} test:coverage
|
||||
|
||||
- name: Upload ${{ matrix.package }} coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./packages/${{ matrix.package }}/coverage/lcov.info
|
||||
flags: packages/${{ matrix.package }}
|
||||
|
||||
|
||||
# App tests
|
||||
test-website:
|
||||
name: Test Website
|
||||
|
||||
@@ -210,6 +210,7 @@
|
||||
"mammoth": "^1.10.0",
|
||||
"markdown-to-txt": "^2.0.1",
|
||||
"mdast-util-to-markdown": "^2.1.2",
|
||||
"model-bank": "workspace:*",
|
||||
"modern-screenshot": "^4.6.5",
|
||||
"nanoid": "^5.1.5",
|
||||
"next": "~15.3.5",
|
||||
|
||||
@@ -2,5 +2,8 @@
|
||||
"name": "@lobechat/const",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"main": "./src/index.ts"
|
||||
"main": "./src/index.ts",
|
||||
"dependencies": {
|
||||
"model-bank": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModelParamsSchema } from '@/libs/standard-parameters';
|
||||
import { ModelParamsSchema } from 'model-bank';
|
||||
|
||||
/**
|
||||
* 默认宽高比,当模型不支持原生宽高比时使用
|
||||
|
||||
@@ -201,7 +201,11 @@ export class AiInfraRepos {
|
||||
providerId: string,
|
||||
): Promise<AiProviderModelListItem[] | undefined> => {
|
||||
try {
|
||||
const { default: providerModels } = await import(`@/config/aiModels/${providerId}.ts`);
|
||||
const modules = await import('model-bank');
|
||||
|
||||
// TODO: when model-bank is a separate module, we will try import from model-bank/[prividerId] again
|
||||
// @ts-expect-error providerId is string
|
||||
const providerModels = modules[providerId];
|
||||
|
||||
// use the serverModelLists as the defined server model list
|
||||
const presetList = this.providerConfigs[providerId]?.serverModelLists || providerModels;
|
||||
@@ -210,7 +214,8 @@ export class AiInfraRepos {
|
||||
enabled: m.enabled || false,
|
||||
source: AiModelSourceEnum.Builtin,
|
||||
}));
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
// maybe provider id not exist
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"name": "model-bank",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./ai21": "./src/aiModels/ai21.ts",
|
||||
"./ai302": "./src/aiModels/ai302.ts",
|
||||
"./ai360": "./src/aiModels/ai360.ts",
|
||||
"./aihubmix": "./src/aiModels/aihubmix.ts",
|
||||
"./akashchat": "./src/aiModels/akashchat.ts",
|
||||
"./anthropic": "./src/aiModels/anthropic.ts",
|
||||
"./azureai": "./src/aiModels/azureai.ts",
|
||||
"./azure": "./src/aiModels/azure.ts",
|
||||
"./baichuan": "./src/aiModels/baichuan.ts",
|
||||
"./bedrock": "./src/aiModels/bedrock.ts",
|
||||
"./bfl": "./src/aiModels/bfl.ts",
|
||||
"./cloudflare": "./src/aiModels/cloudflare.ts",
|
||||
"./cohere": "./src/aiModels/cohere.ts",
|
||||
"./deepseek": "./src/aiModels/deepseek.ts",
|
||||
"./fal": "./src/aiModels/fal.ts",
|
||||
"./fireworksai": "./src/aiModels/fireworksai.ts",
|
||||
"./giteeai": "./src/aiModels/giteeai.ts",
|
||||
"./github": "./src/aiModels/github.ts",
|
||||
"./google": "./src/aiModels/google.ts",
|
||||
"./groq": "./src/aiModels/groq.ts",
|
||||
"./lobehub": "./src/aiModels/lobehub.ts",
|
||||
"./higress": "./src/aiModels/higress.ts",
|
||||
"./huggingface": "./src/aiModels/huggingface.ts",
|
||||
"./hunyuan": "./src/aiModels/hunyuan.ts",
|
||||
"./infiniai": "./src/aiModels/infiniai.ts",
|
||||
"./internlm": "./src/aiModels/internlm.ts",
|
||||
"./jina": "./src/aiModels/jina.ts",
|
||||
"./lmstudio": "./src/aiModels/lmstudio.ts",
|
||||
"./minimax": "./src/aiModels/minimax.ts",
|
||||
"./mistral": "./src/aiModels/mistral.ts",
|
||||
"./modelscope": "./src/aiModels/modelscope.ts",
|
||||
"./moonshot": "./src/aiModels/moonshot.ts",
|
||||
"./novita": "./src/aiModels/novita.ts",
|
||||
"./nvidia": "./src/aiModels/nvidia.ts",
|
||||
"./ollama": "./src/aiModels/ollama.ts",
|
||||
"./openai": "./src/aiModels/openai.ts",
|
||||
"./openrouter": "./src/aiModels/openrouter.ts",
|
||||
"./perplexity": "./src/aiModels/perplexity.ts",
|
||||
"./ppio": "./src/aiModels/ppio.ts",
|
||||
"./qiniu": "./src/aiModels/qiniu.ts",
|
||||
"./qwen": "./src/aiModels/qwen.ts",
|
||||
"./sambanova": "./src/aiModels/sambanova.ts",
|
||||
"./search1api": "./src/aiModels/search1api.ts",
|
||||
"./sensenova": "./src/aiModels/sensenova.ts",
|
||||
"./siliconcloud": "./src/aiModels/siliconcloud.ts",
|
||||
"./spark": "./src/aiModels/spark.ts",
|
||||
"./stepfun": "./src/aiModels/stepfun.ts",
|
||||
"./taichu": "./src/aiModels/taichu.ts",
|
||||
"./tencentcloud": "./src/aiModels/tencentcloud.ts",
|
||||
"./togetherai": "./src/aiModels/togetherai.ts",
|
||||
"./upstage": "./src/aiModels/upstage.ts",
|
||||
"./v0": "./src/aiModels/v0.ts",
|
||||
"./vertexai": "./src/aiModels/vertexai.ts",
|
||||
"./vllm": "./src/aiModels/vllm.ts",
|
||||
"./volcengine": "./src/aiModels/volcengine.ts",
|
||||
"./wenxin": "./src/aiModels/wenxin.ts",
|
||||
"./xai": "./src/aiModels/xai.ts",
|
||||
"./xinference": "./src/aiModels/xinference.ts",
|
||||
"./zeroone": "./src/aiModels/zeroone.ts",
|
||||
"./zhipu": "./src/aiModels/zhipu.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest",
|
||||
"test:coverage": "vitest --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^3.25.76"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PRESET_ASPECT_RATIOS } from '@/const/image';
|
||||
import { ModelParamsSchema } from '@/libs/standard-parameters';
|
||||
import { ModelParamsSchema } from '../standard-parameters';
|
||||
import { AIImageModelCard } from '@/types/aiModel';
|
||||
|
||||
// https://docs.bfl.ai/api-reference/tasks/edit-or-create-an-image-with-flux-kontext-pro
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModelParamsSchema } from '@/libs/standard-parameters';
|
||||
import { ModelParamsSchema } from '../standard-parameters';
|
||||
import { AIImageModelCard } from '@/types/aiModel';
|
||||
|
||||
export const fluxSchnellParamsSchema: ModelParamsSchema = {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CHAT_MODEL_IMAGE_GENERATION_PARAMS } from '@/const/image';
|
||||
import { ModelParamsSchema } from '@/libs/standard-parameters';
|
||||
import { ModelParamsSchema } from '../standard-parameters';
|
||||
import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
|
||||
|
||||
const googleChatModels: AIChatModelCard[] = [
|
||||
@@ -155,7 +155,7 @@ export { default as bfl } from './bfl';
|
||||
export { default as cloudflare } from './cloudflare';
|
||||
export { default as cohere } from './cohere';
|
||||
export { default as deepseek } from './deepseek';
|
||||
export { default as fal } from './fal';
|
||||
export { default as fal, fluxSchnellParamsSchema } from './fal';
|
||||
export { default as fireworksai } from './fireworksai';
|
||||
export { default as giteeai } from './giteeai';
|
||||
export { default as github } from './github';
|
||||
@@ -176,7 +176,7 @@ export { default as moonshot } from './moonshot';
|
||||
export { default as novita } from './novita';
|
||||
export { default as nvidia } from './nvidia';
|
||||
export { default as ollama } from './ollama';
|
||||
export { default as openai } from './openai';
|
||||
export { gptImage1ParamsSchema, default as openai, openaiChatModels } from './openai';
|
||||
export { default as openrouter } from './openrouter';
|
||||
export { default as perplexity } from './perplexity';
|
||||
export { default as ppio } from './ppio';
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModelParamsSchema } from '@/libs/standard-parameters';
|
||||
import { ModelParamsSchema } from '../standard-parameters';
|
||||
import {
|
||||
AIChatModelCard,
|
||||
AIEmbeddingModelCard,
|
||||
@@ -0,0 +1,37 @@
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
// 本测试确保 packages/model-bank/package.json 的 exports 覆盖 src/aiModels 下的所有文件
|
||||
describe('model-bank package.json exports should cover all aiModels files', () => {
|
||||
const packageRoot = path.resolve(__dirname, '..');
|
||||
const aiModelsDir = path.resolve(packageRoot, 'src/aiModels');
|
||||
const packageJsonPath = path.resolve(packageRoot, 'package.json');
|
||||
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {
|
||||
exports?: Record<string, string>;
|
||||
};
|
||||
|
||||
const allModelFiles = readdirSync(aiModelsDir)
|
||||
.filter((f) => f.endsWith('.ts'))
|
||||
.map((f) => f.replace(/\.ts$/, ''))
|
||||
// 排除非 provider 文件,如 index、类型声明等
|
||||
.filter((name) => !['index'].includes(name));
|
||||
|
||||
it('every aiModels file should be exported in package.json.exports', () => {
|
||||
const exportsMap = packageJson.exports ?? {};
|
||||
|
||||
const missing = allModelFiles.filter((name) => {
|
||||
const key = `./${name}`;
|
||||
const expectedPath = `./src/aiModels/${name}.ts`;
|
||||
return !(key in exportsMap) || exportsMap[key] !== expectedPath;
|
||||
});
|
||||
|
||||
if (missing.length > 0) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Missing exports for aiModels files:', missing);
|
||||
}
|
||||
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './aiModels';
|
||||
export * from './standard-parameters';
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import type { Simplify } from 'type-fest';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { MAX_SEED } from '@/const/image';
|
||||
export const MAX_SEED = 2 ** 31 - 1;
|
||||
|
||||
// 定义顶层的元规范 - 平铺结构
|
||||
export const ModelParamsMetaSchema = z.object({
|
||||
@@ -0,0 +1,11 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
coverage: {
|
||||
all: false,
|
||||
reporter: ['text', 'json', 'lcov', 'text-summary'],
|
||||
},
|
||||
environment: 'happy-dom',
|
||||
},
|
||||
});
|
||||
@@ -12,6 +12,7 @@
|
||||
"@lobechat/types": "workspace:*",
|
||||
"@lobechat/utils": "workspace:*",
|
||||
"debug": "^4.4.1",
|
||||
"model-bank": "workspace:*",
|
||||
"openai": "^4.104.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export const LobeAi360AI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_AI360_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const reasoningKeywords = ['360gpt2-o1', '360zhinao2-o1'];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LOBE_DEFAULT_MODEL_LIST } from 'model-bank';
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels';
|
||||
import { responsesAPIModels } from '@/const/models';
|
||||
|
||||
import { createRouterRuntime } from '../RouterRuntime';
|
||||
|
||||
@@ -12,10 +12,10 @@ import { buildAnthropicMessages, buildAnthropicTools } from '../utils/anthropicH
|
||||
import { AgentRuntimeError } from '../utils/createError';
|
||||
import { debugStream } from '../utils/debugStream';
|
||||
import { desensitizeUrl } from '../utils/desensitizeUrl';
|
||||
import { MODEL_LIST_CONFIGS, processModelList } from '../utils/modelParse';
|
||||
import { StreamingResponse } from '../utils/response';
|
||||
import { AnthropicStream } from '../utils/streams';
|
||||
import { handleAnthropicError } from './handleAnthropicError';
|
||||
import { processModelList, MODEL_LIST_CONFIGS } from '../utils/modelParse';
|
||||
|
||||
export interface AnthropicModelCard {
|
||||
created_at: string;
|
||||
@@ -120,7 +120,7 @@ export class LobeAnthropicAI implements LobeRuntimeAI {
|
||||
enabledSearch,
|
||||
} = payload;
|
||||
|
||||
const { default: anthropicModels } = await import('@/config/aiModels/anthropic');
|
||||
const { anthropic: anthropicModels } = await import('model-bank');
|
||||
const modelConfig = anthropicModels.find((m) => m.id === model);
|
||||
const defaultMaxOutput = modelConfig?.maxOutput;
|
||||
|
||||
@@ -231,10 +231,10 @@ export class LobeAnthropicAI implements LobeRuntimeAI {
|
||||
const modelList: AnthropicModelCard[] = json['data'];
|
||||
|
||||
const standardModelList = modelList.map((model) => ({
|
||||
created: model.created_at,
|
||||
displayName: model.display_name,
|
||||
id: model.id,
|
||||
}));
|
||||
created: model.created_at,
|
||||
displayName: model.display_name,
|
||||
id: model.id,
|
||||
}));
|
||||
return processModelList(standardModelList, MODEL_LIST_CONFIGS.anthropic, 'anthropic');
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export const LobeBaichuanAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_BAICHUAN_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const modelsPage = (await client.models.list()) as any;
|
||||
const modelList: BaichuanModelCard[] = modelsPage.data;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { imageUrlToBase64 } from '@lobechat/utils';
|
||||
import createDebug from 'debug';
|
||||
|
||||
import { RuntimeImageGenParamsValue } from '@/libs/standard-parameters/index';
|
||||
import { RuntimeImageGenParamsValue } from 'model-bank';
|
||||
|
||||
import { AgentRuntimeErrorType } from '../error';
|
||||
import { CreateImagePayload, CreateImageResponse } from '../types/image';
|
||||
|
||||
@@ -112,7 +112,7 @@ export class LobeCloudflareAI implements LobeRuntimeAI {
|
||||
}
|
||||
|
||||
async models(): Promise<ChatModelCard[]> {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const url = `${DEFAULT_BASE_URL_PREFIX}/client/v4/accounts/${this.accountID}/ai/models/search`;
|
||||
const response = await fetch(url, {
|
||||
|
||||
@@ -37,7 +37,7 @@ export const LobeCohereAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_COHERE_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
client.baseURL = 'https://api.cohere.com/v1';
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export const LobeDeepSeekAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_DEEPSEEK_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const modelsPage = (await client.models.list()) as any;
|
||||
const modelList: DeepSeekModelCard[] = modelsPage.data;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { fal } from '@fal-ai/client';
|
||||
import debug from 'debug';
|
||||
import { pick } from 'lodash-es';
|
||||
import { RuntimeImageGenParamsValue } from 'model-bank';
|
||||
import { ClientOptions } from 'openai';
|
||||
|
||||
import { RuntimeImageGenParamsValue } from '@/libs/standard-parameters/index';
|
||||
|
||||
import { LobeRuntimeAI } from '../BaseAI';
|
||||
import { AgentRuntimeErrorType } from '../error';
|
||||
import { CreateImagePayload, CreateImageResponse } from '../types/image';
|
||||
|
||||
@@ -16,7 +16,7 @@ export const LobeFireworksAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_FIREWORKSAI_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const reasoningKeywords = ['deepseek-r1', 'qwq'];
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export const LobeGroq = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_GROQ_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const functionCallKeywords = [
|
||||
'tool',
|
||||
|
||||
@@ -27,7 +27,7 @@ export const LobeHigressAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_HIGRESS_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const modelsPage = (await client.models.list()) as any;
|
||||
const modelList: HigressModelCard[] = modelsPage.data;
|
||||
|
||||
@@ -55,7 +55,7 @@ export const LobeHuggingFaceAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_HUGGINGFACE_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async () => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const visionKeywords = ['image-text-to-text', 'multimodal', 'vision'];
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ export const LobeHunyuanAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_HUNYUAN_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const functionCallKeywords = ['hunyuan-functioncall', 'hunyuan-turbo', 'hunyuan-pro'];
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export const LobeInfiniAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_INFINIAI_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const reasoningKeywords = ['deepseek-r1', 'qwq', 'qwen3'];
|
||||
const visionKeywords = ['qwen2.5-vl'];
|
||||
|
||||
@@ -21,7 +21,7 @@ export const LobeInternLMAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_INTERNLM_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const functionCallKeywords = ['internlm'];
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export const LobeJinaAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_JINA_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const reasoningKeywords = ['deepsearch'];
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export const LobeLMStudioAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_LMSTUDIO_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const modelsPage = (await client.models.list()) as any;
|
||||
const modelList: LMStudioModelCard[] = modelsPage.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import minimaxChatModels from '@/config/aiModels/minimax';
|
||||
import { minimax as minimaxChatModels } from 'model-bank';
|
||||
|
||||
import { ModelProvider } from '../types';
|
||||
import { createOpenAICompatibleRuntime } from '../utils/openaiCompatibleFactory';
|
||||
|
||||
@@ -34,7 +34,7 @@ export const LobeMistralAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_MISTRAL_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const modelsPage = (await client.models.list()) as any;
|
||||
const modelList: MistralModelCard[] = modelsPage.data;
|
||||
|
||||
@@ -119,7 +119,7 @@ export class LobeOllamaAI implements LobeRuntimeAI {
|
||||
}
|
||||
|
||||
async models() {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const list = await this.client.list();
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
import OpenAI from 'openai';
|
||||
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
// 引入模块以便于对函数进行spy
|
||||
import { ChatStreamCallbacks } from '@/libs/model-runtime';
|
||||
|
||||
import * as debugStreamModule from '../utils/debugStream';
|
||||
import officalOpenAIModels from './fixtures/openai-models.json';
|
||||
import { LobeOpenAI } from './index';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import OpenRouterModels from '@/config/aiModels/openrouter';
|
||||
import { openrouter as OpenRouterModels } from 'model-bank';
|
||||
|
||||
import { ModelProvider } from '../types';
|
||||
import { processMultiProviderModelList } from '../utils/modelParse';
|
||||
|
||||
@@ -15,7 +15,7 @@ export const LobePPIOAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_PPIO_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const reasoningKeywords = ['deepseek-r1'];
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export const LobeSearch1API = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_SEARCH1API_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const modelsPage = (await client.models.list()) as any;
|
||||
const modelList: Search1APIModelCard[] = modelsPage.data;
|
||||
|
||||
@@ -54,7 +54,7 @@ export const LobeSenseNovaAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_SENSENOVA_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
const functionCallKeywords = ['1202'];
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export const LobeStepfunAI = createOpenAICompatibleRuntime({
|
||||
chatCompletion: () => process.env.DEBUG_STEPFUN_CHAT_COMPLETION === '1',
|
||||
},
|
||||
models: async ({ client }) => {
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
||||
const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
|
||||
|
||||
// ref: https://platform.stepfun.com/docs/llm/modeloverview
|
||||
const functionCallKeywords = ['step-1-', 'step-1o-', 'step-1v-', 'step-2-'];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user