Updated checkPromptType function to handle prompt list in completions (#885)

* updated checkPromptType function to handle prompt list in completions

* removed generated test file

* added corresponding unit testcases

* Updated to use less nesting with early returns
This commit is contained in:
Ayush Sawant
2024-10-25 19:11:45 +05:30
committed by GitHub
parent 3672c0dec6
commit 6e087322b7
2 changed files with 86 additions and 12 deletions

View File

@@ -161,7 +161,23 @@ func checkEndpointSupportsModel(endpoint, model string) bool {
func checkPromptType(prompt any) bool {
_, isString := prompt.(string)
_, isStringSlice := prompt.([]string)
return isString || isStringSlice
if isString || isStringSlice {
return true
}
// check if it is prompt is []string hidden under []any
slice, isSlice := prompt.([]any)
if !isSlice {
return false
}
for _, item := range slice {
_, itemIsString := item.(string)
if !itemIsString {
return false
}
}
return true // all items in the slice are string, so it is []string
}
var unsupportedToolsForO1Models = map[ToolType]struct{}{