Signed-off-by: hpdkhoa <hpdkhoa2311@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Flora Feng <4florafeng@gmail.com>
25 lines
820 B
Python
25 lines
820 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
import regex as re
|
|
|
|
from vllm.tokenizers import TokenizerLike
|
|
from vllm.tool_parsers.abstract_tool_parser import Tool
|
|
from vllm.tool_parsers.hermes_tool_parser import Hermes2ProToolParser
|
|
|
|
|
|
class LongcatFlashToolParser(Hermes2ProToolParser):
|
|
structural_tag_model = "longcat"
|
|
|
|
def __init__(self, tokenizer: TokenizerLike, tools: list[Tool] | None = None):
|
|
super().__init__(tokenizer, tools)
|
|
|
|
self.tool_call_start_token: str = "<longcat_tool_call>"
|
|
self.tool_call_end_token: str = "</longcat_tool_call>"
|
|
|
|
self.tool_call_regex = re.compile(
|
|
r"<longcat_tool_call>(.*?)</longcat_tool_call>"
|
|
r"|<longcat_tool_call>(.*)",
|
|
re.DOTALL,
|
|
)
|