mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-24 12:16:14 +00:00
fix: minor graph rag improvements
This commit is contained in:
1 parent
ae3e79bf8f
commit
d7bbfcfe17
24 files changed
+1048
-277
No files matched your search
@@ -1153,10 +1153,14 @@ class EnableSourceGraphRAG(Resource):
|
||||
return make_response(jsonify({"success": False}), 400)
|
||||
try:
|
||||
from application.worker import (
|
||||
_reset_graph_for_source,
|
||||
_source_updated_at,
|
||||
graph_extraction_key,
|
||||
)
|
||||
|
||||
# Drop any prior graph so each enable rebuilds from scratch rather
|
||||
# than no-opping against an already-``done`` checkpoint.
|
||||
_reset_graph_for_source(resolved_source_id)
|
||||
task = extract_graph.delay(
|
||||
resolved_source_id,
|
||||
owner,
|
||||
|
||||
@@ -137,8 +137,31 @@ def convert_source_to_wiki(self, source_id, user, idempotency_key=None):
|
||||
return resp
|
||||
|
||||
|
||||
def _emit_graph_poison_event(task_name, bound):
|
||||
"""Publish a terminal ``graph.extract.failed`` when the poison-guard trips.
|
||||
|
||||
The guard returns before the worker runs, so the worker's own failed event
|
||||
never fires — without this the build UI spins forever.
|
||||
"""
|
||||
user = bound.get("user")
|
||||
source_id = bound.get("source_id")
|
||||
if not user or not source_id:
|
||||
return
|
||||
from application.events.publisher import publish_user_event
|
||||
|
||||
publish_user_event(
|
||||
user,
|
||||
"graph.extract.failed",
|
||||
{
|
||||
"source_id": str(source_id),
|
||||
"error": "Graph extraction stopped after repeated failures.",
|
||||
},
|
||||
scope={"kind": "source", "id": str(source_id)},
|
||||
)
|
||||
|
||||
|
||||
@celery.task(**DURABLE_TASK)
|
||||
@with_idempotency(task_name="extract_graph")
|
||||
@with_idempotency(task_name="extract_graph", on_poison=_emit_graph_poison_event)
|
||||
def extract_graph(self, source_id, user, idempotency_key=None):
|
||||
from application.worker import extract_graph_worker
|
||||
|
||||
|
||||
Reference in new issue
Block a user