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.
This commit is contained in:
@@ -61,6 +61,7 @@ const modelTypes: ModelType[] = ["LLM", "ASR", "TTS", "Realtime", "Embedding"];
|
|||||||
type ModelResource = {
|
type ModelResource = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
modelId: string;
|
||||||
type: ModelType;
|
type: ModelType;
|
||||||
interfaceType: InterfaceType;
|
interfaceType: InterfaceType;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
@@ -71,6 +72,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_001",
|
id: "model_001",
|
||||||
name: "DeepSeek-V3",
|
name: "DeepSeek-V3",
|
||||||
|
modelId: "deepseek-chat",
|
||||||
type: "LLM",
|
type: "LLM",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "https://api.deepseek.com/v1",
|
apiUrl: "https://api.deepseek.com/v1",
|
||||||
@@ -79,6 +81,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_002",
|
id: "model_002",
|
||||||
name: "Qwen-Max",
|
name: "Qwen-Max",
|
||||||
|
modelId: "qwen-max",
|
||||||
type: "LLM",
|
type: "LLM",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
apiUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||||||
@@ -87,6 +90,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_003",
|
id: "model_003",
|
||||||
name: "讯飞语音识别",
|
name: "讯飞语音识别",
|
||||||
|
modelId: "iat",
|
||||||
type: "ASR",
|
type: "ASR",
|
||||||
interfaceType: "xfyun",
|
interfaceType: "xfyun",
|
||||||
apiUrl: "https://iat-api.xfyun.cn/v2/iat",
|
apiUrl: "https://iat-api.xfyun.cn/v2/iat",
|
||||||
@@ -95,6 +99,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_004",
|
id: "model_004",
|
||||||
name: "Paraformer 识别",
|
name: "Paraformer 识别",
|
||||||
|
modelId: "paraformer-realtime-v2",
|
||||||
type: "ASR",
|
type: "ASR",
|
||||||
interfaceType: "dashscope",
|
interfaceType: "dashscope",
|
||||||
apiUrl: "https://dashscope.aliyuncs.com/api/v1/services/audio/asr",
|
apiUrl: "https://dashscope.aliyuncs.com/api/v1/services/audio/asr",
|
||||||
@@ -103,6 +108,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_005",
|
id: "model_005",
|
||||||
name: "讯飞语音合成",
|
name: "讯飞语音合成",
|
||||||
|
modelId: "tts",
|
||||||
type: "TTS",
|
type: "TTS",
|
||||||
interfaceType: "xfyun",
|
interfaceType: "xfyun",
|
||||||
apiUrl: "https://tts-api.xfyun.cn/v2/tts",
|
apiUrl: "https://tts-api.xfyun.cn/v2/tts",
|
||||||
@@ -111,6 +117,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_006",
|
id: "model_006",
|
||||||
name: "CosyVoice 合成",
|
name: "CosyVoice 合成",
|
||||||
|
modelId: "cosyvoice-v1",
|
||||||
type: "TTS",
|
type: "TTS",
|
||||||
interfaceType: "dashscope",
|
interfaceType: "dashscope",
|
||||||
apiUrl: "https://dashscope.aliyuncs.com/api/v1/services/audio/tts",
|
apiUrl: "https://dashscope.aliyuncs.com/api/v1/services/audio/tts",
|
||||||
@@ -119,6 +126,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_007",
|
id: "model_007",
|
||||||
name: "OpenAI TTS",
|
name: "OpenAI TTS",
|
||||||
|
modelId: "tts-1",
|
||||||
type: "TTS",
|
type: "TTS",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "https://api.openai.com/v1/audio/speech",
|
apiUrl: "https://api.openai.com/v1/audio/speech",
|
||||||
@@ -127,6 +135,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_008",
|
id: "model_008",
|
||||||
name: "GPT Realtime",
|
name: "GPT Realtime",
|
||||||
|
modelId: "gpt-4o-realtime-preview",
|
||||||
type: "Realtime",
|
type: "Realtime",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "https://api.openai.com/v1/realtime",
|
apiUrl: "https://api.openai.com/v1/realtime",
|
||||||
@@ -135,6 +144,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_009",
|
id: "model_009",
|
||||||
name: "Gemini Live",
|
name: "Gemini Live",
|
||||||
|
modelId: "gemini-2.0-flash-live",
|
||||||
type: "Realtime",
|
type: "Realtime",
|
||||||
interfaceType: "gemini",
|
interfaceType: "gemini",
|
||||||
apiUrl: "https://generativelanguage.googleapis.com/v1beta",
|
apiUrl: "https://generativelanguage.googleapis.com/v1beta",
|
||||||
@@ -143,6 +153,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_010",
|
id: "model_010",
|
||||||
name: "text-embedding-3",
|
name: "text-embedding-3",
|
||||||
|
modelId: "text-embedding-3-small",
|
||||||
type: "Embedding",
|
type: "Embedding",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "https://api.openai.com/v1/embeddings",
|
apiUrl: "https://api.openai.com/v1/embeddings",
|
||||||
@@ -151,6 +162,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_011",
|
id: "model_011",
|
||||||
name: "Kimi-K2",
|
name: "Kimi-K2",
|
||||||
|
modelId: "moonshot-v1-8k",
|
||||||
type: "LLM",
|
type: "LLM",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "https://api.moonshot.cn/v1",
|
apiUrl: "https://api.moonshot.cn/v1",
|
||||||
@@ -159,6 +171,7 @@ const mockModels: ModelResource[] = [
|
|||||||
{
|
{
|
||||||
id: "model_012",
|
id: "model_012",
|
||||||
name: "BGE Embedding",
|
name: "BGE Embedding",
|
||||||
|
modelId: "bge-m3",
|
||||||
type: "Embedding",
|
type: "Embedding",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "https://api.siliconflow.cn/v1/embeddings",
|
apiUrl: "https://api.siliconflow.cn/v1/embeddings",
|
||||||
@@ -168,6 +181,7 @@ const mockModels: ModelResource[] = [
|
|||||||
|
|
||||||
type ModelForm = {
|
type ModelForm = {
|
||||||
name: string;
|
name: string;
|
||||||
|
modelId: string;
|
||||||
type: ModelType;
|
type: ModelType;
|
||||||
interfaceType: InterfaceType;
|
interfaceType: InterfaceType;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
@@ -176,6 +190,7 @@ type ModelForm = {
|
|||||||
|
|
||||||
const emptyForm: ModelForm = {
|
const emptyForm: ModelForm = {
|
||||||
name: "",
|
name: "",
|
||||||
|
modelId: "",
|
||||||
type: "LLM",
|
type: "LLM",
|
||||||
interfaceType: "openai",
|
interfaceType: "openai",
|
||||||
apiUrl: "",
|
apiUrl: "",
|
||||||
@@ -245,6 +260,7 @@ export function ComponentsModelsPage() {
|
|||||||
setEditingId(model.id);
|
setEditingId(model.id);
|
||||||
setForm({
|
setForm({
|
||||||
name: model.name,
|
name: model.name,
|
||||||
|
modelId: model.modelId,
|
||||||
type: model.type,
|
type: model.type,
|
||||||
interfaceType: model.interfaceType,
|
interfaceType: model.interfaceType,
|
||||||
apiUrl: model.apiUrl,
|
apiUrl: model.apiUrl,
|
||||||
@@ -265,7 +281,7 @@ export function ComponentsModelsPage() {
|
|||||||
return true;
|
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(" ")
|
.join(" ")
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.includes(keyword);
|
.includes(keyword);
|
||||||
@@ -289,7 +305,8 @@ export function ComponentsModelsPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const interfaceOptions = interfaceOptionsByType[form.type];
|
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 (
|
return (
|
||||||
<div className="mx-auto flex w-full max-w-[1440px] flex-col gap-8">
|
<div className="mx-auto flex w-full max-w-[1440px] flex-col gap-8">
|
||||||
@@ -372,7 +389,9 @@ export function ComponentsModelsPage() {
|
|||||||
<div className="truncate font-medium text-foreground">
|
<div className="truncate font-medium text-foreground">
|
||||||
{model.name}
|
{model.name}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 text-xs text-muted-soft">{model.id}</div>
|
<div className="mt-1 text-xs text-muted-soft">
|
||||||
|
{model.modelId}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="md:w-[110px]">
|
<div className="md:w-[110px]">
|
||||||
@@ -501,27 +520,43 @@ export function ComponentsModelsPage() {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||||
<DialogContent className="sm:max-w-lg">
|
<DialogContent className="max-h-[calc(100vh-3rem)] overflow-y-auto sm:max-w-2xl">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>{editingId ? "编辑模型" : "添加模型"}</DialogTitle>
|
<DialogTitle>{editingId ? "编辑模型" : "添加模型"}</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
填写模型名称、资源类型、接口类型与访问凭证。
|
填写资源名称、模型 ID、资源类型、接口类型与访问凭证。
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-5">
|
||||||
<label className="block">
|
<label className="block">
|
||||||
<div className="mb-2 text-sm font-medium text-foreground">名称</div>
|
<div className="mb-2 text-sm font-medium text-foreground">
|
||||||
|
资源名称
|
||||||
|
</div>
|
||||||
<Input
|
<Input
|
||||||
value={form.name}
|
value={form.name}
|
||||||
autoFocus
|
autoFocus
|
||||||
onChange={(event) => updateForm("name", event.target.value)}
|
onChange={(event) => updateForm("name", event.target.value)}
|
||||||
placeholder="请输入模型名称"
|
placeholder="请输入资源名称"
|
||||||
className="border-hairline-strong bg-background text-foreground placeholder:text-muted-soft"
|
className="border-hairline-strong bg-background text-foreground placeholder:text-muted-soft"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
<label className="block">
|
||||||
|
<div className="mb-2 text-sm font-medium text-foreground">
|
||||||
|
模型 ID
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
value={form.modelId}
|
||||||
|
onChange={(event) =>
|
||||||
|
updateForm("modelId", event.target.value)
|
||||||
|
}
|
||||||
|
placeholder="例如 deepseek-chat"
|
||||||
|
className="border-hairline-strong bg-background text-foreground placeholder:text-muted-soft"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 gap-5 sm:grid-cols-2">
|
||||||
<div className="block">
|
<div className="block">
|
||||||
<div className="mb-2 text-sm font-medium text-foreground">
|
<div className="mb-2 text-sm font-medium text-foreground">
|
||||||
资源类型
|
资源类型
|
||||||
|
|||||||
Reference in New Issue
Block a user