Skip to content

Commit

Permalink
Catch another type of together API exception
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696177257
Change-Id: Idcb276ee0c63c036e04fbf43a81a1ff623068726
  • Loading branch information
jzleibo authored and copybara-github committed Nov 13, 2024
1 parent 853abec commit 0151181
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions concordia/language_model/together_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,14 @@ def sample_text(
)
except (together.error.RateLimitError,
together.error.APIError,
together.error.ServiceUnavailableError) as err:
together.error.ServiceUnavailableError,
together.error.InvalidRequestError) as err:
if attempts >= _NUM_SILENT_ATTEMPTS:
print(f' Exception: {err}')
print(f' Text exception prompt: {prompt}')
if isinstance(err, together.error.APIError):
if isinstance(err, together.error.APIError) or isinstance(
err, together.error.InvalidRequestError
):
# If hit the error that arises from a prompt that is too long then
# re-run the trimming function with a more pessimistic guess of the
# the number of characters per token.
Expand Down Expand Up @@ -282,11 +285,14 @@ def _sample_choice(
)
except (together.error.RateLimitError,
together.error.APIError,
together.error.ServiceUnavailableError) as err:
together.error.ServiceUnavailableError,
together.error.InvalidRequestError) as err:
if attempts >= _NUM_SILENT_ATTEMPTS:
print(f' Exception: {err}')
print(f' Choice exception prompt: {augmented_prompt}')
if isinstance(err, together.error.APIError):
if isinstance(err, together.error.APIError) or isinstance(
err, together.error.InvalidRequestError
):
# If hit the error that arises from a prompt that is too long then
# re-run the trimming function with a more pessimistic guess of the
# the number of characters per token.
Expand Down

0 comments on commit 0151181

Please sign in to comment.