Co-authored-by: Codex <noreply@openai.com> Co-authored-by: yuchuan <yuchuan.7streams@gmail.com> Co-authored-by: Bugen Zhao <i@bugenzhao.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ubospica <ubospica@gmail.com> Signed-off-by: yuchuan <yuchuan.7streams@gmail.com> Signed-off-by: Bugen Zhao <i@bugenzhao.com>
26 lines
881 B
Python
26 lines
881 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
from xgrammar.structural_tag import TriggeredTagsFormat
|
|
|
|
from vllm.parser.engine.registered_adapters import MiMoParserToolAdapter
|
|
from vllm.tool_parsers.tool_strict_level import ToolStrictLevel
|
|
|
|
|
|
class MiMoToolParser(MiMoParserToolAdapter): # type: ignore[valid-type, misc]
|
|
structural_tag_model = "mimo"
|
|
|
|
def get_structural_tag(
|
|
self, request, *, reasoning=False, strict_level=ToolStrictLevel.AUTO
|
|
):
|
|
tag = super().get_structural_tag(
|
|
request, reasoning=reasoning, strict_level=strict_level
|
|
)
|
|
if (
|
|
tag is not None
|
|
and request.parallel_tool_calls is False
|
|
and isinstance(tag.format, TriggeredTagsFormat)
|
|
):
|
|
tag.format.stop_after_first = True
|
|
return tag
|