support o1 models not allowing system prompts
This commit is contained in:
parent
c4f4f6abe6
commit
f603010dee
15
openai.go
15
openai.go
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
oai "github.com/sashabaranov/go-openai"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type openai struct {
|
||||
@ -72,6 +73,20 @@ func (o openai) requestToOpenAIRequest(request Request) oai.ChatCompletionReques
|
||||
res.Temperature = *request.Temperature
|
||||
}
|
||||
|
||||
// is this an o1-* model?
|
||||
isO1 := strings.Split(o.model, "-")[0] == "o1"
|
||||
|
||||
if isO1 {
|
||||
// o1 models do not support system messages, so if any messages are system messages, we need to convert them to
|
||||
// user messages
|
||||
|
||||
for i, msg := range res.Messages {
|
||||
if msg.Role == "system" {
|
||||
res.Messages[i].Role = "user"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user