I am trying to connect to the OpenAI api from python, a simple test, but I am not succeeding as I always get the same error:
MaxRetryError: HTTPSConnectionPool(host=‘api.openai.com’, port=443): Max retries exceeded with url: /v1/engines/text-davinci-001/completions (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))
I have tried to force it to ignore the certificate verification but I can’t, and I don’t know how to make it point to a correct certificate either.
Of course. This is a simple example that I copied from one of the tutorials. I am working on Windows 10.
import pandas as pd
import openai
import certifi
certifi.where()
import requests
openai.api_key = 'MY_API_KEY'
response = openai.Completion.create(
model="text-davinci-003",
prompt="I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:",
temperature=0,
max_tokens=100,
top_p=1,
frequency_penalty=0.0,
presence_penalty=0.0,
stop=["\n"]
)