模型路径
-
@@ -254,18 +291,58 @@
});
});
+ // 切换模型来源
+ function toggleModelSource(source) {
+ const localPanel = document.getElementById('localModelPanel');
+ const onlinePanel = document.getElementById('onlineModelPanel');
+ if (source === 'local') {
+ localPanel.classList.remove('hidden');
+ onlinePanel.classList.add('hidden');
+ } else {
+ localPanel.classList.add('hidden');
+ onlinePanel.classList.remove('hidden');
+ }
+ }
+
// 提交表单
async function submitForm() {
const form = document.getElementById('modelForm');
const formData = new FormData(form);
+ const modelSource = formData.get('model_source');
+
const data = {
name: formData.get('name'),
type: formData.get('type'),
version: formData.get('version'),
- path: formData.get('path'),
+ model_source: modelSource,
description: formData.get('description')
};
+ // 根据模型来源设置不同的字段
+ if (modelSource === 'local') {
+ data.path = formData.get('local_path');
+ if (!data.path) {
+ showMessage('提示', '请输入模型加载路径', 'warning');
+ return;
+ }
+ } else {
+ data.api_url = formData.get('api_url');
+ data.api_key = formData.get('api_key');
+ data.model_name = formData.get('online_model_name');
+ if (!data.api_url) {
+ showMessage('提示', '请输入API地址', 'warning');
+ return;
+ }
+ if (!data.api_key) {
+ showMessage('提示', '请输入API Key', 'warning');
+ return;
+ }
+ if (!data.model_name) {
+ showMessage('提示', '请输入模型名称', 'warning');
+ return;
+ }
+ }
+
// 验证
if (!data.name) {
showMessage('提示', '请输入模型名称', 'warning');
@@ -279,10 +356,6 @@
showMessage('提示', '请输入模型版本', 'warning');
return;
}
- if (!data.path) {
- showMessage('提示', '请输入模型路径', 'warning');
- return;
- }
try {
const response = await fetch(`${API_BASE}/model-manage`, {