File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -229,10 +229,20 @@ def process_input(model_name, inp):
229229 inp = [inp ]
230230 elif isinstance (inp , list ):
231231 if isinstance (inp [0 ], int ):
232- decoding = tiktoken .model .encoding_for_model (model_name )
232+ try :
233+ decoding = tiktoken .model .encoding_for_model (model_name )
234+ except KeyError :
235+ logger .warning ("Warning: model not found. Using cl100k_base encoding." )
236+ model = "cl100k_base"
237+ decoding = tiktoken .get_encoding (model )
233238 inp = [decoding .decode (inp )]
234239 elif isinstance (inp [0 ], list ):
235- decoding = tiktoken .model .encoding_for_model (model_name )
240+ try :
241+ decoding = tiktoken .model .encoding_for_model (model_name )
242+ except KeyError :
243+ logger .warning ("Warning: model not found. Using cl100k_base encoding." )
244+ model = "cl100k_base"
245+ decoding = tiktoken .get_encoding (model )
236246 inp = [decoding .decode (text ) for text in inp ]
237247
238248 return inp
You can’t perform that action at this time.
0 commit comments