vllm_mlx.tool_parsers.deepseek_tool_parser¶
DeepSeek tool call parser for vllm-mlx.
View the complete module source at #L1-L170.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
vllm_mlx.tool_parsers.deepseek_tool_parser
¶
DeepSeek tool call parser for vllm-mlx.
Handles DeepSeek V3 and R1 tool calling formats:
- <|tool▁calls▁begin|>...<|tool▁calls▁end|> wrapper
- <|tool▁call▁begin|>function<|tool▁sep|>name
json
{...}<|tool▁call▁end|>
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser
¶
Bases: ToolParser
Tool call parser for DeepSeek V3 and R1 models.
Supports DeepSeek's tool call format with special unicode tokens:
<|tool▁calls▁begin|>
<|tool▁call▁begin|>function<|tool▁sep|>get_weather
json
{"city": "Paris"}<|tool▁call▁end|>
<|tool▁calls▁end|>
Used when --enable-auto-tool-choice --tool-call-parser deepseek are set.
Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.SUPPORTS_NATIVE_TOOL_FORMAT
class-attribute
instance-attribute
¶
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.TOOL_CALLS_START
class-attribute
instance-attribute
¶
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.TOOL_CALLS_END
class-attribute
instance-attribute
¶
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.TOOL_CALL_START
class-attribute
instance-attribute
¶
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.TOOL_CALL_END
class-attribute
instance-attribute
¶
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.TOOL_SEP
class-attribute
instance-attribute
¶
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.TOOL_CALL_PATTERN
class-attribute
instance-attribute
¶
TOOL_CALL_PATTERN = re.compile('<|tool▁call▁begin|>(?P<type>.*?)<|tool▁sep|>(?P<name>.*?)\\n```json\\n(?P<args>.*?)\\n```<|tool▁call▁end|>', re.DOTALL)
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.TOOL_CALL_SIMPLE_PATTERN
class-attribute
instance-attribute
¶
TOOL_CALL_SIMPLE_PATTERN = re.compile('<|tool▁call▁begin|>(?P<name>.*?)\\n```json\\n(?P<args>.*?)\\n```<|tool▁call▁end|>', re.DOTALL)
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.extract_tool_calls
¶
extract_tool_calls(model_output: str, request: dict[str, Any] | None = None) -> ExtractedToolCallInformation
Extract tool calls from DeepSeek model output.
Source code in vllm_mlx/tool_parsers/deepseek_tool_parser.py
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.extract_tool_calls_streaming
¶
extract_tool_calls_streaming(previous_text: str, current_text: str, delta_text: str, previous_token_ids: Sequence[int] | None = None, current_token_ids: Sequence[int] | None = None, delta_token_ids: Sequence[int] | None = None, request: dict[str, Any] | None = None) -> dict[str, Any] | None
Extract tool calls from streaming DeepSeek model output.
Source code in vllm_mlx/tool_parsers/deepseek_tool_parser.py
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
vllm_mlx.tool_parsers.deepseek_tool_parser.generate_tool_id · function
Generate a unique tool call ID.
Parameters
This callable has no explicit inputs.
Returns
- Type:
str - Direct return expressions:
f'call_{uuid.uuid4().hex[:8]}'
Exceptions and behavior
Function generate_tool_id calls uuid.uuid4; returns f'call_{uuid.uuid4().hex[:8]}'.
No direct raise statement appears in this definition.
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser · class
Tool call parser for DeepSeek V3 and R1 models.
Parameters
This callable has no explicit inputs.
Returns
- Constructs:
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser
Exceptions and behavior
Class DeepSeekToolParser derives from ToolParser and declares 2 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.extract_tool_calls · method
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.extract_tool_calls(model_output: str, request: dict[str, Any] | None = None) -> ExtractedToolCallInformation
Extract tool calls from DeepSeek model output.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_output |
str |
yes |
none |
Required positional or keyword input. |
request |
dict[str, Any] \| None |
no |
None |
Optional positional or keyword input; defaults to None. |
Returns
- Type:
ExtractedToolCallInformation - Direct return expressions:
ExtractedToolCallInformation(tools_called=False, tool_calls=[], content=model_output);ExtractedToolCallInformation(tools_called=True, tool_calls=tool_calls, content=content)
Exceptions and behavior
Method DeepSeekToolParser.extract_tool_calls calls ExtractedToolCallInformation, model_output.find, model_output[:content_end].strip, self.TOOL_CALL_PATTERN.findall; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.extract_tool_calls_streaming · method
vllm_mlx.tool_parsers.deepseek_tool_parser.DeepSeekToolParser.extract_tool_calls_streaming(previous_text: str, current_text: str, delta_text: str, previous_token_ids: Sequence[int] | None = None, current_token_ids: Sequence[int] | None = None, delta_token_ids: Sequence[int] | None = None, request: dict[str, Any] | None = None) -> dict[str, Any] | None
Extract tool calls from streaming DeepSeek model output.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
previous_text |
str |
yes |
none |
Required positional or keyword input. |
current_text |
str |
yes |
none |
Required positional or keyword input. |
delta_text |
str |
yes |
none |
Required positional or keyword input. |
previous_token_ids |
Sequence[int] \| None |
no |
None |
Optional positional or keyword input; defaults to None. |
current_token_ids |
Sequence[int] \| None |
no |
None |
Optional positional or keyword input; defaults to None. |
delta_token_ids |
Sequence[int] \| None |
no |
None |
Optional positional or keyword input; defaults to None. |
request |
dict[str, Any] \| None |
no |
None |
Optional positional or keyword input; defaults to None. |
Returns
- Type:
dict[str, Any] | None - Direct return expressions:
{'content': delta_text};{'tool_calls': [{'index': i, 'id': tc['id'], 'type': 'function', 'function': {'name': tc['name'], 'arguments': tc['argu…;None
Exceptions and behavior
Method DeepSeekToolParser.extract_tool_calls_streaming calls self.extract_tool_calls, enumerate; has 3 explicit return paths.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
generate_tool_id |
function | generate_tool_id() -> str |
Generate a unique tool call ID. | #L26-L28 |
DeepSeekToolParser |
class | DeepSeekToolParser() |
Tool call parser for DeepSeek V3 and R1 models. | #L32-L170 |
DeepSeekToolParser.extract_tool_calls |
method | DeepSeekToolParser.extract_tool_calls(model_output: str, request: dict[str, Any] \| None = None) -> ExtractedToolCallInformation |
Extract tool calls from DeepSeek model output. | #L69-L133 |
DeepSeekToolParser.extract_tool_calls_streaming |
method | DeepSeekToolParser.extract_tool_calls_streaming(previous_text: str, current_text: str, delta_text: str, previous_token_ids: Sequence[int] \| None = None, current_token_ids: Sequence[int] \| None = None, delta_token_ids: Sequence[int] \| None = None, request: dict[str, Any] \| None = None) -> dict[str, Any] \| None |
Extract tool calls from streaming DeepSeek model output. | #L135-L170 |