From 0daebc6b8d1ca5349b12628f9b1dc85b663700e0 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Tue, 3 Sep 2024 15:19:32 +0300 Subject: [PATCH] cont : fix [no ci] --- src/llama-sampling.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/llama-sampling.cpp b/src/llama-sampling.cpp index becc949dc..f6328b601 100644 --- a/src/llama-sampling.cpp +++ b/src/llama-sampling.cpp @@ -973,8 +973,14 @@ struct llama_constraint * llama_constraint_init_grammar_impl(const struct llama_ auto * ctx = (llama_constraint_context_grammar *) result->ctx; if (grammar_str != nullptr && grammar_str[0] != '\0') { + ctx->grammar_str = grammar_str; + ctx->grammar_root = grammar_root; + ctx->grammar = llama_grammar_init_impl(&vocab, grammar_str, grammar_root); } else { + ctx->grammar_str.clear(); + ctx->grammar_root.clear(); + ctx->grammar = nullptr; }