Skip to content

Commit

Permalink
PromptTooLong error (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
technillogue authored Sep 4, 2024
1 parent 48359ee commit 69318df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ async def predict( # pylint: disable=invalid-overridden-method, arguments-diffe
len(result.outputs) == 1
), "Expected exactly one output from generation request."

if result.outputs[0].finish_reason == "length" and start != 0:
# hard to find the max length though, sorry
raise UserError(
"E1002 PromptTooLong: Prompt length exceeds maximum input length"
)
text = result.outputs[0].text

# Normalize text by removing any incomplete surrogate pairs (common with emojis)
Expand Down

0 comments on commit 69318df

Please sign in to comment.