2026-03-09 08:10:48 +00:00
|
|
|
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
2026-07-02 07:19:11 +00:00
|
|
|
|
import {
|
|
|
|
|
|
App,
|
|
|
|
|
|
AutoComplete,
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Col,
|
|
|
|
|
|
Divider,
|
|
|
|
|
|
Drawer,
|
|
|
|
|
|
Form,
|
|
|
|
|
|
Input,
|
|
|
|
|
|
InputNumber,
|
|
|
|
|
|
Popconfirm,
|
|
|
|
|
|
Row,
|
|
|
|
|
|
Select,
|
|
|
|
|
|
Space,
|
|
|
|
|
|
Switch,
|
|
|
|
|
|
Table,
|
|
|
|
|
|
Tabs,
|
|
|
|
|
|
Tag,
|
|
|
|
|
|
Tooltip,
|
|
|
|
|
|
Typography,
|
|
|
|
|
|
} from "antd";
|
2026-03-09 08:10:48 +00:00
|
|
|
|
import {
|
|
|
|
|
|
DeleteOutlined,
|
|
|
|
|
|
EditOutlined,
|
|
|
|
|
|
PlusOutlined,
|
|
|
|
|
|
SafetyCertificateOutlined,
|
|
|
|
|
|
SaveOutlined,
|
|
|
|
|
|
SearchOutlined,
|
|
|
|
|
|
SyncOutlined,
|
2026-03-26 09:42:29 +00:00
|
|
|
|
WifiOutlined,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
} from "@ant-design/icons";
|
2026-07-02 07:19:11 +00:00
|
|
|
|
import PageContainer from "@/components/shared/PageContainer";
|
|
|
|
|
|
import DataListPanel from "@/components/shared/DataListPanel";
|
|
|
|
|
|
import SectionCard from "@/components/shared/SectionCard";
|
|
|
|
|
|
import AppPagination from "../../components/shared/AppPagination";
|
2026-03-09 08:10:48 +00:00
|
|
|
|
import { useDict } from "../../hooks/useDict";
|
|
|
|
|
|
import {
|
2026-03-26 09:42:29 +00:00
|
|
|
|
AiLocalProfileVO,
|
2026-07-02 07:19:11 +00:00
|
|
|
|
AiModelDTO,
|
2026-03-02 11:59:47 +00:00
|
|
|
|
AiModelVO,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
deleteAiModelByType,
|
|
|
|
|
|
getAiModelPage,
|
|
|
|
|
|
getRemoteModelList,
|
|
|
|
|
|
saveAiModel,
|
2026-07-02 07:19:11 +00:00
|
|
|
|
setTenantDefaultModel,
|
|
|
|
|
|
syncCurrentAsrSpeakers,
|
|
|
|
|
|
tenantDisableModel,
|
|
|
|
|
|
tenantEnableModel,
|
2026-04-22 01:40:15 +00:00
|
|
|
|
testLlmModelConnectivity,
|
2026-03-26 09:42:29 +00:00
|
|
|
|
testLocalModelConnectivity,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
updateAiModel,
|
2026-07-02 07:19:11 +00:00
|
|
|
|
updatePlatformModelStatus,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
} from "../../api/business/aimodel";
|
2026-06-29 01:00:12 +00:00
|
|
|
|
import {getMeetingCreateConfig, type MeetingCreateConfig} from "../../api/business/meeting";
|
2026-06-29 02:17:30 +00:00
|
|
|
|
import "./AiModels.css";
|
2026-03-02 11:59:47 +00:00
|
|
|
|
|
|
|
|
|
|
const { Option } = Select;
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const { Title } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
type ModelType = "ASR" | "LLM";
|
|
|
|
|
|
|
2026-06-29 01:00:12 +00:00
|
|
|
|
const DEFAULT_CREATE_CONFIG: MeetingCreateConfig = {
|
|
|
|
|
|
offlineEnabled: true,
|
|
|
|
|
|
realtimeEnabled: false,
|
|
|
|
|
|
offlineAudioMaxSizeMb: 1024,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const PROVIDER_BASE_URL_MAP: Record<string, string> = {
|
2026-04-24 05:44:29 +00:00
|
|
|
|
openai: "https://api.openai.com",
|
2026-03-09 08:10:48 +00:00
|
|
|
|
deepseek: "https://api.deepseek.com",
|
2026-04-24 05:44:29 +00:00
|
|
|
|
aliyun: "https://dashscope.aliyuncs.com/compatible-mode",
|
|
|
|
|
|
qwen: "https://dashscope.aliyuncs.com/compatible-mode",
|
|
|
|
|
|
dashscope: "https://dashscope.aliyuncs.com/compatible-mode",
|
|
|
|
|
|
moonshot: "https://api.moonshot.cn",
|
|
|
|
|
|
kimi: "https://api.moonshot.cn",
|
|
|
|
|
|
groq: "https://api.groq.com/openai",
|
2026-03-09 08:10:48 +00:00
|
|
|
|
};
|
2026-03-02 11:59:47 +00:00
|
|
|
|
|
2026-07-02 07:19:11 +00:00
|
|
|
|
const DEFAULT_LLM_TEST_MESSAGE = "请只返回固定成功结果,用于 LLM 连通性测试。";
|
2026-04-22 01:40:15 +00:00
|
|
|
|
|
2026-03-02 11:59:47 +00:00
|
|
|
|
const AiModels: React.FC = () => {
|
2026-04-08 06:34:59 +00:00
|
|
|
|
const { message } = App.useApp();
|
2026-03-02 11:59:47 +00:00
|
|
|
|
const [form] = Form.useForm();
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const { items: providers } = useDict("biz_ai_provider");
|
|
|
|
|
|
|
|
|
|
|
|
const [activeType, setActiveType] = useState<ModelType>("ASR");
|
2026-03-02 11:59:47 +00:00
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
|
const [data, setData] = useState<AiModelVO[]>([]);
|
|
|
|
|
|
const [total, setTotal] = useState(0);
|
|
|
|
|
|
const [current, setCurrent] = useState(1);
|
|
|
|
|
|
const [size, setSize] = useState(10);
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const [searchName, setSearchName] = useState("");
|
|
|
|
|
|
|
2026-03-02 11:59:47 +00:00
|
|
|
|
const [drawerVisible, setDrawerVisible] = useState(false);
|
|
|
|
|
|
const [editingId, setEditingId] = useState<number | null>(null);
|
|
|
|
|
|
const [submitLoading, setSubmitLoading] = useState(false);
|
|
|
|
|
|
const [fetchLoading, setFetchLoading] = useState(false);
|
2026-03-26 09:42:29 +00:00
|
|
|
|
const [connectivityLoading, setConnectivityLoading] = useState(false);
|
2026-03-02 11:59:47 +00:00
|
|
|
|
const [remoteModels, setRemoteModels] = useState<string[]>([]);
|
2026-06-29 01:00:12 +00:00
|
|
|
|
const [createConfig, setCreateConfig] = useState<MeetingCreateConfig>(DEFAULT_CREATE_CONFIG);
|
2026-07-02 07:19:11 +00:00
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const modelNameAutoFilledRef = useRef(false);
|
2026-03-26 09:42:29 +00:00
|
|
|
|
const localProfileLoadedRef = useRef(false);
|
2026-03-02 11:59:47 +00:00
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const provider = Form.useWatch("provider", form);
|
2026-04-23 07:47:29 +00:00
|
|
|
|
const isDefaultChecked = Form.useWatch("isDefaultChecked", form);
|
2026-06-30 07:17:18 +00:00
|
|
|
|
const isLocalProvider = String(provider || "").toLowerCase() === "local";
|
2026-06-26 03:11:58 +00:00
|
|
|
|
const isTencentProvider = String(provider || "").toLowerCase() === "tencent";
|
2026-03-09 08:10:48 +00:00
|
|
|
|
|
|
|
|
|
|
const isPlatformAdmin = useMemo(() => {
|
2026-03-02 11:59:47 +00:00
|
|
|
|
const profileStr = sessionStorage.getItem("userProfile");
|
2026-03-09 08:10:48 +00:00
|
|
|
|
if (!profileStr) {
|
|
|
|
|
|
return false;
|
2026-03-02 11:59:47 +00:00
|
|
|
|
}
|
2026-07-02 07:19:11 +00:00
|
|
|
|
try {
|
|
|
|
|
|
const profile = JSON.parse(profileStr);
|
|
|
|
|
|
return profile.isPlatformAdmin === true;
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2026-03-02 11:59:47 +00:00
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-03-12 12:39:49 +00:00
|
|
|
|
void fetchData();
|
2026-03-09 08:10:48 +00:00
|
|
|
|
}, [current, size, searchName, activeType]);
|
|
|
|
|
|
|
2026-06-29 01:00:12 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
getMeetingCreateConfig()
|
|
|
|
|
|
.then((res) => {
|
|
|
|
|
|
const config = (res as any)?.data?.data ?? (res as any);
|
|
|
|
|
|
setCreateConfig({
|
|
|
|
|
|
...DEFAULT_CREATE_CONFIG,
|
|
|
|
|
|
...(config || {}),
|
|
|
|
|
|
});
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
setCreateConfig(DEFAULT_CREATE_CONFIG);
|
|
|
|
|
|
});
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (!drawerVisible || !provider) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-03-12 12:39:49 +00:00
|
|
|
|
|
|
|
|
|
|
const providerItem = providers.find((item) => item.itemValue === provider);
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const providerLabel = providerItem?.itemLabel || provider;
|
|
|
|
|
|
const currentDisplayName = form.getFieldValue("modelName");
|
|
|
|
|
|
if (!editingId && (!currentDisplayName || modelNameAutoFilledRef.current)) {
|
|
|
|
|
|
form.setFieldValue("modelName", providerLabel);
|
|
|
|
|
|
modelNameAutoFilledRef.current = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const baseUrl = form.getFieldValue("baseUrl");
|
|
|
|
|
|
const providerKey = String(provider).toLowerCase();
|
|
|
|
|
|
const defaultBaseUrl = PROVIDER_BASE_URL_MAP[providerKey];
|
|
|
|
|
|
if (!baseUrl && defaultBaseUrl) {
|
|
|
|
|
|
form.setFieldValue("baseUrl", defaultBaseUrl);
|
|
|
|
|
|
}
|
2026-07-02 07:19:11 +00:00
|
|
|
|
}, [drawerVisible, editingId, form, provider, providers]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (!drawerVisible || !isLocalProvider || !editingId || localProfileLoadedRef.current) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const values = form.getFieldsValue(["baseUrl", "apiKey"]);
|
|
|
|
|
|
if (!values.baseUrl || !values.apiKey) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
localProfileLoadedRef.current = true;
|
|
|
|
|
|
void handleTestConnectivity();
|
|
|
|
|
|
}, [drawerVisible, editingId, form, isLocalProvider]);
|
2026-03-02 11:59:47 +00:00
|
|
|
|
|
|
|
|
|
|
const fetchData = async () => {
|
|
|
|
|
|
setLoading(true);
|
|
|
|
|
|
try {
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const res = await getAiModelPage({
|
|
|
|
|
|
current,
|
|
|
|
|
|
size,
|
|
|
|
|
|
name: searchName || undefined,
|
|
|
|
|
|
type: activeType,
|
|
|
|
|
|
});
|
|
|
|
|
|
const pageData = (res as any)?.data?.data ?? (res as any);
|
|
|
|
|
|
setData(pageData?.records || []);
|
|
|
|
|
|
setTotal(pageData?.total || 0);
|
2026-03-02 11:59:47 +00:00
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const openDrawer = (record?: AiModelVO) => {
|
2026-03-02 11:59:47 +00:00
|
|
|
|
setRemoteModels([]);
|
2026-03-09 08:10:48 +00:00
|
|
|
|
modelNameAutoFilledRef.current = false;
|
2026-03-26 09:42:29 +00:00
|
|
|
|
localProfileLoadedRef.current = false;
|
2026-03-12 12:39:49 +00:00
|
|
|
|
|
2026-03-02 11:59:47 +00:00
|
|
|
|
if (record) {
|
|
|
|
|
|
setEditingId(record.id);
|
2026-03-09 08:10:48 +00:00
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
|
...record,
|
|
|
|
|
|
modelType: record.modelType,
|
2026-07-02 07:19:11 +00:00
|
|
|
|
speakerModel: record.mediaConfig?.speakerModel,
|
|
|
|
|
|
svThreshold: record.mediaConfig?.svThreshold,
|
|
|
|
|
|
tencentAppId: record.mediaConfig?.tencentAppId,
|
|
|
|
|
|
tencentSecretId: record.mediaConfig?.tencentSecretId,
|
|
|
|
|
|
tencentSecretKey: record.mediaConfig?.tencentSecretKey,
|
|
|
|
|
|
tencentOfflineModelCode: record.mediaConfig?.tencentOfflineModelCode || record.modelCode,
|
|
|
|
|
|
tencentRealtimeModelCode: record.mediaConfig?.tencentRealtimeModelCode || record.modelCode,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
isDefaultChecked: record.isDefault === 1,
|
|
|
|
|
|
statusChecked: record.status === 1,
|
|
|
|
|
|
});
|
|
|
|
|
|
if (record.modelCode) {
|
|
|
|
|
|
setRemoteModels([record.modelCode]);
|
|
|
|
|
|
}
|
2026-03-02 11:59:47 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
setEditingId(null);
|
|
|
|
|
|
form.resetFields();
|
2026-03-09 08:10:48 +00:00
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
|
modelType: activeType,
|
|
|
|
|
|
isDefaultChecked: false,
|
|
|
|
|
|
statusChecked: true,
|
2026-04-23 07:47:29 +00:00
|
|
|
|
sortOrder: 0,
|
2026-05-13 06:31:48 +00:00
|
|
|
|
temperature: 0.2,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
topP: 0.9,
|
|
|
|
|
|
apiPath: "/v1/chat/completions",
|
2026-03-26 09:42:29 +00:00
|
|
|
|
svThreshold: 0.45,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
});
|
2026-03-02 11:59:47 +00:00
|
|
|
|
}
|
2026-03-12 12:39:49 +00:00
|
|
|
|
|
2026-03-02 11:59:47 +00:00
|
|
|
|
setDrawerVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleFetchRemote = async () => {
|
2026-03-26 09:42:29 +00:00
|
|
|
|
if (isLocalProvider) {
|
|
|
|
|
|
await handleTestConnectivity();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 12:39:49 +00:00
|
|
|
|
const values = form.getFieldsValue(["provider", "baseUrl", "apiKey"]);
|
|
|
|
|
|
if (!values.provider || !values.baseUrl) {
|
2026-03-09 08:10:48 +00:00
|
|
|
|
message.warning("请先填写提供商和 Base URL");
|
2026-03-02 11:59:47 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-03-12 12:39:49 +00:00
|
|
|
|
|
2026-03-02 11:59:47 +00:00
|
|
|
|
setFetchLoading(true);
|
|
|
|
|
|
try {
|
2026-03-12 12:39:49 +00:00
|
|
|
|
const res = await getRemoteModelList(values);
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const rawModels = (res as any)?.data?.data ?? (Array.isArray(res) ? res : []);
|
|
|
|
|
|
const models = Array.isArray(rawModels) ? rawModels : [];
|
|
|
|
|
|
setRemoteModels(models);
|
|
|
|
|
|
message.success(`获取到 ${models.length} 个模型`);
|
2026-03-02 11:59:47 +00:00
|
|
|
|
} finally {
|
|
|
|
|
|
setFetchLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-26 09:42:29 +00:00
|
|
|
|
const resolveLocalWsUrl = (baseUrl: string, wsEndpoint?: string) => {
|
|
|
|
|
|
if (!wsEndpoint) {
|
|
|
|
|
|
return undefined;
|
|
|
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
|
|
|
const base = new URL(baseUrl);
|
|
|
|
|
|
const endpoint = wsEndpoint.startsWith("/") ? wsEndpoint : `/${wsEndpoint}`;
|
|
|
|
|
|
const protocol = base.protocol === "https:" ? "wss:" : "ws:";
|
|
|
|
|
|
return `${protocol}//${base.host}${endpoint}`;
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
return undefined;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const applyLocalProfile = (profile: AiLocalProfileVO, baseUrl: string) => {
|
|
|
|
|
|
const nextRemoteModels = Array.isArray(profile.asrModels) ? profile.asrModels : [];
|
|
|
|
|
|
setRemoteModels(nextRemoteModels);
|
|
|
|
|
|
|
|
|
|
|
|
const nextValues: Record<string, unknown> = {};
|
|
|
|
|
|
if (profile.activeAsrModel) {
|
|
|
|
|
|
nextValues.modelCode = profile.activeAsrModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (profile.activeSpeakerModel) {
|
|
|
|
|
|
nextValues.speakerModel = profile.activeSpeakerModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (profile.svThreshold !== undefined) {
|
|
|
|
|
|
nextValues.svThreshold = profile.svThreshold;
|
|
|
|
|
|
}
|
|
|
|
|
|
const wsUrl = resolveLocalWsUrl(baseUrl, profile.wsEndpoint);
|
|
|
|
|
|
if (wsUrl) {
|
|
|
|
|
|
nextValues.wsUrl = wsUrl;
|
|
|
|
|
|
}
|
|
|
|
|
|
form.setFieldsValue(nextValues);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-02 11:59:47 +00:00
|
|
|
|
const handleSubmit = async () => {
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const values = await form.validateFields();
|
2026-04-23 07:47:29 +00:00
|
|
|
|
if (values.isDefaultChecked && !values.statusChecked) {
|
|
|
|
|
|
message.warning("默认模型必须保持启用状态");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-07-02 07:19:11 +00:00
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const payload: AiModelDTO = {
|
|
|
|
|
|
id: editingId ?? undefined,
|
|
|
|
|
|
modelType: values.modelType,
|
|
|
|
|
|
modelName: values.modelName,
|
|
|
|
|
|
provider: values.provider,
|
|
|
|
|
|
baseUrl: values.baseUrl,
|
|
|
|
|
|
apiPath: values.apiPath,
|
|
|
|
|
|
apiKey: values.apiKey,
|
2026-06-29 01:00:12 +00:00
|
|
|
|
modelCode: activeType === "ASR" && isTencentProvider ? values.tencentOfflineModelCode : values.modelCode,
|
|
|
|
|
|
wsUrl: activeType === "ASR" ? values.wsUrl : undefined,
|
2026-03-26 09:42:29 +00:00
|
|
|
|
mediaConfig:
|
|
|
|
|
|
activeType === "ASR" && isLocalProvider
|
|
|
|
|
|
? {
|
|
|
|
|
|
speakerModel: values.speakerModel,
|
|
|
|
|
|
svThreshold: values.svThreshold,
|
|
|
|
|
|
}
|
2026-06-26 03:11:58 +00:00
|
|
|
|
: activeType === "ASR" && isTencentProvider
|
|
|
|
|
|
? {
|
2026-07-02 07:19:11 +00:00
|
|
|
|
tencentAppId: values.tencentAppId,
|
|
|
|
|
|
tencentSecretId: values.tencentSecretId,
|
|
|
|
|
|
tencentSecretKey: values.tencentSecretKey,
|
|
|
|
|
|
tencentOfflineModelCode: values.tencentOfflineModelCode,
|
|
|
|
|
|
tencentRealtimeModelCode: values.tencentRealtimeModelCode,
|
|
|
|
|
|
}
|
|
|
|
|
|
: undefined,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
temperature: values.temperature,
|
|
|
|
|
|
topP: values.topP,
|
|
|
|
|
|
isDefault: values.isDefaultChecked ? 1 : 0,
|
|
|
|
|
|
status: values.statusChecked ? 1 : 0,
|
2026-04-23 07:47:29 +00:00
|
|
|
|
sortOrder: values.sortOrder ?? 0,
|
2026-03-09 08:10:48 +00:00
|
|
|
|
remark: values.remark,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
setSubmitLoading(true);
|
2026-03-02 11:59:47 +00:00
|
|
|
|
try {
|
|
|
|
|
|
if (editingId) {
|
2026-03-09 08:10:48 +00:00
|
|
|
|
await updateAiModel(payload);
|
|
|
|
|
|
message.success("更新成功");
|
2026-03-02 11:59:47 +00:00
|
|
|
|
} else {
|
2026-03-09 08:10:48 +00:00
|
|
|
|
await saveAiModel(payload);
|
|
|
|
|
|
message.success("新增成功");
|
2026-03-02 11:59:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
setDrawerVisible(false);
|
2026-03-12 12:39:49 +00:00
|
|
|
|
void fetchData();
|
2026-03-02 11:59:47 +00:00
|
|
|
|
} finally {
|
|
|
|
|
|
setSubmitLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-26 09:42:29 +00:00
|
|
|
|
const handleTestConnectivity = async () => {
|
2026-04-22 01:40:15 +00:00
|
|
|
|
if (activeType === "LLM") {
|
|
|
|
|
|
const values = await form.validateFields(["provider", "baseUrl", "apiPath", "modelCode"]);
|
|
|
|
|
|
const extraValues = form.getFieldsValue(["apiKey", "temperature", "topP"]);
|
|
|
|
|
|
setConnectivityLoading(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
await testLlmModelConnectivity({
|
|
|
|
|
|
provider: values.provider,
|
|
|
|
|
|
baseUrl: values.baseUrl,
|
|
|
|
|
|
apiPath: values.apiPath,
|
|
|
|
|
|
apiKey: extraValues.apiKey,
|
|
|
|
|
|
modelCode: values.modelCode,
|
|
|
|
|
|
temperature: extraValues.temperature,
|
|
|
|
|
|
topP: extraValues.topP,
|
|
|
|
|
|
testMessage: DEFAULT_LLM_TEST_MESSAGE,
|
|
|
|
|
|
});
|
|
|
|
|
|
message.success("LLM 连通性测试成功");
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setConnectivityLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-22 01:53:34 +00:00
|
|
|
|
const values = await form.validateFields(["provider", "baseUrl"]);
|
2026-06-30 07:17:18 +00:00
|
|
|
|
if (String(values.provider || "").toLowerCase() !== "local") {
|
2026-07-02 07:19:11 +00:00
|
|
|
|
message.warning("只有本地 ASR 支持该连通性测试");
|
2026-03-26 09:42:29 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-02 07:19:11 +00:00
|
|
|
|
const { apiKey } = form.getFieldsValue(["apiKey"]);
|
2026-03-26 09:42:29 +00:00
|
|
|
|
setConnectivityLoading(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await testLocalModelConnectivity({
|
|
|
|
|
|
baseUrl: values.baseUrl,
|
2026-04-22 01:53:34 +00:00
|
|
|
|
apiKey,
|
2026-03-26 09:42:29 +00:00
|
|
|
|
});
|
|
|
|
|
|
const profile = (res as any)?.data?.data ?? (res as any)?.data ?? (res as any);
|
|
|
|
|
|
applyLocalProfile(profile as AiLocalProfileVO, values.baseUrl);
|
|
|
|
|
|
message.success("本地模型连通性测试成功");
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setConnectivityLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
const handleDelete = async (record: AiModelVO) => {
|
|
|
|
|
|
await deleteAiModelByType(record.id, record.modelType);
|
|
|
|
|
|
message.success("删除成功");
|
2026-03-12 12:39:49 +00:00
|
|
|
|
void fetchData();
|
2026-03-09 08:10:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-07-02 07:19:11 +00:00
|
|
|
|
const handleTenantToggle = async (record: AiModelVO, checked: boolean) => {
|
|
|
|
|
|
if (checked) {
|
|
|
|
|
|
await tenantEnableModel(record.id, activeType);
|
|
|
|
|
|
message.success(activeType === "ASR" ? "已切换当前 ASR" : "已启用当前 LLM");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await tenantDisableModel(record.id, activeType);
|
|
|
|
|
|
message.success(activeType === "ASR" ? "已关闭当前 ASR" : "已关闭当前 LLM");
|
|
|
|
|
|
}
|
|
|
|
|
|
await fetchData();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handlePlatformStatusToggle = async (record: AiModelVO, checked: boolean) => {
|
|
|
|
|
|
await updatePlatformModelStatus(record.id, activeType, checked ? 1 : 0);
|
|
|
|
|
|
message.success(checked ? `平台级 ${activeType} 已启用` : `平台级 ${activeType} 已禁用`);
|
|
|
|
|
|
await fetchData();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSyncCurrentAsr = async () => {
|
|
|
|
|
|
await syncCurrentAsrSpeakers();
|
|
|
|
|
|
message.success("已提交后台同步任务");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSetTenantDefault = async (record: AiModelVO) => {
|
|
|
|
|
|
await setTenantDefaultModel(record.id, "LLM");
|
|
|
|
|
|
message.success("已设置为默认 LLM");
|
|
|
|
|
|
await fetchData();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const resolvedTableColumns = [
|
2026-03-02 11:59:47 +00:00
|
|
|
|
{
|
2026-03-09 08:10:48 +00:00
|
|
|
|
title: "模型名称",
|
|
|
|
|
|
dataIndex: "modelName",
|
|
|
|
|
|
key: "modelName",
|
2026-03-02 11:59:47 +00:00
|
|
|
|
render: (text: string, record: AiModelVO) => (
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
{text}
|
2026-07-02 07:19:11 +00:00
|
|
|
|
{record.isDefault === 1 && <Tag color="gold">系统默认</Tag>}
|
|
|
|
|
|
{record.tenantDefault === 1 && <Tag color="blue">租户默认</Tag>}
|
2026-03-09 08:10:48 +00:00
|
|
|
|
{record.tenantId === 0 && (
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Tooltip title="平台透传模型">
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<SafetyCertificateOutlined style={{ color: "#52c41a" }} />
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
)}
|
2026-07-02 07:19:11 +00:00
|
|
|
|
{record.scope && (
|
|
|
|
|
|
<Tag bordered={false} color={record.scope === "PLATFORM" ? "geekblue" : "default"}>
|
|
|
|
|
|
{record.scope === "PLATFORM" ? "平台级" : "租户级"}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
)}
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Space>
|
2026-03-09 08:10:48 +00:00
|
|
|
|
),
|
2026-03-02 11:59:47 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-03-09 08:10:48 +00:00
|
|
|
|
title: "提供商",
|
|
|
|
|
|
dataIndex: "provider",
|
|
|
|
|
|
key: "provider",
|
2026-03-12 12:39:49 +00:00
|
|
|
|
render: (value: string) => {
|
|
|
|
|
|
const item = providers.find((providerItem) => providerItem.itemValue === value);
|
|
|
|
|
|
return item ? <Tag>{item.itemLabel}</Tag> : value;
|
2026-03-09 08:10:48 +00:00
|
|
|
|
},
|
2026-03-02 11:59:47 +00:00
|
|
|
|
},
|
2026-07-02 07:19:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
title: "模型编码",
|
|
|
|
|
|
dataIndex: "modelCode",
|
|
|
|
|
|
key: "modelCode",
|
|
|
|
|
|
},
|
2026-04-23 07:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
|
title: "排序",
|
|
|
|
|
|
dataIndex: "sortOrder",
|
|
|
|
|
|
key: "sortOrder",
|
|
|
|
|
|
render: (value: number | undefined) => value ?? 0,
|
|
|
|
|
|
},
|
2026-03-02 11:59:47 +00:00
|
|
|
|
{
|
2026-03-09 08:10:48 +00:00
|
|
|
|
title: "状态",
|
|
|
|
|
|
dataIndex: "status",
|
|
|
|
|
|
key: "status",
|
2026-07-02 07:19:11 +00:00
|
|
|
|
render: (status: number, record: AiModelVO) => {
|
|
|
|
|
|
if (isPlatformAdmin && record.scope === "PLATFORM") {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Switch
|
|
|
|
|
|
checked={status === 1}
|
|
|
|
|
|
checkedChildren="启用"
|
|
|
|
|
|
unCheckedChildren="禁用"
|
|
|
|
|
|
onChange={(checked) => void handlePlatformStatusToggle(record, checked)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Switch
|
|
|
|
|
|
checked={record.tenantEnabled === 1}
|
|
|
|
|
|
checkedChildren={activeType === "ASR" ? "当前生效" : "已启用"}
|
|
|
|
|
|
unCheckedChildren={activeType === "ASR" ? "未启用" : "已关闭"}
|
|
|
|
|
|
disabled={status !== 1}
|
|
|
|
|
|
onChange={(checked) => void handleTenantToggle(record, checked)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
2026-03-02 11:59:47 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-03-09 08:10:48 +00:00
|
|
|
|
title: "操作",
|
|
|
|
|
|
key: "action",
|
|
|
|
|
|
render: (_: unknown, record: AiModelVO) => {
|
2026-07-02 07:19:11 +00:00
|
|
|
|
const canEdit = record.canEditConfig ?? (record.tenantId !== 0 || isPlatformAdmin);
|
|
|
|
|
|
const canSetDefault = activeType === "LLM" && record.tenantEnabled === 1;
|
2026-03-02 11:59:47 +00:00
|
|
|
|
return (
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Space>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
{canSetDefault && (
|
|
|
|
|
|
<Button type="link" onClick={() => void handleSetTenantDefault(record)}>
|
|
|
|
|
|
{record.tenantDefault === 1 ? "默认 LLM" : "设为默认"}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2026-03-02 11:59:47 +00:00
|
|
|
|
{canEdit && (
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Button type="link" icon={<EditOutlined />} onClick={() => openDrawer(record)}>
|
|
|
|
|
|
编辑
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{canEdit && (
|
|
|
|
|
|
<Popconfirm title="确定删除吗?" onConfirm={() => handleDelete(record)}>
|
|
|
|
|
|
<Button type="link" danger icon={<DeleteOutlined />}>
|
|
|
|
|
|
删除
|
|
|
|
|
|
</Button>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
);
|
2026-03-09 08:10:48 +00:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2026-03-02 11:59:47 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
2026-07-02 07:19:11 +00:00
|
|
|
|
const leftActions = (
|
|
|
|
|
|
<Space wrap>
|
|
|
|
|
|
<Button type="primary" icon={<PlusOutlined/>} onClick={() => openDrawer()}>
|
|
|
|
|
|
新增模型
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
{activeType === "ASR" && (
|
|
|
|
|
|
<Button icon={<SyncOutlined/>} onClick={() => void handleSyncCurrentAsr()}>
|
|
|
|
|
|
同步当前 ASR 声纹
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2026-03-02 11:59:47 +00:00
|
|
|
|
return (
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<PageContainer title={null} className="ai-models-page">
|
2026-06-29 02:17:30 +00:00
|
|
|
|
<SectionCard
|
|
|
|
|
|
title="AI 模型配置"
|
|
|
|
|
|
description="管理 ASR 语音识别和 LLM 大语言模型。"
|
|
|
|
|
|
tabs={
|
|
|
|
|
|
<Tabs
|
|
|
|
|
|
activeKey={activeType}
|
|
|
|
|
|
onChange={(key) => {
|
|
|
|
|
|
setActiveType(key as ModelType);
|
|
|
|
|
|
setCurrent(1);
|
|
|
|
|
|
}}
|
|
|
|
|
|
items={[
|
|
|
|
|
|
{ key: "ASR", label: "ASR 模型" },
|
|
|
|
|
|
{ key: "LLM", label: "LLM 模型" },
|
|
|
|
|
|
]}
|
|
|
|
|
|
size="middle"
|
|
|
|
|
|
type="card"
|
|
|
|
|
|
/>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<DataListPanel
|
2026-06-30 05:37:33 +00:00
|
|
|
|
className="ai-models-data-panel"
|
2026-07-02 07:19:11 +00:00
|
|
|
|
leftActions={leftActions}
|
2026-06-29 02:17:30 +00:00
|
|
|
|
rightActions={
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Input.Search
|
|
|
|
|
|
allowClear
|
2026-06-29 02:17:30 +00:00
|
|
|
|
placeholder="搜索模型名称"
|
|
|
|
|
|
prefix={<SearchOutlined />}
|
2026-06-30 05:37:33 +00:00
|
|
|
|
className="ai-models-search"
|
2026-07-02 07:19:11 +00:00
|
|
|
|
onSearch={(value) => {
|
|
|
|
|
|
setCurrent(1);
|
|
|
|
|
|
setSearchName(value.trim());
|
|
|
|
|
|
}}
|
2026-06-29 02:17:30 +00:00
|
|
|
|
/>
|
|
|
|
|
|
}
|
|
|
|
|
|
footer={
|
|
|
|
|
|
<AppPagination
|
|
|
|
|
|
current={current}
|
|
|
|
|
|
pageSize={size}
|
|
|
|
|
|
total={total}
|
|
|
|
|
|
onChange={(page, pageSize) => {
|
|
|
|
|
|
setCurrent(page);
|
|
|
|
|
|
setSize(pageSize);
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Table
|
|
|
|
|
|
rowKey="id"
|
2026-07-02 07:19:11 +00:00
|
|
|
|
columns={resolvedTableColumns}
|
2026-06-29 02:17:30 +00:00
|
|
|
|
dataSource={data}
|
|
|
|
|
|
loading={loading}
|
|
|
|
|
|
scroll={{ x: "max-content", y: "100%" }}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</DataListPanel>
|
|
|
|
|
|
</SectionCard>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
|
|
|
|
|
|
<Drawer
|
|
|
|
|
|
width={600}
|
|
|
|
|
|
open={drawerVisible}
|
2026-03-09 08:10:48 +00:00
|
|
|
|
onClose={() => setDrawerVisible(false)}
|
|
|
|
|
|
title={<Title level={4} style={{ margin: 0 }}>{editingId ? "编辑模型" : "新增模型"}</Title>}
|
2026-04-08 08:16:21 +00:00
|
|
|
|
forceRender
|
2026-03-02 11:59:47 +00:00
|
|
|
|
extra={
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<Button onClick={() => setDrawerVisible(false)}>取消</Button>
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Button type="primary" icon={<SaveOutlined />} loading={submitLoading} onClick={handleSubmit}>
|
|
|
|
|
|
保存
|
|
|
|
|
|
</Button>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Space>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Form form={form} layout="vertical">
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Form.Item name="modelType" hidden>
|
|
|
|
|
|
<Input />
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item label="模型类型">
|
|
|
|
|
|
<Tag color={activeType === "ASR" ? "blue" : "purple"}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
{activeType === "ASR" ? "语音识别 (ASR)" : "大语言模型 (LLM)"}
|
2026-03-09 08:10:48 +00:00
|
|
|
|
</Tag>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={12}>
|
2026-03-12 12:39:49 +00:00
|
|
|
|
<Form.Item
|
|
|
|
|
|
name="modelName"
|
|
|
|
|
|
label="显示名称"
|
|
|
|
|
|
rules={[{ required: true, message: "请输入显示名称" }]}
|
|
|
|
|
|
>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Input onChange={() => {
|
|
|
|
|
|
modelNameAutoFilledRef.current = false;
|
|
|
|
|
|
}}/>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
2026-03-12 12:39:49 +00:00
|
|
|
|
<Form.Item
|
|
|
|
|
|
name="provider"
|
|
|
|
|
|
label="提供商"
|
|
|
|
|
|
rules={[{ required: true, message: "请选择提供商" }]}
|
|
|
|
|
|
>
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Select allowClear placeholder="请选择">
|
|
|
|
|
|
{providers.map((item) => (
|
|
|
|
|
|
<Option key={item.itemValue} value={item.itemValue}>
|
|
|
|
|
|
{item.itemLabel}
|
|
|
|
|
|
</Option>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
))}
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
2026-04-23 07:47:29 +00:00
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.Item name="sortOrder" label="排序值">
|
|
|
|
|
|
<InputNumber min={0} style={{ width: "100%" }} />
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
2026-06-26 03:11:58 +00:00
|
|
|
|
{!isTencentProvider && (
|
|
|
|
|
|
<>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="baseUrl" label="Base URL" rules={[{required: true, message: "请输入 Base URL"}]}>
|
|
|
|
|
|
<Input placeholder="https://api.example.com"/>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
</Form.Item>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="apiKey" label="API Key">
|
|
|
|
|
|
<Input.Password/>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
2026-03-26 09:42:29 +00:00
|
|
|
|
|
2026-04-22 01:40:15 +00:00
|
|
|
|
{(activeType === "LLM" || isLocalProvider) && (
|
2026-03-26 09:42:29 +00:00
|
|
|
|
<Form.Item label="连通性测试">
|
|
|
|
|
|
<Button icon={<WifiOutlined />} loading={connectivityLoading} onClick={handleTestConnectivity}>
|
|
|
|
|
|
测试连接
|
|
|
|
|
|
</Button>
|
2026-03-04 07:19:40 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
)}
|
2026-03-02 11:59:47 +00:00
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Divider orientation="left" style={{ fontSize: 14, color: "#999" }}>
|
|
|
|
|
|
模型参数
|
|
|
|
|
|
</Divider>
|
|
|
|
|
|
|
2026-03-12 12:39:49 +00:00
|
|
|
|
<Form.Item
|
2026-07-02 07:19:11 +00:00
|
|
|
|
label="模型编码"
|
2026-06-05 10:31:44 +00:00
|
|
|
|
required={activeType === "LLM"}
|
2026-06-29 01:00:12 +00:00
|
|
|
|
hidden={activeType === "ASR" && isTencentProvider}
|
2026-07-02 07:19:11 +00:00
|
|
|
|
tooltip="可从远程列表选择,也可手动输入;该值会作为模型编码传给后端"
|
2026-03-12 12:39:49 +00:00
|
|
|
|
>
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Space.Compact style={{ width: "100%" }}>
|
2026-03-12 12:39:49 +00:00
|
|
|
|
<Form.Item
|
|
|
|
|
|
name="modelCode"
|
|
|
|
|
|
noStyle
|
2026-07-02 07:19:11 +00:00
|
|
|
|
rules={activeType === "LLM" ? [{required: true, message: "请输入或选择模型编码"}] : []}
|
2026-03-12 12:39:49 +00:00
|
|
|
|
>
|
|
|
|
|
|
<AutoComplete
|
2026-03-09 08:10:48 +00:00
|
|
|
|
style={{ width: "calc(100% - 100px)" }}
|
2026-03-26 09:42:29 +00:00
|
|
|
|
onFocus={() => {
|
|
|
|
|
|
if (isLocalProvider && remoteModels.length === 0) {
|
|
|
|
|
|
void handleFetchRemote();
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
2026-03-12 12:39:49 +00:00
|
|
|
|
options={remoteModels.map((model) => ({ value: model }))}
|
|
|
|
|
|
filterOption={(inputValue, option) =>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
isLocalProvider || String(option?.value || "").toLowerCase().includes(inputValue.toLowerCase())
|
2026-03-12 12:39:49 +00:00
|
|
|
|
}
|
2026-03-02 11:59:47 +00:00
|
|
|
|
>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Input allowClear placeholder="可选择或手动输入模型编码"/>
|
2026-03-12 12:39:49 +00:00
|
|
|
|
</AutoComplete>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
{!isTencentProvider && (
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Button icon={<SyncOutlined spin={fetchLoading}/>} onClick={handleFetchRemote} style={{width: 100}}>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
刷新
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Space.Compact>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="wsUrl" label="WebSocket 地址"
|
|
|
|
|
|
hidden={!(activeType === "ASR" && createConfig.realtimeEnabled)}>
|
2026-06-05 10:31:44 +00:00
|
|
|
|
<Input placeholder="wss://api.example.com/v1/ws" />
|
|
|
|
|
|
</Form.Item>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
|
2026-03-26 09:42:29 +00:00
|
|
|
|
{activeType === "ASR" && isLocalProvider && (
|
2026-06-05 10:31:44 +00:00
|
|
|
|
<Row gutter={16} hidden>
|
2026-03-26 09:42:29 +00:00
|
|
|
|
<Col span={12}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="svThreshold" label="声纹阈值">
|
2026-03-26 09:42:29 +00:00
|
|
|
|
<InputNumber min={0} max={1} step={0.01} style={{ width: "100%" }} />
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
2026-06-26 03:11:58 +00:00
|
|
|
|
{activeType === "ASR" && isTencentProvider && (
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={12}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="tencentAppId" label="App ID" rules={[{required: true, message: "请输入 App ID"}]}>
|
|
|
|
|
|
<Input/>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="tencentSecretId" label="Secret ID"
|
|
|
|
|
|
rules={[{required: true, message: "请输入 Secret ID"}]}>
|
|
|
|
|
|
<Input/>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={24}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="tencentSecretKey" label="Secret Key"
|
|
|
|
|
|
rules={[{required: true, message: "请输入 Secret Key"}]}>
|
|
|
|
|
|
<Input.Password/>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
2026-06-29 01:00:12 +00:00
|
|
|
|
<Col span={12}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="tencentOfflineModelCode" label="离线识别模型"
|
|
|
|
|
|
rules={[{required: true, message: "请输入离线识别模型"}]}>
|
|
|
|
|
|
<Input placeholder="例如:16k_zh"/>
|
2026-06-29 01:00:12 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="tencentRealtimeModelCode" label="实时识别模型"
|
|
|
|
|
|
rules={[{required: true, message: "请输入实时识别模型"}]}>
|
|
|
|
|
|
<Input placeholder="例如:16k_zh_realtime"/>
|
2026-06-29 01:00:12 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
2026-06-26 03:11:58 +00:00
|
|
|
|
</Row>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
{activeType === "LLM" && (
|
2026-03-02 11:59:47 +00:00
|
|
|
|
<>
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Form.Item name="apiPath" label="API 路径" initialValue="/v1/chat/completions">
|
|
|
|
|
|
<Input />
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={12}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="temperature" label="Temperature">
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<InputNumber min={0} max={2} step={0.1} style={{ width: "100%" }} />
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
2026-07-02 07:19:11 +00:00
|
|
|
|
<Form.Item name="topP" label="Top P">
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<InputNumber min={0} max={1} step={0.1} style={{ width: "100%" }} />
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={8}>
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Form.Item name="isDefaultChecked" label="设为默认" valuePropName="checked">
|
2026-04-23 07:47:29 +00:00
|
|
|
|
<Switch
|
|
|
|
|
|
checkedChildren="是"
|
|
|
|
|
|
unCheckedChildren="否"
|
|
|
|
|
|
onChange={(checked) => {
|
|
|
|
|
|
if (checked) {
|
|
|
|
|
|
form.setFieldValue("statusChecked", true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={8}>
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Form.Item name="statusChecked" label="状态" valuePropName="checked">
|
2026-04-23 07:47:29 +00:00
|
|
|
|
<Switch checkedChildren="启用" unCheckedChildren="禁用" disabled={Boolean(isDefaultChecked)} />
|
2026-03-02 11:59:47 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
2026-03-09 08:10:48 +00:00
|
|
|
|
<Form.Item name="remark" label="备注">
|
2026-03-02 11:59:47 +00:00
|
|
|
|
<Input.TextArea rows={2} />
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
</Drawer>
|
2026-05-09 02:17:46 +00:00
|
|
|
|
</PageContainer>
|
2026-03-02 11:59:47 +00:00
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default AiModels;
|