add function call parser for DeepSeek V3 (#5224)

This commit is contained in:
Yi Zhou
2025-04-21 08:38:08 +08:00
committed by GitHub
parent 8b39274e34
commit fac17acf08
4 changed files with 119 additions and 1 deletions

View File

@@ -938,6 +938,35 @@ def v1_chat_generate_request(
if chat_template_name is None:
openai_compatible_messages = []
if (
tools
and tokenizer_manager.server_args.tool_call_parser == "deepseekv3"
):
# add function call prompt to deepseekv3
openai_compatible_messages.append(
{
"role": "system",
"content": """You are a helpful Assistant.
## Tools
### Function
You have the following functions available:
"""
+ "".join(
[
f"""
- `{tool['name']}`:
```json
{json.dumps(tool)}
```
"""
for tool in tools
]
),
}
)
# TODO fix the compatible issues with xgrammar
strict_tag = None
for message in request.messages:
if isinstance(message.content, str):
openai_compatible_messages.append(