马一丁

Build query params from chapter_targets instead of TemplateSection

@@ -651,12 +651,20 @@ class ReportAgent: @@ -651,12 +651,20 @@ class ReportAgent:
651 if graphrag_enabled and knowledge_graph and graphrag_query_node: 651 if graphrag_enabled and knowledge_graph and graphrag_query_node:
652 try: 652 try:
653 max_queries = getattr(self.config, 'GRAPHRAG_MAX_QUERIES', 3) 653 max_queries = getattr(self.config, 'GRAPHRAG_MAX_QUERIES', 3)
  654 + chapter_meta = chapter_targets.get(section.chapter_id, {}) if isinstance(chapter_targets, dict) else {}
  655 + emphasis_value = chapter_meta.get('emphasis') or chapter_meta.get('emphasisPoints') or ''
  656 + if isinstance(emphasis_value, list):
  657 + emphasis_value = ';'.join(str(item) for item in emphasis_value if item)
  658 + role_text = getattr(section, 'description', None) or chapter_meta.get('rationale') or ''
  659 + if not isinstance(role_text, str):
  660 + role_text = self._stringify(role_text)
  661 +
654 section_info = { 662 section_info = {
655 'title': section.title, 663 'title': section.title,
656 'id': section.chapter_id, 664 'id': section.chapter_id,
657 - 'role': section.description,  
658 - 'target_words': chapter_targets.get(section.chapter_id, {}).get('targetWords', 500),  
659 - 'emphasis': chapter_targets.get(section.chapter_id, {}).get('emphasisPoints', '') 665 + 'role': role_text,
  666 + 'target_words': chapter_meta.get('targetWords', 500),
  667 + 'emphasis': emphasis_value
660 } 668 }
661 669
662 graph_results = graphrag_query_node.run( 670 graph_results = graphrag_query_node.run(