Skip to content

Commit

Permalink
don't crash on over-constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Feb 22, 2024
1 parent 111a0e6 commit 9722795
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py/pyaici/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ def mid_process(self) -> MidProcessResult:
if log_level >= 2:
print("ALLOW:", bias)
if bias.num_set() == 0:
print("Constraint doesn't allow any tokens")
raise StopIteration
if log_level >= 1:
print("Constraint doesn't allow any tokens; adding EOS")
bias[eos_token()] = True
return MidProcessResult.bias(bias)

def post_process(self, tokens: List[Token]):
Expand Down

0 comments on commit 9722795

Please sign in to comment.