fix(cockpit_chat): 修复f-string引号转义导致的500语法错误,统一\n换行join

This commit is contained in:
yumoqing 2026-08-04 16:44:38 +08:00
parent 446b42e491
commit f7faed4b83

View File

@ -606,7 +606,7 @@ if action == 'send_message':
repo_lines.append("关联代码仓库:")
for rp in repos:
repo_lines.append(f" - {rp['name']}: {rp['url']} (分支:{rp['branch']}, 本地:{rp['path']})")
results.append('\\n'.join(repo_lines))
results.append('\n'.join(repo_lines))
for t in tasks:
try:
@ -619,19 +619,19 @@ if action == 'send_message':
sp = sp + skills_prompt
task_msgs = [{"role": "system", "content": sp}]
prompt_parts = [f"请完成:{t.title}"]
prompt_parts.append('\\n'.join(repo_lines))
prompt_parts.append('\n'.join(repo_lines))
prompt_parts.append("请在关联仓库中直接修改代码文件,完成后提供变更摘要。")
task_msgs.append({"role": "user", "content": '\\n'.join(prompt_parts)})
task_msgs.append({"role": "user", "content": '\n'.join(prompt_parts)})
result = await _call_llm(model_info, task_msgs, settings['temperature'])
did = getID()
role_dir = f\"{ws}/deliverables/agent\" if ws else \"deliverables/agent\"
role_dir = f"{ws}/deliverables/agent" if ws else "deliverables/agent"
# Detect primary repo for deliverable
primary_repo = repos[0]['name'] if repos else ''
await sor.C('pipeline_deliverables', {
'id': did, 'project_id': pid, 'task_id': t.id,
'deliverable_type': 'code', 'title': t.title, 'content': result,
'repo_name': primary_repo, 'target_path': '',
'file_path': f\"{role_dir}/{t.id}.md\",
'file_path': f"{role_dir}/{t.id}.md",
'quality_score': 80, 'review_status': 'pending', 'created_by': 'agent'
})
await sor.sqlExe("UPDATE pipeline_tasks SET state='completed' WHERE id=${tid}$", {"tid": t.id})