-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Describe the bug
I got the following error when using openai arequest_raw.
Traceback (most recent call last):
File "/home/admin/gpt/curious-cub-server/test_openai.py", line 31, in arequest_raw
result = await session.request(**request_kwargs)
File "/home/admin/.local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
File "/home/admin/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
File "/home/admin/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/home/admin/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/home/admin/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/home/admin/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host www.baidu.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
To Reproduce
Even i added the following line to fix my issue, i just wanna know if it's due to ssl lib issue.
ssl_ctx = ssl.create_default_context(cafile=certifi.where()) //add ssl ctx
try:
result = await session.request(**request_kwargs, ssl=ssl_ctx) //add ssl=ssl_ctx
util.log_info(
"OpenAI API response",
path=abs_url,
response_code=result.status,
processing_ms=result.headers.get("OpenAI-Processing-Ms"),
request_id=result.headers.get("X-Request-Id"),
)
# Don't read the whole stream for debug logging unless necessary.
if openai.log == "debug":
util.log_debug(
"API response body", body=result.content, headers=result.headers
)
return result
except (aiohttp.ServerTimeoutError, asyncio.TimeoutError) as e:
raise error.Timeout("Request timed out") from e
except aiohttp.ClientError as e:
raise error.APIConnectionError("Error communicating with OpenAI") from e
aiohttp version: 3.8.4
Code snippets
No response
OS
CentOS7.9
Python version
Python3.10
Library version
openai-python0.27.7