File tree 1 file changed +7
-2
lines changed
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(
11861
11861
std::vector<std::vector<const llama_grammar_element *>> & new_stacks) {
11862
11862
11863
11863
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
+ }
11865
11867
return;
11866
11868
}
11867
11869
@@ -11898,7 +11900,10 @@ static void llama_grammar_advance_stack(
11898
11900
}
11899
11901
case LLAMA_GRETYPE_CHAR:
11900
11902
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
+ }
11902
11907
break;
11903
11908
default:
11904
11909
// 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