mirror of
https://github.com/usestrix/strix.git
synced 2026-09-13 23:11:07 +00:00
fix: MiniMax tool call normalization and thinking block handling
This commit is contained in:
parent
15c95718e6
commit
dba1a45c0e
2 changed files with 8 additions and 1 deletions
|
|
@ -202,6 +202,13 @@ class LLM:
|
|||
|
||||
accumulated = normalize_tool_format(accumulated)
|
||||
accumulated = fix_incomplete_tool_call(_truncate_to_first_function(accumulated))
|
||||
|
||||
thinking_content = ""
|
||||
for match in re.finditer(r"<thinking[^>]*>(.*?)</thinking>", accumulated, re.DOTALL):
|
||||
thinking_content += match.group(1) + "\n"
|
||||
if thinking_content:
|
||||
accumulated = accumulated.replace(thinking_content, "")
|
||||
|
||||
yield LLMResponse(
|
||||
content=accumulated,
|
||||
tool_invocations=parse_tool_invocations(accumulated),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ def normalize_tool_format(content: str) -> str:
|
|||
<function="X"> → <function=X>
|
||||
<parameter="X"> → <parameter=X>
|
||||
"""
|
||||
if "<invoke" in content or "<function_calls" in content:
|
||||
if "<invoke" in content or "<function_calls" in content or '<parameter name="' in content:
|
||||
content = _FUNCTION_CALLS_TAG.sub("", content)
|
||||
content = _INVOKE_OPEN.sub(r"<function=\1>", content)
|
||||
content = _PARAM_NAME_ATTR.sub(r"<parameter=\1>", content)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue