feat: 后台管理添加大模型接口配置功能
- 网站配置页面新增 LLM 配置区域 - 支持配置 API 地址、API Key、文本模型、视觉模型 - LLM 配置从 config.json 动态读取 - 不再使用硬编码的 LLM_CONFIG 常量
This commit is contained in:
@@ -57,6 +57,8 @@
|
||||
<h1 class="text-2xl font-bold text-gray-800 mb-6">网站配置</h1>
|
||||
<div class="bg-white rounded-xl shadow-sm p-6">
|
||||
<form id="configForm" class="space-y-6">
|
||||
<!-- 网站基础配置 -->
|
||||
<h3 class="text-lg font-semibold text-gray-800 border-b pb-2 mb-4"><i class="ri-global-line mr-2"></i>网站基础配置</h3>
|
||||
<div class="grid grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">网站名称</label>
|
||||
@@ -87,6 +89,33 @@
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">页脚文字</label>
|
||||
<textarea name="footer_text" id="config_footer_text" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="网站底部的版权信息等"></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 大模型接口配置 -->
|
||||
<h3 class="text-lg font-semibold text-gray-800 border-b pb-2 mb-4 mt-8"><i class="ri-robot-line mr-2"></i>大模型接口配置(用于智能解析)</h3>
|
||||
<div class="bg-blue-50 rounded-lg p-4 mb-4">
|
||||
<p class="text-sm text-blue-700"><i class="ri-information-line mr-1"></i>配置用于智能解析产品参数的大模型API接口。文本解析使用普通模型,图片解析使用视觉模型。</p>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">API地址</label>
|
||||
<input type="url" name="llm_base_url" id="config_llm_base_url" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="http://192.168.2.17:19007/v1">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">API Key</label>
|
||||
<input type="text" name="llm_api_key" id="config_llm_api_key" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="留空则不验证">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">文本解析模型</label>
|
||||
<input type="text" name="llm_model" id="config_llm_model" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="auto">
|
||||
<p class="text-xs text-gray-500 mt-1">用于解析文本数据,如 deepseek-v3、qwen3.5 等</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">图片解析模型(视觉模型)</label>
|
||||
<input type="text" name="llm_vision_model" id="config_llm_vision_model" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="gpt-4-vision-preview">
|
||||
<p class="text-xs text-gray-500 mt-1">用于解析图片,如 Qwen/Qwen2-VL-72B-Instruct、gpt-4-vision-preview 等</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-4">
|
||||
<button type="button" onclick="loadSiteConfig()" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300"><i class="ri-refresh-line mr-1"></i>重置</button>
|
||||
<button type="button" onclick="saveSiteConfig()" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"><i class="ri-save-line mr-1"></i>保存配置</button>
|
||||
@@ -553,6 +582,7 @@
|
||||
const res = await fetch('/api/config');
|
||||
const config = await res.json();
|
||||
|
||||
// 网站基础配置
|
||||
document.getElementById('config_site_name').value = config.site_name || '';
|
||||
document.getElementById('config_site_subtitle').value = config.site_subtitle || '';
|
||||
document.getElementById('config_icp_number').value = config.icp_number || '';
|
||||
@@ -560,11 +590,18 @@
|
||||
document.getElementById('config_github_url').value = config.github_url || '';
|
||||
document.getElementById('config_copyright_year').value = config.copyright_year || '';
|
||||
document.getElementById('config_footer_text').value = config.footer_text || '';
|
||||
|
||||
// LLM配置
|
||||
document.getElementById('config_llm_base_url').value = config.llm_base_url || 'http://192.168.2.17:19007/v1';
|
||||
document.getElementById('config_llm_api_key').value = config.llm_api_key || '';
|
||||
document.getElementById('config_llm_model').value = config.llm_model || 'auto';
|
||||
document.getElementById('config_llm_vision_model').value = config.llm_vision_model || 'gpt-4-vision-preview';
|
||||
}
|
||||
|
||||
// 保存网站配置
|
||||
async function saveSiteConfig() {
|
||||
const config = {
|
||||
// 网站基础配置
|
||||
site_name: document.getElementById('config_site_name').value,
|
||||
site_subtitle: document.getElementById('config_site_subtitle').value,
|
||||
icp_number: document.getElementById('config_icp_number').value,
|
||||
@@ -572,6 +609,11 @@
|
||||
github_url: document.getElementById('config_github_url').value,
|
||||
copyright_year: document.getElementById('config_copyright_year').value,
|
||||
footer_text: document.getElementById('config_footer_text').value,
|
||||
// LLM配置
|
||||
llm_base_url: document.getElementById('config_llm_base_url').value,
|
||||
llm_api_key: document.getElementById('config_llm_api_key').value,
|
||||
llm_model: document.getElementById('config_llm_model').value,
|
||||
llm_vision_model: document.getElementById('config_llm_vision_model').value,
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user