Error when invoking OpenAI

I am trying to run the L2 lab in my local Jupyter notebook. I have the correct version of Python and have used the requirements.txt file that was in the first lesson for setup.

My OpenAi key connects fine to the gpt-3.5-turbo model via another test call.

When I run the following code, however, I get an error shown below:

from llama_index.llms.openai import OpenAI

llm = OpenAI(model="gpt-3.5-turbo")
response = llm.predict_and_call(
    [add_tool, mystery_tool], 
    "Tell me the output of the mystery function on 2 and 9", 
    verbose=True
)

print(str(response))

The error is:

Retrying llama_index.llms.openai.base.OpenAI._chat in 0.974705252265967 seconds as it raised APIConnectionError: Connection error…

This occurs a few times and then the whole call errors out with a long trace.

This is as simple a call as I can think of and it still seems to fail. Any ideas?

Thanks,

Did you download all the files required to run the files, if you check other thread it states importing openai resolved this error.

Yes, I did load all pre- req libs including OpenAI.

I am curious if any one had got this to work on their own Jupyter lab env.

Can you share the screenshot of the error you are talking about

Hi Deepti, here is a screen shot:

Also, here is the full error dump.
eeroDump.zip (7.3 KB)

So I changed the LLM to use Mistral and that worked straight away. I then on a whim went and created a new OpenAI key (even though the previous key was working fine with another piece of code). Using the new OpenAI key, the code started to work.

Whew! I wish the error message was more explicit. But all working now. Thanks for your help.

2 Likes