mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
- Added logic to return an empty slice when the raw JSON equals the `[DONE]` marker. - Ensures proper termination of streamed Gemini responses.
20 lines
529 B
Go
20 lines
529 B
Go
package gemini
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
)
|
|
|
|
// PassthroughGeminiResponseStream forwards Gemini responses unchanged.
|
|
func PassthroughGeminiResponseStream(_ context.Context, _ string, rawJSON []byte, _ *any) []string {
|
|
if bytes.Equal(rawJSON, []byte("[DONE]")) {
|
|
return []string{}
|
|
}
|
|
return []string{string(rawJSON)}
|
|
}
|
|
|
|
// PassthroughGeminiResponseNonStream forwards Gemini responses unchanged.
|
|
func PassthroughGeminiResponseNonStream(_ context.Context, _ string, rawJSON []byte, _ *any) string {
|
|
return string(rawJSON)
|
|
}
|