update
This commit is contained in:
510
web/index.html
510
web/index.html
@@ -218,44 +218,124 @@
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.config-btn {
|
||||
background: inherit;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 8px;
|
||||
padding: 10px 15px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
margin-left: 10px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.config-btn:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.config-panel {
|
||||
display: none;
|
||||
background-color: white;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.config-panel.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
color: #95a5a6;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.json-output {
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.config-btn {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 15px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.config-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.config-panel {
|
||||
display: none;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
backdrop-filter: blur(10px);
|
||||
border-radius: 15px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.config-panel.active {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>🏭 WASM企业分析工具套件</h1>
|
||||
<h1>🚀 Excel转JSON工具</h1>
|
||||
<p class="subtitle">基于WebAssembly的多功能企业数据分析平台</p>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<div class="features">
|
||||
<div class="feature-card">
|
||||
<span class="feature-icon">📊</span>
|
||||
<h3 class="feature-title">行业分析</h3>
|
||||
<p class="feature-desc">基于企业信息的国民经济行业分类</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<span class="feature-icon">📄</span>
|
||||
<h3 class="feature-title">Excel解析</h3>
|
||||
<p class="feature-desc">在浏览器中直接解析Excel文件</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<span class="feature-icon">🤖</span>
|
||||
<h3 class="feature-title">AI分析</h3>
|
||||
<p class="feature-desc">利用大模型进行智能数据分析</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<span class="feature-icon">💰</span>
|
||||
<h3 class="feature-title">税务健康</h3>
|
||||
<p class="feature-desc">企业税务健康状况评估</p>
|
||||
|
||||
|
||||
<!-- 顶部导航栏 -->
|
||||
<div class="navbar">
|
||||
<h1>🚀 Excel转JSON工具</h1>
|
||||
<!-- LLM配置按钮 -->
|
||||
<button id="llmConfigBtn" class="config-btn" onclick="toggleLLMConfig()">⚙️ LLM配置</button>
|
||||
</div>
|
||||
|
||||
<!-- LLM配置面板 -->
|
||||
<div id="llmConfigPanel" class="config-panel">
|
||||
<div class="section">
|
||||
<h3>🤖 LLM配置</h3>
|
||||
|
||||
<label for="llmProviderSelect">Provider:</label>
|
||||
<select id="llmProviderSelect">
|
||||
<option value="ollama">Ollama</option>
|
||||
<option value="openai">OpenAI</option>
|
||||
</select>
|
||||
|
||||
<label for="llmBaseUrlInput">Base URL:</label>
|
||||
<input type="text" id="llmBaseUrlInput" placeholder="输入API基础URL" value="http://localhost:11434">
|
||||
|
||||
<label for="llmModelInput">Model:</label>
|
||||
<input type="text" id="llmModelInput" placeholder="输入模型名称" value="qwen3.5:9b">
|
||||
|
||||
<label for="llmApiKeyInput">API Key:</label>
|
||||
<input type="password" id="llmApiKeyInput" placeholder="输入API密钥(如果需要)">
|
||||
|
||||
<button id="saveLlmConfigBtn" class="btn">💾 保存配置</button>
|
||||
<button id="closeLlmConfigBtn" class="btn cancel-btn" onclick="toggleLLMConfig()">❌ 关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 标签页导航 -->
|
||||
<div class="tab">
|
||||
<button class="tablinks active" onclick="openTab(event, 'company')">企业行业分析</button>
|
||||
<button class="tablinks" onclick="openTab(event, 'excel')">Excel解析</button>
|
||||
@@ -293,9 +373,60 @@
|
||||
<!-- 税务健康标签页 -->
|
||||
<div id="tax" class="tabcontent">
|
||||
<div class="section">
|
||||
<label for="taxJson">💼 请输入企业JSON数据:</label>
|
||||
<textarea id="taxJson" rows="6" placeholder='请输入企业数据,例如: {"revenue": 1000000, "expenses": 800000}'>{"revenue": 1000000, "expenses": 800000, "tax_paid": 50000}</textarea>
|
||||
<button id="callTaxBtn" disabled>评估税务健康</button>
|
||||
<h3>📊 税务健康评估参数</h3>
|
||||
|
||||
<label for="companyNameInput">🏢 企业名称:</label>
|
||||
<input type="text" id="companyNameInput" placeholder="请输入企业全称" value="企业名称">
|
||||
|
||||
<label for="periodInput">📅 测评周期:</label>
|
||||
<select id="periodInput">
|
||||
<option value="Q1">第一季度</option>
|
||||
<option value="Q2">第二季度</option>
|
||||
<option value="Q3">第三季度</option>
|
||||
<option value="Q4">第四季度</option>
|
||||
<option value="年度">年度</option>
|
||||
</select>
|
||||
|
||||
<label for="yearInput">📅 报告期:</label>
|
||||
<input type="number" id="yearInput" placeholder="年份" value="2025" min="1900" max="2100">
|
||||
|
||||
<label for="citInput">💰 企业所得税应纳税额合计 (万元):</label>
|
||||
<input type="number" id="citInput" placeholder="单位:万元" value="100.0" step="0.01">
|
||||
|
||||
<label for="vatInput">💰 增值税应纳税额合计 (万元):</label>
|
||||
<input type="number" id="vatInput" placeholder="单位:万元" value="50.0" step="0.01">
|
||||
|
||||
<label for="inputVatInput">💰 增值税进项税额 (万元):</label>
|
||||
<input type="number" id="inputVatInput" placeholder="单位:万元" value="30.0" step="0.01">
|
||||
|
||||
<label for="outputVatInput">💰 增值税销项税额 (万元):</label>
|
||||
<input type="number" id="outputVatInput" placeholder="单位:万元" value="80.0" step="0.01">
|
||||
|
||||
<label for="preCitInput">💰 上一期企业所得税应纳税额合计 (万元):</label>
|
||||
<input type="number" id="preCitInput" placeholder="单位:万元" value="90.0" step="0.01">
|
||||
|
||||
<label for="preVatInput">💰 上一期增值税应纳税额合计 (万元):</label>
|
||||
<input type="number" id="preVatInput" placeholder="单位:万元" value="45.0" step="0.01">
|
||||
|
||||
<label for="preInputVatInput">💰 上一期增值税进项税额 (万元):</label>
|
||||
<input type="number" id="preInputVatInput" placeholder="单位:万元" value="25.0" step="0.01">
|
||||
|
||||
<label for="preOutputVatInput">💰 上一期增值税销项税额 (万元):</label>
|
||||
<input type="number" id="preOutputVatInput" placeholder="单位:万元" value="70.0" step="0.01">
|
||||
|
||||
<label for="excelFileInput">📁 上传Excel财务报表 (可选):</label>
|
||||
<input type="file" id="excelFileInput" accept=".xlsx,.xls">
|
||||
|
||||
<label for="taxJsonInput">📄 或者直接粘贴JSON数据:</label>
|
||||
<textarea id="taxJsonInput" rows="4" placeholder='粘贴财务报表JSON数据'>{"LC0000003E_T0I0331": 741213833.14, "LC0000003E_T0I0101": 578064138.06}</textarea>
|
||||
|
||||
<button id="submitTaxBtn" disabled>提交税务评估</button>
|
||||
<button id="queryResultBtn" disabled style="background: linear-gradient(45deg, #4CAF50, #8BC34A);">查询评估结果</button>
|
||||
|
||||
<div style="margin-top: 15px;">
|
||||
<label for="orderNoInput">📋 订单号 (用于查询):</label>
|
||||
<input type="text" id="orderNoInput" placeholder="输入订单号查询结果">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -326,7 +457,8 @@
|
||||
document.getElementById('analyzeCompanyBtn').disabled = false;
|
||||
document.getElementById('parseExcelBtn').disabled = false;
|
||||
document.getElementById('callLLMBtn').disabled = false;
|
||||
document.getElementById('callTaxBtn').disabled = false;
|
||||
document.getElementById('submitTaxBtn').disabled = false;
|
||||
document.getElementById('queryResultBtn').disabled = false;
|
||||
console.log('WASM模块加载完成');
|
||||
}).catch((err) => {
|
||||
console.error('WASM加载失败:', err);
|
||||
@@ -337,11 +469,9 @@
|
||||
const analyzeCompanyBtn = document.getElementById('analyzeCompanyBtn');
|
||||
const parseExcelBtn = document.getElementById('parseExcelBtn');
|
||||
const callLLMBtn = document.getElementById('callLLMBtn');
|
||||
const callTaxBtn = document.getElementById('callTaxBtn');
|
||||
const companyNameInput = document.getElementById('companyName');
|
||||
const excelFileInput = document.getElementById('excelFile');
|
||||
const llmPromptInput = document.getElementById('llmPrompt');
|
||||
const taxJsonInput = document.getElementById('taxJson');
|
||||
const resultSection = document.getElementById('resultSection');
|
||||
const resultContent = document.getElementById('resultContent');
|
||||
const loadingDiv = document.getElementById('loading');
|
||||
@@ -361,7 +491,10 @@
|
||||
resultSection.classList.remove('show');
|
||||
|
||||
try {
|
||||
const result = await window.analyzeCompanyIndustryAsync(companyName);
|
||||
// 获取当前LLM配置
|
||||
const llmConfig = getCurrentLLMConfig();
|
||||
|
||||
const result = await window.analyzeCompanyIndustryAsync(companyName, JSON.stringify(llmConfig));
|
||||
|
||||
if (result && result.error) {
|
||||
showError(result.error);
|
||||
@@ -421,12 +554,17 @@
|
||||
resultSection.classList.remove('show');
|
||||
|
||||
try {
|
||||
const result = await window.callLLMAsync(prompt);
|
||||
// 获取当前LLM配置
|
||||
const llmConfig = getCurrentLLMConfig();
|
||||
|
||||
// 调用大模型
|
||||
const result = await window.callLLMAsync(prompt, JSON.stringify(llmConfig));
|
||||
|
||||
if (result && result.error) {
|
||||
showError(result.error);
|
||||
showError('调用大模型失败: ' + result.error);
|
||||
} else {
|
||||
displayResults('AI分析结果', result);
|
||||
// 显示结果
|
||||
displayResults('大模型调用结果', result);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('AI分析过程中发生错误: ' + error.message);
|
||||
@@ -435,12 +573,46 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 税务健康按钮事件
|
||||
callTaxBtn.addEventListener('click', async () => {
|
||||
// 税务健康提交按钮事件
|
||||
const submitTaxBtn = document.getElementById('submitTaxBtn');
|
||||
const queryResultBtn = document.getElementById('queryResultBtn');
|
||||
const taxCompanyNameInput = document.getElementById('companyNameInput');
|
||||
const periodInput = document.getElementById('periodInput');
|
||||
const yearInput = document.getElementById('yearInput');
|
||||
const citInput = document.getElementById('citInput');
|
||||
const vatInput = document.getElementById('vatInput');
|
||||
const inputVatInput = document.getElementById('inputVatInput');
|
||||
const outputVatInput = document.getElementById('outputVatInput');
|
||||
const preCitInput = document.getElementById('preCitInput');
|
||||
const preVatInput = document.getElementById('preVatInput');
|
||||
const preInputVatInput = document.getElementById('preInputVatInput');
|
||||
const preOutputVatInput = document.getElementById('preOutputVatInput');
|
||||
const taxExcelFileInput = document.getElementById('excelFileInput');
|
||||
const taxJsonInput = document.getElementById('taxJsonInput');
|
||||
const orderNoInput = document.getElementById('orderNoInput');
|
||||
|
||||
submitTaxBtn.addEventListener('click', async () => {
|
||||
// 收集所有输入的参数
|
||||
const companyName = taxCompanyNameInput.value.trim();
|
||||
const period = periodInput.value;
|
||||
const year = yearInput.value;
|
||||
const cit = parseFloat(citInput.value) || 0;
|
||||
const vat = parseFloat(vatInput.value) || 0;
|
||||
const inputVat = parseFloat(inputVatInput.value) || 0;
|
||||
const outputVat = parseFloat(outputVatInput.value) || 0;
|
||||
const preCit = parseFloat(preCitInput.value) || 0;
|
||||
const preVat = parseFloat(preVatInput.value) || 0;
|
||||
const preInputVat = parseFloat(preInputVatInput.value) || 0;
|
||||
const preOutputVat = parseFloat(preOutputVatInput.value) || 0;
|
||||
const jsonData = taxJsonInput.value.trim();
|
||||
|
||||
if (!jsonData) {
|
||||
showError('请输入企业JSON数据');
|
||||
if (!companyName) {
|
||||
showError('请输入企业名称');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!year || isNaN(year)) {
|
||||
showError('请输入有效的年份');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -449,15 +621,182 @@
|
||||
resultSection.classList.remove('show');
|
||||
|
||||
try {
|
||||
const result = await window.callTaxHealthAsync(jsonData);
|
||||
// 构建请求数据
|
||||
let requestData = {
|
||||
req_no: 'REQ' + Date.now().toString(),
|
||||
company_name: companyName,
|
||||
period: period,
|
||||
year: year.toString(),
|
||||
cit: cit,
|
||||
vat: vat,
|
||||
input_vat: inputVat,
|
||||
output_vat: outputVat,
|
||||
pre_cit: preCit,
|
||||
pre_vat: preVat,
|
||||
pre_input_vat: preInputVat,
|
||||
pre_output_vat: preOutputVat
|
||||
};
|
||||
|
||||
// 处理Excel文件或JSON数据
|
||||
if (taxExcelFileInput.files.length > 0) {
|
||||
// 如果用户选择了Excel文件,需要先解析它并通过LLM转换为JSON
|
||||
const file = taxExcelFileInput.files[0];
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
|
||||
// 获取期间参数
|
||||
const period = periodInput.value;
|
||||
|
||||
// 获取当前LLM配置
|
||||
const llmConfig = getCurrentLLMConfig();
|
||||
|
||||
// 使用新的函数将Excel数据通过LLM转换为JSON格式,传入期间参数和配置
|
||||
const conversionResult = await window.convertExcelToJsonViaLLM(arrayBuffer, period, JSON.stringify(llmConfig));
|
||||
|
||||
// 检查转换结果是否包含错误
|
||||
if (conversionResult && conversionResult.error) {
|
||||
showError('Excel转JSON过程中发生错误: ' + conversionResult.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (conversionResult && conversionResult.error) {
|
||||
showError('Excel转JSON过程中发生错误: ' + conversionResult.error);
|
||||
return;
|
||||
}
|
||||
|
||||
// 优先使用转换后的JSON数据
|
||||
if (conversionResult.json_data) {
|
||||
requestData.data = conversionResult.json_data;
|
||||
} else if (conversionResult.parsed_json) {
|
||||
// 如果有解析后的JSON字符串,尝试解析它
|
||||
try {
|
||||
requestData.data = JSON.parse(conversionResult.parsed_json);
|
||||
} catch (e) {
|
||||
console.warn('无法解析LLM返回的JSON,使用原始响应:', e);
|
||||
// 如果解析失败,使用原始响应作为数据
|
||||
requestData.data = conversionResult;
|
||||
}
|
||||
} else {
|
||||
showError('Excel转JSON失败,未获得有效数据');
|
||||
return;
|
||||
}
|
||||
} else if (jsonData) {
|
||||
// 如果提供了JSON数据
|
||||
try {
|
||||
const parsedData = JSON.parse(jsonData);
|
||||
requestData.data = parsedData;
|
||||
} catch (e) {
|
||||
showError('JSON数据格式不正确: ' + e.message);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
showError('请上传Excel文件或提供JSON数据');
|
||||
return;
|
||||
}
|
||||
|
||||
// 首先调用税务健康API获取订单号
|
||||
const result = await window.callTaxHealthAsync(JSON.stringify(requestData));
|
||||
|
||||
if (result && result.error) {
|
||||
showError(result.error);
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示初始结果并开始轮询
|
||||
displayResults('税务健康评估提交结果', result);
|
||||
|
||||
// 自动填充订单号到查询框
|
||||
if (result.order_no) {
|
||||
orderNoInput.value = result.order_no;
|
||||
|
||||
// 开始轮询查询结果
|
||||
console.log('开始轮询查询结果...');
|
||||
let attempts = 0;
|
||||
const maxAttempts = 60; // 最多轮询60次
|
||||
|
||||
const pollForResult = async () => {
|
||||
if (attempts >= maxAttempts) {
|
||||
console.log('轮询超时');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const pollResult = await window.queryTaxResultAsync(result.order_no);
|
||||
|
||||
if (pollResult && pollResult.error) {
|
||||
showError('查询结果时发生错误: ' + pollResult.error);
|
||||
return;
|
||||
}
|
||||
|
||||
const queryResponse = pollResult.query_response;
|
||||
|
||||
console.log(`轮询结果 - 状态码: ${queryResponse.code}, 订单状态: ${queryResponse.data.status}`);
|
||||
|
||||
// 根据状态码判断处理结果
|
||||
switch (queryResponse.data.status) {
|
||||
case 99: // 执行成功
|
||||
console.log('税务评估已完成!');
|
||||
displayResults('税务评估最终结果', pollResult);
|
||||
|
||||
// 显示结果文件地址
|
||||
if (queryResponse.data.detail && queryResponse.data.detail.files) {
|
||||
console.log('结果文件地址:', queryResponse.data.detail.files);
|
||||
}
|
||||
return;
|
||||
case 0: // 正在执行
|
||||
console.log(`任务仍在处理中... (${attempts + 1}/${maxAttempts})`);
|
||||
attempts++;
|
||||
setTimeout(pollForResult, 5000); // 5秒后再次查询
|
||||
break;
|
||||
case -1: // 无效订单
|
||||
showError(`订单无效: ${queryResponse.data.detail?.error || '未知错误'}`);
|
||||
return;
|
||||
case 98: // 执行失败
|
||||
showError(`任务执行失败: ${queryResponse.data.detail?.error || '未知错误'}`);
|
||||
return;
|
||||
default:
|
||||
console.log(`未知状态码: ${queryResponse.data.status}`);
|
||||
attempts++;
|
||||
setTimeout(pollForResult, 5000);
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
showError('轮询过程中发生错误: ' + error.message);
|
||||
}
|
||||
};
|
||||
|
||||
// 开始轮询
|
||||
setTimeout(pollForResult, 5000);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('税务健康评估过程中发生错误: ' + error.message);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
// 查询税务评估结果按钮事件
|
||||
queryResultBtn.addEventListener('click', async () => {
|
||||
const orderNo = orderNoInput.value.trim();
|
||||
|
||||
if (!orderNo) {
|
||||
showError('请输入订单号');
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(true);
|
||||
hideError();
|
||||
resultSection.classList.remove('show');
|
||||
|
||||
try {
|
||||
const result = await window.queryTaxResultAsync(orderNo);
|
||||
|
||||
if (result && result.error) {
|
||||
showError(result.error);
|
||||
} else {
|
||||
displayResults('税务健康评估结果', result);
|
||||
displayResults('税务评估查询结果', result);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('税务健康评估过程中发生错误: ' + error.message);
|
||||
showError('查询税务评估结果过程中发生错误: ' + error.message);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
@@ -471,7 +810,8 @@
|
||||
analyzeCompanyBtn.disabled = true;
|
||||
parseExcelBtn.disabled = true;
|
||||
callLLMBtn.disabled = true;
|
||||
callTaxBtn.disabled = true;
|
||||
submitTaxBtn.disabled = true;
|
||||
queryResultBtn.disabled = true;
|
||||
} else {
|
||||
loadingDiv.classList.remove('show');
|
||||
// 重新启用按钮(但保持初始状态由WASM加载决定)
|
||||
@@ -480,7 +820,8 @@
|
||||
analyzeCompanyBtn.disabled = false;
|
||||
parseExcelBtn.disabled = false;
|
||||
callLLMBtn.disabled = false;
|
||||
callTaxBtn.disabled = false;
|
||||
submitTaxBtn.disabled = false;
|
||||
queryResultBtn.disabled = false;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
@@ -513,6 +854,91 @@
|
||||
resultSection.classList.add('show');
|
||||
}
|
||||
|
||||
// 切换LLM配置面板显示/隐藏
|
||||
function toggleLLMConfig() {
|
||||
const panel = document.getElementById('llmConfigPanel');
|
||||
const isActive = panel.classList.contains('active');
|
||||
|
||||
if (isActive) {
|
||||
panel.classList.remove('active');
|
||||
} else {
|
||||
panel.classList.add('active');
|
||||
}
|
||||
}
|
||||
|
||||
// 保存LLM配置
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const saveLlmConfigBtn = document.getElementById('saveLlmConfigBtn');
|
||||
if (saveLlmConfigBtn) {
|
||||
saveLlmConfigBtn.addEventListener('click', function() {
|
||||
const provider = document.getElementById('llmProviderSelect').value;
|
||||
const baseUrl = document.getElementById('llmBaseUrlInput').value;
|
||||
const model = document.getElementById('llmModelInput').value;
|
||||
const apiKey = document.getElementById('llmApiKeyInput').value;
|
||||
|
||||
// 保存配置到localStorage
|
||||
const llmConfig = {
|
||||
provider: provider,
|
||||
base_url: baseUrl,
|
||||
model: model,
|
||||
api_key: apiKey
|
||||
};
|
||||
|
||||
localStorage.setItem('llmConfig', JSON.stringify(llmConfig));
|
||||
alert('LLM配置已保存!');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 从localStorage加载LLM配置
|
||||
function loadLLMConfig() {
|
||||
const savedConfig = localStorage.getItem('llmConfig');
|
||||
if (savedConfig) {
|
||||
try {
|
||||
const config = JSON.parse(savedConfig);
|
||||
if (document.getElementById('llmProviderSelect')) {
|
||||
document.getElementById('llmProviderSelect').value = config.provider || 'ollama';
|
||||
}
|
||||
if (document.getElementById('llmBaseUrlInput')) {
|
||||
document.getElementById('llmBaseUrlInput').value = config.base_url || 'http://localhost:11434';
|
||||
}
|
||||
if (document.getElementById('llmModelInput')) {
|
||||
document.getElementById('llmModelInput').value = config.model || 'qwen3.5:9b';
|
||||
}
|
||||
if (document.getElementById('llmApiKeyInput')) {
|
||||
document.getElementById('llmApiKeyInput').value = config.api_key || '';
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载LLM配置失败:', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 在页面加载完成后初始化LLM配置
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadLLMConfig();
|
||||
});
|
||||
|
||||
// 获取当前LLM配置
|
||||
function getCurrentLLMConfig() {
|
||||
const savedConfig = localStorage.getItem('llmConfig');
|
||||
if (savedConfig) {
|
||||
try {
|
||||
return JSON.parse(savedConfig);
|
||||
} catch (e) {
|
||||
console.error('解析LLM配置失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 返回默认配置
|
||||
return {
|
||||
provider: 'ollama',
|
||||
base_url: 'http://localhost:11434',
|
||||
model: 'qwen3.5:9b',
|
||||
api_key: ''
|
||||
};
|
||||
}
|
||||
|
||||
// 标签页功能
|
||||
function openTab(evt, tabName) {
|
||||
var i, tabcontent, tablinks;
|
||||
@@ -537,7 +963,7 @@
|
||||
} else if (activeTab.id === 'llm') {
|
||||
callLLMBtn.click();
|
||||
} else if (activeTab.id === 'tax') {
|
||||
callTaxBtn.click();
|
||||
submitTaxBtn.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user