mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Forward missing explain_triples through RAG clients and agent tool callback (#768)
fix: forward explain_triples through RAG clients and agent tool callback - RAG clients and the KnowledgeQueryImpl tool callback were dropping explain_triples from explain events, losing provenance data (including focus edge selections) when graph-rag is invoked via the agent. Tests for provenance and explainability (56 new): - Client-level forwarding of explain_triples - Graph-RAG structural chain (question → grounding → exploration → focus → synthesis) - Graph-RAG integration with mocked subsidiary clients - Document-RAG integration (question → grounding → exploration → synthesis) - Agent-orchestrator all 3 patterns: react, plan-then-execute, supervisor
This commit is contained in:
parent
e899370d98
commit
4b5bfacab1
9 changed files with 2178 additions and 7 deletions
|
|
@ -15,7 +15,7 @@ class GraphRagClient(RequestResponse):
|
|||
user: User identifier
|
||||
collection: Collection identifier
|
||||
chunk_callback: Optional async callback(text, end_of_stream) for text chunks
|
||||
explain_callback: Optional async callback(explain_id, explain_graph) for explain notifications
|
||||
explain_callback: Optional async callback(explain_id, explain_graph, explain_triples) for explain notifications
|
||||
timeout: Request timeout in seconds
|
||||
|
||||
Returns:
|
||||
|
|
@ -30,7 +30,7 @@ class GraphRagClient(RequestResponse):
|
|||
# Handle explain notifications
|
||||
if resp.message_type == 'explain':
|
||||
if explain_callback and resp.explain_id:
|
||||
await explain_callback(resp.explain_id, resp.explain_graph)
|
||||
await explain_callback(resp.explain_id, resp.explain_graph, resp.explain_triples)
|
||||
return False # Continue receiving
|
||||
|
||||
# Handle text chunks
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class DocumentRagClient(BaseClient):
|
|||
user: User identifier
|
||||
collection: Collection identifier
|
||||
chunk_callback: Optional callback(text, end_of_stream) for text chunks
|
||||
explain_callback: Optional callback(explain_id, explain_graph) for explain notifications
|
||||
explain_callback: Optional callback(explain_id, explain_graph, explain_triples) for explain notifications
|
||||
timeout: Request timeout in seconds
|
||||
|
||||
Returns:
|
||||
|
|
@ -55,7 +55,7 @@ class DocumentRagClient(BaseClient):
|
|||
# Handle explain notifications (response is None/empty, explain_id present)
|
||||
if x.explain_id and not x.response:
|
||||
if explain_callback:
|
||||
explain_callback(x.explain_id, x.explain_graph)
|
||||
explain_callback(x.explain_id, x.explain_graph, x.explain_triples)
|
||||
return False # Continue receiving
|
||||
|
||||
# Handle text chunks
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class GraphRagClient(BaseClient):
|
|||
user: User identifier
|
||||
collection: Collection identifier
|
||||
chunk_callback: Optional callback(text, end_of_stream) for text chunks
|
||||
explain_callback: Optional callback(explain_id, explain_graph) for explain notifications
|
||||
explain_callback: Optional callback(explain_id, explain_graph, explain_triples) for explain notifications
|
||||
timeout: Request timeout in seconds
|
||||
|
||||
Returns:
|
||||
|
|
@ -59,7 +59,7 @@ class GraphRagClient(BaseClient):
|
|||
# Handle explain notifications
|
||||
if x.message_type == 'explain':
|
||||
if explain_callback and x.explain_id:
|
||||
explain_callback(x.explain_id, x.explain_graph)
|
||||
explain_callback(x.explain_id, x.explain_graph, x.explain_triples)
|
||||
return False # Continue receiving
|
||||
|
||||
# Handle text chunks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue