feat: 步骤4提取产品数据改用智能体hz4th_editor执行
- 步骤4调用 openclaw agent --agent hz4th_editor --message 执行提取任务
- 新增任务文本模板(config/agent_task_template.txt),支持变量填充
- /process页面新增模板编辑面板,可查看/编辑/保存/预览模板
- 模板变量: {{product_name}} {{category}} {{subcategory}} {{library_results}} {{internet_results}}
- 新增API: GET/POST /api/process/agent-template, POST /api/process/agent-template/preview
This commit is contained in:
+52
-1
@@ -350,4 +350,55 @@
|
||||
.steps-progress {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 智能体任务模板区域 */
|
||||
.template-section .panel-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.template-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.template-info {
|
||||
background: #f0f4ff;
|
||||
border: 1px solid #c7d2fe;
|
||||
border-radius: 8px;
|
||||
padding: 12px 16px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 13px;
|
||||
color: #4338ca;
|
||||
}
|
||||
|
||||
.template-info p {
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
.template-info code {
|
||||
background: #e0e7ff;
|
||||
padding: 1px 5px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
color: #3730a3;
|
||||
}
|
||||
|
||||
.template-editor {
|
||||
width: 100%;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
padding: 12px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
resize: vertical;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.template-editor:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
loadStepDefinitions();
|
||||
loadActiveProcesses();
|
||||
loadHistory();
|
||||
loadAgentTemplate();
|
||||
|
||||
// 启动自动刷新(每2秒)
|
||||
startAutoRefresh();
|
||||
@@ -428,4 +429,83 @@ function showToast(message, type = '') {
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('active');
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// ===== 智能体任务模板 =====
|
||||
|
||||
// 加载模板
|
||||
async function loadAgentTemplate() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/process/agent-template`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
document.getElementById('agent-template-editor').value = data.template;
|
||||
} else {
|
||||
document.getElementById('agent-template-editor').value = '// 模板加载失败: ' + (data.error || '未知错误');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载模板失败:', error);
|
||||
document.getElementById('agent-template-editor').value = '// 加载模板失败: ' + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
// 保存模板
|
||||
async function saveTemplate() {
|
||||
const template = document.getElementById('agent-template-editor').value;
|
||||
|
||||
if (!template.trim()) {
|
||||
showToast('模板内容不能为空', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/process/agent-template`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ template })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('模板已保存 ✓', 'success');
|
||||
} else {
|
||||
showToast('保存失败: ' + data.error, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('保存失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 预览模板
|
||||
function previewTemplate() {
|
||||
document.getElementById('template-preview-modal').classList.add('active');
|
||||
doPreview();
|
||||
}
|
||||
|
||||
// 执行预览
|
||||
async function doPreview() {
|
||||
const product = document.getElementById('preview-product').value || '示例产品';
|
||||
const category = document.getElementById('preview-category').value || 'AI模型';
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/process/agent-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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user