mirror of
https://github.com/ollama/ollama.git
synced 2025-04-06 10:58:36 +02:00
server: prepend system message in chat handler
This commit is contained in:
parent
1ed0aa8fea
commit
f7ee012300
@ -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()})
|
||||
|
Loading…
x
Reference in New Issue
Block a user