```
All checks were successful
Deploy Vue App / build-and-deploy (push) Successful in 9s

feat(llm): 添加AI智能分析配置功能

新增LLM配置模块,支持通过阿里云DashScope API进行招标金额的智能提取。
配置包括API Key、Base URL、模型选择等,并提供启用开关。
前端界面增加“AI配置”标签页,包含状态展示、配置表单及测试连接功能。
后端增强parseDetailEnhanced方法,优先使用LLM提取金额,失败时降级至正则表达式。
同时实现LLM状态查询与连接测试接口,确保配置有效性。
配置文件中新增llm字段,默认关闭,支持安全存储API密钥。
```
This commit is contained in:
2025-12-15 17:49:11 +08:00
parent f797ed9a61
commit 6fc9748009
6 changed files with 562 additions and 7 deletions

View File

@@ -344,6 +344,7 @@
<button class="tab" onclick="switchTab('report')">生成报告</button>
<button class="tab" onclick="switchTab('scheduler')">定时任务</button>
<button class="tab" onclick="switchTab('email')">邮件配置</button>
<button class="tab" onclick="switchTab('llm')">AI配置</button>
</div>
<div class="content">
@@ -632,6 +633,103 @@
</p>
</div>
</div>
<!-- AI配置 -->
<div id="llm" class="tab-content">
<h2 style="margin-bottom: 20px; color: #667eea;">AI 智能分析配置</h2>
<p style="color: #666; margin-bottom: 20px;">使用大语言模型智能提取招标金额,提高金额识别的准确性</p>
<!-- AI 状态 -->
<div id="llmStatus" style="margin-bottom: 30px; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 8px;">
<h3 style="margin-top: 0; margin-bottom: 15px;">AI 服务状态</h3>
<div style="display: flex; gap: 30px; flex-wrap: wrap;">
<div>
<div style="opacity: 0.9; font-size: 14px;">服务状态</div>
<div style="font-size: 20px; font-weight: bold; margin-top: 5px;" id="llmRunningStatus">加载中...</div>
</div>
<div>
<div style="opacity: 0.9; font-size: 14px;">当前模型</div>
<div style="font-size: 20px; font-weight: bold; margin-top: 5px;" id="llmModelName">-</div>
</div>
</div>
</div>
<!-- 配置表单 -->
<div class="form-group">
<div class="checkbox-wrapper" onclick="document.getElementById('llmEnabled').click();">
<input type="checkbox" id="llmEnabled" onclick="event.stopPropagation();">
<label for="llmEnabled">启用 AI 金额提取</label>
</div>
</div>
<div class="form-group">
<label>API Key *</label>
<input type="password" id="llmApiKey" placeholder="请输入阿里云 DashScope API Key">
<small style="color: #666; display: block; margin-top: 5px;">
<a href="https://dashscope.console.aliyun.com/apiKey" target="_blank" style="color: #667eea;">点击这里获取 API Key</a>
</small>
</div>
<div class="form-group">
<label>API 地址</label>
<input type="text" id="llmBaseUrl" value="https://dashscope.aliyuncs.com/compatible-mode/v1" placeholder="https://dashscope.aliyuncs.com/compatible-mode/v1">
</div>
<div class="form-group">
<label>模型选择</label>
<select id="llmModel" style="width: 100%; padding: 12px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;">
<option value="qwen-turbo">通义千问 Turbo (快速、低成本)</option>
<option value="qwen-plus">通义千问 Plus (更准确)</option>
<option value="qwen-max">通义千问 Max (最强)</option>
</select>
</div>
<button class="btn" onclick="saveLLMConfig()">保存配置</button>
<button class="btn" onclick="testLLMConnection()" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">测试连接</button>
<button class="btn" onclick="loadLLMConfig()" style="background: #6c757d;">刷新状态</button>
<div id="llmConfigStatus" style="margin-top: 20px;"></div>
<div style="margin-top: 30px; padding: 20px; background: #e8f5e9; border-radius: 8px; border-left: 4px solid #4caf50;">
<h3 style="margin-top: 0; color: #2e7d32;">功能说明</h3>
<ul style="line-height: 1.8; color: #2e7d32;">
<li><strong>智能提取:</strong> 使用大语言模型理解公告内容,准确提取预算金额</li>
<li><strong>自动降级:</strong> 当 AI 服务不可用时,自动使用正则表达式提取</li>
<li><strong>支持模型:</strong> 阿里云通义千问系列模型qwen-turbo/plus/max</li>
<li><strong>计费说明:</strong> 按实际调用量计费qwen-turbo 约 0.0008元/千tokens</li>
</ul>
</div>
<div style="margin-top: 20px; padding: 20px; background: #fff3cd; border-radius: 8px; border-left: 4px solid #ffc107;">
<h3 style="margin-top: 0; color: #856404;">模型对比</h3>
<table style="width: 100%; border-collapse: collapse; margin-top: 10px;">
<tr style="border-bottom: 1px solid #ddd;">
<th style="text-align: left; padding: 8px; color: #856404;">模型</th>
<th style="text-align: left; padding: 8px; color: #856404;">速度</th>
<th style="text-align: left; padding: 8px; color: #856404;">准确度</th>
<th style="text-align: left; padding: 8px; color: #856404;">成本</th>
</tr>
<tr style="border-bottom: 1px solid #ddd;">
<td style="padding: 8px;">qwen-turbo</td>
<td style="padding: 8px;">最快</td>
<td style="padding: 8px;">良好</td>
<td style="padding: 8px;">最低</td>
</tr>
<tr style="border-bottom: 1px solid #ddd;">
<td style="padding: 8px;">qwen-plus</td>
<td style="padding: 8px;">较快</td>
<td style="padding: 8px;">优秀</td>
<td style="padding: 8px;">中等</td>
</tr>
<tr>
<td style="padding: 8px;">qwen-max</td>
<td style="padding: 8px;">较慢</td>
<td style="padding: 8px;">最佳</td>
<td style="padding: 8px;">较高</td>
</tr>
</table>
</div>
</div>
</div>
</div>