Add Mistral Small 4 (Pixtral) support (#20708)
Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com> Co-authored-by: Alex Nails <alexnails@radixark.ai> Co-authored-by: Dimitrios Bariamis <12195802+dbari@users.noreply.github.com> Co-authored-by: dbari <dbari@users.noreply.github.com>
This commit is contained in:
@@ -90,19 +90,27 @@ class MistralDetector(BaseFormatDetector):
|
||||
return StreamingParseResult(normal_text=combined_normal, calls=calls)
|
||||
|
||||
# Compact: `[TOOL_CALLS]tool_name[ARGS]{...}`
|
||||
parsed = self._try_parse_compact_args_format(tool_part)
|
||||
if not parsed:
|
||||
return StreamingParseResult(normal_text=normal_text, calls=[])
|
||||
func_name, args_obj, consumed = parsed
|
||||
# Loop to extract all consecutive compact tool calls.
|
||||
all_calls: list = []
|
||||
remaining = tool_part
|
||||
while remaining:
|
||||
parsed = self._try_parse_compact_args_format(remaining)
|
||||
if not parsed:
|
||||
break
|
||||
func_name, args_obj, consumed = parsed
|
||||
new_calls = self.parse_base_json(
|
||||
{"name": func_name, "arguments": args_obj}, tools
|
||||
)
|
||||
all_calls.extend(new_calls)
|
||||
remaining = remaining[consumed:].strip()
|
||||
|
||||
if not all_calls:
|
||||
return StreamingParseResult(normal_text=normal_text, calls=[])
|
||||
|
||||
calls = self.parse_base_json({"name": func_name, "arguments": args_obj}, tools)
|
||||
trailing_text = tool_part[consumed:].strip()
|
||||
combined_normal = (
|
||||
(normal_text + " " + trailing_text).strip()
|
||||
if trailing_text
|
||||
else normal_text
|
||||
(normal_text + " " + remaining).strip() if remaining else normal_text
|
||||
)
|
||||
return StreamingParseResult(normal_text=combined_normal, calls=calls)
|
||||
return StreamingParseResult(normal_text=combined_normal, calls=all_calls)
|
||||
|
||||
def parse_streaming_increment(
|
||||
self, new_text: str, tools: List[Tool]
|
||||
|
||||
Reference in New Issue
Block a user