anjalib
anjalib

Reputation: 41

AttributeError: module ‘openai’ has no attribute ‘error’

I'm running a Python summarizer in Azure ML that queries my gpt4 deployment for information. Everything was working fine until two days ago, when I decided to switch the output directory of the summaries to a different blob storage. Since then I am strangely getting the above error. My openAI version is 1.3.3 and langchain 0.0.301, and python 3.8. I have looked this up online and downgraded the version of openAI but it doesn't help. I've also tried the solutions here https://community.openai.com/t/attributeerror-module-openai-has-no-attribute-error/486676/8

but none have worked for me. Has anyone else also faced this?

I tried downgrading OpenAI and langchain Python libraries. I deleted the repo clone and AzureML notebook and made everything from scratch multiple times. This was working perfectly just two days ago and now it doesn't.

Upvotes: 1

Views: 6963

Answers (3)

Benyamin Jafari
Benyamin Jafari

Reputation: 34216

You can use the new interface of OpenAI Exceptions:

from openai import RateLimitError, Timeout, APIError, APIConnectionError, OpenAIError


try:
    ...
except OpenAIError as exc:
    ...

The OpenAI version I'm using is 1.13.3

Upvotes: 0

RubenAMtz
RubenAMtz

Reputation: 1

so many wrappers and so many moving parts, I faced the same problem when using the promptflow_vectordb interface to create a vector store. After trying to upgrade/downgrade to many different version combinations I realized this module is behind the latest langchain/openai implementations, I can't downgrade now as my project is reliant of current features so I had to change the code base. I expect they update this soon.

class AOAIEmbedding(Embedding):

    @retry_and_handle_exceptions(exception_to_check=openai.error.RateLimitError,
                                 max_retries=5,
                                 extract_delay_from_error_message=extract_delay_from_rate_limit_error_msg)
    def embed(self, text: str) -> List[float]:
        return openai.Embedding.create(
            input=text,
            engine=self.__config.model_name)["data"][0]["embedding"]

Upvotes: 0

Kiên Nguyễn
Kiên Nguyễn

Reputation: 21

I also got the same error and i downgraded openai version to 0.27.4 and it worked

Upvotes: 2

Related Questions