Browse Source

Merge branch 'dev_sgsc_wxm' of CRBC-MaaS-Platform-Project/LQAgentPlatform into dev

WangXuMing 3 weeks ago
parent
commit
7fcab5d0d7

+ 1 - 11
core/construction_review/component/reviewers/completeness_reviewer.py

@@ -695,15 +695,6 @@ class LightweightCompletenessChecker:
                     missing_labels.append(f"等共{n}项")
                 missing_str = "、".join(missing_labels)
 
-                # 全量要求列表(用于 reason,最多展示 8 条)
-                all_labels = [
-                    f"{i + 1}.{self.tertiary_specs[k].third_cn}"
-                    for i, k in enumerate(all_required_keys[:8])
-                ]
-                if len(all_required_keys) > 8:
-                    all_labels.append(f"等共{len(all_required_keys)}项")
-                all_str = "、".join(all_labels)
-
                 recommendations.append({
                     "level": "三级",
                     "issue_point": (
@@ -714,8 +705,7 @@ class LightweightCompletenessChecker:
                         f"请补充'{second_name}'以下{n}个要点内容:{missing_str}"
                     ),
                     "reason": (
-                        f"根据规范要求,'{second_name}'应包含:{all_str}。"
-                        f"当前缺失:{missing_str}"
+                        f"'{second_name}'下缺失以下{n}个规范要求的内容要点:{missing_str}"
                     ),
                 })
 

+ 13 - 12
core/construction_review/component/reviewers/utils/llm_content_classifier_v2.py

@@ -1202,7 +1202,7 @@ class ContentClassifierClient:
                     # 验证分类代码是否在有效列表中
                     valid_codes = set(v[1] for v in index_mapping.values())
                     if category_code not in valid_codes:
-                        print(f"    警告: 发现非标准分类 '{category_name}' ({category_code}),强制归为非标准项")
+                        logger.warning(f"发现非标准分类 '{category_name}' ({category_code}),强制归为非标准项")
                         category_code = "no_standard"
                         category_name = "非标准项"
 
@@ -1251,7 +1251,7 @@ class ContentClassifierClient:
                         category_name = item.get("third_category_name", "")
                         valid_codes = set(v[1] for v in index_mapping.values())
                         if category_code not in valid_codes:
-                            print(f"    警告: 发现非标准分类 '{category_name}' ({category_code}),强制归为非标准项")
+                            logger.warning(f"发现非标准分类 '{category_name}' ({category_code}),强制归为非标准项")
                             category_code = "no_standard"
                             category_name = "非标准项"
 
@@ -1268,10 +1268,9 @@ class ContentClassifierClient:
                 contents = self._merge_classified_contents(contents, section)
                 return contents, True  # 解析成功(可能为空结果)
             except Exception as e2:
-                error_msg = f"解析JSON失败: {e}, 二次修复也失败: {e2}"
-                print(error_msg)
-                print(f"原始响应前500字符: {response[:500]}...")
-                print(f"提取的JSON前300字符: {json_str[:300]}...")
+                logger.error(f"解析JSON失败: {e}, 二次修复也失败: {e2}")
+                logger.debug(f"原始响应前500字符: {response[:500]}...")
+                logger.debug(f"提取的JSON前300字符: {json_str[:300]}...")
                 return [], False  # 解析失败
 
     def _merge_classified_contents(self, contents: List[ClassifiedContent], section: SectionContent) -> List[ClassifiedContent]:
@@ -1786,14 +1785,14 @@ class LLMContentClassifier:
                 - tertiary_category_cn: 三级分类名称
                 - tertiary_classification_details: 行级分类详情列表
         """
-        print(f"\n正在对 {len(chunks)} 个内容块进行三级分类...")
+        logger.info(f"正在对 {len(chunks)} 个内容块进行三级分类...")
 
         # 步骤1: 将 chunks 转换为 SectionContent 列表
         sections = self.converter.chunks_to_sections(chunks)
-        print(f"  按二级标题分组后得到 {len(sections)} 个段落")
+        logger.info(f"按二级标题分组后得到 {len(sections)} 个段落")
 
         if not sections:
-            print("  没有有效的段落需要分类")
+            logger.info("没有有效的段落需要分类")
             return chunks
 
         # 步骤2: 创建分类客户端
@@ -1812,10 +1811,12 @@ class LLMContentClassifier:
             results_map[section.section_key] = result
 
             if progress_callback:
-                progress_callback(idx + 1, total)
+                ret = progress_callback(idx + 1, total, section.section_name, not result.error)
+                if asyncio.iscoroutine(ret):
+                    await ret
             else:
                 status = "成功" if not result.error else f"失败: {result.error[:30]}"
-                print(f"  [{idx + 1}/{total}] {section.section_name}: {status}")
+                logger.debug(f"[{idx + 1}/{total}] {section.section_name}: {status}")
 
             return result
 
@@ -1890,7 +1891,7 @@ class LLMContentClassifier:
 
             updated_chunks.append(updated_chunk)
 
-        print(f"  三级分类完成!共处理 {len(updated_chunks)} 个 chunks")
+        logger.info(f"三级分类完成!共处理 {len(updated_chunks)} 个 chunks")
         return updated_chunks