Skip to content

Conversation

ritik4ever
Copy link

Fix chat_template for Function Calling (Issue #860)
This PR fixes a bug in the tokenizer's chat template that caused errors when using apply_chat_template with function calling tools.
Description of changes
I've modified the chat template in tokenizer_config.json to:

Use safer dictionary access through .get() methods
Properly convert function arguments to JSON strings using the |tojson filter
Support empty content fields gracefully

Additional documentation

Added a demonstration script showing how to use function calling
Updated documentation on function calling capabilities

Related issues
Fixes #860

This commit fixes the chat template to properly handle function calls by:
1. Using safe dictionary access with .get()
2. Converting function arguments to JSON with |tojson filter
3. Adding better empty content handling

Fixes deepseek-ai#860
@ritik4ever
Copy link
Author

Please review .

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.

Failed to use apply_chat_template when adding tools
1 participant