Skip to content

Commit c2e8bba

Browse files
committed
fix(input): handle correctly case where we pass by string list as inputs
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 6073b99 commit c2e8bba

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

core/http/middleware/request.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,28 @@ func mergeOpenAIRequestAndBackendConfig(config *config.BackendConfig, input *sch
383383
if inputs != "" {
384384
config.InputStrings = append(config.InputStrings, inputs)
385385
}
386-
case []interface{}:
386+
case []any:
387387
for _, pp := range inputs {
388388
switch i := pp.(type) {
389389
case string:
390390
config.InputStrings = append(config.InputStrings, i)
391-
case []interface{}:
391+
case []any:
392392
tokens := []int{}
393+
inputStrings := []string{}
393394
for _, ii := range i {
394-
tokens = append(tokens, int(ii.(float64)))
395+
switch ii := ii.(type) {
396+
case int:
397+
tokens = append(tokens, ii)
398+
case float64:
399+
tokens = append(tokens, int(ii))
400+
case string:
401+
inputStrings = append(inputStrings, ii)
402+
default:
403+
log.Error().Msgf("Unknown input type: %T", ii)
404+
}
395405
}
396406
config.InputToken = append(config.InputToken, tokens)
407+
config.InputStrings = append(config.InputStrings, inputStrings...)
397408
}
398409
}
399410
}

0 commit comments

Comments
 (0)