Spaces:
Paused
Paused
lanny xu
commited on
Commit
·
67b4685
1
Parent(s):
399f3c6
resolve conflict
Browse files- graph_indexer.py +6 -3
- workflow_nodes.py +4 -1
graph_indexer.py
CHANGED
|
@@ -3,8 +3,11 @@ GraphRAG索引器
|
|
| 3 |
负责构建层次化的知识图谱索引,包括实体提取、图谱构建、社区检测和摘要生成
|
| 4 |
"""
|
| 5 |
|
| 6 |
-
from typing import List, Dict
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
from entity_extractor import EntityExtractor, EntityDeduplicator
|
| 10 |
from knowledge_graph import KnowledgeGraph, CommunitySummarizer
|
|
@@ -27,7 +30,7 @@ class GraphRAGIndexer:
|
|
| 27 |
|
| 28 |
def index_documents(self, documents: List[Document],
|
| 29 |
batch_size: int = 10,
|
| 30 |
-
save_path: str = None) -> KnowledgeGraph:
|
| 31 |
"""
|
| 32 |
对文档集合建立GraphRAG索引
|
| 33 |
|
|
|
|
| 3 |
负责构建层次化的知识图谱索引,包括实体提取、图谱构建、社区检测和摘要生成
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
from typing import List, Dict, Optional
|
| 7 |
+
try:
|
| 8 |
+
from langchain_core.documents import Document
|
| 9 |
+
except ImportError:
|
| 10 |
+
from langchain.schema import Document
|
| 11 |
|
| 12 |
from entity_extractor import EntityExtractor, EntityDeduplicator
|
| 13 |
from knowledge_graph import KnowledgeGraph, CommunitySummarizer
|
|
|
|
| 30 |
|
| 31 |
def index_documents(self, documents: List[Document],
|
| 32 |
batch_size: int = 10,
|
| 33 |
+
save_path: Optional[str] = None) -> KnowledgeGraph:
|
| 34 |
"""
|
| 35 |
对文档集合建立GraphRAG索引
|
| 36 |
|
workflow_nodes.py
CHANGED
|
@@ -5,7 +5,10 @@
|
|
| 5 |
|
| 6 |
from typing import List
|
| 7 |
from typing_extensions import TypedDict
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
from langchain_community.chat_models import ChatOllama
|
| 10 |
from langchain_core.output_parsers import StrOutputParser
|
| 11 |
from langchain_community.tools.tavily_search import TavilySearchResults
|
|
|
|
| 5 |
|
| 6 |
from typing import List
|
| 7 |
from typing_extensions import TypedDict
|
| 8 |
+
try:
|
| 9 |
+
from langchain_core.documents import Document
|
| 10 |
+
except ImportError:
|
| 11 |
+
from langchain.schema import Document
|
| 12 |
from langchain_community.chat_models import ChatOllama
|
| 13 |
from langchain_core.output_parsers import StrOutputParser
|
| 14 |
from langchain_community.tools.tavily_search import TavilySearchResults
|