refactor: Reorganize prompt definitions and update agent implementation.
This commit is contained in:
@@ -131,6 +131,17 @@ class DataAnalysisAgent:
|
||||
print(f" 📝 描述: {description}")
|
||||
print(f" 🔍 分析: {analysis}")
|
||||
|
||||
|
||||
# 记录图片信息
|
||||
collected_figures.append(
|
||||
{
|
||||
"figure_number": figure_number,
|
||||
"filename": filename,
|
||||
"file_path": file_path,
|
||||
"description": description,
|
||||
"analysis": analysis,
|
||||
}
|
||||
)
|
||||
# 验证文件是否存在
|
||||
# 只有文件真正存在时才加入列表,防止报告出现裂图
|
||||
if file_path and os.path.exists(file_path):
|
||||
@@ -326,11 +337,13 @@ class DataAnalysisAgent:
|
||||
elif process_result["action"] == "collect_figures":
|
||||
# 记录图片收集结果
|
||||
collected_figures = process_result.get("collected_figures", [])
|
||||
|
||||
missing_figures = process_result.get("missing_figures", [])
|
||||
|
||||
feedback = f"已收集 {len(collected_figures)} 个有效图片及其分析。"
|
||||
if missing_figures:
|
||||
feedback += f"\n⚠️ 以下图片未找到,请检查代码是否成功保存了这些图片: {missing_figures}"
|
||||
|
||||
self.conversation_history.append(
|
||||
{
|
||||
"role": "user",
|
||||
@@ -345,6 +358,7 @@ class DataAnalysisAgent:
|
||||
"action": "collect_figures",
|
||||
"collected_figures": collected_figures,
|
||||
"missing_figures": missing_figures,
|
||||
|
||||
"response": response,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user