openai: align chat temperature and frequency_penalty options with completion (#6688)

This commit is contained in:
frob 2024-09-07 18:08:08 +02:00 committed by GitHub
parent 108fb6c1d1
commit 06d4fba851
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -452,7 +452,7 @@ func fromChatRequest(r ChatCompletionRequest) (*api.ChatRequest, error) {
} }
if r.Temperature != nil { if r.Temperature != nil {
options["temperature"] = *r.Temperature * 2.0 options["temperature"] = *r.Temperature
} else { } else {
options["temperature"] = 1.0 options["temperature"] = 1.0
} }
@ -462,11 +462,11 @@ func fromChatRequest(r ChatCompletionRequest) (*api.ChatRequest, error) {
} }
if r.FrequencyPenalty != nil { if r.FrequencyPenalty != nil {
options["frequency_penalty"] = *r.FrequencyPenalty * 2.0 options["frequency_penalty"] = *r.FrequencyPenalty
} }
if r.PresencePenalty != nil { if r.PresencePenalty != nil {
options["presence_penalty"] = *r.PresencePenalty * 2.0 options["presence_penalty"] = *r.PresencePenalty
} }
if r.TopP != nil { if r.TopP != nil {

View file

@ -102,9 +102,9 @@ func TestChatMiddleware(t *testing.T) {
"num_predict": 999.0, // float because JSON doesn't distinguish between float and int "num_predict": 999.0, // float because JSON doesn't distinguish between float and int
"seed": 123.0, "seed": 123.0,
"stop": []any{"\n", "stop"}, "stop": []any{"\n", "stop"},
"temperature": 6.0, "temperature": 3.0,
"frequency_penalty": 8.0, "frequency_penalty": 4.0,
"presence_penalty": 10.0, "presence_penalty": 5.0,
"top_p": 6.0, "top_p": 6.0,
}, },
Format: "json", Format: "json",