+ + +
diff --git a/app/static/ai_config.js b/app/static/ai_config.js index 75f5786..b958e2e 100644 --- a/app/static/ai_config.js +++ b/app/static/ai_config.js @@ -134,6 +134,16 @@ function populateForm(config) { document.getElementById('temperature').value = activeModel.temperature || 0.7; document.getElementById('temp-value').textContent = activeModel.temperature || 0.7; document.getElementById('max-tokens').value = activeModel.max_tokens || 2000; + + // 选中当前启用的提供商卡片 + const providerCard = document.querySelector(`.provider-card[data-provider="${activeModel.provider}"]`); + if (providerCard) { + document.querySelectorAll('.provider-card').forEach(c => c.classList.remove('active')); + providerCard.classList.add('active'); + } + + // 更新模型下拉框 + updateProviderModels(); } if (config.analysis_settings) { @@ -147,11 +157,36 @@ function populateForm(config) { function renderModelsList(models) { const list = document.getElementById('models-list'); + const activeCard = document.getElementById('active-ai-card'); + if (!models || models.length === 0) { list.innerHTML = '
暂无已保存的模型
'; + activeCard.style.display = 'none'; return; } + const activeModel = models.find(m => m.enabled); + if (activeModel) { + activeCard.style.display = 'block'; + document.getElementById('active-ai-name').textContent = getProviderName(activeModel.provider || activeModel.api_base); + document.getElementById('active-ai-model').textContent = activeModel.model_name || activeModel.model_id || '--'; + + const iconMap = { + 'openai': 'fab fa-openai', + 'anthropic': 'fas fa-robot', + 'google': 'fab fa-google', + 'aliyun': 'fas fa-cloud', + 'aliyun_coding': 'fas fa-code', + 'bailian': 'fas fa-flask', + 'baidu': 'fas fa-comments', + 'zhipu': 'fas fa-lightbulb' + }; + const icon = document.getElementById('active-ai-icon').querySelector('i'); + icon.className = iconMap[activeModel.provider] || 'fas fa-robot'; + } else { + activeCard.style.display = 'none'; + } + list.innerHTML = models.map((model, index) => `
@@ -162,7 +197,7 @@ function renderModelsList(models) {
- ${!model.enabled ? `` : '默认'} + ${!model.enabled ? `` : '当前启用'}
@@ -273,6 +308,10 @@ async function saveConfig() { models.push(newModel); } + models.forEach(m => { + m.enabled = (m.provider === selectedProvider && m.model_id === modelId); + }); + const config = { models: models, active_model: selectedProvider,