Skip to content

vllm.parser.deepseek_v4

DeepSeek V4 parser: <think>/</think> reasoning plus DSML tool calls in a single state machine.

DeepSeek V4 output format::

<think>
...reasoning...
</think>
<|DSML|tool_calls>
<|DSML|invoke name="func_name">
<|DSML|parameter name="location" string="true">杭州</|DSML|parameter>
<|DSML|parameter name="count" string="false">5</|DSML|parameter>
</|DSML|invoke>
</|DSML|tool_calls>

_match_open_param(raw_args, pos, partial_param_re, param_start)

Return (name, is_str, value, held_back) for the trailing open param.

An unfinished next parameter tag (param_start with no > after it) is cut from the value; held_back reports whether that happened.

_param_patterns(param_start, param_close)

Complete and trailing-partial parameter regexes for one DSML dialect.

The string attribute is optional: the model sometimes omits it, and dropping such a parameter hands the client a tool call with no arguments. The trailing-partial regex captures the open value up to the end of the text; _match_open_param holds back an unfinished next parameter tag so a streamed string value never includes it.