Skip to content

Commit be52e98

Browse files
committed
Add Exception handling chat_utils
Signed-off-by: Jasmond Loh <Jasmond.Loh@hotmail.com>
1 parent cded7bd commit be52e98

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

vllm/entrypoints/chat_utils.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,14 +1199,24 @@ def apply_hf_chat_template(
11991199
"allowed, so you must provide a chat template if the tokenizer "
12001200
"does not define one.")
12011201

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+
)
12091211

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
12101220

12111221
def apply_mistral_chat_template(
12121222
tokenizer: MistralTokenizer,

0 commit comments

Comments
 (0)