diff --git a/core/config/backend_config.go b/core/config/backend_config.go index 32e10a174367..db9c66654ddd 100644 --- a/core/config/backend_config.go +++ b/core/config/backend_config.go @@ -185,7 +185,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/http/endpoints/openai/request.go b/core/http/endpoints/openai/request.go index 1f845c6f1cc1..c99812045ad8 100644 --- a/core/http/endpoints/openai/request.go +++ b/core/http/endpoints/openai/request.go @@ -146,7 +146,14 @@ func updateRequestConfig(config *config.BackendConfig, input *schema.OpenAIReque if input.ToolsChoice != nil { var toolChoice grammar.Tool - json.Unmarshal([]byte(input.ToolsChoice.(string)), &toolChoice) + + switch content := input.ToolsChoice.(type) { + case string: + _ = json.Unmarshal([]byte(content), &toolChoice) + case map[string]interface{}: + dat, _ := json.Marshal(content) + _ = json.Unmarshal(dat, &toolChoice) + } input.FunctionCall = map[string]interface{}{ "name": toolChoice.Function.Name, }