From b6ed03cb22fda8edbbbd94d3885e5fa39fc29a63 Mon Sep 17 00:00:00 2001 From: Soheil Date: Sun, 23 Apr 2023 07:51:21 -0700 Subject: [PATCH] handle API timeouts --- autogpt/llm_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autogpt/llm_utils.py b/autogpt/llm_utils.py index 8b85959cdb93..1cebce54a143 100644 --- a/autogpt/llm_utils.py +++ b/autogpt/llm_utils.py @@ -5,7 +5,7 @@ import openai from colorama import Fore, Style -from openai.error import APIError, RateLimitError +from openai.error import APIError, RateLimitError, Timeout from autogpt.config import Config from autogpt.logs import logger @@ -122,7 +122,7 @@ def create_chat_completion( + f"You can read more here: {Fore.CYAN}https://github.com/Significant-Gravitas/Auto-GPT#openai-api-keys-configuration{Fore.RESET}" ) warned_user = True - except APIError as e: + except (APIError, Timeout) as e: if e.http_status != 502: raise if attempt == num_retries - 1: @@ -172,7 +172,7 @@ def create_embedding_with_ada(text) -> list: )["data"][0]["embedding"] except RateLimitError: pass - except APIError as e: + except (APIError, Timeout) as e: if e.http_status != 502: raise if attempt == num_retries - 1: