🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: resolve browser model config import (#15089)
YuTengjingaca724c430cf
diff --git a/packages/model-runtime/src/utils/getModelPricing.ts b/packages/model-runtime/src/utils/getModelPricing.tsindex 0de8b37f6f3..b4ff24988f1 100644--- a/packages/model-runtime/src/utils/getModelPricing.ts+++ b/packages/model-runtime/src/utils/getModelPricing.ts@@ -1,7 +1,5 @@import type { LobeDefaultAiModelListItem, Pricing } from 'model-bank';-const BUSINESS_MODEL_CONFIG_MODULE = '@lobechat/business-model-bank/model-config';-interface BusinessModelConfigModule {loadModels: () => Promise<LobeDefaultAiModelListItem[]>;}@@ -17,9 +15,8 @@ export async function getModelPricing(model: string,provider?: string,): Promise<Pricing | undefined> {- const { loadModels } = (await import(- /* @vite-ignore */ BUSINESS_MODEL_CONFIG_MODULE- )) as BusinessModelConfigModule;+ const { loadModels } =+ (await import('@lobechat/business-model-bank/model-config')) as BusinessModelConfigModule;const models = await loadModels();// 1. First try to get pricing from the specified providerdiff --git a/packages/model-runtime/src/utils/modelConfigImport.test.ts b/packages/model-runtime/src/utils/modelConfigImport.test.tsnew file mode 100644index 00000000000..2277e19d679--- /dev/null+++ b/packages/model-runtime/src/utils/modelConfigImport.test.ts@@ -0,0 +1,22 @@+import { readFile } from 'node:fs/promises';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++import { describe, expect, it } from 'vitest';++const utilsDir = path.dirname(fileURLToPath(import.meta.url));++describe('model config imports', () => {+ it('keeps runtime model-config imports statically analyzable for browser bundlers', async () => {+ const sources = await Promise.all(+ ['getModelPricing.ts', 'getFallbackModelProperty.ts', 'modelParse.ts'].map((file) =>+ readFile(path.resolve(utilsDir, file), 'utf8'),+ ),+ );++ for (const source of sources) {+ expect(source).not.toContain('@vite-ignore');+ expect(source).not.toContain('BUSINESS_MODEL_CONFIG_MODULE');+ }+ });+});diff --git a/packages/model-runtime/src/utils/modelParse.ts b/packages/model-runtime/src/utils/modelParse.tsindex 30ba91d61f2..8480f59a552 100644--- a/packages/model-runtime/src/utils/modelParse.ts+++ b/packages/model-runtime/src/utils/modelParse.ts@@ -201,7 +201,6 @@ export const IMAGE_MODEL_KEYWORDS = [export const EMBEDDING_MODEL_KEYWORDS = ['embedding', 'embed', 'bge', 'm3e'] as const;const AI_MODEL_TYPE_SET = new Set<AiModelType>(AiModelTypeSchema.options);-const BUSINESS_MODEL_CONFIG_MODULE = '@lobechat/business-model-bank/model-config';interface BusinessModelConfigModule {loadModels: () => Promise<LobeDefaultAiModelListItem[]>;@@ -464,9 +463,8 @@ const getProviderLocalConfig = async (if (!provider) return null;if (provider === ModelProvider.LobeHub) {- const { loadModels } = (await import(- /* @vite-ignore */ BUSINESS_MODEL_CONFIG_MODULE- )) as BusinessModelConfigModule;+ const { loadModels } =+ (await import('@lobechat/business-model-bank/model-config')) as BusinessModelConfigModule;const models = await loadModels();return models.filter((model) => model.providerId === ModelProvider.LobeHub);}