diff --git a/server/routes.go b/server/routes.go index 5b6d0978..edaec691 100644 --- a/server/routes.go +++ b/server/routes.go @@ -1181,6 +1181,10 @@ func (s *Server) ChatHandler(c *gin.Context) { return } + if req.Messages[0].Role != "system" { + req.Messages = append([]api.Message{{Role: "system", Content: m.System}}, req.Messages...) + } + prompt, images, err := chatPrompt(c.Request.Context(), m, r.Tokenize, opts, req.Messages) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})