feat: add response_id from API response to prediction results#401
feat: add response_id from API response to prediction results#401xuchi-0808 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a response_id field to track API response identifiers across text and stream responses. It updates the Output class, the VLLM custom API models, and the output handler to capture and propagate this ID. The feedback suggests using getattr to retrieve response_id in the output handler, which provides a more robust and Pythonic approach by avoiding explicit type checks and potential attribute errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "response_id": ( | ||
| output.response_id if isinstance(output, Output) and output.response_id else "" | ||
| ), |
There was a problem hiding this comment.
Using getattr(output, "response_id", "") is a more robust and Pythonic way to retrieve the response_id attribute. It avoids potential AttributeError if output is a mock object or a custom subclass that does not have the response_id attribute initialized, and it eliminates the need for explicit type checking since getattr safely handles any object type (including str).
"response_id": getattr(output, "response_id", ""),bb8a0b8 to
59dd8ac
Compare
Parse the 'id' field (e.g. chatcmpl-xxx) from OpenAI-compatible API responses in VLLMCustomAPIChat and VLLMCustomAPI, store it in the Output object, and include it in the generated prediction JSONL files under the predictions/ directory. The response_id helps trace inference results back to specific API calls for debugging and audit purposes. Signed-off-by: xuchi-0808 <xuchi0808@gmail.com> Signed-off-by: xuchi <xuchicolson@163.com>
59dd8ac to
214c702
Compare
Summary
Add the
idfield from OpenAI-compatible API responses (e.g.,chatcmpl-xxxfrom/v1/chat/completions) to the prediction result JSONL files.Currently, AISBench discards the
idfield from API responses. This PR captures it and stores it asresponse_idin the prediction output, making it possible to trace inference results back to specific API calls.Changes
response_idfield toOutputclassidfrom/v1/chat/completionsresponses (both text and stream modes)idfrom/v1/completionsresponses (both text and stream modes)response_idin the prediction result dict written topredictions/{dataset}.jsonlExample output
Each line in
predictions/{model_abbr}/{dataset_abbr}.jsonlwill now include:{ "success": true, "uuid": "abc12345", "response_id": "chatcmpl-9a8b7c6d5e", "origin_prompt": "...", "prediction": "...", "gold": "..." }Design notes
idis captured from the first SSE chunk and preservedresponse_idfield defaults to empty string when not available (backward compatible)/v1/chat/completions) and legacy completion API (/v1/completions) are covered