Open jmanhype opened 1 year ago
@jmanhype has the OpenAI API worked for you on other projects? Perhaps you can see if you get the same error when trying the openai api quickstart project here: https://github.com/openai/openai-quickstart-python
i just got this issue, seems to be a working openai api key otherwise?
Yeah, I've verified that this is a good API key, but still always getting error above of OP @biobootloader
@jmanhype @Bbasche can you tell me the following?
Also, if you installed Mentat by cloning the repo, trying running this:
python tests/measure_api_speed.py "list 10 random words"
That's a standalone script I used to measure the api speed, so would rule out Mentat itself causing a problem.
this is the error im seeing please help
Last login: Wed Jul 26 13:13:02 on ttys002 rileylovett@Rileys-MacBook-Air ~ % /Users/rileylovett/.venv_new/bin/mentat /Users/rileylovett/Discord2 Files included in context: Discord2 ├── .env ├── README.md ├── app.py ├── bot.py ├── boty.py ├── pp.py └── requirements.txt
File token count: 6671 Type 'q' or use Ctrl-C to quit at any time.
What can I do for you?
Total token count: 7518
Total session cost: $0.00 Traceback (most recent call last): File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection transport, protocol = await self._create_connection_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport await waiter File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/sslproto.py", line 575, in _on_handshake_complete raise handshake_exc File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/sslproto.py", line 557, in _do_handshake self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 979, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/openai/api_requestor.py", line 592, in arequest_raw result = await session.request(**request_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection raise last_exc File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rileylovett/.venv_new/lib/python3.11/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 api.openai.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)')]
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Users/rileylovett/.venv_new/bin/mentat", line 8, in
sys.exit(run_cli())
^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/mentat/app.py", line 24, in run_cli
run(paths)
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/mentat/app.py", line 35, in run
loop(paths, cost_tracker)
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/mentat/app.py", line 57, in loop
explanation, code_changes = conv.get_model_response(code_file_manager, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/mentat/conversation.py", line 52, in get_model_response
state = run_async_stream_and_parse_llm_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/mentat/parsing.py", line 129, in run_async_stream_and_parse_llm_response
asyncio.run(
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/mentat/parsing.py", line 152, in stream_and_parse_llm_response
response = await call_llm_api(messages, model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/mentat/llm_api.py", line 46, in call_llm_api
response = await openai.ChatCompletion.acreate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 45, in acreate
return await super().acreate(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/openai/api_resources/abstract/engine_apiresource.py", line 217, in acreate
response, , api_key = await requestor.arequest(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/openai/api_requestor.py", line 304, in arequest
result = await self.arequest_raw(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rileylovett/.venv_new/lib/python3.11/site-packages/openai/api_requestor.py", line 609, in arequest_raw
raise error.APIConnectionError("Error communicating with OpenAI") from e
openai.error.APIConnectionError: Error communicating with OpenAI
rileylovett@Rileys-MacBook-Air ~ %