[Bugfix] Fix the issue where tool calling does not work when using fast detokenization with dsv32 (#33964)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
Chauncey
2026-02-07 01:23:44 +08:00
committed by GitHub
parent 5c52644b10
commit 7bec435130

View File

@@ -110,6 +110,18 @@ class DeepSeekV32ToolParser(ToolParser):
"""Generate a unique tool call ID."""
return f"call_{uuid.uuid4().hex[:24]}"
def adjust_request(self, request):
request = super().adjust_request(request)
if request.tools and request.tool_choice != "none":
# Ensure tool call tokens
# (<DSMLfunction_calls>, </DSMLfunction_calls>)
# are not skippedduring decoding.
# Even though they are not marked as special tokens,
# setting skip_special_tokens=False ensures proper handling in
# transformers 5.x where decoding behavior may have changed.
request.skip_special_tokens = False
return request
def _reset_streaming_state(self):
"""Reset all streaming state."""
self.current_tool_index = 0