Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion api/openai/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion api/openai/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion api/schema/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down