screenshot-to-code
screenshot-to-code copied to clipboard
OpenAI APIConnectionError
Exception in ASGI application Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\anyio_core_sockets.py", line 167, in try_connect stream = await asynclib.connect_tcp(remote_host, remote_port, local_address) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\anyio_backends_asyncio.py", line 1627, in connect_tcp await get_running_loop().create_connection( File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 1076, in create_connection raise exceptions[0] File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 1060, in create_connection sock = await self._connect_sock( File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 969, in _connect_sock await self.sock_connect(sock, address) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\asyncio\selector_events.py", line 501, in sock_connect return await fut File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\asyncio\selector_events.py", line 541, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') TimeoutError: [Errno 10060] Connect call failed ('199.59.148.201', 443)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_exceptions.py", line 10, in map_exceptions yield File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_backends\anyio.py", line 114, in connect_tcp stream: anyio.abc.ByteStream = await anyio.connect_tcp( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\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 "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpx_transports\default.py", line 66, in map_httpcore_exceptions yield File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpx_transports\default.py", line 366, in handle_async_request resp = await self._pool.handle_async_request(req) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_async\connection_pool.py", line 268, in handle_async_request raise exc File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_async\connection_pool.py", line 251, in handle_async_request response = await connection.handle_async_request(request) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_async\connection.py", line 99, in handle_async_request raise exc File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_async\connection.py", line 76, in handle_async_request stream = await self._connect(request) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_async\connection.py", line 124, in _connect stream = await self._network_backend.connect_tcp(**kwargs) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_backends\auto.py", line 30, in connect_tcp return await self._backend.connect_tcp( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpcore_backends\anyio.py", line 112, in connect_tcp with map_exceptions(exc_map): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 153, in exit self.gen.throw(typ, value, traceback) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\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 "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1342, in _request response = await self._client.send( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpx_client.py", line 1617, in send response = await self._send_handling_auth( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpx_client.py", line 1645, in _send_handling_auth response = await self._send_handling_redirects( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpx_client.py", line 1682, in _send_handling_redirects response = await self._send_single_request(request) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpx_client.py", line 1719, in _send_single_request response = await transport.handle_async_request(request) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\httpx_transports\default.py", line 365, in handle_async_request with map_httpcore_exceptions(): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 153, in exit self.gen.throw(typ, value, traceback) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\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 "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 247, in run_asgi result = await self.app(self.scope, self.asgi_receive, self.asgi_send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call return await self.app(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\fastapi\applications.py", line 276, in call await super().call(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\middleware\errors.py", line 149, in call await self.app(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\middleware\cors.py", line 75, in call await self.app(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call raise e File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\routing.py", line 718, in call await route.handle(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\routing.py", line 341, in handle await self.app(scope, receive, send) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\starlette\routing.py", line 82, in app await func(session) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\fastapi\routing.py", line 289, in app await dependant.call(**values) File "E:\html\screenshot-to-code\backend\main.py", line 180, in stream_code completion = await stream_openai_response( File "E:\html\screenshot-to-code\backend\llm.py", line 26, in stream_openai_response completion = await client.chat.completions.create(**params) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai\resources\chat\completions.py", line 1199, in create return await self._post( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1542, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1316, in request return await self._request( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1389, in _request return await self._retry_request( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1424, in _retry_request return await self._request( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1389, in _request return await self._retry_request( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1424, in _retry_request return await self._request( File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Local\pypoetry\Cache\virtualenvs\backend-upPVKXMs-py3.10\lib\site-packages\openai_base_client.py", line 1398, in _request raise APIConnectionError(request=request) from err openai.APIConnectionError: Connection error. INFO: connection closed INFO: ('127.0.0.1', 51007) - "WebSocket /generate-code" [accepted] Incoming websocket connection... INFO: connection open
You're getting openai.APIConnectionError
perhaps the OpenAI API is blocked or your internet is bad? You can also set a different base url in settings if you have a proxy.
I meet same question, please ask which file setting proxyURL
@wujunya You can do it by UI in the settings (gear icon) or set OPENAI_BASE_URL
in backend/.env Make sure to restart everything for changes to apply
I set the proxy in both the web page and the.env file and still 443 error occurs