Skip to content

Commit

Permalink
handle err vs _
Browse files Browse the repository at this point in the history
security scanners prefer if we put these branches in, and I tend to agree.

Signed-off-by: Dave <dave@gray101.com>
  • Loading branch information
dave-gray101 authored Aug 7, 2024
1 parent 848a557 commit 8e6052b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions core/http/endpoints/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,26 @@ func ChatEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, startup

if config.ResponseFormatMap != nil {
d := schema.ChatCompletionResponseFormat{}
dat, _ := json.Marshal(config.ResponseFormatMap)
_ = json.Unmarshal(dat, &d)
dat, err := json.Marshal(config.ResponseFormatMap)
if err != nil {
return err
}
err = json.Unmarshal(dat, &d)
if err != nil {
return err
}
if d.Type == "json_object" {
input.Grammar = functions.JSONBNF
} else if d.Type == "json_schema" {
d := schema.JsonSchemaRequest{}
dat, _ := json.Marshal(config.ResponseFormatMap)
_ = json.Unmarshal(dat, &d)
dat, err := json.Marshal(config.ResponseFormatMap)
if err != nil {
return err
}
err = json.Unmarshal(dat, &d)
if err != nil {
return err
}
fs := &functions.JSONFunctionStructure{
AnyOf: []functions.Item{d.JsonSchema.Schema},
}
Expand Down

0 comments on commit 8e6052b

Please sign in to comment.