AI提到后端
This commit is contained in:
+59
-1
@@ -112,6 +112,7 @@
|
||||
<div class="menu-item active" data-page="data">投递数据</div>
|
||||
<div class="menu-item" data-page="blacklist">公司黑名单</div>
|
||||
<div class="menu-item" data-page="remote">远程控制</div>
|
||||
<div class="menu-item" data-page="aiConfig">模型配置</div>
|
||||
</aside>
|
||||
|
||||
<!-- 右侧内容 -->
|
||||
@@ -244,6 +245,25 @@
|
||||
</table>
|
||||
<div class="empty hidden" id="taskEmpty">暂无远程任务</div>
|
||||
</div>
|
||||
|
||||
<!-- 模型配置(AI 代理:客户端评分统一经服务端转发) -->
|
||||
<div id="pageAiConfig" class="hidden">
|
||||
<div class="bl-tip">客户端的 AI 评分/简历整理统一由服务端代理调用大模型(OpenAI 兼容接口),客户端不再保存任何模型密钥。</div>
|
||||
<div class="bl-add" style="flex-wrap:wrap;align-items:flex-end;">
|
||||
<div style="flex:2;min-width:260px;"><label style="font-size:12px;color:#666;">Base URL(OpenAI 兼容)</label>
|
||||
<input type="text" id="aiBaseUrl" placeholder="如:https://api.siliconflow.cn/v1" style="width:100%;padding:9px 10px;border:1px solid #d9d9d9;border-radius:6px;"></div>
|
||||
<div style="flex:2;min-width:260px;"><label style="font-size:12px;color:#666;">API Key</label>
|
||||
<input type="text" id="aiApiKey" placeholder="sk-..." style="width:100%;padding:9px 10px;border:1px solid #d9d9d9;border-radius:6px;"></div>
|
||||
<div style="min-width:220px;"><label style="font-size:12px;color:#666;">模型名</label>
|
||||
<input type="text" id="aiModel" placeholder="如:deepseek-ai/DeepSeek-V3" style="width:100%;padding:9px 10px;border:1px solid #d9d9d9;border-radius:6px;"></div>
|
||||
<div style="width:150px;"><label style="font-size:12px;color:#666;">调用超时(秒,10-600)</label>
|
||||
<input type="number" id="aiTimeout" value="300" min="10" max="600" style="width:100%;padding:9px 10px;border:1px solid #d9d9d9;border-radius:6px;"></div>
|
||||
<label style="display:flex;align-items:center;gap:4px;font-size:13px;padding-bottom:10px;"><input type="checkbox" id="aiEnabled" checked> 启用 AI 代理</label>
|
||||
<button id="btnAiSave" style="background:#1890ff;">保存配置</button>
|
||||
<button id="btnAiTest">连通测试</button>
|
||||
</div>
|
||||
<div class="bl-tip" id="aiConfigTip">更新时间:-</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -445,6 +465,40 @@ async function sendTask(taskType, params) {
|
||||
} catch (e) { alert('下发失败:' + (e.message || '')); }
|
||||
}
|
||||
|
||||
/* ---------- 模型配置(AI 代理) ---------- */
|
||||
async function loadAiConfig() {
|
||||
try {
|
||||
const d = await api('/api/ai/config?with_key=true');
|
||||
document.getElementById('aiBaseUrl').value = d.base_url || '';
|
||||
document.getElementById('aiApiKey').value = d.api_key || '';
|
||||
document.getElementById('aiModel').value = d.model || '';
|
||||
document.getElementById('aiTimeout').value = d.timeout_s || 300;
|
||||
document.getElementById('aiEnabled').checked = !!d.enabled;
|
||||
document.getElementById('aiConfigTip').textContent = '更新时间:' + (d.updated_at || '-');
|
||||
} catch (e) { /* 401 已在 api 内处理 */ }
|
||||
}
|
||||
|
||||
async function saveAiConfig() {
|
||||
try {
|
||||
await api('/api/ai/config', { method: 'PUT', body: JSON.stringify({
|
||||
base_url: document.getElementById('aiBaseUrl').value.trim(),
|
||||
api_key: document.getElementById('aiApiKey').value.trim(),
|
||||
model: document.getElementById('aiModel').value.trim(),
|
||||
timeout_s: parseInt(document.getElementById('aiTimeout').value, 10) || 300,
|
||||
enabled: document.getElementById('aiEnabled').checked,
|
||||
})});
|
||||
alert('模型配置已保存');
|
||||
await loadAiConfig();
|
||||
} catch (e) { alert('保存失败:' + (e.message || '')); }
|
||||
}
|
||||
|
||||
async function testAiConfig() {
|
||||
try {
|
||||
const d = await api('/api/ai/config/test', { method: 'POST' });
|
||||
alert(d.ok ? '连通测试通过' : '连通失败:' + d.detail);
|
||||
} catch (e) { alert('测试失败:' + (e.message || '')); }
|
||||
}
|
||||
|
||||
/* ---------- 页面切换 ---------- */
|
||||
function switchPage(page) {
|
||||
document.querySelectorAll('aside .menu-item').forEach(el =>
|
||||
@@ -452,7 +506,9 @@ function switchPage(page) {
|
||||
document.getElementById('pageData').classList.toggle('hidden', page !== 'data');
|
||||
document.getElementById('pageBlacklist').classList.toggle('hidden', page !== 'blacklist');
|
||||
document.getElementById('pageRemote').classList.toggle('hidden', page !== 'remote');
|
||||
if (page === 'data') load(); else if (page === 'blacklist') loadBlacklist(); else loadRemote();
|
||||
document.getElementById('pageAiConfig').classList.toggle('hidden', page !== 'aiConfig');
|
||||
if (page === 'data') load(); else if (page === 'blacklist') loadBlacklist();
|
||||
else if (page === 'aiConfig') loadAiConfig(); else loadRemote();
|
||||
}
|
||||
|
||||
/* ---------- 事件绑定 ---------- */
|
||||
@@ -525,6 +581,8 @@ document.getElementById('btnStopRemote').onclick = () => {
|
||||
if (!confirm('确认远程结束投递任务?')) return;
|
||||
sendTask('stop_apply', null);
|
||||
};
|
||||
document.getElementById('btnAiSave').onclick = saveAiConfig;
|
||||
document.getElementById('btnAiTest').onclick = testAiConfig;
|
||||
document.getElementById('blTbody').addEventListener('click', e => {
|
||||
const btn = e.target.closest('.bl-remove');
|
||||
if (btn) removeBlacklist(btn.dataset.id);
|
||||
|
||||
Reference in New Issue
Block a user