feat:rag_graph

This commit is contained in:
aries_ckt 2023-10-19 12:02:27 +08:00
parent aff0553b7e
commit 39219a4fdc
2 changed files with 12 additions and 6 deletions

View File

@ -129,6 +129,11 @@ class RAGGraphEngine:
) )
result = [future.result() for future in future_tasks] result = [future.result() for future in future_tasks]
# for triplet in triplets:
# subj, _, obj = triplet
# self.graph_store.upsert_triplet(*triplet)
# self.graph_store.upsert_triplet(*triplet)
# index_struct.add_node([subj, obj], text_node)
return index_struct return index_struct
# for doc in documents: # for doc in documents:
# triplets = self._extract_triplets(doc.page_content) # triplets = self._extract_triplets(doc.page_content)
@ -162,8 +167,9 @@ class RAGGraphEngine:
print( print(
f"current thread-{thread_id} end extract triplets tasks, triplets-{triplets}" f"current thread-{thread_id} end extract triplets tasks, triplets-{triplets}"
) )
for triplet in triplets: return triplets
subj, _, obj = triplet # for triplet in triplets:
self.graph_store.upsert_triplet(*triplet) # subj, _, obj = triplet
self.graph_store.upsert_triplet(*triplet) # self.graph_store.upsert_triplet(*triplet)
index_struct.add_node([subj, obj], text_node) # self.graph_store.upsert_triplet(*triplet)
# index_struct.add_node([subj, obj], text_node)

View File

@ -145,7 +145,7 @@ class RAGGraphSearch(BaseSearch):
if len(sorted_nodes_with_scores) == 0: if len(sorted_nodes_with_scores) == 0:
logger.info("> No nodes found by keywords, returning empty response.") logger.info("> No nodes found by keywords, returning empty response.")
return [ return [
NodeWithScore(node=TextNode(text="No relationships found."), score=1.0) Document(page_content="No relationships found.")
] ]
# add relationships as Node # add relationships as Node