Compare commits

..

4 Commits

Author SHA1 Message Date
Luis Pater
00bd6a3e46 Update .goreleaser.yml to include config.example.yaml instead of config.yaml in release assets
Some checks failed
docker-image / docker (push) Has been cancelled
goreleaser / goreleaser (push) Has been cancelled
2025-07-26 22:19:33 +08:00
Luis Pater
5812229d9b Add .gitignore and ignore config.yaml 2025-07-26 22:10:07 +08:00
Luis Pater
0b026933a7 Update example configuration file (config.example.yaml) 2025-07-26 22:08:25 +08:00
Luis Pater
3b2ab0d7bd Fix SSE headers initialization for geminiStreamGenerateContent and internalStreamGenerateContent
Some checks failed
docker-image / docker (push) Has been cancelled
goreleaser / goreleaser (push) Has been cancelled
- Added conditional logic to properly initialize SSE headers only when `alt` is empty.
- Ensured headers like `Content-Type`, `Cache-Control`, and `Access-Control-Allow-Origin` are set for better compatibility.
2025-07-26 17:16:55 +08:00
5 changed files with 20 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
config.yaml

View File

@@ -15,4 +15,4 @@ archives:
- LICENSE
- README.md
- README_CN.md
- config.yaml
- config.example.yaml

View File

@@ -99,6 +99,15 @@ func (h *APIHandlers) CLIHandler(c *gin.Context) {
}
func (h *APIHandlers) internalStreamGenerateContent(c *gin.Context, rawJson []byte) {
alt := h.getAlt(c)
if alt == "" {
c.Header("Content-Type", "text/event-stream")
c.Header("Cache-Control", "no-cache")
c.Header("Connection", "keep-alive")
c.Header("Access-Control-Allow-Origin", "*")
}
// Get the http.Flusher interface to manually flush the response.
flusher, ok := c.Writer.(http.Flusher)
if !ok {

View File

@@ -107,6 +107,15 @@ func (h *APIHandlers) GeminiHandler(c *gin.Context) {
}
func (h *APIHandlers) geminiStreamGenerateContent(c *gin.Context, rawJson []byte) {
alt := h.getAlt(c)
if alt == "" {
c.Header("Content-Type", "text/event-stream")
c.Header("Cache-Control", "no-cache")
c.Header("Connection", "keep-alive")
c.Header("Access-Control-Allow-Origin", "*")
}
// Get the http.Flusher interface to manually flush the response.
flusher, ok := c.Writer.(http.Flusher)
if !ok {
@@ -122,8 +131,6 @@ func (h *APIHandlers) geminiStreamGenerateContent(c *gin.Context, rawJson []byte
modelResult := gjson.GetBytes(rawJson, "model")
modelName := modelResult.String()
alt := h.getAlt(c)
cliCtx, cliCancel := context.WithCancel(context.Background())
var cliClient *client.Client
defer func() {