File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -45,16 +45,19 @@ def parse_raw_prompts(
4545
4646 # case 4: array of token arrays
4747 if is_list_of (prompt , list ):
48- first = prompt [0 ]
49- if not isinstance (first , list ):
50- raise ValueError ("prompt expected to be a list of lists" )
51-
52- if len (first ) == 0 :
53- raise ValueError ("Please provide at least one prompt" )
54-
55- # strict validation: every nested list must be list[int]
56- if not all (is_list_of (elem , int ) for elem in prompt ):
57- raise TypeError ("Nested lists must contain only integers" )
48+ for elem in prompt :
49+ if not isinstance (elem , list ):
50+ raise TypeError (
51+ "prompt must be a list of lists, but found a non-list element."
52+ )
53+ if not elem :
54+ raise ValueError (
55+ "Empty lists of tokens are not allowed in prompts."
56+ )
57+ if not is_list_of (elem , int , check = "all" ):
58+ raise TypeError (
59+ "Nested lists of tokens must contain only integers."
60+ )
5861
5962 prompt = cast (list [list [int ]], prompt )
6063 return [TokensPrompt (prompt_token_ids = elem ) for elem in prompt ]
You can’t perform that action at this time.
0 commit comments