🤯 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
♻️ refactor(model-bank): rename model type `stt` to standard `asr` (runtime migration, non-breaking) (#16002)
Arvin Xu7b932a01d041
diff --git a/apps/cli/src/commands/model.test.ts b/apps/cli/src/commands/model.test.tsindex d5e43ed1f76..89af52111b9 100644--- a/apps/cli/src/commands/model.test.ts+++ b/apps/cli/src/commands/model.test.ts@@ -100,6 +100,19 @@ describe('model command', () => {expect(consoleSpy).toHaveBeenCalledWith(JSON.stringify(visibleModels, null, 2));});++ it('should normalize the legacy `stt` type to `asr` when filtering', async () => {+ mockTrpcClient.aiModel.getAiProviderModelList.query.mockResolvedValue([+ { displayName: 'Whisper', enabled: true, id: 'whisper-1', type: 'asr' },+ ]);++ const program = createProgram();+ await program.parseAsync(['node', 'test', 'model', 'list', 'openai', '--type', 'stt']);++ expect(mockTrpcClient.aiModel.getAiProviderModelList.query).toHaveBeenCalledWith(+ expect.objectContaining({ id: 'openai', type: 'asr' }),+ );+ });});describe('view', () => {@@ -157,6 +170,28 @@ describe('model command', () => {);expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Created model'));});++ it('should normalize the legacy `stt` type to `asr`', async () => {+ mockTrpcClient.aiModel.createAiModel.mutate.mockResolvedValue('whisper-1');++ const program = createProgram();+ await program.parseAsync([+ 'node',+ 'test',+ 'model',+ 'create',+ '--id',+ 'whisper-1',+ '--provider',+ 'openai',+ '--type',+ 'stt',+ ]);++ expect(mockTrpcClient.aiModel.createAiModel.mutate).toHaveBeenCalledWith(+ expect.objectContaining({ id: 'whisper-1', providerId: 'openai', type: 'asr' }),+ );+ });});describe('edit', () => {@@ -184,6 +219,29 @@ describe('model command', () => {expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Updated model'));});+ it('should normalize the legacy `stt` type to `asr`', async () => {+ mockTrpcClient.aiModel.updateAiModel.mutate.mockResolvedValue({});++ const program = createProgram();+ await program.parseAsync([+ 'node',+ 'test',+ 'model',+ 'edit',+ 'whisper-1',+ '--provider',+ 'openai',+ '--type',+ 'stt',+ ]);++ expect(mockTrpcClient.aiModel.updateAiModel.mutate).toHaveBeenCalledWith({+ id: 'whisper-1',+ providerId: 'openai',+ value: expect.objectContaining({ type: 'asr' }),+ });+ });+it('should error when no changes specified', async () => {const program = createProgram();await program.parseAsync(['node', 'test', 'model', 'edit', 'gpt-4', '--provider', 'openai']);diff --git a/apps/cli/src/commands/model.ts b/apps/cli/src/commands/model.tsindex 64023fb1dba..fff671593dc 100644--- a/apps/cli/src/commands/model.ts+++ b/apps/cli/src/commands/model.ts@@ -7,6 +7,11 @@ import { log } from '../utils/logger';const isVisibleModel = (model: { visible?: boolean }) => model.visible !== false;+// The model type `stt` was renamed to the standard `asr`. Accept the legacy+// alias on CLI input and forward/compare `asr`, so existing scripts and muscle+// memory keep working against the new router schema.+const normalizeModelType = (type: string): string => (type === 'stt' ? 'asr' : type);+export function registerModelCommand(program: Command) {const model = program.command('model').description('Manage AI models');@@ -19,7 +24,7 @@ export function registerModelCommand(program: Command) {.option('--enabled', 'Only show enabled models').option('--type <type>',- 'Filter by model type (chat|embedding|tts|stt|image|video|text2music|realtime)',+ 'Filter by model type (chat|embedding|tts|asr|image|video|text2music|realtime)',).option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)').action(@@ -29,18 +34,20 @@ export function registerModelCommand(program: Command) {) => {const client = await getTrpcClient();+ const typeFilter = options.type ? normalizeModelType(options.type) : undefined;+const input: Record<string, any> = { id: providerId };if (options.limit) input.limit = Number.parseInt(options.limit, 10);if (options.enabled) input.enabled = true;- if (options.type) input.type = options.type;+ if (typeFilter) input.type = typeFilter;const result = await client.aiModel.getAiProviderModelList.query(input as any);let items = (Array.isArray(result) ? result : ((result as any).items ?? [])).filter(isVisibleModel,);- if (options.type) {- items = items.filter((m: any) => m.type === options.type);+ if (typeFilter) {+ items = items.filter((m: any) => m.type === typeFilter);}if (options.json !== undefined) {@@ -106,7 +113,7 @@ export function registerModelCommand(program: Command) {.option('--display-name <name>', 'Display name').option('--type <type>',- 'Model type (chat|embedding|tts|stt|image|video|text2music|realtime)',+ 'Model type (chat|embedding|tts|asr|image|video|text2music|realtime)','chat',).action(@@ -116,7 +123,7 @@ export function registerModelCommand(program: Command) {const input: Record<string, any> = {id: options.id,providerId: options.provider,- type: options.type || 'chat',+ type: normalizeModelType(options.type || 'chat'),};if (options.displayName) input.displayName = options.displayName;@@ -132,7 +139,7 @@ export function registerModelCommand(program: Command) {.description('Update model info').requiredOption('--provider <providerId>', 'Provider ID').option('--display-name <name>', 'Display name')- .option('--type <type>', 'Model type (chat|embedding|tts|stt|image|video|text2music|realtime)')+ .option('--type <type>', 'Model type (chat|embedding|tts|asr|image|video|text2music|realtime)').action(async (id: string, options: { displayName?: string; provider: string; type?: string }) => {if (!options.displayName && !options.type) {@@ -144,7 +151,7 @@ export function registerModelCommand(program: Command) {const value: Record<string, any> = {};if (options.displayName) value.displayName = options.displayName;- if (options.type) value.type = options.type;+ if (options.type) value.type = normalizeModelType(options.type);await client.aiModel.updateAiModel.mutate({id,diff --git a/locales/en-US/modelProvider.json b/locales/en-US/modelProvider.jsonindex 05958b88365..a29c5ee50c9 100644--- a/locales/en-US/modelProvider.json+++ b/locales/en-US/modelProvider.json@@ -272,11 +272,11 @@"providerModels.item.modelConfig.tokens.title": "Maximum Context Window","providerModels.item.modelConfig.tokens.unlimited": "Unlimited","providerModels.item.modelConfig.type.extra": "Different model types have distinct use cases and capabilities",+ "providerModels.item.modelConfig.type.options.asr": "Speech-to-Text","providerModels.item.modelConfig.type.options.chat": "Chat","providerModels.item.modelConfig.type.options.embedding": "Embedding","providerModels.item.modelConfig.type.options.image": "Image Generation","providerModels.item.modelConfig.type.options.realtime": "Real-time Chat",- "providerModels.item.modelConfig.type.options.stt": "Speech-to-Text","providerModels.item.modelConfig.type.options.text2music": "Text-to-Music","providerModels.item.modelConfig.type.options.tts": "Text-to-Speech","providerModels.item.modelConfig.type.options.video": "Video Generation",@@ -325,10 +325,10 @@"providerModels.list.total": "{{count}} models available","providerModels.searchNotFound": "No search results found","providerModels.tabs.all": "All",+ "providerModels.tabs.asr": "ASR","providerModels.tabs.chat": "Chat","providerModels.tabs.embedding": "Embedding","providerModels.tabs.image": "Image",- "providerModels.tabs.stt": "ASR","providerModels.tabs.tts": "TTS","providerModels.tabs.video": "Video","sortModal.success": "Sort update successful",diff --git a/locales/zh-CN/modelProvider.json b/locales/zh-CN/modelProvider.jsonindex b44a8fc6eb9..e0b778ba2a9 100644--- a/locales/zh-CN/modelProvider.json+++ b/locales/zh-CN/modelProvider.json@@ -272,11 +272,11 @@"providerModels.item.modelConfig.tokens.title": "最大上下文窗口","providerModels.item.modelConfig.tokens.unlimited": "无限制","providerModels.item.modelConfig.type.extra": "不同模型类型拥有差异化的使用场景与能力",+ "providerModels.item.modelConfig.type.options.asr": "语音转文本","providerModels.item.modelConfig.type.options.chat": "对话","providerModels.item.modelConfig.type.options.embedding": "向量化","providerModels.item.modelConfig.type.options.image": "图片生成","providerModels.item.modelConfig.type.options.realtime": "实时对话",- "providerModels.item.modelConfig.type.options.stt": "语音转文本","providerModels.item.modelConfig.type.options.text2music": "文本转音乐","providerModels.item.modelConfig.type.options.tts": "语音合成","providerModels.item.modelConfig.type.options.video": "视频生成",@@ -325,10 +325,10 @@"providerModels.list.total": "共 {{count}} 个模型可用","providerModels.searchNotFound": "未找到搜索结果","providerModels.tabs.all": "全部",+ "providerModels.tabs.asr": "ASR","providerModels.tabs.chat": "对话","providerModels.tabs.embedding": "向量化","providerModels.tabs.image": "图片",- "providerModels.tabs.stt": "ASR","providerModels.tabs.tts": "TTS","providerModels.tabs.video": "视频","sortModal.success": "排序更新成功",diff --git a/packages/database/src/models/__tests__/aiModel.test.ts b/packages/database/src/models/__tests__/aiModel.test.tsindex dacacec817f..acec43b29fa 100644--- a/packages/database/src/models/__tests__/aiModel.test.ts+++ b/packages/database/src/models/__tests__/aiModel.test.ts@@ -69,6 +69,23 @@ describe('AiModelModel', () => {releasedAt: '2025-01-01',});});++ it('should heal the legacy `stt` type to `asr` on write', async () => {+ // The model type was renamed `stt` → `asr`. A deprecated `stt` input+ // (e.g. from the OpenAPI back-compat path) must be persisted as `asr`,+ // so writes lazily migrate the value without a bulk DB migration.+ const result = await aiProviderModel.create({+ id: 'my-transcribe',+ providerId: 'openai',+ type: 'stt' as NewAiModelItem['type'],+ });+ expect(result.type).toBe('asr');++ const persisted = await serverDB.query.aiModels.findFirst({+ where: eq(aiModels.id, 'my-transcribe'),+ });+ expect(persisted!.type).toBe('asr');+ });});describe('delete', () => {it('should delete a ai provider by id', async () => {diff --git a/packages/database/src/models/aiModel.ts b/packages/database/src/models/aiModel.tsindex 30dc5bdd184..a55baa66aa2 100644--- a/packages/database/src/models/aiModel.ts+++ b/packages/database/src/models/aiModel.ts@@ -5,7 +5,7 @@ import type {EnabledAiModel,ToggleAiModelEnableParams,} from 'model-bank';-import { AiModelSourceEnum } from 'model-bank';+import { AiModelSourceEnum, normalizeAiModelType } from 'model-bank';import type { AiModelSelectItem, NewAiModelItem } from '../schemas';import { aiModels } from '../schemas';@@ -30,10 +30,16 @@ export class AiModelModel {return releasedAt.length > 10 ? releasedAt.slice(0, 10) : releasedAt;}- private normalizeAiModelValues<T extends { releasedAt?: string | null }>(values: T): T {+ private normalizeAiModelValues<T extends { releasedAt?: string | null; type?: string | null }>(+ values: T,+ ): T {return {...values,releasedAt: this.normalizeReleasedAt(values.releasedAt),+ // Heal the legacy `stt` value on write (lazy migration): any natural+ // create/update persists the standard `asr`. `undefined` is left as-is so+ // partial updates don't clobber the column (drizzle skips undefined).+ type: normalizeAiModelType(values.type),};}@@ -174,14 +180,14 @@ export class AiModelModel {userId: this.userId,} as typeof aiModels.$inferInsert;- if (value.type) insertValues.type = value.type;+ if (value.type) insertValues.type = normalizeAiModelType(value.type);const updateValues: Partial<typeof aiModels.$inferInsert> = {enabled: value.enabled,updatedAt: now,};- if (value.type) updateValues.type = value.type;+ if (value.type) updateValues.type = normalizeAiModelType(value.type);return this.db.insert(aiModels)@@ -204,6 +210,7 @@ export class AiModelModel {id,providerId,releasedAt: this.normalizeReleasedAt(model.releasedAt),+ type: normalizeAiModelType(model.type),updatedAt: new Date(),userId: this.userId,}));diff --git a/packages/database/src/repositories/aiInfra/__tests__/getAiProviderModelList.test.ts b/packages/database/src/repositories/aiInfra/__tests__/getAiProviderModelList.test.tsindex ab61c5ea94a..3db0eb436a7 100644--- a/packages/database/src/repositories/aiInfra/__tests__/getAiProviderModelList.test.ts+++ b/packages/database/src/repositories/aiInfra/__tests__/getAiProviderModelList.test.ts@@ -779,7 +779,7 @@ describe('AiInfraRepos', () => {{ id: 'dall-e-3', type: 'image', enabled: true },{ id: 'text-embedding-3-small', type: 'embedding', enabled: true },{ id: 'tts-1', type: 'tts', enabled: true },- { id: 'whisper-1', type: 'stt', enabled: true },+ { id: 'whisper-1', type: 'asr', enabled: true },] as AiProviderModelListItem[];vi.spyOn(repo.aiModelModel, 'getModelListByProviderId').mockResolvedValue(userModels);@@ -790,7 +790,7 @@ describe('AiInfraRepos', () => {expect(result.find((m) => m.id === 'dall-e-3')!.type).toBe('image');expect(result.find((m) => m.id === 'text-embedding-3-small')!.type).toBe('embedding');expect(result.find((m) => m.id === 'tts-1')!.type).toBe('tts');- expect(result.find((m) => m.id === 'whisper-1')!.type).toBe('stt');+ expect(result.find((m) => m.id === 'whisper-1')!.type).toBe('asr');});it('should keep user type for custom models not in builtin list', async () => {@@ -814,5 +814,26 @@ describe('AiInfraRepos', () => {expect(custom).toBeDefined();expect(custom!.type).toBe('chat');});++ it('should normalize the legacy `stt` type to `asr` for custom models on read', async () => {+ const providerId = 'openai';++ // A custom model not in the builtin list, still stored with the old `stt`+ // value in the DB (no bulk migration). It should read back as `asr`.+ const userModels: AiProviderModelListItem[] = [+ { id: 'my-custom-transcribe', type: 'stt', enabled: true },+ ] as unknown as AiProviderModelListItem[];++ const builtinModels: AiProviderModelListItem[] = [+ { id: 'gpt-4', type: 'chat', enabled: true },+ ] as AiProviderModelListItem[];++ vi.spyOn(repo.aiModelModel, 'getModelListByProviderId').mockResolvedValue(userModels);+ vi.spyOn(repo as any, 'fetchBuiltinModels').mockResolvedValue(builtinModels);++ const result = await repo.getAiProviderModelList(providerId);++ expect(result.find((m) => m.id === 'my-custom-transcribe')!.type).toBe('asr');+ });});});diff --git a/packages/database/src/repositories/aiInfra/index.ts b/packages/database/src/repositories/aiInfra/index.tsindex aaf75aa12b4..61dcad1bd05 100644--- a/packages/database/src/repositories/aiInfra/index.ts+++ b/packages/database/src/repositories/aiInfra/index.ts@@ -9,7 +9,7 @@ import type {} from '@lobechat/types';import { isEmpty } from 'es-toolkit/compat';import type { AIChatModelCard, AiProviderModelListItem, EnabledAiModel } from 'model-bank';-import { AiModelSourceEnum, isAiModelVisible } from 'model-bank';+import { AiModelSourceEnum, isAiModelVisible, normalizeAiModelType } from 'model-bank';import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';import pMap from 'p-map';@@ -230,7 +230,7 @@ export class AiInfraRepos {? item.settings: merge(item.settings || {}, user.settings || {}),sort: user.sort ?? undefined,- type: user.type || item.type,+ type: normalizeAiModelType(user.type || item.type),};return injectSearchSettings(provider.id, mergedModel); // User modified local model, check search settings})@@ -251,7 +251,9 @@ export class AiInfraRepos {if (builtinModelKeys.has(`${item.providerId}:${item.id}`)) return false;return filterEnabled ? enabledProviderIds.has(item.providerId) && item.enabled : true;})- .map((item) => injectSearchSettings(item.providerId, item));+ .map((item) =>+ injectSearchSettings(item.providerId, { ...item, type: normalizeAiModelType(item.type) }),+ );return [...builtinModels, ...appendedUserModels].sort((a, b) => (a?.sort ?? Infinity) - (b?.sort ?? Infinity),@@ -417,6 +419,9 @@ export class AiInfraRepos {for (const m of mergedModel) {const builtinType = builtinTypeMap.get(m.id);if (builtinType) m.type = builtinType;+ // Read-time map for the legacy `stt` → `asr` rename (custom models that+ // aren't in the builtin list and still carry the old value in the DB).+ m.type = normalizeAiModelType(m.type);}// Filter out DB residual models that are no longer in the builtin list for branding providerdiff --git a/packages/locales/src/default/modelProvider.ts b/packages/locales/src/default/modelProvider.tsindex 722c861c911..202f10e9e76 100644--- a/packages/locales/src/default/modelProvider.ts+++ b/packages/locales/src/default/modelProvider.ts@@ -348,11 +348,11 @@ export default {'providerModels.item.modelConfig.tokens.unlimited': 'Unlimited','providerModels.item.modelConfig.type.extra':'Different model types have distinct use cases and capabilities',+ 'providerModels.item.modelConfig.type.options.asr': 'Speech-to-Text','providerModels.item.modelConfig.type.options.chat': 'Chat','providerModels.item.modelConfig.type.options.embedding': 'Embedding','providerModels.item.modelConfig.type.options.image': 'Image Generation','providerModels.item.modelConfig.type.options.realtime': 'Real-time Chat',- 'providerModels.item.modelConfig.type.options.stt': 'Speech-to-Text','providerModels.item.modelConfig.type.options.text2music': 'Text-to-Music','providerModels.item.modelConfig.type.options.tts': 'Text-to-Speech','providerModels.item.modelConfig.type.options.video': 'Video Generation',@@ -405,10 +405,10 @@ export default {'providerModels.list.total': '{{count}} models available','providerModels.searchNotFound': 'No search results found','providerModels.tabs.all': 'All',+ 'providerModels.tabs.asr': 'ASR','providerModels.tabs.chat': 'Chat','providerModels.tabs.embedding': 'Embedding','providerModels.tabs.image': 'Image',- 'providerModels.tabs.stt': 'ASR','providerModels.tabs.tts': 'TTS','providerModels.tabs.video': 'Video','sortModal.success': 'Sort update successful',diff --git a/packages/model-bank/src/aiModels/openai.ts b/packages/model-bank/src/aiModels/openai.tsindex 39926b3265f..f74b0d79d6b 100644--- a/packages/model-bank/src/aiModels/openai.ts+++ b/packages/model-bank/src/aiModels/openai.ts@@ -1,10 +1,10 @@import { gptImage1Schema, gptImage2Schema } from '../const/imageParameters';import type {+ AIASRModelCard,AIChatModelCard,AIEmbeddingModelCard,AIImageModelCard,AIRealtimeModelCard,- AISTTModelCard,AITTSModelCard,AIVideoModelCard,} from '../types/aiModel';@@ -1555,7 +1555,7 @@ export const openaiTTSModels: AITTSModelCard[] = [];// Speech recognition models-export const openaiSTTModels: AISTTModelCard[] = [+export const openaiASRModels: AIASRModelCard[] = [{description:'A general speech recognition model supporting multilingual ASR, speech translation, and language identification.',@@ -1571,7 +1571,7 @@ export const openaiSTTModels: AISTTModelCard[] = [},],},- type: 'stt',+ type: 'asr',},{contextWindowTokens: 16_000,@@ -1587,7 +1587,7 @@ export const openaiSTTModels: AISTTModelCard[] = [{ name: 'textOutput', rate: 10, strategy: 'fixed', unit: 'millionTokens' },],},- type: 'stt',+ type: 'asr',},{contextWindowTokens: 16_000,@@ -1603,7 +1603,7 @@ export const openaiSTTModels: AISTTModelCard[] = [{ name: 'textOutput', rate: 5, strategy: 'fixed', unit: 'millionTokens' },],},- type: 'stt',+ type: 'asr',},];@@ -1850,7 +1850,7 @@ export const allModels = [...openaiChatModels,...openaiEmbeddingModels,...openaiTTSModels,- ...openaiSTTModels,+ ...openaiASRModels,...openaiImageModels,...openaiRealtimeModels,...openaiVideoModels,diff --git a/packages/model-bank/src/types/aiModel.ts b/packages/model-bank/src/types/aiModel.tsindex ed9a9f83fef..39f33f0cff1 100644--- a/packages/model-bank/src/types/aiModel.ts+++ b/packages/model-bank/src/types/aiModel.ts@@ -16,7 +16,7 @@ export const AiModelTypeSchema = z.enum(['chat','embedding','tts',- 'stt',+ 'asr','image','video','text2music',@@ -25,6 +25,15 @@ export const AiModelTypeSchema = z.enum([export type AiModelType = z.infer<typeof AiModelTypeSchema>;+/**+ * The speech-to-text model type was renamed from the legacy `stt` to the+ * standard `asr`. Instead of a bulk DB data migration, persisted rows and+ * external API inputs are normalized at the read/write boundary — only data+ * that is actually touched gets converted, old untouched rows stay valid.+ */+export const normalizeAiModelType = <T extends string | null | undefined>(type: T): T =>+ (type === 'stt' ? 'asr' : type) as T;+export interface ModelAbilities {/*** whether model supports audio input understanding@@ -412,9 +421,9 @@ export interface AITTSModelCard extends AIBaseModelCard {type: 'tts';}-export interface AISTTModelCard extends AIBaseModelCard {+export interface AIASRModelCard extends AIBaseModelCard {pricing?: Pricing;- type: 'stt';+ type: 'asr';}export interface AIRealtimeModelCard extends AIBaseModelCard {diff --git a/packages/model-runtime/src/providers/aihubmix/index.ts b/packages/model-runtime/src/providers/aihubmix/index.tsindex b2c15743a77..11f4d76bbbc 100644--- a/packages/model-runtime/src/providers/aihubmix/index.ts+++ b/packages/model-runtime/src/providers/aihubmix/index.ts@@ -69,7 +69,7 @@ const TYPE_MAP: Record<string, string> = {embedding: 'embedding',image_generation: 'image',llm: 'chat',- stt: 'stt',+ stt: 'asr',tts: 'tts',video: 'video',// Legacy aliases (platform docs note automatic bidirectional mapping)diff --git a/packages/model-runtime/src/utils/modelParse.test.ts b/packages/model-runtime/src/utils/modelParse.test.tsindex a663f7c675d..3a2f37ab893 100644--- a/packages/model-runtime/src/utils/modelParse.test.ts+++ b/packages/model-runtime/src/utils/modelParse.test.ts@@ -112,7 +112,7 @@ const { loadModelsMock, mockDefaultModelList } = vi.hoisted(() => ({// Mock the importvi.mock('model-bank', () => ({AiModelTypeSchema: {- options: ['chat', 'embedding', 'tts', 'stt', 'image', 'video', 'text2music', 'realtime'],+ options: ['chat', 'embedding', 'tts', 'asr', 'image', 'video', 'text2music', 'realtime'],},LOBE_DEFAULT_MODEL_LIST: mockDefaultModelList,loadModels: vi.fn().mockResolvedValue(mockDefaultModelList),diff --git a/packages/openapi/src/services/model.service.ts b/packages/openapi/src/services/model.service.tsindex 417858107fa..8dae6dab609 100644--- a/packages/openapi/src/services/model.service.ts+++ b/packages/openapi/src/services/model.service.ts@@ -14,6 +14,11 @@ import type {UpdateModelRequest,} from '../types/model.type';+// `stt` was renamed to the standard `asr`. Old rows / deprecated API inputs are+// normalized at the service boundary instead of running a bulk data migration —+// responses always emit `asr`, and `stt` is never persisted for new writes.+const normalizeModelType = <T>(type: T): T => (type === 'stt' ? ('asr' as T) : type);+/*** Model service implementation class (dedicated to Hono API)* Provides model query and grouping functionality@@ -67,7 +72,14 @@ export class ModelService extends BaseService {}if (type) {- conditions.push(eq(aiModels.type, type));+ const normalizedType = normalizeModelType(type);+ // Match both the new `asr` and the legacy `stt` so un-migrated rows+ // still surface when a client filters by the standard type.+ conditions.push(+ normalizedType === 'asr'+ ? or(eq(aiModels.type, 'asr'), eq(aiModels.type, 'stt'))+ : eq(aiModels.type, normalizedType),+ );}if (typeof enabled === 'boolean') {@@ -91,7 +103,7 @@ export class ModelService extends BaseService {]);return {- models: result,+ models: result.map((model) => ({ ...model, type: normalizeModelType(model.type) })),total: totalResult[0]?.count ?? 0,};} catch (error) {@@ -125,7 +137,7 @@ export class ModelService extends BaseService {throw this.createNotFoundError(`模型 ${providerId}/${modelId} 不存在`);}- return model;+ return { ...model, type: normalizeModelType(model.type) };} catch (error) {this.handleServiceError(error, '获取模型详情');}@@ -177,7 +189,7 @@ export class ModelService extends BaseService {releasedAt: payload.releasedAt ?? null,sort: payload.sort ?? null,source: payload.source ?? null,- type: payload.type ?? 'chat',+ type: normalizeModelType(payload.type ?? 'chat'),...this.buildWorkspacePayload({}),}).returning();@@ -234,7 +246,7 @@ export class ModelService extends BaseService {...(payload.releasedAt !== undefined && { releasedAt: payload.releasedAt }),...(payload.sort !== undefined && { sort: payload.sort }),...(payload.source !== undefined && { source: payload.source }),- ...(payload.type !== undefined && { type: payload.type }),+ ...(payload.type !== undefined && { type: normalizeModelType(payload.type) }),updatedAt: new Date(),} as Record<string, unknown>;diff --git a/packages/openapi/src/types/model.type.ts b/packages/openapi/src/types/model.type.tsindex 554f198b5cc..5ad385a0d9d 100644--- a/packages/openapi/src/types/model.type.ts+++ b/packages/openapi/src/types/model.type.ts@@ -11,20 +11,25 @@ const MODEL_TYPES = ['chat','embedding','tts',- 'stt',+ 'asr','image','text2video','text2music','realtime',] as const;+// `stt` was renamed to the standard `asr`. It is still accepted on input as a+// deprecated alias (so existing API clients don't break) and normalized to+// `asr` in the service layer; it is never emitted in responses.+const MODEL_TYPE_INPUTS = [...MODEL_TYPES, 'stt'] as const;+/*** Model list query parameters*/export interface ModelsListQuery extends IPaginationQuery {enabled?: boolean;provider?: string;- type?: (typeof MODEL_TYPES)[number];+ type?: (typeof MODEL_TYPE_INPUTS)[number];}export const ModelsListQuerySchema = PaginationQuerySchema.extend({@@ -34,7 +39,7 @@ export const ModelsListQuerySchema = PaginationQuerySchema.extend({.pipe(z.boolean()).nullish(),provider: z.string().min(1).max(64).nullish(),- type: z.enum(MODEL_TYPES).nullish(),+ type: z.enum(MODEL_TYPE_INPUTS).nullish(),});// ==================== Model Response Types ====================@@ -60,15 +65,19 @@ const ModelPayloadBaseSchema = z.object({releasedAt: z.string().nullish(),sort: z.number().int().nullish(),source: z.enum(['remote', 'custom', 'builtin']).nullish(),- type: z- .enum(['chat', 'embedding', 'tts', 'stt', 'image', 'text2video', 'text2music', 'realtime'])- .nullish(),+ type: z.enum(MODEL_TYPE_INPUTS).nullish(),});export const CreateModelRequestSchema = ModelPayloadBaseSchema.extend({displayName: z.string().min(1, 'Model display name cannot be empty'),- id: z.string().min(1, 'Model ID cannot be empty').max(150, 'Model ID cannot exceed 150 characters'),- providerId: z.string().min(1, 'Provider ID cannot be empty').max(64, 'Provider ID cannot exceed 64 characters'),+ id: z+ .string()+ .min(1, 'Model ID cannot be empty')+ .max(150, 'Model ID cannot exceed 150 characters'),+ providerId: z+ .string()+ .min(1, 'Provider ID cannot be empty')+ .max(64, 'Provider ID cannot exceed 64 characters'),});export const UpdateModelRequestSchema = ModelPayloadBaseSchema.partial();@@ -77,6 +86,12 @@ export type CreateModelRequest = z.infer<typeof CreateModelRequestSchema>;export type UpdateModelRequest = z.infer<typeof UpdateModelRequestSchema>;export const ModelIdParamSchema = z.object({- modelId: z.string().min(1, 'Model ID cannot be empty').max(150, 'Model ID cannot exceed 150 characters'),- providerId: z.string().min(1, 'Provider ID cannot be empty').max(64, 'Provider ID cannot exceed 64 characters'),+ modelId: z+ .string()+ .min(1, 'Model ID cannot be empty')+ .max(150, 'Model ID cannot exceed 150 characters'),+ providerId: z+ .string()+ .min(1, 'Provider ID cannot be empty')+ .max(64, 'Provider ID cannot exceed 64 characters'),});diff --git a/src/routes/(main)/community/(list)/model/features/List/ModelTypeIcon.tsx b/src/routes/(main)/community/(list)/model/features/List/ModelTypeIcon.tsxindex 7fac94de162..cf61145df91 100644--- a/src/routes/(main)/community/(list)/model/features/List/ModelTypeIcon.tsx+++ b/src/routes/(main)/community/(list)/model/features/List/ModelTypeIcon.tsx@@ -16,11 +16,11 @@ import { type AiModelType } from 'model-bank';import { memo } from 'react';const icons: Record<AiModelType, LucideIcon> = {+ asr: MicIcon,chat: MessageSquareTextIcon,embedding: BoltIcon,image: ImageIcon,realtime: PhoneIcon,- stt: MicIcon,text2music: MusicIcon,tts: AudioLines,video: VideoIcon,diff --git a/src/routes/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsx b/src/routes/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsxindex cec07834149..83eeabe56f8 100644--- a/src/routes/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsx+++ b/src/routes/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsx@@ -45,7 +45,7 @@ const ModelConfigForm = memo<ModelConfigFormProps>('chat','embedding','tts',- 'stt',+ 'asr','image','video','text2music',diff --git a/src/routes/(main)/settings/provider/features/ModelList/ModelItem.tsx b/src/routes/(main)/settings/provider/features/ModelList/ModelItem.tsxindex b276ba94a90..6e50702ffe4 100644--- a/src/routes/(main)/settings/provider/features/ModelList/ModelItem.tsx+++ b/src/routes/(main)/settings/provider/features/ModelList/ModelItem.tsx@@ -131,7 +131,7 @@ const ModelItem = memo<ModelItemProps>(}),].filter(Boolean) as string[];}- case 'stt': {+ case 'asr': {const inputRate = getAudioInputUnitRate(pricing);return [typeof inputRate === 'number' &&diff --git a/src/routes/(main)/settings/provider/features/ModelList/index.tsx b/src/routes/(main)/settings/provider/features/ModelList/index.tsxindex c9ab29093e6..20dca6bf5bf 100644--- a/src/routes/(main)/settings/provider/features/ModelList/index.tsx+++ b/src/routes/(main)/settings/provider/features/ModelList/index.tsx@@ -50,10 +50,10 @@ const Content = memo<ContentProps>(({ id }) => {const modelCounts = useMemo(() => {const counts = {all: allModels.length,+ asr: 0,chat: 0,embedding: 0,image: 0,- stt: 0,tts: 0,video: 0,};@@ -105,10 +105,10 @@ const Content = memo<ContentProps>(({ id }) => {label: formatTabLabel(t('providerModels.tabs.embedding'), modelCounts.embedding),},{- count: modelCounts.stt,+ count: modelCounts.asr,icon: <Icon icon={MicIcon} size={16} />,- key: 'stt',- label: formatTabLabel(t('providerModels.tabs.stt'), modelCounts.stt),+ key: 'asr',+ label: formatTabLabel(t('providerModels.tabs.asr'), modelCounts.asr),},{count: modelCounts.tts,