fix: parse streamed Responses image events#9
Open
ss7777q wants to merge 1 commit intoCookSleep:mainfrom
Open
Conversation
c030806 to
5be822b
Compare
Owner
|
其实主要是流式要多扣钱…… 我先把遮罩那个改完再看看这个 |
5be822b to
f15c664
Compare
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.
背景
关联 #7。
长时间图片生成失败通常有两类场景:
自建 Nginx/OpenResty/1Panel 反代时,Images API 非流式请求可能因为
proxy_read_timeout等配置较短,在 60 秒左右返回 504。这个场景仍然应优先通过提高反代超时解决。使用第三方 OpenAI 兼容中转时,调用方无法修改对方网关配置。复杂图片生成可能超过代理层空闲超时,非流式请求会在最终 JSON 返回前被断开。
本 PR 主要补充第二类场景的前端兼容方案:在 Responses API 下支持流式响应,并从 SSE 事件中提取图片数据。
改动
stream: truepartial_images: 1response.output_item.doneresponse.image_generation_call.partial_imageresponse.completedresultpartial_image_b64b64_json行为说明
这个 PR 不改变 Images API
/v1/images/generations的行为。对于 Images API 的 504 问题,仍然需要调整网关超时,例如: