From edf21484730ed4c1e46a066b89665fa795b65515 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Mon, 8 Jun 2026 09:56:57 +0800 Subject: [PATCH] Add modelId field to ModelResource and ModelForm in ComponentsModelsPage Updated the ComponentsModelsPage to include a new modelId property in both ModelResource and ModelForm types. Enhanced mock model data with corresponding modelId values for better identification. Adjusted form handling and UI elements to accommodate the new modelId field, ensuring improved data management and user experience when adding or editing models. --- src/components/pages/ComponentsModelsPage.tsx | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/src/components/pages/ComponentsModelsPage.tsx b/src/components/pages/ComponentsModelsPage.tsx index bb61df5..e4301d0 100644 --- a/src/components/pages/ComponentsModelsPage.tsx +++ b/src/components/pages/ComponentsModelsPage.tsx @@ -61,6 +61,7 @@ const modelTypes: ModelType[] = ["LLM", "ASR", "TTS", "Realtime", "Embedding"]; type ModelResource = { id: string; name: string; + modelId: string; type: ModelType; interfaceType: InterfaceType; apiUrl: string; @@ -71,6 +72,7 @@ const mockModels: ModelResource[] = [ { id: "model_001", name: "DeepSeek-V3", + modelId: "deepseek-chat", type: "LLM", interfaceType: "openai", apiUrl: "https://api.deepseek.com/v1", @@ -79,6 +81,7 @@ const mockModels: ModelResource[] = [ { id: "model_002", name: "Qwen-Max", + modelId: "qwen-max", type: "LLM", interfaceType: "openai", apiUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1", @@ -87,6 +90,7 @@ const mockModels: ModelResource[] = [ { id: "model_003", name: "讯飞语音识别", + modelId: "iat", type: "ASR", interfaceType: "xfyun", apiUrl: "https://iat-api.xfyun.cn/v2/iat", @@ -95,6 +99,7 @@ const mockModels: ModelResource[] = [ { id: "model_004", name: "Paraformer 识别", + modelId: "paraformer-realtime-v2", type: "ASR", interfaceType: "dashscope", apiUrl: "https://dashscope.aliyuncs.com/api/v1/services/audio/asr", @@ -103,6 +108,7 @@ const mockModels: ModelResource[] = [ { id: "model_005", name: "讯飞语音合成", + modelId: "tts", type: "TTS", interfaceType: "xfyun", apiUrl: "https://tts-api.xfyun.cn/v2/tts", @@ -111,6 +117,7 @@ const mockModels: ModelResource[] = [ { id: "model_006", name: "CosyVoice 合成", + modelId: "cosyvoice-v1", type: "TTS", interfaceType: "dashscope", apiUrl: "https://dashscope.aliyuncs.com/api/v1/services/audio/tts", @@ -119,6 +126,7 @@ const mockModels: ModelResource[] = [ { id: "model_007", name: "OpenAI TTS", + modelId: "tts-1", type: "TTS", interfaceType: "openai", apiUrl: "https://api.openai.com/v1/audio/speech", @@ -127,6 +135,7 @@ const mockModels: ModelResource[] = [ { id: "model_008", name: "GPT Realtime", + modelId: "gpt-4o-realtime-preview", type: "Realtime", interfaceType: "openai", apiUrl: "https://api.openai.com/v1/realtime", @@ -135,6 +144,7 @@ const mockModels: ModelResource[] = [ { id: "model_009", name: "Gemini Live", + modelId: "gemini-2.0-flash-live", type: "Realtime", interfaceType: "gemini", apiUrl: "https://generativelanguage.googleapis.com/v1beta", @@ -143,6 +153,7 @@ const mockModels: ModelResource[] = [ { id: "model_010", name: "text-embedding-3", + modelId: "text-embedding-3-small", type: "Embedding", interfaceType: "openai", apiUrl: "https://api.openai.com/v1/embeddings", @@ -151,6 +162,7 @@ const mockModels: ModelResource[] = [ { id: "model_011", name: "Kimi-K2", + modelId: "moonshot-v1-8k", type: "LLM", interfaceType: "openai", apiUrl: "https://api.moonshot.cn/v1", @@ -159,6 +171,7 @@ const mockModels: ModelResource[] = [ { id: "model_012", name: "BGE Embedding", + modelId: "bge-m3", type: "Embedding", interfaceType: "openai", apiUrl: "https://api.siliconflow.cn/v1/embeddings", @@ -168,6 +181,7 @@ const mockModels: ModelResource[] = [ type ModelForm = { name: string; + modelId: string; type: ModelType; interfaceType: InterfaceType; apiUrl: string; @@ -176,6 +190,7 @@ type ModelForm = { const emptyForm: ModelForm = { name: "", + modelId: "", type: "LLM", interfaceType: "openai", apiUrl: "", @@ -245,6 +260,7 @@ export function ComponentsModelsPage() { setEditingId(model.id); setForm({ name: model.name, + modelId: model.modelId, type: model.type, interfaceType: model.interfaceType, apiUrl: model.apiUrl, @@ -265,7 +281,7 @@ export function ComponentsModelsPage() { return true; } - return [model.name, model.id, model.type, model.interfaceType, model.apiUrl] + return [model.name, model.modelId, model.type, model.interfaceType, model.apiUrl] .join(" ") .toLowerCase() .includes(keyword); @@ -289,7 +305,8 @@ export function ComponentsModelsPage() { } const interfaceOptions = interfaceOptionsByType[form.type]; - const canSave = form.name.trim() && form.apiUrl.trim(); + const canSave = + form.name.trim() && form.modelId.trim() && form.apiUrl.trim(); return (
@@ -372,7 +389,9 @@ export function ComponentsModelsPage() {
{model.name}
-
{model.id}
+
+ {model.modelId} +
@@ -501,27 +520,43 @@ export function ComponentsModelsPage() { - + {editingId ? "编辑模型" : "添加模型"} - 填写模型名称、资源类型、接口类型与访问凭证。 + 填写资源名称、模型 ID、资源类型、接口类型与访问凭证。 -
+
-
+ + +
资源类型