"git@web.lueluesay.top:chenxi/sub2api.git" did not exist on "46bc5ca73b8e8e166321e789f47e24ede50677d2"
Commit bcaae2eb authored by erio's avatar erio
Browse files

fix: use shared max_line_size config for OpenAI Responses SSE scanner

Two SSE scanners in openai_gateway_messages.go were hardcoded to 1MB
while all other scanners use defaultMaxLineSize (500MB) with config
override. This caused Responses API streams to fail on large payloads.
parent c8eff343
...@@ -279,7 +279,11 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse( ...@@ -279,7 +279,11 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse(
requestID := resp.Header.Get("x-request-id") requestID := resp.Header.Get("x-request-id")
scanner := bufio.NewScanner(resp.Body) scanner := bufio.NewScanner(resp.Body)
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) maxLineSize := defaultMaxLineSize
if s.cfg != nil && s.cfg.Gateway.MaxLineSize > 0 {
maxLineSize = s.cfg.Gateway.MaxLineSize
}
scanner.Buffer(make([]byte, 0, 64*1024), maxLineSize)
var finalResponse *apicompat.ResponsesResponse var finalResponse *apicompat.ResponsesResponse
var usage OpenAIUsage var usage OpenAIUsage
...@@ -378,7 +382,11 @@ func (s *OpenAIGatewayService) handleAnthropicStreamingResponse( ...@@ -378,7 +382,11 @@ func (s *OpenAIGatewayService) handleAnthropicStreamingResponse(
firstChunk := true firstChunk := true
scanner := bufio.NewScanner(resp.Body) scanner := bufio.NewScanner(resp.Body)
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) maxLineSize := defaultMaxLineSize
if s.cfg != nil && s.cfg.Gateway.MaxLineSize > 0 {
maxLineSize = s.cfg.Gateway.MaxLineSize
}
scanner.Buffer(make([]byte, 0, 64*1024), maxLineSize)
// resultWithUsage builds the final result snapshot. // resultWithUsage builds the final result snapshot.
resultWithUsage := func() *OpenAIForwardResult { resultWithUsage := func() *OpenAIForwardResult {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment