| 216 | } |
| 217 | |
| 218 | void llama_sampling_accept( |
| 219 | struct llama_sampling_context * ctx_sampling, |
| 220 | struct llama_context * ctx_main, |
| 221 | llama_token id, |
| 222 | bool apply_grammar) { |
| 223 | ctx_sampling->prev.erase(ctx_sampling->prev.begin()); |
| 224 | ctx_sampling->prev.push_back(id); |
| 225 | |
| 226 | if (ctx_sampling->grammar != NULL && apply_grammar) { |
| 227 | llama_grammar_accept_token(ctx_main, ctx_sampling->grammar, id); |
| 228 | } |
| 229 | } |