初始化高级图RAG系统
(self)
| 59 | self.system_ready = False |
| 60 | |
| 61 | def initialize_system(self): |
| 62 | """初始化高级图RAG系统""" |
| 63 | logger.info("启动高级图RAG系统...") |
| 64 | |
| 65 | try: |
| 66 | # 1. 数据准备模块 |
| 67 | print("初始化数据准备模块...") |
| 68 | self.data_module = GraphDataPreparationModule( |
| 69 | uri=self.config.neo4j_uri, |
| 70 | user=self.config.neo4j_user, |
| 71 | password=self.config.neo4j_password, |
| 72 | database=self.config.neo4j_database |
| 73 | ) |
| 74 | |
| 75 | # 2. 向量索引模块 |
| 76 | print("初始化Milvus向量索引...") |
| 77 | self.index_module = MilvusIndexConstructionModule( |
| 78 | host=self.config.milvus_host, |
| 79 | port=self.config.milvus_port, |
| 80 | collection_name=self.config.milvus_collection_name, |
| 81 | dimension=self.config.milvus_dimension, |
| 82 | model_name=self.config.embedding_model |
| 83 | ) |
| 84 | |
| 85 | # 3. 生成模块 |
| 86 | print("初始化生成模块...") |
| 87 | self.generation_module = GenerationIntegrationModule( |
| 88 | model_name=self.config.llm_model, |
| 89 | temperature=self.config.temperature, |
| 90 | max_tokens=self.config.max_tokens |
| 91 | ) |
| 92 | |
| 93 | # 4. 传统混合检索模块 |
| 94 | print("初始化传统混合检索...") |
| 95 | self.traditional_retrieval = HybridRetrievalModule( |
| 96 | config=self.config, |
| 97 | milvus_module=self.index_module, |
| 98 | data_module=self.data_module, |
| 99 | llm_client=self.generation_module.client |
| 100 | ) |
| 101 | |
| 102 | # 5. 图RAG检索模块 |
| 103 | print("初始化图RAG检索引擎...") |
| 104 | self.graph_rag_retrieval = GraphRAGRetrieval( |
| 105 | config=self.config, |
| 106 | llm_client=self.generation_module.client |
| 107 | ) |
| 108 | |
| 109 | # 6. 智能查询路由器 |
| 110 | print("初始化智能查询路由器...") |
| 111 | self.query_router = IntelligentQueryRouter( |
| 112 | traditional_retrieval=self.traditional_retrieval, |
| 113 | graph_rag_retrieval=self.graph_rag_retrieval, |
| 114 | llm_client=self.generation_module.client, |
| 115 | config=self.config |
| 116 | ) |
| 117 | |
| 118 | print("✅ 高级图RAG系统初始化完成!") |
no test coverage detected