fix: only flush template in chat when current role encountered (#1426)

This commit is contained in:
Bruce MacDonald
2023-12-08 16:44:24 -05:00
committed by GitHub
parent e3f925fc1b
commit 3b0b8930d4
2 changed files with 92 additions and 15 deletions

View File

@@ -103,16 +103,16 @@ func (m *Model) ChatPrompt(msgs []api.Message) (string, error) {
}
for _, msg := range msgs {
switch msg.Role {
switch strings.ToLower(msg.Role) {
case "system":
if currentVars.Prompt != "" || currentVars.System != "" {
if currentVars.System != "" {
if err := writePrompt(); err != nil {
return "", err
}
}
currentVars.System = msg.Content
case "user":
if currentVars.Prompt != "" || currentVars.System != "" {
if currentVars.Prompt != "" {
if err := writePrompt(); err != nil {
return "", err
}