Unverified Commit 31b8c6a2 authored by Sos Pogosyan's avatar Sos Pogosyan Committed by GitHub
Browse files

fix(api): correct Content-Type header for /api/chat and /api/generate when...


fix(api): correct Content-Type header for /api/chat and /api/generate when using cloud models (#13279)

---------
Co-authored-by: default avatarPogosyan Sos <sos_pogosyan@MacBook-Pro-Sos.local>
Co-authored-by: default avatarPatrick Devine <patrick@infrahq.com>
parent 9191dfaf
......@@ -262,6 +262,12 @@ func (s *Server) GenerateHandler(c *gin.Context) {
slog.Warn("embedded messages in the model not supported with '/api/generate'; try '/api/chat' instead")
}
contentType := "application/x-ndjson"
if req.Stream != nil && !*req.Stream {
contentType = "application/json; charset=utf-8"
}
c.Header("Content-Type", contentType)
fn := func(resp api.GenerateResponse) error {
resp.Model = origModel
resp.RemoteModel = m.Config.RemoteModel
......@@ -303,12 +309,6 @@ func (s *Server) GenerateHandler(c *gin.Context) {
return
}
contentType := "application/json; charset=utf-8"
if req.Stream != nil && *req.Stream {
contentType = "application/x-ndjson"
}
c.Header("Content-Type", contentType)
return
}
......@@ -1939,6 +1939,12 @@ func (s *Server) ChatHandler(c *gin.Context) {
}
}
contentType := "application/x-ndjson"
if req.Stream != nil && !*req.Stream {
contentType = "application/json; charset=utf-8"
}
c.Header("Content-Type", contentType)
fn := func(resp api.ChatResponse) error {
resp.Model = origModel
resp.RemoteModel = m.Config.RemoteModel
......@@ -1980,12 +1986,6 @@ func (s *Server) ChatHandler(c *gin.Context) {
return
}
contentType := "application/json; charset=utf-8"
if req.Stream != nil && *req.Stream {
contentType = "application/x-ndjson"
}
c.Header("Content-Type", contentType)
return
}
......
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