* feat(images): 接入 OpenAI 图片生成与编辑 * fix(images): 补齐响应容量与边界处理 * fix(images): 修正协议观测与响应上限覆盖 * fix(stream): 保证取消优先于流关闭 * fix(images): 修正空 SSE 错误对象判定 * fix(images): 避免媒体数据触发凭据误判 * fix(images): 阻止流式响应泄漏凭据 * fix(images): 校验完整流事件后再转发 * fix(images): 修正响应模型观测
29 lines
909 B
Go
29 lines
909 B
Go
package execution
|
|
|
|
import "gpt-load/internal/protocol"
|
|
|
|
const (
|
|
DefaultUnaryResponseBodyLimitBytes = int64(32 << 20)
|
|
OpenAIImagesUnaryResponseBodyLimitBytes = int64(64 << 20)
|
|
DefaultSSEEventLimitBytes = 10 << 20
|
|
OpenAIImagesSSEEventLimitBytes = 32 << 20
|
|
)
|
|
|
|
// UnaryResponseBodyLimit returns the internal buffered success-response limit
|
|
// for one client wire protocol.
|
|
func UnaryResponseBodyLimit(clientProtocol protocol.Protocol) int64 {
|
|
if clientProtocol == protocol.OpenAIImages {
|
|
return OpenAIImagesUnaryResponseBodyLimitBytes
|
|
}
|
|
return DefaultUnaryResponseBodyLimitBytes
|
|
}
|
|
|
|
// SSEEventLimit returns the internal maximum size of one complete SSE event
|
|
// for one client wire protocol.
|
|
func SSEEventLimit(clientProtocol protocol.Protocol) int {
|
|
if clientProtocol == protocol.OpenAIImages {
|
|
return OpenAIImagesSSEEventLimitBytes
|
|
}
|
|
return DefaultSSEEventLimitBytes
|
|
}
|