Skip to content

Commit

Permalink
fixes #1051: handle openai presence and request penalty parameters (#…
Browse files Browse the repository at this point in the history
…1817)

* fix request debugging, disable marshalling of context fields

Signed-off-by: blob42 <[email protected]>

* merge frequency_penalty request parm with config

Signed-off-by: blob42 <[email protected]>

* openai: add presence_penalty parameter

Signed-off-by: blob42 <[email protected]>

---------

Signed-off-by: blob42 <[email protected]>
  • Loading branch information
blob42 authored Mar 17, 2024
1 parent 8967ed1 commit 801b481
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions core/http/endpoints/openai/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ func updateRequestConfig(config *config.BackendConfig, input *schema.OpenAIReque
config.RepeatPenalty = input.RepeatPenalty
}

if input.FrequencyPenalty!= 0 {
config.FrequencyPenalty = input.FrequencyPenalty
}

if input.PresencePenalty!= 0 {
config.PresencePenalty = input.PresencePenalty
}

if input.Keep != 0 {
config.Keep = input.Keep
}
Expand Down
2 changes: 1 addition & 1 deletion core/schema/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type ChatCompletionResponseFormat struct {
type OpenAIRequest struct {
PredictionOptions

Context context.Context `json:"-"`
Context context.Context `json:"-"`
Cancel context.CancelFunc `json:"-"`

// whisper
Expand Down
1 change: 1 addition & 0 deletions core/schema/prediction.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type PredictionOptions struct {
Keep int `json:"n_keep" yaml:"n_keep"`

FrequencyPenalty float64 `json:"frequency_penalty" yaml:"frequency_penalty"`
PresencePenalty float64 `json:"presence_penalty" yaml:"presence_penalty"`
TFZ float64 `json:"tfz" yaml:"tfz"`

TypicalP float64 `json:"typical_p" yaml:"typical_p"`
Expand Down

0 comments on commit 801b481

Please sign in to comment.