File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -11861,7 +11861,9 @@ static void llama_grammar_advance_stack(
1186111861 std::vector<std::vector<const llama_grammar_element *>> & new_stacks) {
1186211862
1186311863 if (stack.empty()) {
11864- new_stacks.emplace_back(stack);
11864+ if (std::find(new_stacks.begin(), new_stacks.end(), stack) == new_stacks.end()) {
11865+ new_stacks.emplace_back(stack);
11866+ }
1186511867 return;
1186611868 }
1186711869
@@ -11898,7 +11900,10 @@ static void llama_grammar_advance_stack(
1189811900 }
1189911901 case LLAMA_GRETYPE_CHAR:
1190011902 case LLAMA_GRETYPE_CHAR_NOT:
11901- new_stacks.emplace_back(stack);
11903+ if (std::find(new_stacks.begin(), new_stacks.end(), stack) == new_stacks.end()) {
11904+ // only add the stack if it's not a duplicate of one we already have
11905+ new_stacks.emplace_back(stack);
11906+ }
1190211907 break;
1190311908 default:
1190411909 // end of alternate (LLAMA_GRETYPE_END, LLAMA_GRETYPE_ALT) or middle of char range
You can’t perform that action at this time.
0 commit comments