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:
Ettore Di Giacinto 2025-05-29 19:28:46 +02:00
parent 6073b9944e
commit c2e8bba3d4

View file

@ -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...)
}
}
}