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. #296

Open
penelope1234564867 opened this issue Apr 7, 2024 · 3 comments
Open

openai.APIConnectionError: Connection error. #296

penelope1234564867 opened this issue Apr 7, 2024 · 3 comments

Comments

@penelope1234564867
Copy link

No description provided.

@penelope1234564867
Copy link
Author

ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 66, in map_httpcore_exceptions
yield
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 366, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpcore_async\connection_pool.py", line 167, in handle_async_request
raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

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

Traceback (most recent call last):
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1470, in _request
response = await self._client.send(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1617, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 365, in handle_async_request
with map_httpcore_exceptions():
File "C:\Python312\Lib\contextlib.py", line 158, in exit
self.gen.throw(value)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 83, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 66, in map_httpcore_exceptions
yield
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 366, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpcore_async\connection_pool.py", line 167, in handle_async_request
raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

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

Traceback (most recent call last):
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1470, in _request
response = await self._client.send(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1617, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 365, in handle_async_request
with map_httpcore_exceptions():
File "C:\Python312\Lib\contextlib.py", line 158, in exit
self.gen.throw(value)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 83, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 66, in map_httpcore_exceptions
yield
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 366, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpcore_async\connection_pool.py", line 167, in handle_async_request
raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

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

Traceback (most recent call last):
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1470, in _request
response = await self._client.send(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1617, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 365, in handle_async_request
with map_httpcore_exceptions():
File "C:\Python312\Lib\contextlib.py", line 158, in exit
self.gen.throw(value)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\httpx_transports\default.py", line 83, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

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

Traceback (most recent call last):
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 250, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\fastapi\applications.py", line 276, in call
await super().call(scope, receive, send)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\middleware\errors.py", line 149, in call
await self.app(scope, receive, send)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\middleware\cors.py", line 75, in call
await self.app(scope, receive, send)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in call
raise exc
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call
raise e
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\routing.py", line 718, in call
await route.handle(scope, receive, send)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\routing.py", line 341, in handle
await self.app(scope, receive, send)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\starlette\routing.py", line 82, in app
await func(session)
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\fastapi\routing.py", line 289, in app
await dependant.call(**values)
File "D:\python\screenshot-to-code-main\backend\routes\generate_code.py", line 260, in stream_code
completion = await stream_openai_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\screenshot-to-code-main\backend\llm.py", line 52, in stream_openai_response
stream = await client.chat.completions.create(**params) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai\resources\chat\completions.py", line 1334, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1738, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1441, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1494, in _request
return await self._retry_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1563, in _retry_request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1494, in _request
return await self._retry_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1563, in _retry_request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\18194\AppData\Local\pypoetry\Cache\virtualenvs\backend-8Vl--rHk-py3.12\Lib\site-packages\openai_base_client.py", line 1504, in _request
raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.
INFO: connection closed

@penelope1234564867
Copy link
Author

This is ERROR. I wnat to ask how can i use screentoshot to code by OPENAI_API_BASE_URL. I only use OPENAI_API_KEY But I can't use it? how can i do?

@abi
Copy link
Owner

abi commented Apr 7, 2024

Yeah you're likely having issues connecting to the default OpenAI URL so try setting a proxy url as base url in the .env file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants