| 432 | } |
| 433 | |
| 434 | void common_sampler_accept(struct common_sampler * gsmpl, llama_token token, bool accept_grammar) { |
| 435 | if (!gsmpl) { |
| 436 | return; |
| 437 | } |
| 438 | |
| 439 | const auto tm = gsmpl->tm(); |
| 440 | |
| 441 | // grammar_should_apply() checks the reasoning budget state, so calculate this before we accept |
| 442 | accept_grammar = accept_grammar && grammar_should_apply(gsmpl); |
| 443 | |
| 444 | llama_sampler_accept(gsmpl->rbudget, token); |
| 445 | |
| 446 | if (gsmpl->grmr && accept_grammar) { |
| 447 | llama_sampler_accept(gsmpl->grmr, token); |
| 448 | } |
| 449 | |
| 450 | llama_sampler_accept(gsmpl->chain, token); |
| 451 | |
| 452 | gsmpl->prev.push_back(token); |
| 453 | } |
| 454 | |
| 455 | void common_sampler_reset(struct common_sampler * gsmpl) { |
| 456 | if (!gsmpl) { |