[PARSER][Mistral] unified engine-based parser for reasoning and tool calls (#48947)
This commit is contained in:
@@ -533,8 +533,8 @@ class ChatCompletionRequest(OpenAIBaseModel):
|
||||
msg["tool_calls"] = list(tool_calls)
|
||||
return self
|
||||
|
||||
_grammar_from_tool_parser: bool = PrivateAttr(default=False)
|
||||
"""CAUTION: Should only be set by ``ToolParser.adjust_request``."""
|
||||
_grammar_from_parser: bool = PrivateAttr(default=False)
|
||||
"""CAUTION: Should only be set by the parser-engine adapter's adjust_request."""
|
||||
|
||||
def build_chat_params(
|
||||
self,
|
||||
|
||||
@@ -65,7 +65,6 @@ from vllm.renderers.online_renderer import OnlineRenderer
|
||||
from vllm.sampling_params import BeamSearchParams, SamplingParams
|
||||
from vllm.tokenizers import TokenizerLike
|
||||
from vllm.utils.collection_utils import as_list
|
||||
from vllm.utils.mistral import is_mistral_tool_parser
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
@@ -157,15 +156,6 @@ class OpenAIServingChat(GenerateBaseServing):
|
||||
model_name=self.model_config.model,
|
||||
is_harmony=self.model_config.hf_config.model_type == "gpt_oss",
|
||||
)
|
||||
if (
|
||||
self.parser_cls is not None
|
||||
and is_mistral_tool_parser(self.parser_cls.tool_parser_cls)
|
||||
and self.parser_cls.reasoning_parser_cls is not None
|
||||
):
|
||||
from vllm.tool_parsers.mistral_tool_parser import MistralToolParser
|
||||
|
||||
MistralToolParser.model_can_reason = True
|
||||
|
||||
self.exclude_tools_when_tool_choice_none = exclude_tools_when_tool_choice_none
|
||||
|
||||
self.enable_prompt_tokens_details = enable_prompt_tokens_details
|
||||
@@ -350,7 +340,7 @@ class OpenAIServingChat(GenerateBaseServing):
|
||||
else:
|
||||
if not request.include_reasoning:
|
||||
reasoning_ended = True
|
||||
elif request._grammar_from_tool_parser:
|
||||
elif request._grammar_from_parser:
|
||||
# The Mistral grammar already includes an optional
|
||||
# `think?` rule that handles both reasoning and
|
||||
# non-reasoning outputs.
|
||||
|
||||
@@ -284,7 +284,7 @@ class DerenderChatRequest(BaseModel):
|
||||
|
||||
Required by the parsing so that tool/reasoning parsers can receive the full
|
||||
request context they expect (request.tools, request.tool_choice,
|
||||
request._grammar_from_tool_parser, etc.).
|
||||
request._grammar_from_parser, etc.).
|
||||
"""
|
||||
# --8<-- [end:derender-chat-request]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user