From 794a164098dc78d3d9cba854fbee6b5321566abd Mon Sep 17 00:00:00 2001 From: Soheil Sam Yasrebi <52513082+soheil@users.noreply.github.com> Date: Mon, 24 Apr 2023 00:26:14 -0700 Subject: [PATCH] handle API timeouts (#3024) --- 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 ba7521a4..cc650f21 100644 --- a/autogpt/llm_utils.py +++ b/autogpt/llm_utils.py @@ -5,7 +5,7 @@ from typing import List, Optional import openai from colorama import Fore, Style -from openai.error import APIError, RateLimitError +from openai.error import APIError, RateLimitError, Timeout from autogpt.api_manager import api_manager from autogpt.config import Config @@ -123,7 +123,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: ) except RateLimitError: pass - except APIError as e: + except (APIError, Timeout) as e: if e.http_status != 502: raise if attempt == num_retries - 1: