[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:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user