Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ais_bench/benchmark/models/api_models/vllm_custom_api_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ async def parse_stream_response(self, json_content, output):
for item in json_content.get("choices", []):
if item["delta"].get("content"):
output.content += item["delta"]["content"]
if item["delta"].get("reasoning_content"):
output.reasoning_content += item["delta"]["reasoning_content"]
if reasoning := item["delta"].get("reasoning_content") or item["delta"].get("reasoning"):
output.reasoning_content += reasoning
Comment on lines +144 to +145
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The addition of the or item["delta"].get("reasoning") fallback is a good improvement for robustness. Please consider adding a unit test case in tests/UT/models/api_models/test_vllm_custom_api_chat.py to specifically verify that the reasoning field is correctly parsed when reasoning_content is absent in the API response. This ensures full coverage of the new logic.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

【review】添加 or item["delta"].get("reasoning") 回退机制可以有效提高健壮性。请考虑在 tests/UT/models/api_models/test_vllm_custom_api_chat.py 中添加一个单元测试用例,专门验证当 API 响应中缺少 reasoning_content 时,reasoning 字段是否能被正确解析。这将确保新逻辑得到全面覆盖。

await self._parse_usage(json_content, output)

async def parse_text_response(self, json_content, output):
for item in json_content.get("choices", []):
if content:=item["message"].get("content"):
output.content += content
if reasoning_content:=item["message"].get("reasoning_content"):
if reasoning_content:=item["message"].get("reasoning_content") or item["message"].get("reasoning"):
output.reasoning_content += reasoning_content
await self._parse_usage(json_content, output)
output.update_extra_details_data_from_text_response(json_content)
Expand Down
Loading