-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Support DeepSeek-V3.1 tool call #23454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support DeepSeek-V3.1 tool call #23454
Conversation
Signed-off-by: Xu Wenqing <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for DeepSeek-V3.1 tool calling by introducing a new tool parser and chat template. The changes are well-structured, including documentation updates and a new Jinja template. However, the implementation of the new DeepSeekV31ToolParser contains a couple of significant issues in its streaming logic. There's an incorrect type check and a fragile method for parsing the end of a JSON argument stream, which could lead to runtime errors and incorrect parsing of tool call arguments. Addressing these issues is crucial for ensuring robust functionality.
| if '"}' not in delta_text: | ||
| return None | ||
| end_loc = delta_text.rindex('"}') | ||
| diff = delta_text[:end_loc] + '"}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic to determine the end of the JSON arguments by searching for "} is not robust. It assumes a flat JSON structure where the last key-value pair is a string. This will fail for other valid JSON structures, such as those with nested objects (e.g., {"a": {"b": "c"}} which ends in }}) or non-string final values. This can lead to a ValueError from rindex or malformed JSON, causing tool call parsing to fail. A more robust parsing method should be used to handle arbitrary valid JSON.
|
After I added deepseekv31.tool_parser.py to the vllm v0.9.0 image following your method, it didn't take effect. Could there be an issue with my configuration? openai_api_base = "http://localhost:8000" client = OpenAI( tools = [ response = client.chat.completions.create( print(response) |
@makabaka6338 the tool parser not compatible with old vLLM version, please use latest main branch of vLLM. |
Signed-off-by: Xu Wenqing <[email protected]>
Signed-off-by: Xu Wenqing <[email protected]> Signed-off-by: Xiao Yu <[email protected]>
Signed-off-by: Xu Wenqing <[email protected]>
Signed-off-by: Xu Wenqing <[email protected]>
|
Signed-off-by: Xu Wenqing <[email protected]>
Signed-off-by: Xu Wenqing <[email protected]> Signed-off-by: Ekagra Ranjan <[email protected]>
Signed-off-by: Xu Wenqing <[email protected]>
Signed-off-by: Xu Wenqing <[email protected]>
Signed-off-by: Xu Wenqing <[email protected]>
Purpose
Support DeepSeek-V3.1 tool call.
The tool call format of DeepSeek-V3.1 is different from DeepSeek-V3/R1:
DeepSeek-V3.1: <|tool▁calls▁begin|><|tool▁call▁begin|>tool_call_name<|tool▁sep|>tool_call_arguments<|tool▁call▁end|><|tool▁calls▁end|>
DeepSeek-R1/V3: <|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>FUNCTION_NAME\n'
json\n{"param1": "value1", "param2": "value2"}\n<|tool▁call▁end|><|tool▁calls▁end|>So we can't use --tool-call-parser deepseek_v3 for this DeepSeek-V3.1, we need a new tool call parser "deepseek_v31"
Test Plan
Test Script (Streaming):
Test Script (Non-Streaming):
Test Result
Test Result (Streaming):
Test Result (Non-Streaming):
(Optional) Documentation Update
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.