- reference/vllm/tokenizers/ — official DSV4 tokenizer + encoding (read-only) - reference/vllm/reasoning/ — thinking mode parsers (DeepSeekR1 style ) - reference/vllm/tool_parsers/ — DSML tool call parsers (V3.2 base, V4 variant) - reference/official_inference/ — original weight's generate.py, model.py, kernel.py - reference/README.md documents the layout and which files matter for our pipeline - These are read-only references for cross-checking, not imported by production code
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||
|
||
from vllm.entrypoints.openai.chat_completion.protocol import (
|
||
ChatCompletionRequest,
|
||
)
|
||
from vllm.tool_parsers.deepseekv32_tool_parser import DeepSeekV32ToolParser
|
||
from vllm.tool_parsers.structural_tag_registry import (
|
||
get_enable_structured_outputs_in_reasoning,
|
||
get_model_structural_tag,
|
||
)
|
||
|
||
|
||
class DeepSeekV4ToolParser(DeepSeekV32ToolParser):
|
||
"""
|
||
DeepSeek V4 DSML tool parser.
|
||
|
||
V4 keeps the V3.2 DSML invoke/parameter grammar, but wraps tool calls in
|
||
``<|DSML|tool_calls>`` instead of ``<|DSML|function_calls>``.
|
||
"""
|
||
|
||
tool_call_start_token: str = "<|DSML|tool_calls>"
|
||
tool_call_end_token: str = "</|DSML|tool_calls>"
|
||
|
||
def get_structural_tag(self, request: ChatCompletionRequest):
|
||
return get_model_structural_tag(
|
||
model="deepseek_v4",
|
||
tools=request.tools,
|
||
tool_choice=request.tool_choice,
|
||
reasoning=get_enable_structured_outputs_in_reasoning(),
|
||
)
|