Skip to content

Add DeepSeek v4 tool parser#22

Open
spicyneuron wants to merge 2 commits into
Blaizzy:pc/add-deepseekv4flash-modelfrom
spicyneuron:ds4-tools
Open

Add DeepSeek v4 tool parser#22
spicyneuron wants to merge 2 commits into
Blaizzy:pc/add-deepseekv4flash-modelfrom
spicyneuron:ds4-tools

Conversation

@spicyneuron
Copy link
Copy Markdown

@spicyneuron spicyneuron commented May 7, 2026

Adds preliminary tool parsing support.

I copied the hidden but presumably official chat template into one of your quants, and ran against the official encoding tests to validate.

Tool calls seem to work as expected via mlx-lm server + Anthropic proxy + Claude Code.

Worth noting, mlx-lm matches tool calls at the token-level, which is different than the official repo's \n\n<|DSML|tool_calls string. The newlines aren't reliable matched because white space can get tokenized with punctuation (ex: .\n\n). So I opted to match on <|DSML|tool_calls instead.

That works reliably but means newlines slip into message content. The fix would need to touch server.py, so I left it out for now. Open to other suggestions.

@spicyneuron spicyneuron marked this pull request as ready for review May 7, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant