显示知识库统计信息
(self)
| 200 | print("✅ 检索引擎初始化完成!") |
| 201 | |
| 202 | def _show_knowledge_base_stats(self): |
| 203 | """显示知识库统计信息""" |
| 204 | print(f"\n知识库统计:") |
| 205 | |
| 206 | # 数据统计 |
| 207 | stats = self.data_module.get_statistics() |
| 208 | print(f" 疾病数量: {stats.get('total_diseases', 0)}") |
| 209 | print(f" 症状数量: {stats.get('total_symptoms', 0)}") |
| 210 | print(f" 治疗方案: {stats.get('total_treatments', 0)}") |
| 211 | print(f" 药物数量: {stats.get('total_medications', 0)}") |
| 212 | print(f" 文档数量: {stats.get('total_documents', 0)}") |
| 213 | print(f" 文本块数: {stats.get('total_chunks', 0)}") |
| 214 | |
| 215 | # Milvus统计 |
| 216 | milvus_stats = self.index_module.get_collection_stats() |
| 217 | print(f" 向量索引: {milvus_stats.get('row_count', 0)} 条记录") |
| 218 | |
| 219 | # 图RAG统计 |
| 220 | route_stats = self.query_router.get_route_statistics() |
| 221 | print(f" 路由统计: 总查询 {route_stats.get('total_queries', 0)} 次") |
| 222 | |
| 223 | if stats.get('categories'): |
| 224 | categories = list(stats['categories'].keys())[:10] |
| 225 | print(f" 🏷️ 主要疾病分类: {', '.join(categories)}") |
| 226 | if stats.get('severity_distribution'): |
| 227 | severities = list(stats['severity_distribution'].items()) |
| 228 | top_severities = ', '.join(f"{k}:{v}" for k, v in severities[:5]) |
| 229 | if top_severities: |
| 230 | print(f" ⚕️ 严重程度分布: {top_severities}") |
| 231 | |
| 232 | def ask_question_with_routing(self, question: str, stream: bool = False, explain_routing: bool = False): |
| 233 | """ |
no test coverage detected