bosprimigenious opened a new pull request, #411:
URL: https://github.com/apache/hugegraph-ai/pull/411

   Closes #347.
   
   ## What
   
   `/rag` returns only the requested answer fields, so retrieval debugging 
needs log parsing even though the graph flow already computes the intermediates 
that `/rag/graph` exposes. This adds an **opt-in** `trace` to `/rag` and leaves 
the default response unchanged.
   
   ## How
   
   - `RAGRequest.include_trace: bool = False` (opt-in, default false).
   - `rag_answer()` gained `include_trace: bool = False`. When true it returns 
the trace dict as a fifth element; when false it returns the same four-tuple as 
before, so the Gradio callers and existing callers are untouched.
   - The trace reuses the `/rag/graph` field names: `keywords`, `match_vids`, 
`graph_result_flag`, `gremlin`, `graph_result`, `vertex_degree_list`. Only 
fields present in the flow state are emitted.
   - `/rag` attaches it as `"trace"` and keeps the output-flag filtering for 
the answer fields.
   
   ```json
   {
     "query": "...",
     "graph_only": "...",
     "trace": {"keywords": [...], "match_vids": [...], "gremlin": "...", 
"graph_result": [...], ...}
   }
   ```
   
   ## Scope
   
   Vector recall and rerank traces are intentionally left out, per the issue's 
suggested first version. This does not change `/rag/graph`, the graph flow 
contract, or default responses.
   
   ## Tests
   
   `src/tests/api/test_rag_api.py`:
   
   - `test_rag_default_response_has_no_trace_field` — default response keeps 
its old shape.
   - `test_rag_include_trace_returns_graph_recall_fields` — 
`include_trace=true` returns the trace under `"trace"`, keeps the answer-field 
filtering, and passes the flag through to the callback.
   
   ```
   $ pytest src/tests/api/test_rag_api.py -q
   21 passed
   ```
   
   (Environment note: run with proxy env vars unset; the sandbox's `NO_PROXY` 
entry `[::1]` makes httpx raise `InvalidURL` at import time.)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to