preserve last system message from modelfile (#2289)

This commit is contained in:
Bruce MacDonald
2024-01-31 21:45:01 -05:00
committed by GitHub
parent 583950c828
commit a896079705
2 changed files with 66 additions and 17 deletions

View File

@@ -156,7 +156,7 @@ type ChatHistory struct {
func (m *Model) ChatPrompts(msgs []api.Message) (*ChatHistory, error) {
// build the prompt from the list of messages
var currentImages []api.ImageData
var lastSystem string
lastSystem := m.System
currentVars := PromptVars{
First: true,
System: m.System,
@@ -167,7 +167,8 @@ func (m *Model) ChatPrompts(msgs []api.Message) (*ChatHistory, error) {
for _, msg := range msgs {
switch strings.ToLower(msg.Role) {
case "system":
if currentVars.System != "" {
// if this is the first message it overrides the system prompt in the modelfile
if !currentVars.First && currentVars.System != "" {
prompts = append(prompts, currentVars)
currentVars = PromptVars{}
}