mirror of
https://github.com/mudler/LocalAI.git
synced 2025-06-06 19:04:59 +00:00
fix(input): handle correctly case where we pass by string list as inputs
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
6073b9944e
commit
c2e8bba3d4
1 changed files with 14 additions and 3 deletions
|
@ -383,17 +383,28 @@ func mergeOpenAIRequestAndBackendConfig(config *config.BackendConfig, input *sch
|
||||||
if inputs != "" {
|
if inputs != "" {
|
||||||
config.InputStrings = append(config.InputStrings, inputs)
|
config.InputStrings = append(config.InputStrings, inputs)
|
||||||
}
|
}
|
||||||
case []interface{}:
|
case []any:
|
||||||
for _, pp := range inputs {
|
for _, pp := range inputs {
|
||||||
switch i := pp.(type) {
|
switch i := pp.(type) {
|
||||||
case string:
|
case string:
|
||||||
config.InputStrings = append(config.InputStrings, i)
|
config.InputStrings = append(config.InputStrings, i)
|
||||||
case []interface{}:
|
case []any:
|
||||||
tokens := []int{}
|
tokens := []int{}
|
||||||
|
inputStrings := []string{}
|
||||||
for _, ii := range i {
|
for _, ii := range i {
|
||||||
tokens = append(tokens, int(ii.(float64)))
|
switch ii := ii.(type) {
|
||||||
|
case int:
|
||||||
|
tokens = append(tokens, ii)
|
||||||
|
case float64:
|
||||||
|
tokens = append(tokens, int(ii))
|
||||||
|
case string:
|
||||||
|
inputStrings = append(inputStrings, ii)
|
||||||
|
default:
|
||||||
|
log.Error().Msgf("Unknown input type: %T", ii)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
config.InputToken = append(config.InputToken, tokens)
|
config.InputToken = append(config.InputToken, tokens)
|
||||||
|
config.InputStrings = append(config.InputStrings, inputStrings...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue