mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-20 21:23:10 +00:00
fix(functions): respect when selected from string (#1940)
* fix(functions): respect when selected from string * fix(toolschoice): decode both string and objects
This commit is contained in:
parent
ebb1fcedea
commit
e8f02c083f
@ -185,7 +185,12 @@ func (c *BackendConfig) ShouldCallSpecificFunction() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *BackendConfig) FunctionToCall() string {
|
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) {
|
func (cfg *BackendConfig) SetDefaults(opts ...ConfigLoaderOption) {
|
||||||
|
@ -146,7 +146,14 @@ func updateRequestConfig(config *config.BackendConfig, input *schema.OpenAIReque
|
|||||||
|
|
||||||
if input.ToolsChoice != nil {
|
if input.ToolsChoice != nil {
|
||||||
var toolChoice grammar.Tool
|
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{}{
|
input.FunctionCall = map[string]interface{}{
|
||||||
"name": toolChoice.Function.Name,
|
"name": toolChoice.Function.Name,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user