Kaynağa Gözat

v0.0.5-功能优化-兼容原数据响应格式

WangXuMing 1 ay önce
ebeveyn
işleme
18bada228d

+ 2 - 1
core/base/workflow_manager.py

@@ -411,7 +411,7 @@ class WorkflowManager:
             logger.error(f"获取任务信息失败: {str(e)}", exc_info=True)
             return None
 
-    # ==================== LangGraph 任务链工作流(方案D)====================
+
 
     def _build_task_chain_workflow(self) -> StateGraph:
         """
@@ -894,6 +894,7 @@ class WorkflowManager:
                 "stage_status": state["stage_status"],
                 "document_result": state.get("document_result"),
                 "ai_review_result": state.get("ai_review_result"),
+                "issues": state.get("ai_review_result").get("review_results"),
                 "report_result": report_result,
                 "timestamp": datetime.now().isoformat()
             }

+ 24 - 3
core/construction_review/workflows/ai_review_workflow.py

@@ -313,10 +313,31 @@ class AIReviewWorkflow:
             # 根据标准配置对review_item_config进行排序
             review_item_dict_sorted = self.core_fun._check_item_mapping_order(review_item_config)
             logger.info(f"审查项配置解析完成: {review_item_dict_sorted}")
-
+            outline_content_list = []
             # 3️ 获取结构化内容
             original_chunks = state.get("structured_content", {}).get("chunks", [])
             original_outline = state.get("structured_content", {}).get("outline", [])["chapters"]
+
+            def extract_original_recursive(content):
+                """递归提取 original 字段,包括主目录和所有子目录"""
+                result = []
+                if isinstance(content, dict):
+                    # 提取当前层级的 original
+                    if "original" in content:
+                        result.append(content["original"])
+                    # 递归提取 subsections
+                    if "subsections" in content and isinstance(content["subsections"], list):
+                        for subsection in content["subsections"]:
+                            result.extend(extract_original_recursive(subsection))
+                return result
+
+            for content in original_outline:
+                # 递归提取主目录和子目录的 original 字段
+                originals = extract_original_recursive(content)
+                outline_content_list.extend(originals)
+
+            # 4. 最终拼接成字符串(列表join效率远高于str+=)
+            outline_content_str = "".join(outline_content_list)
             # with open(r"temp/document_temp/original_outline.json", "w", encoding="utf-8") as f:
             #     json.dump(original_outline, f, ensure_ascii=False, indent=2)
             logger.info(f"开始目录审查")
@@ -381,7 +402,7 @@ class AIReviewWorkflow:
             catalogue = [{
                     "chunk_id": "outline_1",
                     "page": 1,
-                    "content": "full_content",
+                    "content": outline_content_str,
                     "section_label": "目录",
                     "project_plan_type": "catalogue",
                     "chapter_classification": "catalogue",
@@ -392,7 +413,7 @@ class AIReviewWorkflow:
                     },
                     "chapter": "目录",
                     "title": "目录",
-                    "original_content": "full_content",
+                    "original_content": outline_content_str,
                     "is_complete_field": True
                 }
             ]