fix: 修复意外丢失流式chunk #5
Open
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.
流式输出Chunk丢失问题修复报告
问题描述
在某次流式输出中,以下数据块被服务器接收但未传输给API客户端:
根因分析
原始假设(错误)
最初以为是正则表达式无法匹配深层嵌套结构,但测试证明正则表达式工作正常。
真正原因
问题出现在
openai_compatible_server.py第234行的过滤逻辑:丢失的文本内容为:
因为以
**开头,被错误过滤掉了。修复方案
实施的方案(智能过滤)
将过滤逻辑从:
修改为:
修复逻辑说明
**开头的内容会被保留**符号和类似的短内容修复效果验证
测试结果
**符号的过滤边界情况测试
*********a