mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 06:45:01 +08:00
[Bugfix] Fix Mistral ChatCompletionRequest Body Exception (#16769)
Signed-off-by: Jasmond Loh <Jasmond.Loh@hotmail.com> Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
This commit is contained in:
parent
19dcc02a72
commit
d5615af9ae
@ -1198,14 +1198,25 @@ def apply_hf_chat_template(
|
|||||||
"allowed, so you must provide a chat template if the tokenizer "
|
"allowed, so you must provide a chat template if the tokenizer "
|
||||||
"does not define one.")
|
"does not define one.")
|
||||||
|
|
||||||
return tokenizer.apply_chat_template(
|
try:
|
||||||
conversation=conversation, # type: ignore[arg-type]
|
|
||||||
tools=tools, # type: ignore[arg-type]
|
|
||||||
chat_template=hf_chat_template,
|
|
||||||
tokenize=tokenize,
|
|
||||||
**kwargs,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
return tokenizer.apply_chat_template(
|
||||||
|
conversation=conversation, # type: ignore[arg-type]
|
||||||
|
tools=tools, # type: ignore[arg-type]
|
||||||
|
chat_template=hf_chat_template,
|
||||||
|
tokenize=tokenize,
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
# External library exceptions can sometimes occur despite the framework's
|
||||||
|
# internal exception management capabilities.
|
||||||
|
except Exception as e:
|
||||||
|
|
||||||
|
# Log and report any library-related exceptions for further
|
||||||
|
# investigation.
|
||||||
|
logger.exception(
|
||||||
|
"An error occurred in `transformers` while applying chat template")
|
||||||
|
raise ValueError from e
|
||||||
|
|
||||||
def apply_mistral_chat_template(
|
def apply_mistral_chat_template(
|
||||||
tokenizer: MistralTokenizer,
|
tokenizer: MistralTokenizer,
|
||||||
@ -1214,6 +1225,8 @@ def apply_mistral_chat_template(
|
|||||||
tools: Optional[list[dict[str, Any]]],
|
tools: Optional[list[dict[str, Any]]],
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> list[int]:
|
) -> list[int]:
|
||||||
|
from mistral_common.exceptions import MistralCommonException
|
||||||
|
|
||||||
# The return value of resolve_mistral_chat_template is always None,
|
# The return value of resolve_mistral_chat_template is always None,
|
||||||
# and we won't use it.
|
# and we won't use it.
|
||||||
resolve_mistral_chat_template(
|
resolve_mistral_chat_template(
|
||||||
@ -1231,5 +1244,16 @@ def apply_mistral_chat_template(
|
|||||||
# if input does not comply with the expected format.
|
# if input does not comply with the expected format.
|
||||||
# We convert those assertion errors to ValueErrors so they can be
|
# We convert those assertion errors to ValueErrors so they can be
|
||||||
# are properly caught in the preprocessing_input step
|
# are properly caught in the preprocessing_input step
|
||||||
except AssertionError as e:
|
except (AssertionError, MistralCommonException) as e:
|
||||||
|
raise ValueError from e
|
||||||
|
|
||||||
|
# External library exceptions can sometimes occur despite the framework's
|
||||||
|
# internal exception management capabilities.
|
||||||
|
except Exception as e:
|
||||||
|
|
||||||
|
# Log and report any library-related exceptions for further
|
||||||
|
# investigation.
|
||||||
|
logger.exception(
|
||||||
|
"An error occurred in `mistral_common` while applying chat "
|
||||||
|
"template")
|
||||||
raise ValueError from e
|
raise ValueError from e
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user