Skip to content

Commit

Permalink
Print less warnings from mistral wrapper when they do not indicate a …
Browse files Browse the repository at this point in the history
…real problem

PiperOrigin-RevId: 672574924
Change-Id: I6c5f33d8c80a35ba2d54bad1d6b0d92b3f1197c3
  • Loading branch information
jzleibo authored and copybara-github committed Sep 9, 2024
1 parent 1c717c2 commit a62e960
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions concordia/language_model/mistral_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
'codestral-2405',
)

_NUM_SILENT_ATTEMPTS = 3


class MistralLanguageModel(language_model.LanguageModel):
"""Language Model wrapper that uses Mistral models."""
Expand Down Expand Up @@ -97,8 +99,9 @@ def _complete_text(
result = ''
for attempts in range(_MAX_CHAT_ATTEMPTS):
if attempts > 0:
print('Sleeping for 10 seconds... ' +
f'attempt: {attempts} / {_MAX_CHAT_ATTEMPTS}')
if attempts >= _NUM_SILENT_ATTEMPTS:
print('Sleeping for 10 seconds... ' +
f'attempt: {attempts} / {_MAX_CHAT_ATTEMPTS}')
time.sleep(10)
try:
response = self._client.fim.complete(
Expand Down Expand Up @@ -163,8 +166,9 @@ def _chat_text(
]
for attempts in range(_MAX_CHAT_ATTEMPTS):
if attempts > 0:
print('Sleeping for 10 seconds... ' +
f'attempt: {attempts} / {_MAX_CHAT_ATTEMPTS}')
if attempts >= _NUM_SILENT_ATTEMPTS:
print('Sleeping for 10 seconds... ' +
f'attempt: {attempts} / {_MAX_CHAT_ATTEMPTS}')
time.sleep(10)
try:
response = self._client.chat.complete(
Expand Down

0 comments on commit a62e960

Please sign in to comment.