screenshot-to-code icon indicating copy to clipboard operation
screenshot-to-code copied to clipboard

Run the first screenshot then error

Open LeonLaigogo opened this issue 2 years ago • 5 comments

After I copy a screenshop and run, there is an error messgae "Error generating code. Check the Developer Console AND the backend logs for details. Feel free to open a Github issue."

then I copied the backend logs below


generating code... ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\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\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\fastapi\applications.py", line 276, in call await super().call(scope, receive, send) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\middleware\errors.py", line 149, in call await self.app(scope, receive, send) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\middleware\cors.py", line 75, in call await self.app(scope, receive, send) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call raise e File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\routing.py", line 718, in call await route.handle(scope, receive, send) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\routing.py", line 341, in handle await self.app(scope, receive, send) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\starlette\routing.py", line 82, in app await func(session) File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\fastapi\routing.py", line 289, in app await dependant.call(**values) File "C:\screenshot-to-code\backend\main.py", line 174, in stream_code completion = await stream_openai_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\screenshot-to-code\backend\llm.py", line 26, in stream_openai_response completion = await client.chat.completions.create(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\openai\resources\chat\completions.py", line 1191, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\openai_base_client.py", line 1474, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\openai_base_client.py", line 1275, in request return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11\Lib\site-packages\openai_base_client.py", line 1318, in _request raise self._make_status_error_from_response(err.response) from None openai.NotFoundError: Error code: 404 - {'error': {'message': 'The model gpt-4-vision-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}} INFO: connection closed


I have check my openapi key, please help me figure this problem, thanks a lot.

LeonLaigogo avatar Dec 02 '23 05:12 LeonLaigogo

yarn: 1.22.21 node: v20.10.0 Python: 3.11.3

These are the versions of my relevant environment. I hope they can provide more clues.

LeonLaigogo avatar Dec 02 '23 05:12 LeonLaigogo

The error message indicates that your api key can't access vision: The model gpt-4-vision-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4

Please see https://github.com/abi/screenshot-to-code/blob/main/Troubleshooting.md

abi avatar Dec 02 '23 06:12 abi

@abi thanks for your quick reply, and I found there is another error on my console below

when I run this command : poetry run uvicorn main:app --reload --port 7001 then

PS C:\screenshot-to-code\backend> poetry shell Virtual environment already activated: C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\backend-RpSLUTQm-py3.11 PS C:\screenshot-to-code\backend> poetry run uvicorn main:app --reload --port 7001 INFO: Will watch for changes in these directories: ['C:\screenshot-to-code\backend'] INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit) INFO: Started reloader process [25064] using StatReload ERROR: Error loading ASGI app. Could not import module "main".

LeonLaigogo avatar Dec 02 '23 06:12 LeonLaigogo

The error message indicates that your api key can't access vision: The model gpt-4-vision-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4

Please see https://github.com/abi/screenshot-to-code/blob/main/Troubleshooting.md

this pro can't be used if I don't update ChatGPT 4 from ChatGPT 3.5, right?

tranBean avatar Dec 02 '23 07:12 tranBean

Please read the docs. What ChatGPT you have doesn't matter, you need an API key which is separate.

abi avatar Dec 02 '23 13:12 abi