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

openai.APIConnectionError: Connection error. #684

Open
Shi-YuZhang opened this issue Mar 10, 2024 · 1 comment
Open

openai.APIConnectionError: Connection error. #684

Shi-YuZhang opened this issue Mar 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Shi-YuZhang
Copy link

After install jupyter-ai extension, i ask some questions in jupyternaut chatbox, no response displayed but the following error message:

anyio._backends._asyncio.ExceptionGroup: 2 exceptions were raised in the task group:

Traceback (most recent call last):
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/anyio/_core/_sockets.py", line 167, in try_connect
stream = await asynclib.connect_tcp(remote_host, remote_port, local_address)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1627, in connect_tcp
await get_running_loop().create_connection(
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
raise exceptions[0]
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
await self.sock_connect(sock, address)
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
return await fut
^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
sock.connect(address)
OSError: [Errno 101] Network is unreachable

Traceback (most recent call last):
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/anyio/_core/_sockets.py", line 167, in try_connect
stream = await asynclib.connect_tcp(remote_host, remote_port, local_address)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1627, in connect_tcp
await get_running_loop().create_connection(
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
raise exceptions[0]
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
await self.sock_connect(sock, address)
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
return await fut
^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('128.242.240.180', 443)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
yield
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 114, in connect_tcp
stream: anyio.abc.ByteStream = await anyio.connect_tcp(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/anyio/_core/_sockets.py", line 225, in connect_tcp
raise OSError("All connection attempts failed") from cause
OSError: All connection attempts failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
yield
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_transports/default.py", line 366, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 268, in handle_async_request
raise exc
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 251, in handle_async_request
response = await connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_async/connection.py", line 99, in handle_async_request
raise exc
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_async/connection.py", line 76, in handle_async_request
stream = await self._connect(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_async/connection.py", line 124, in _connect
stream = await self._network_backend.connect_tcp(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_backends/auto.py", line 30, in connect_tcp
return await self._backend.connect_tcp(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 112, in connect_tcp
with map_exceptions(exc_map):
File "/home/zhangshiyu/miniconda3/lib/python3.11/contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectError: All connection attempts failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1457, in _request
response = await self._client.send(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_client.py", line 1617, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_transports/default.py", line 365, in handle_async_request
with map_httpcore_exceptions():
File "/home/zhangshiyu/miniconda3/lib/python3.11/contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: All connection attempts failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/jupyter_ai/chat_handlers/base.py", line 113, in on_message
await self.process_message(message)
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/jupyter_ai/chat_handlers/default.py", line 57, in process_message
response = await self.llm_chain.apredict(input=message.body, stop=["\nHuman:"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain/chains/llm.py", line 310, in apredict
return (await self.acall(kwargs, callbacks=callbacks))[self.output_key]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain_core/_api/deprecation.py", line 154, in awarning_emitting_wrapper
return await wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain/chains/base.py", line 413, in acall
return await self.ainvoke(
^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain/chains/base.py", line 209, in ainvoke
raise e
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain/chains/base.py", line 203, in ainvoke
await self._acall(inputs, run_manager=run_manager)
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain/chains/llm.py", line 275, in _acall
response = await self.agenerate([inputs], run_manager=run_manager)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain/chains/llm.py", line 142, in agenerate
return await self.llm.agenerate_prompt(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 554, in agenerate_prompt
return await self.agenerate(
^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 514, in agenerate
raise exceptions[0]
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 617, in _agenerate_with_cache
return await self._agenerate(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain_community/chat_models/openai.py", line 530, in _agenerate
response = await acompletion_with_retry(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/langchain_community/chat_models/openai.py", line 105, in acompletion_with_retry
return await llm.async_client.create(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/resources/chat/completions.py", line 1330, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1725, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1428, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1481, in _request
return await self._retry_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1550, in _retry_request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1481, in _request
return await self._retry_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1550, in _retry_request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "/home/zhangshiyu/miniconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1491, in _request
raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.

@Shi-YuZhang Shi-YuZhang added the bug Something isn't working label Mar 10, 2024
Copy link

welcome bot commented Mar 10, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant