fix(ai-proxy): fix streaming process

This commit is contained in:
johnlanni
2025-09-23 19:44:30 +08:00
parent 9a3ccff4c8
commit 063bfbfcfe
2 changed files with 5 additions and 1 deletions

View File

@@ -433,6 +433,10 @@ func onStreamingResponseBody(ctx wrapper.HttpContext, pluginConfig config.Plugin
return claudeChunk
}
if !needsClaudeResponseConversion(ctx) {
return chunk
}
// If provider doesn't implement any streaming handlers but we need Claude conversion
// First extract complete events from the chunk
events := provider.ExtractStreamingEvents(ctx, chunk)

View File

@@ -825,7 +825,7 @@ func ExtractStreamingEvents(ctx wrapper.HttpContext, chunk []byte) []StreamEvent
continue
}
if lineStartIndex != -1 && valueStartIndex != -1 {
if lineStartIndex != -1 {
value := string(body[valueStartIndex:i])
currentEvent.SetValue(currentKey, value)
} else {