Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle API timeouts #3024

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions autogpt/llm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down