File tree 1 file changed +17
-7
lines changed
1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -1199,14 +1199,24 @@ def apply_hf_chat_template(
1199
1199
"allowed, so you must provide a chat template if the tokenizer "
1200
1200
"does not define one." )
1201
1201
1202
- return tokenizer .apply_chat_template (
1203
- conversation = conversation , # type: ignore[arg-type]
1204
- tools = tools , # type: ignore[arg-type]
1205
- chat_template = hf_chat_template ,
1206
- tokenize = tokenize ,
1207
- ** kwargs ,
1208
- )
1202
+ try :
1203
+
1204
+ return tokenizer .apply_chat_template (
1205
+ conversation = conversation , # type: ignore[arg-type]
1206
+ tools = tools , # type: ignore[arg-type]
1207
+ chat_template = hf_chat_template ,
1208
+ tokenize = tokenize ,
1209
+ ** kwargs ,
1210
+ )
1209
1211
1212
+ # External library exceptions can sometimes occur despite the framework's
1213
+ # internal exception management capabilities.
1214
+ except Exception as e :
1215
+
1216
+ # Log and report any library-related exceptions for further
1217
+ # investigation.
1218
+ logger .exception (traceback .format_exc ())
1219
+ raise ValueError from e
1210
1220
1211
1221
def apply_mistral_chat_template (
1212
1222
tokenizer : MistralTokenizer ,
You can’t perform that action at this time.
0 commit comments