Skip to content

fix: skip id: lines in streaming response parsing - #481

Open
navtrade wants to merge 1 commit into
AISBench:masterfrom
navtrade:fix/skip-id-lines-in-stream-response
Open

fix: skip id: lines in streaming response parsing#481
navtrade wants to merge 1 commit into
AISBench:masterfrom
navtrade:fix/skip-id-lines-in-stream-response

Conversation

@navtrade

@navtrade navtrade commented Aug 21, 2026

Copy link
Copy Markdown

PR Type / PR类型

  • Feature(功能新增)
  • Bugfix(Bug 修复)
  • Docs(文档更新)
  • CI/CD(持续集成/持续部署)
  • Refactor(代码重构)
  • Perf(性能优化)
  • Dependency(依赖项更新)
  • Test-Cases(测试用例更新)
  • Other(其他)

Related Issue | 关联 Issue
Fixes #482

🔍 Motivation / 变更动机

问题背景:

在与某些流式 API 服务(如 OpenAI-compatible、vLLM 等)交互时,服务会返回包含元数据的流式响应
这些元数据行采用 id: xxxx 的格式,不是有效的 JSON 数据
当前代码尝试将这些行解析为 JSON,导致 json.JSONDecodeError 错误
请求因此失败

影响范围:

所有使用流式 API 的模型评估都会遇到此问题
特别是与支持流式输出的服务(OpenAI API、vLLM、Ollama 等)的集成

📝 Modification / 修改内容

  • 文件: ais_bench/benchmark/models/api_models/base_api.py
  • 方法: stream_infer (第 452-483 行)
  • 具体位置: 第 465 行后添加,新增跳过 id: xxx 行逻辑

- Add check to skip lines starting with 'id:' in stream_infer method
- This prevents JSON parsing errors when API returns metadata lines like 'id: xxx'
- Similar to existing handling for ':' (comments) and 'data:' prefix removal
@github-actions

Copy link
Copy Markdown

🚫 PR 合入质量检查未通过,PR 已被禁止合入。

未通过项:no_issueno_review

  • 未关联 Issue:请在 PR 描述中关联 Issue,例如 Fixes #123Relates to #123
  • 无检视意见:请至少邀请一位 reviewer 提交检视意见(Approve / Request changes / Comment 均可)。

请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。

@github-actions github-actions Bot added no_issue PR 未关联任何 Issue,合入前必须关联 Issue no_review PR 未包含任何检视意见,合入前必须包含检视意见 labels Aug 21, 2026
@navtrade
navtrade marked this pull request as draft August 21, 2026 08:36
@navtrade
navtrade marked this pull request as ready for review August 21, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix no_issue PR 未关联任何 Issue,合入前必须关联 Issue no_review PR 未包含任何检视意见,合入前必须包含检视意见

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 流式 API 响应中的 id: 元数据行导致 JSON 解析失败

1 participant