Unverified Commit 7bec4351 authored by Chauncey's avatar Chauncey Committed by GitHub
Browse files

[Bugfix] Fix the issue where tool calling does not work when using fast...


[Bugfix] Fix the issue where tool calling does not work when using fast detokenization with dsv32 (#33964)
Signed-off-by: default avatarchaunceyjiang <chaunceyjiang@gmail.com>
parent 5c52644b
...@@ -110,6 +110,18 @@ class DeepSeekV32ToolParser(ToolParser): ...@@ -110,6 +110,18 @@ class DeepSeekV32ToolParser(ToolParser):
"""Generate a unique tool call ID.""" """Generate a unique tool call ID."""
return f"call_{uuid.uuid4().hex[:24]}" 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
# (<|DSML|function_calls>, </|DSML|function_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): def _reset_streaming_state(self):
"""Reset all streaming state.""" """Reset all streaming state."""
self.current_tool_index = 0 self.current_tool_index = 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment