diff --git a/api/openai/chat.go b/api/openai/chat.go index 8837c65c790c..cd0b82dd93b3 100644 --- a/api/openai/chat.go +++ b/api/openai/chat.go @@ -81,7 +81,7 @@ func ChatEndpoint(cm *config.ConfigLoader, o *options.Option) func(c *fiber.Ctx) noActionDescription = config.FunctionsConfig.NoActionDescriptionName } - if input.ResponseFormat == "json_object" { + if input.ResponseFormat.Type == "json_object" { input.Grammar = grammar.JSONBNF } diff --git a/api/openai/completion.go b/api/openai/completion.go index fa7e6bacba12..da28d63cb799 100644 --- a/api/openai/completion.go +++ b/api/openai/completion.go @@ -65,7 +65,7 @@ func CompletionEndpoint(cm *config.ConfigLoader, o *options.Option) func(c *fibe return fmt.Errorf("failed reading parameters from request:%w", err) } - if input.ResponseFormat == "json_object" { + if input.ResponseFormat.Type == "json_object" { input.Grammar = grammar.JSONBNF } diff --git a/api/openai/image.go b/api/openai/image.go index 8243e167b63b..2fe6c5a70b6d 100644 --- a/api/openai/image.go +++ b/api/openai/image.go @@ -100,7 +100,7 @@ func ImageEndpoint(cm *config.ConfigLoader, o *options.Option) func(c *fiber.Ctx } b64JSON := false - if input.ResponseFormat == "b64_json" { + if input.ResponseFormat.Type == "b64_json" { b64JSON = true } // src and clip_skip diff --git a/api/schema/openai.go b/api/schema/openai.go index 899f1b741678..6355ff63d5e2 100644 --- a/api/schema/openai.go +++ b/api/schema/openai.go @@ -83,6 +83,12 @@ type OpenAIModel struct { Object string `json:"object"` } +type ChatCompletionResponseFormatType string + +type ChatCompletionResponseFormat struct { + Type ChatCompletionResponseFormatType `json:"type,omitempty"` +} + type OpenAIRequest struct { config.PredictionOptions @@ -92,7 +98,7 @@ type OpenAIRequest struct { // whisper File string `json:"file" validate:"required"` //whisper/image - ResponseFormat string `json:"response_format"` + ResponseFormat ChatCompletionResponseFormat `json:"response_format"` // image Size string `json:"size"` // Prompt is read only by completion/image API calls