# coding=gbk
import openai
openai.api_key = "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■sJqxxxx"
openai.api_base = "https://api.openai.com/v1/chat/completions"
openai.proxy = "http://127.0.0.1:7890"
i=openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}
]
)
print(i)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “F:\pythonWP\cljy\ss_script\test.py”, line 8, in
i=openai.ChatCompletion.create(
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\chat_completion.py”, line 25, in create
return super().create(*args, **kwargs)
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py”, line 153, in create
response, _, api_key = requestor.request(
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py”, line 216, in request
result = self.request_raw(
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py”, line 528, in request_raw
raise error.APIConnectionError(
openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host=‘api.openai.com’, port=443): Max retries exceeded with url: /v1/chat/completions/chat/completions (Caused by SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1129)’)))
I have downgraded my urllib3 module to 1.25.11
Does anyone know how to solve this problem?