mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(gemini): handle "[DONE]" chunk, trim "data:" prefix, and remove session_id from requests
- Adjusted stream handling to skip "[DONE]" chunks. - Ensured "data:" prefix is trimmed for non-prefixed input in translation. - Removed `session_id` from request bodies before processing.
This commit is contained in:
@@ -193,7 +193,14 @@ func (h *GeminiCLIAPIHandler) forwardCLIStream(c *gin.Context, flusher http.Flus
|
||||
return
|
||||
}
|
||||
if alt == "" {
|
||||
_, _ = c.Writer.Write([]byte("data: "))
|
||||
if bytes.Equal(chunk, []byte("data: [DONE]")) || bytes.Equal(chunk, []byte("[DONE]")) {
|
||||
continue
|
||||
}
|
||||
|
||||
if !bytes.HasPrefix(chunk, []byte("data:")) {
|
||||
_, _ = c.Writer.Write([]byte("data: "))
|
||||
}
|
||||
|
||||
_, _ = c.Writer.Write(chunk)
|
||||
_, _ = c.Writer.Write([]byte("\n\n"))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user