Browse Source

完善提示

jiaqiang 6 hours ago
parent
commit
ab2095a9d8
2 changed files with 8 additions and 4 deletions
  1. 3 3
      llmops/agents/report_agent.py
  2. 5 1
      llmops/complete_agent_flow_rule.py

+ 3 - 3
llmops/agents/report_agent.py

@@ -157,7 +157,7 @@ class ReportSectionGeneratorAgent:
 
         return section_content
 
-async def generate_report_section_content(api_key: str, base_url: str, model_name: str, section: Dict[str, Any], max_retries: int = 2) -> str:
+async def generate_report_section_content(api_key: str, base_url: str, model_name: str, section: Dict[str, Any], chapter_num: int, total_sections: int, max_retries: int = 2) -> str:
     """
     生成报告章节内容(可以重试)
 
@@ -176,7 +176,7 @@ async def generate_report_section_content(api_key: str, base_url: str, model_nam
 
     agent = ReportSectionGeneratorAgent(api_key=api_key, base_url=base_url, model_name=model_name)
 
-    print(f"📝 开始生成报告章节:{section['title']} 内容(最多重试 {max_retries} 次)...")
+    print(f"📝 开始生成报告第 {chapter_num}章/{total_sections} 内容:{section['title']} 内容(最多重试 {max_retries} 次)...")
     section_content = ""
     for attempt in range(max_retries):
         try:
@@ -186,7 +186,7 @@ async def generate_report_section_content(api_key: str, base_url: str, model_nam
             section_content = await agent.generate_section_content(section)
             elapsed_time = time.time() - start_time
             print(f"{elapsed_time:.2f}")
-            print(f"\n📝 章节{section['title']}生成成功:")
+            print(f"\n📝 章节{section['title']} 内容生成成功:")
 
             return section_content
 

+ 5 - 1
llmops/complete_agent_flow_rule.py

@@ -353,6 +353,9 @@ class CompleteAgentFlow:
                 "metrics_detail": {}
             }
 
+            chapter_num = 0
+            total_sections = len(outline.sections)
+
             # 构建章节内容
             for section in outline.sections:
                 section_content = {
@@ -373,8 +376,9 @@ class CompleteAgentFlow:
                         else:
                             section_content["metrics"][metric_id] = "数据缺失"
 
+                chapter_num += 1
                 # 生成章节内容
-                chapter_content = await generate_report_section_content(api_key=self.api_key, base_url=self.base_url, model_name=self.model_name, section=section_content)
+                chapter_content = await generate_report_section_content(api_key=self.api_key, base_url=self.base_url, model_name=self.model_name, section=section_content, chapter_num=chapter_num, total_sections=total_sections)
                 print(f"生成章节内容:{chapter_content}")
                 section_content["content"] = chapter_content
                 final_report["sections"].append(section_content)