Spaces:
Paused
Paused
lanny xu
commited on
Commit
·
67e46c9
1
Parent(s):
3d13055
add cuda
Browse files- main_graphrag.py +10 -0
main_graphrag.py
CHANGED
|
@@ -70,6 +70,16 @@ class AdaptiveRAGWithGraph:
|
|
| 70 |
else:
|
| 71 |
print("📝 首次构建索引...")
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
# 构建索引
|
| 74 |
self.knowledge_graph = self.graph_indexer.index_documents(
|
| 75 |
documents=self.doc_splits,
|
|
|
|
| 70 |
else:
|
| 71 |
print("📝 首次构建索引...")
|
| 72 |
|
| 73 |
+
# 当持久化向量库已加载时,doc_splits 可能为 None;为 GraphRAG 索引补齐文档块
|
| 74 |
+
if self.doc_splits is None:
|
| 75 |
+
print(" ℹ️ 未提供文档块,重新加载默认数据源以供GraphRAG索引...")
|
| 76 |
+
try:
|
| 77 |
+
docs = self.doc_processor.load_documents()
|
| 78 |
+
self.doc_splits = self.doc_processor.split_documents(docs)
|
| 79 |
+
except Exception as e:
|
| 80 |
+
print(f" ❌ 重新加载文档失败: {e}")
|
| 81 |
+
raise
|
| 82 |
+
|
| 83 |
# 构建索引
|
| 84 |
self.knowledge_graph = self.graph_indexer.index_documents(
|
| 85 |
documents=self.doc_splits,
|