File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,7 @@ struct llama_server_context
196
196
llama_context *ctx = nullptr ;
197
197
gpt_params params;
198
198
199
+ grammar_parser::parse_state parsed_grammar;
199
200
llama_grammar *grammar = nullptr ;
200
201
201
202
bool truncated = false ;
@@ -241,10 +242,13 @@ struct llama_server_context
241
242
stopped_limit = false ;
242
243
stopping_word = " " ;
243
244
multibyte_pending = 0 ;
244
- grammar = nullptr ;
245
-
246
245
n_remain = 0 ;
247
246
n_past = 0 ;
247
+
248
+ if (grammar != nullptr ) {
249
+ llama_grammar_free (grammar);
250
+ grammar = nullptr ;
251
+ }
248
252
}
249
253
250
254
bool loadModel (const gpt_params ¶ms_)
@@ -265,8 +269,6 @@ struct llama_server_context
265
269
bool loadGrammar ()
266
270
{
267
271
if (!params.grammar .empty ()) {
268
- grammar_parser::parse_state parsed_grammar;
269
-
270
272
parsed_grammar = grammar_parser::parse (params.grammar .c_str ());
271
273
// will be empty (default) if there are parse errors
272
274
if (parsed_grammar.rules .empty ()) {
You can’t perform that action at this time.
0 commit comments