Support DeepSeek-V3.1 tool call#23454
Conversation
Signed-off-by: Xu Wenqing <xuwq1993@qq.com>
There was a problem hiding this comment.
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.
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 <xuwq1993@qq.com>
Signed-off-by: Xu Wenqing <xuwq1993@qq.com> Signed-off-by: Xiao Yu <xiao.yu@amd.com>
Signed-off-by: Xu Wenqing <xuwq1993@qq.com>
Signed-off-by: Xu Wenqing <xuwq1993@qq.com>
|
Signed-off-by: Xu Wenqing <xuwq1993@qq.com>
Signed-off-by: Xu Wenqing <xuwq1993@qq.com> Signed-off-by: Ekagra Ranjan <3116519+ekagra-ranjan@users.noreply.github.com>
Signed-off-by: Xu Wenqing <xuwq1993@qq.com>
Signed-off-by: Xu Wenqing <xuwq1993@qq.com>
Signed-off-by: Xu Wenqing <xuwq1993@qq.com>
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.