Skip to content

fix(core): align tool chat template JSON rendering - #2371

Open
atirna wants to merge 2 commits into
EricLBuehler:masterfrom
atirna:fix/align-tool-call-chat-template
Open

fix(core): align tool chat template JSON rendering#2371
atirna wants to merge 2 commits into
EricLBuehler:masterfrom
atirna:fix/align-tool-call-chat-template

Conversation

@atirna

@atirna atirna commented Aug 15, 2026

Copy link
Copy Markdown

Summary

  • preserve tool-schema insertion order through MiniJinja and serde_json
  • match transformers' default JSON separators and unescaped tool text
  • use local time for strftime_now and date_string

Testing

  • cargo fmt --all -- --check
  • cargo test -p mistralrs-core chat_template::tests --no-default-features
  • cargo check -p mistralrs-core --no-default-features

Fixes #2363

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Code Metrics Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Language              Files        Lines         Code     Comments       Blanks
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 C Header                 24         4497         3151          790          556
 CSS                       3          281          252            5           24
 CUDA                    124        26446        21759         1707         2980
 Dockerfile                1           35           19            9            7
 HTML                      2           27           27            0            0
 JavaScript                3          582          567           12            3
 Jinja2                    7          694          656            5           33
 JSON                     27        18278        18275            0            3
 Makefile                  1           18           16            0            2
 MDX                      37         6771            0         4994         1777
 Metal Shading Lan|       37        14416        11408         1136         1872
 PowerShell                1          657          571           31           55
 Python                  152        12617        10486          480         1651
 Shell                     3         1071          852          115          104
 Plain Text               53        10687            0         9209         1478
 TOML                     28         1397         1213           43          141
 TypeScript               11         1658         1418           66          174
 YAML                      3           25           23            2            0
─────────────────────────────────────────────────────────────────────────────────
 Jupyter Notebooks         3          122           83           23           16
 |- Markdown               1           60           30           22            8
 |- Python                 1          122          113            1            8
 (Total)                              304          226           46           32
─────────────────────────────────────────────────────────────────────────────────
 Markdown                275        12394            0         9265         3129
 |- BASH                  25          306          225           48           33
 |- Dockerfile             2           14           12            0            2
 |- JSON                   6          289          289            0            0
 |- PowerShell             1            1            1            0            0
 |- Python               135         7349         6119          306          924
 |- Rust                  62         3845         2851          396          598
 |- TOML                   7          116           97            0           19
 (Total)                            24314         9594        10015         4705
─────────────────────────────────────────────────────────────────────────────────
 Rust                    728       399029       360689         5489        32851
 |- Markdown             427        10136          452         8486         1198
 (Total)                           409165       361141        13975        34049
─────────────────────────────────────────────────────────────────────────────────
 Svelte                   19         1974         1832           50           92
 |- CSS                    1            4            4            0            0
 |- JavaScript            19          921          767           25          129
 (Total)                             2899         2603           75          221
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Total                  1542       536839       444257        42715        49867
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

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.

Chat template output differs from transformers on tool-calling prompts

1 participant