fix: skip id: lines in streaming response parsing - #481
Open
navtrade wants to merge 1 commit into
Open
Conversation
- 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
|
🚫 PR 合入质量检查未通过,PR 已被禁止合入。 未通过项:
请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。 |
navtrade
marked this pull request as draft
August 21, 2026 08:36
navtrade
marked this pull request as ready for review
August 21, 2026 08:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type / PR类型
Related Issue | 关联 Issue
Fixes #482
🔍 Motivation / 变更动机
问题背景:
在与某些流式 API 服务(如 OpenAI-compatible、vLLM 等)交互时,服务会返回包含元数据的流式响应
这些元数据行采用 id: xxxx 的格式,不是有效的 JSON 数据
当前代码尝试将这些行解析为 JSON,导致 json.JSONDecodeError 错误
请求因此失败
影响范围:
所有使用流式 API 的模型评估都会遇到此问题
特别是与支持流式输出的服务(OpenAI API、vLLM、Ollama 等)的集成
📝 Modification / 修改内容