Update test-tool-call.cpp
This commit is contained in:
parent
e70ce3f613
commit
f0bd69380b
1 changed files with 2 additions and 5 deletions
|
@ -44,13 +44,10 @@ static std::unique_ptr<llama_grammar> build_grammar(const std::string & grammar_
|
||||||
static bool match_string(const std::string & input, llama_grammar * grammar) {
|
static bool match_string(const std::string & input, llama_grammar * grammar) {
|
||||||
const auto cpts = unicode_cpts_from_utf8(input);
|
const auto cpts = unicode_cpts_from_utf8(input);
|
||||||
|
|
||||||
const llama_grammar_rules & rules = llama_grammar_get_rules (grammar);
|
auto & stacks_cur = llama_grammar_get_stacks(grammar);
|
||||||
llama_grammar_stacks & stacks_cur = llama_grammar_get_stacks(grammar);
|
|
||||||
|
|
||||||
for (const auto & cpt : cpts) {
|
for (const auto & cpt : cpts) {
|
||||||
const llama_grammar_stacks stacks_prev = llama_grammar_get_stacks(grammar); // copy
|
llama_grammar_accept(grammar, cpt);
|
||||||
|
|
||||||
llama_grammar_accept(rules, stacks_prev, cpt, stacks_cur);
|
|
||||||
|
|
||||||
if (stacks_cur.empty()) {
|
if (stacks_cur.empty()) {
|
||||||
// no stacks means that the grammar failed to match at this point
|
// no stacks means that the grammar failed to match at this point
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue