Skip to content

fix(sdk): propagate enable_thinking from TextMessages and add set_sampler_repetition_penalty#1967

Open
jm-observer wants to merge 2 commits intoEricLBuehler:masterfrom
jm-observer:try-fix
Open

fix(sdk): propagate enable_thinking from TextMessages and add set_sampler_repetition_penalty#1967
jm-observer wants to merge 2 commits intoEricLBuehler:masterfrom
jm-observer:try-fix

Conversation

@jm-observer
Copy link
Copy Markdown

Summary

Two small but impactful bug fixes in the Rust SDK:

  • enable_thinking was silently dropped when converting TextMessages
    into RequestBuilder. The From<TextMessages> for RequestBuilder impl
    always set enable_thinking: None, ignoring whatever the caller had
    configured on the TextMessages instance. This meant calling
    .enable_thinking(true/false) on a TextMessages had no effect.

  • set_sampler_frequency_penalty does not exist on RequestBuilder,
    but the websocket UI handler was calling it. This would fail to compile
    unless the method happened to be defined elsewhere. The correct method
    for repetition penalty is set_sampler_repetition_penalty, which is now
    added to RequestBuilder.

Changes

  • mistralrs/src/messages.rs: Forward value.enable_thinking in the
    From<TextMessages> conversion instead of hardcoding None.
  • mistralrs/src/messages.rs: Add RequestBuilder::set_sampler_repetition_penalty
    (sets sampling_params.repetition_penalty).
  • mistralrs-cli/src/ui/handlers/websocket.rs: Call
    set_sampler_repetition_penalty instead of the non-existent
    set_sampler_frequency_penalty.

…pler_repetition_penalty

- Fix enable_thinking field not being forwarded when converting TextMessages
  to RequestBuilder (was always None)
- Add RequestBuilder::set_sampler_repetition_penalty replacing the
  non-existent set_sampler_frequency_penalty used in websocket handler
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

Code Metrics Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Language              Files        Lines         Code     Comments       Blanks
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 C Header                  5          305          210           52           43
 CSS                       2         1181         1036           34          111
 CUDA                     46        13150         9967         1467         1716
 Dockerfile                1           39           22            8            9
 HTML                      2          235          197           14           24
 JavaScript               16         3546         2676          482          388
 Jinja2                    7          694          656            5           33
 JSON                     21          409          406            0            3
 Makefile                  1            6            5            0            1
 Metal Shading Lan|       31        11519         8914         1048         1557
 PowerShell                1          300          227           30           43
 Python                  119         8050         6579          405         1066
 Shell                     2          424          274           92           58
 Plain Text                3         3723            0         2413         1310
 TOML                     27         1290         1124           35          131
 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                 98        10470            0         7673         2797
 |- BASH                  48          708          535          107           66
 |- JSON                  16          666          666            0            0
 |- PowerShell             2            2            2            0            0
 |- Python                19          740          563           83           94
 |- Rust                  46         1826         1519           51          256
 |- TOML                   6          207          164            0           43
 |- YAML                   2            9            8            1            0
 (Total)                            14628         3457         7915         3256
─────────────────────────────────────────────────────────────────────────────────
 Rust                    524       221388       194812         6095        20481
 |- Markdown             339         8370          451         6865         1054
 (Total)                           229758       195263        12960        21535
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Total                   912       289586       231262        27008        31316
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Copy link
Copy Markdown
Owner

@EricLBuehler EricLBuehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jm-observer! Looks good, just 1 small comment?

.set_sampler_topp(top_p)
.set_sampler_topk(top_k)
.set_sampler_max_len(max_tokens)
.set_sampler_frequency_penalty(rep_penalty);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed in favor of set_sampler_repetition_penalty? I think it should be both.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 I’m not sure—this was modified by AI.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! Lets just make sure its both . set_sampler_repetition_penalty and . set_sampler_frequency_penalty.

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.

2 participants