Skip to content

Commit

Permalink
Raise exception if no response after all retries
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelOwenDyer committed Oct 11, 2024
1 parent 2438c5e commit b213250
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/llm/external/openai_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def chat(
traceback.print_exc()
logging.info(f"Retrying in {wait_time} seconds...")
time.sleep(wait_time)
logging.error(f"Failed to get response from OpenAI after {retries} retries")
raise Exception(f"Failed to get response from OpenAI after {retries} retries")


class DirectOpenAIChatModel(OpenAIChatModel):
Expand Down
3 changes: 1 addition & 2 deletions app/llm/external/openai_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def embed(self, text: str) -> list[float]:
logging.warning(f"OpenAI error on attempt {attempt + 1}: {e}")
logging.info(f"Retrying in {wait_time} seconds...")
time.sleep(wait_time)
logging.error(f"Failed to get embedding after {retries} retries.")
return []
raise Exception(f"Failed to get embedding from OpenAI after {retries} retries.")


class DirectOpenAIEmbeddingModel(OpenAIEmbeddingModel):
Expand Down

0 comments on commit b213250

Please sign in to comment.