mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-08 12:30:14 +00:00
✨ feat(GraphRAG): enhance GraphRAG by graph community summary (#1801)
Co-authored-by: Florian <fanzhidongyzby@163.com> Co-authored-by: KingSkyLi <15566300566@163.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: yvonneyx <zhuyuxin0627@gmail.com>
This commit is contained in:
@@ -112,13 +112,15 @@ def arguments(space_id: str):
|
||||
|
||||
|
||||
@router.post("/knowledge/{space_name}/recall_test")
|
||||
def recall_test(
|
||||
async def recall_test(
|
||||
space_name: str,
|
||||
request: DocumentRecallTestRequest,
|
||||
):
|
||||
print(f"/knowledge/{space_name}/recall_test params:")
|
||||
try:
|
||||
return Result.succ(knowledge_space_service.recall_test(space_name, request))
|
||||
return Result.succ(
|
||||
await knowledge_space_service.recall_test(space_name, request)
|
||||
)
|
||||
except Exception as e:
|
||||
return Result.failed(code="E000X", msg=f"{space_name} recall_test error {e}")
|
||||
|
||||
|
@@ -309,7 +309,7 @@ class KnowledgeService:
|
||||
"""
|
||||
return knowledge_space_dao.get_knowledge_space_by_ids(ids)
|
||||
|
||||
def recall_test(
|
||||
async def recall_test(
|
||||
self, space_name, doc_recall_test_request: DocumentRecallTestRequest
|
||||
):
|
||||
logger.info(f"recall_test {space_name}, {doc_recall_test_request}")
|
||||
@@ -338,7 +338,7 @@ class KnowledgeService:
|
||||
knowledge_space_retriever = KnowledgeSpaceRetriever(
|
||||
space_id=space.id, top_k=top_k
|
||||
)
|
||||
chunks = knowledge_space_retriever.retrieve_with_scores(
|
||||
chunks = await knowledge_space_retriever.aretrieve_with_scores(
|
||||
question, score_threshold
|
||||
)
|
||||
retrievers_end_time = timeit.default_timer()
|
||||
@@ -646,13 +646,16 @@ class KnowledgeService:
|
||||
graph = vector_store_connector.client.query_graph(limit=limit)
|
||||
res = {"nodes": [], "edges": []}
|
||||
for node in graph.vertices():
|
||||
res["nodes"].append({"vid": node.vid})
|
||||
for edge in graph.edges():
|
||||
res["edges"].append(
|
||||
res["nodes"].append(
|
||||
{
|
||||
"src": edge.sid,
|
||||
"dst": edge.tid,
|
||||
"label": edge.props[graph.edge_label],
|
||||
"id": node.vid,
|
||||
"communityId": node.get_prop("_community_id"),
|
||||
"name": node.vid,
|
||||
"type": "",
|
||||
}
|
||||
)
|
||||
for edge in graph.edges():
|
||||
res["edges"].append(
|
||||
{"source": edge.sid, "target": edge.tid, "name": edge.name, "type": ""}
|
||||
)
|
||||
return res
|
||||
|
Reference in New Issue
Block a user