Maintain respect for GraphRAG configuration files in .env files
Showing
1 changed file
with
39 additions
and
39 deletions
| @@ -151,47 +151,47 @@ class GraphRAGQueryNode(BaseNode): | @@ -151,47 +151,47 @@ class GraphRAGQueryNode(BaseNode): | ||
| 151 | break | 151 | break |
| 152 | 152 | ||
| 153 | # 4. 执行查询 | 153 | # 4. 执行查询 |
| 154 | - params = QueryParams( | ||
| 155 | - keywords=decision.get('keywords', []), | ||
| 156 | - node_types=decision.get('node_types'), | ||
| 157 | - engine_filter=decision.get('engine_filter'), | ||
| 158 | - depth=decision.get('depth', 1) | ||
| 159 | - ) | ||
| 160 | - params_dict = { | ||
| 161 | - 'keywords': params.keywords, | ||
| 162 | - 'node_types': params.node_types, | ||
| 163 | - 'engine_filter': params.engine_filter, | ||
| 164 | - 'depth': params.depth, | ||
| 165 | - } | 154 | + params = QueryParams( |
| 155 | + keywords=decision.get('keywords', []), | ||
| 156 | + node_types=decision.get('node_types'), | ||
| 157 | + engine_filter=decision.get('engine_filter'), | ||
| 158 | + depth=decision.get('depth', 1) | ||
| 159 | + ) | ||
| 160 | + params_dict = { | ||
| 161 | + 'keywords': params.keywords, | ||
| 162 | + 'node_types': params.node_types, | ||
| 163 | + 'engine_filter': params.engine_filter, | ||
| 164 | + 'depth': params.depth, | ||
| 165 | + } | ||
| 166 | 166 | ||
| 167 | - result = query_engine.query(params) | ||
| 168 | - all_results.append(result) | ||
| 169 | - | ||
| 170 | - self.log_info(f"查询返回 {result.total_nodes} 个节点") | ||
| 171 | - try: | ||
| 172 | - append_knowledge_log( | ||
| 173 | - "GRAPH_QUERY_NODE", | ||
| 174 | - { | ||
| 175 | - "chapter_id": chapter_id or "", | ||
| 176 | - "chapter_title": chapter_title, | ||
| 177 | - "round": round_idx + 1, | ||
| 178 | - "params": params_dict, | ||
| 179 | - "result_counts": { | ||
| 180 | - "matched_sections": len(result.matched_sections), | ||
| 181 | - "matched_queries": len(result.matched_queries), | ||
| 182 | - "matched_sources": len(result.matched_sources), | ||
| 183 | - "total_nodes": result.total_nodes, | ||
| 184 | - }, | ||
| 185 | - "matched_sections": compact_records(result.matched_sections[:5]), | ||
| 186 | - "matched_queries": compact_records(result.matched_queries[:5]), | ||
| 187 | - "matched_sources": compact_records(result.matched_sources[:5]), | 167 | + result = query_engine.query(params) |
| 168 | + all_results.append(result) | ||
| 169 | + | ||
| 170 | + self.log_info(f"查询返回 {result.total_nodes} 个节点") | ||
| 171 | + try: | ||
| 172 | + append_knowledge_log( | ||
| 173 | + "GRAPH_QUERY_NODE", | ||
| 174 | + { | ||
| 175 | + "chapter_id": chapter_id or "", | ||
| 176 | + "chapter_title": chapter_title, | ||
| 177 | + "round": round_idx + 1, | ||
| 178 | + "params": params_dict, | ||
| 179 | + "result_counts": { | ||
| 180 | + "matched_sections": len(result.matched_sections), | ||
| 181 | + "matched_queries": len(result.matched_queries), | ||
| 182 | + "matched_sources": len(result.matched_sources), | ||
| 183 | + "total_nodes": result.total_nodes, | ||
| 188 | }, | 184 | }, |
| 189 | - ) | ||
| 190 | - except Exception as log_exc: # pragma: no cover - 日志失败不阻塞流程 | ||
| 191 | - logger.warning(f"Knowledge Query: GraphRAG 节点写日志失败: {log_exc}") | ||
| 192 | - | ||
| 193 | - # 5. 记录历史 | ||
| 194 | - history.add(decision, result) | 185 | + "matched_sections": compact_records(result.matched_sections[:5]), |
| 186 | + "matched_queries": compact_records(result.matched_queries[:5]), | ||
| 187 | + "matched_sources": compact_records(result.matched_sources[:5]), | ||
| 188 | + }, | ||
| 189 | + ) | ||
| 190 | + except Exception as log_exc: # pragma: no cover - 日志失败不阻塞流程 | ||
| 191 | + logger.warning(f"Knowledge Query: GraphRAG 节点写日志失败: {log_exc}") | ||
| 192 | + | ||
| 193 | + # 5. 记录历史 | ||
| 194 | + history.add(decision, result) | ||
| 195 | 195 | ||
| 196 | # 6. 合并所有结果 | 196 | # 6. 合并所有结果 |
| 197 | merged = self._merge_results(all_results) | 197 | merged = self._merge_results(all_results) |
-
Please register or login to post a comment