From 3c20e16321894ff8bdd303621c567ba0ff8f82b5 Mon Sep 17 00:00:00 2001 From: Johnny Huynh <27847622+johnnyhuy@users.noreply.github.com> Date: Mon, 20 May 2024 08:28:06 +1000 Subject: [PATCH] fix: Improve error handling in summarizer module - Improve error handling in summarizer.py - Provide specific error messages for different exceptions --- transcribe_me/summarization/summarizer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transcribe_me/summarization/summarizer.py b/transcribe_me/summarization/summarizer.py index 8f4de1e..d5a35de 100644 --- a/transcribe_me/summarization/summarizer.py +++ b/transcribe_me/summarization/summarizer.py @@ -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: @@ -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