RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Introduced delete_knowledge_graph (#6605)
Zhichang Yufe0396bbb9de
diff --git a/api/apps/kb_app.py b/api/apps/kb_app.pyindex 35e80b5e64..58fdd44b0d 100644--- a/api/apps/kb_app.py+++ b/api/apps/kb_app.py@@ -322,4 +322,18 @@ def knowledge_graph(kb_id):node_id_set = { o["id"] for o in obj["graph"]["nodes"] }filtered_edges = [o for o in obj["graph"]["edges"] if o["source"] != o["target"] and o["source"] in node_id_set and o["target"] in node_id_set]obj["graph"]["edges"] = sorted(filtered_edges, key=lambda x: x.get("weight", 0), reverse=True)[:128]- return get_json_result(data=obj)\ No newline at end of file+ return get_json_result(data=obj)+[email protected]('/<kb_id>/knowledge_graph', methods=['DELETE']) # noqa: F821+@login_required+def delete_knowledge_graph(kb_id):+ if not KnowledgebaseService.accessible(kb_id, current_user.id):+ return get_json_result(+ data=False,+ message='No authorization.',+ code=settings.RetCode.AUTHENTICATION_ERROR+ )+ _, kb = KnowledgebaseService.get_by_id(kb_id)+ settings.docStoreConn.delete({"knowledge_graph_kwd": ["graph", "subgraph", "entity", "relation"]}, search.index_name(kb.tenant_id), kb_id)++ return get_json_result(data=True)diff --git a/graphrag/utils.py b/graphrag/utils.pyindex 8ed3890eae..d370d0a25a 100644--- a/graphrag/utils.py+++ b/graphrag/utils.py@@ -466,8 +466,6 @@ async def set_graph(tenant_id: str, kb_id: str, embd_mdl, graph: nx.Graph, changcallback(msg=f"set_graph converted graph change to {len(chunks)} chunks in {now - start:.2f}s.")start = now- await trio.to_thread.run_sync(lambda: settings.docStoreConn.delete({"knowledge_graph_kwd": ["graph", "entity", "relation"]}, search.index_name(tenant_id), kb_id))-es_bulk_size = 4for b in range(0, len(chunks), es_bulk_size):doc_store_result = await trio.to_thread.run_sync(lambda: settings.docStoreConn.insert(chunks[b:b + es_bulk_size], search.index_name(tenant_id), kb_id))