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:
@@ -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{}{
|
||||
|
||||
Reference in New Issue
Block a user