Skip to content

Commit

Permalink
models: improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
miltondp committed Jan 5, 2023
1 parent 8462bf7 commit 2c817d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libs/manubot/ai_editor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ def revise_paragraph(self, paragraph_text, section_name):

# if the error message suggests to sample again, let's do that
if "Please sample again" in error_message:
continue
break

if "server is overloaded" in error_message:
time.sleep(5)
continue
break

# if the error mesaage suggests to reduce the number of tokens,
# obtain the number of tokens to reduce and retry
Expand All @@ -461,7 +461,7 @@ def revise_paragraph(self, paragraph_text, section_name):
tokens_in_prompt = token_stats["tokens_in_prompt"]

params["max_tokens"] = max_context_length - tokens_in_prompt

retry_count += 1
finally:
retry_count += 1

return message

0 comments on commit 2c817d9

Please sign in to comment.