diff --git a/core/config/backend_config.go b/core/config/backend_config.go index 1eb2fcbf067..660d257166d 100644 --- a/core/config/backend_config.go +++ b/core/config/backend_config.go @@ -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) { diff --git a/core/config/backend_config_loader.go b/core/config/backend_config_loader.go index 5d1df2694f7..c1fed818726 100644 --- a/core/config/backend_config_loader.go +++ b/core/config/backend_config_loader.go @@ -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, }