feat: 步骤5填充字段改用智能体执行

- 新增步骤5任务模板(config/agent_fill_fields_template.txt)
- 步骤5调用智能体hz4th_editor执行:
  1. 获取API文档了解对应类别字段定义
  2. 从内容库获取相关内容数据
  3. 整理产品参数
  4. 通过API提交到ParamHub审核系统
- /process页面新增步骤5模板编辑面板
- 步骤6改为确认提交结果(备用本地提交)
- 新增API: GET/POST /api/process/fill-fields-template
This commit is contained in:
2026-07-15 16:31:00 +08:00
parent 5fdcf7a5b6
commit eea7269eda
5 changed files with 416 additions and 15 deletions
+80 -1
View File
@@ -10,6 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
loadActiveProcesses();
loadHistory();
loadAgentTemplate();
loadFillFieldsTemplate();
// 启动自动刷新(每2秒)
startAutoRefresh();
@@ -508,4 +509,82 @@ async function doPreview() {
} catch (error) {
document.getElementById('template-preview-content').textContent = '预览失败: ' + error.message;
}
}
}
// ===== 步骤5填充字段模板 =====
// 加载步骤5模板
async function loadFillFieldsTemplate() {
try {
const response = await fetch(`${API_BASE}/api/process/fill-fields-template`);
const data = await response.json();
if (data.success) {
document.getElementById('fill-fields-template-editor').value = data.template;
} else {
document.getElementById('fill-fields-template-editor').value = '// 模板加载失败: ' + (data.error || '未知错误');
}
} catch (error) {
console.error('加载填充字段模板失败:', error);
document.getElementById('fill-fields-template-editor').value = '// 加载模板失败: ' + error.message;
}
}
// 保存步骤5模板
async function saveFillFieldsTemplate() {
const template = document.getElementById('fill-fields-template-editor').value;
if (!template.trim()) {
showToast('模板内容不能为空', 'error');
return;
}
try {
const response = await fetch(`${API_BASE}/api/process/fill-fields-template`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ template })
});
const data = await response.json();
if (data.success) {
showToast('步骤5模板已保存 ✓', 'success');
} else {
showToast('保存失败: ' + data.error, 'error');
}
} catch (error) {
showToast('保存失败: ' + error.message, 'error');
}
}
// 预览步骤5模板
function previewFillFieldsTemplate() {
document.getElementById('template-preview-modal').classList.add('active');
doFillFieldsPreview();
}
// 执行步骤5预览
async function doFillFieldsPreview() {
const product = document.getElementById('preview-product').value || '示例产品';
const category = document.getElementById('preview-category').value || 'AI模型';
try {
const response = await fetch(`${API_BASE}/api/process/fill-fields-template/preview`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
product_name: product,
category: category,
subcategory: ''
})
});
const data = await response.json();
if (data.success) {
document.getElementById('template-preview-content').textContent = data.preview;
} else {
document.getElementById('template-preview-content').textContent = '预览失败: ' + data.error;
}
} catch (error) {
document.getElementById('template-preview-content').textContent = '预览失败: ' + error.message;
}
}