Skip to content

Commit f18e9f8

Browse files
committed
feat: convert MistralTokenizer AssertionError to ValueError
Signed-off-by: Guillaume Calmettes <gcalmettes@scaleway.com>
1 parent 98d01d3 commit f18e9f8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

vllm/entrypoints/chat_utils.py

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

1196-
return tokenizer.apply_chat_template(
1196+
try:
1197+
tokens_ids = tokenizer.apply_chat_template(
11971198
messages=messages,
11981199
tools=tools,
11991200
**kwargs,
1200-
)
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
1208+
return tokens_ids

0 commit comments

Comments
 (0)