mirror of
https://github.com/mudler/LocalAI.git
synced 2025-06-04 09:55:00 +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 != "" {
|
||||
config.InputStrings = append(config.InputStrings, inputs)
|
||||
}
|
||||
case []interface{}:
|
||||
case []any:
|
||||
for _, pp := range inputs {
|
||||
switch i := pp.(type) {
|
||||
case string:
|
||||
config.InputStrings = append(config.InputStrings, i)
|
||||
case []interface{}:
|
||||
case []any:
|
||||
tokens := []int{}
|
||||
inputStrings := []string{}
|
||||
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.InputStrings = append(config.InputStrings, inputStrings...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue