[Bugfix] Fix Mistral tool-parser regex for nested JSON (#20093)

Signed-off-by: mgoin <mgoin64@gmail.com>
This commit is contained in:
Michael Goin
2025-06-26 01:01:17 +00:00
committed by GitHub
parent 296ce95d8e
commit 754b00edb3
2 changed files with 53 additions and 2 deletions
@@ -77,8 +77,8 @@ class MistralToolParser(ToolParser):
self.bot_token_id = self.vocab.get(self.bot_token)
self.tool_call_regex = re.compile(r"\[{.*}\]", re.DOTALL)
if _is_fn_name_regex_support(self.model_tokenizer):
self.fn_name_regex = re.compile(r'([a-zA-Z0-9_-]+)(\{.*?\})',
re.DOTALL)
self.fn_name_regex = re.compile(
r'([a-zA-Z0-9_-]+)(\{[\s\S]*?\})(?=\s*$|,|\s)', re.DOTALL)
else:
self.fn_name_regex = None