Skip to content

Commit c3b5189

Browse files
authored
[Bugfix] catch AssertionError in MistralTokenizer as ValueError (#16344)
Signed-off-by: Guillaume Calmettes <gcalmettes@scaleway.com>
1 parent a25866a commit c3b5189

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

vllm/entrypoints/chat_utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,15 @@ def apply_mistral_chat_template(
11931193
**kwargs,
11941194
)
11951195

1196-
return tokenizer.apply_chat_template(
1197-
messages=messages,
1198-
tools=tools,
1199-
**kwargs,
1200-
)
1196+
try:
1197+
return tokenizer.apply_chat_template(
1198+
messages=messages,
1199+
tools=tools,
1200+
**kwargs,
1201+
)
1202+
# mistral-common uses assert statements to stop processing of input
1203+
# if input does not comply with the expected format.
1204+
# We convert those assertion errors to ValueErrors so they can be
1205+
# are properly caught in the preprocessing_input step
1206+
except AssertionError as e:
1207+
raise ValueError from e

0 commit comments

Comments
 (0)