File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -266,10 +266,14 @@ void common_sampler_reset(struct common_sampler * gsmpl) {
266266 llama_sampler_reset (gsmpl->chain );
267267}
268268
269- void common_sampler_reset_grammar (struct common_sampler * gsmpl) {
269+ void common_sampler_reinit_grammar (struct common_sampler * gsmpl, const struct llama_model * model, const char * grammar ) {
270270 llama_sampler_reset (gsmpl->grmr );
271271
272- llama_sampler_reset (gsmpl->chain );
272+ gsmpl->grmr = llama_sampler_init_grammar (model, grammar, " root" );
273+ }
274+
275+ void common_sampler_reset_grammar (struct common_sampler * gsmpl) {
276+ llama_sampler_reset (gsmpl->grmr );
273277}
274278
275279struct common_sampler * common_sampler_clone (common_sampler * gsmpl) {
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ void common_sampler_free(struct common_sampler * gsmpl);
4343// if accept_grammar is true, the token is accepted both by the sampling chain and the grammar
4444void common_sampler_accept (struct common_sampler * gsmpl, llama_token token, bool accept_grammar);
4545void common_sampler_reset (struct common_sampler * gsmpl);
46+ void common_sampler_reinit_grammar (struct common_sampler * gsmpl, const struct llama_model * model, const char * grammar);
4647void common_sampler_reset_grammar (struct common_sampler * gsmpl);
4748struct common_sampler * common_sampler_clone (struct common_sampler * gsmpl);
4849
You can’t perform that action at this time.
0 commit comments