From ba7a468f025c49cc235700f5a5119dfbbc5b252d Mon Sep 17 00:00:00 2001 From: Kye Date: Sat, 11 Nov 2023 18:17:17 -0500 Subject: [PATCH] openai api fix --- swarms/models/openai_chat.py | 2 +- swarms/models/openai_models.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/swarms/models/openai_chat.py b/swarms/models/openai_chat.py index aaf2eb191..d101a533e 100644 --- a/swarms/models/openai_chat.py +++ b/swarms/models/openai_chat.py @@ -102,7 +102,7 @@ def _create_retry_decorator( errors = [ openai.Timeout, - openai.error.APIError, + openai.APIError, openai.error.APIConnectionError, openai.error.RateLimitError, openai.error.ServiceUnavailableError, diff --git a/swarms/models/openai_models.py b/swarms/models/openai_models.py index 1aea7b03c..35894d7f9 100644 --- a/swarms/models/openai_models.py +++ b/swarms/models/openai_models.py @@ -788,10 +788,10 @@ def validate_environment(cls, values: Dict) -> Dict: if openai_organization: raise Exception("The 'openai.organization' option isn't read in the client API. You will need to pass it when you instantiate the client, e.g. 'OpenAI(organization=openai_organization)'") if openai_proxy: - raise Exception("The 'openai.proxy' option isn't read in the client API. You will need to pass it when you instantiate the client, e.g. 'OpenAI(proxy={ + openai.proxy = { "http": openai_proxy, "https": openai_proxy, - })'") # type: ignore[assignment] # noqa: E501 + } # type: ignore[assignment] # noqa: E501 except ImportError: raise ImportError( "Could not import openai python package. "