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

APIConnectionError in the first Jupyter notebook, lesson 4 #239

Open
webr5214 opened this issue Dec 14, 2023 · 6 comments
Open

APIConnectionError in the first Jupyter notebook, lesson 4 #239

webr5214 opened this issue Dec 14, 2023 · 6 comments

Comments

@webr5214
Copy link

I forked the repository to run in GitHub Codespaces. I am loading my API key from a codespaces secret into the .env file. When I run the first code cell that uses the openai module in lesson 4, I get an http error. I tested with a print statement to make sure the OpenAI client is receiving my API key.

I tested with a curl command to see if I could access the openai api from within Codespaces and received the expected result.

curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer API_KEY " -d '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7}'

Which makes me think it's a Jupyter environment problem.

Here's the error message:
codespaces_lesson4

Copy link

👋 Thanks for contributing @webr5214! We will review the issue and get back to you soon.

@yankeeshcn
Copy link

Hello, i have got same issue when run Exercise 2,
Ex2-error
I used latest openai package version 1.61.
I have checked the requirements.txt and downgrade openai from 1.61 to 0.28.0 and got another error. with below picture
Ex2-error-openai0 28 0
Do you have any idea?

@koreyspace
Copy link
Collaborator

Thanks for reporting, will take a look and let you know if we need any additional information!

@nitya
Copy link
Member

nitya commented Feb 7, 2024

I just walked through the notebook for Lesson 4 right now. I believe that has been updated now to use the Azure OpenAI provider key/endpoint vs. OpenAI which might be a reason why the call to the OpenAI API works from command-line, but the code fails.

I believe there is an OpenAI-specific set of exercises planned for the lessons. But for now, you will need to use an Azure OpenAI endpoint. If you have issues with that, can you please update this with new details?

Here is what the successful run looks like:

image

image

cc @koreyspace

@yuguangmao
Copy link

The reason for this error is usually that a firewall or permissions are blocking access to the api; please check: 1) the correct api access permissions; 2) that there is no firewall between the client application and the api.

Copy link

This issue has not seen any action for a while! Closing for now, but it can be reopened at a later date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants