Skip to content

Commit

Permalink
manual merge of mudler#1940
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-gray101 committed Apr 1, 2024
2 parents 5111556 + e8f02c0 commit 1d39388
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion core/config/backend_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ func (c *BackendConfig) ShouldCallSpecificFunction() bool {
}

func (c *BackendConfig) FunctionToCall() string {
return c.functionCallNameString
if c.functionCallNameString != "" &&
c.functionCallNameString != "none" && c.functionCallNameString != "auto" {
return c.functionCallNameString
}

return c.functionCallString
}

func (cfg *BackendConfig) SetDefaults(opts ...ConfigLoaderOption) {
Expand Down
8 changes: 7 additions & 1 deletion core/config/backend_config_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,13 @@ func updateBackendConfigFromOpenAIRequest(bc *BackendConfig, request *schema.Ope

if request.ToolsChoice != nil {
var toolChoice grammar.Tool
json.Unmarshal([]byte(request.ToolsChoice.(string)), &toolChoice)
switch content := request.ToolsChoice.(type) {
case string:
_ = json.Unmarshal([]byte(content), &toolChoice)
case map[string]interface{}:
dat, _ := json.Marshal(content)
_ = json.Unmarshal(dat, &toolChoice)
}
request.FunctionCall = map[string]interface{}{
"name": toolChoice.Function.Name,
}
Expand Down

0 comments on commit 1d39388

Please sign in to comment.