Skip to content

Commit

Permalink
fix: Improve error handling in summarizer module
Browse files Browse the repository at this point in the history
- Improve error handling in summarizer.py
- Provide specific error messages for different exceptions
  • Loading branch information
johnnyhuy committed May 19, 2024
1 parent 1c91b64 commit 3c20e16
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions transcribe_me/summarization/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def generate_summary(
summary = openai_response.choices[0].message.content.strip()
except openai.error.RateLimitError as e:
print(f"{Fore.YELLOW}Rate limit reached, retrying in a bit...")
raise e
except e:
print(f"{Fore.RED}Error: {e}")
elif "anthropic" in platform:
anthropic_client = anthropic.Anthropic(api_key=ANTHROPIC_API_KEY)
try:
Expand All @@ -55,8 +56,8 @@ def generate_summary(
summary = anthropic_response.content[0].text
except anthropic.error.RateLimitError as e:
print(f"{Fore.YELLOW}Rate limit reached, retrying in a bit...")
raise e

except e:
print(f"{Fore.RED}Error: {e}")
return summary


Expand Down

0 comments on commit 3c20e16

Please sign in to comment.