abi / screenshot-to-code

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
https://screenshottocode.com
MIT License
60.03k stars 7.38k forks source link

mistake #406

Closed localmiracle closed 1 month ago

localmiracle commented 2 months ago

photo_2024-09-18_15-40-19

abi commented 2 months ago

Please provide logs as requested when opening a new issue

localmiracle commented 2 months ago

this is a response from vscode

(backend-py3.12) PS C:\Users\Максимка\Desktop\screenshot-to-code-main\backend> uvicorn main:app --reload --port 7001

INFO: Will watch for changes in these directories: ['C:\Users\Максимка\Desktop\screenshot-to-code-main\backend'] INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit) INFO: Started reloader process [68108] using StatReload INFO: Started server process [85672] INFO: Waiting for application startup. INFO: Application startup complete. INFO: 127.0.0.1:61758 - "GET / HTTP/1.1" 200 OK INFO: ('127.0.0.1', 61779) - "WebSocket /generate-code" [accepted] Incoming websocket connection... INFO: connection open Received params Using openAiApiKey from client-side settings dialog Using official OpenAI URL Generating react_tailwind code in image mode using Llm.CLAUDE_3_5_SONNET_2024_06_20... Status (variant 0): Generating code... Status (variant 1): Generating code... Error generating code. Please contact support. ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-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\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\fastapi\applications.py", line 276, in call await super().call(scope, receive, send) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\middleware\errors.py", line 149, in call await self.app(scope, receive, send) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\middleware\cors.py", line 75, in call await self.app(scope, receive, send) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call raise e File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\routing.py", line 718, in call await route.handle(scope, receive, send) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\routing.py", line 341, in handle await self.app(scope, receive, send) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\starlette\routing.py", line 82, in app await func(session) File "C:\Users\Максимка\AppData\Local\pypoetry\Cache\virtualenvs\backend-bbLjbw3J-py3.12\Lib\site-packages\fastapi\routing.py", line 289, in app await dependant.call(**values) File "C:\Users\Максимка\Desktop\screenshot-to-code-main\backend\routes\generate_code.py", line 324, in stream_code raise Exception("All generations failed") Exception: All generations failed INFO: connection closed

localmiracle commented 2 months ago

react-dom.development.js:29840 Download the React DevTools for a better development experience: https://reactjs.org/link/react-devtools generateCode.ts:30 Connecting to backend @ ws://127.0.0.1:7001/generate-code generateCode.ts:48 Error generating code Error generating code. Please contact support. (анонимный) @ generateCode.ts:48 generateCode.ts:54 Connection closed 4332 generateCode.ts:59 Known server error CloseEvent {isTrusted: true, wasClean: true, code: 4332, reason: '', type: 'close', …} (анонимный) @ generateCode.ts:59 index.ts-BWeybLTk.js:380 Extension Version 0.15.0 c8811c4 index.ts-BWeybLTk.js:381 Development Page chrome-extension://agjkebmgjmcckikllpabicoddephklgh/src/pages/dev/index.html

abi commented 2 months ago

Thanks! I made a change yesterday that unfortunately hides the underlying error during code generation. I'll need to push a new change tomorrow so we can have more information.

From what I can see so far,

It is starting to generating the code on the backend so you're getting some error from OpenAI and/or Anthropic. Do you have keys set for both models? And are you in a country where both APIs are accessible?

I'll add more logging tomorrow to further help with this issue.

localmiracle commented 2 months ago

Yes I have token OpenAI and Anthropic

qazwsx7410pl commented 2 months ago

I have the same problem , help

abi commented 1 month ago

@localmiracle I added more logging. If you pull the latest code and re-run it, please share the logs and I can help pinpoint the exact issue.

Tomicampos commented 1 month ago

Tengo exactamente el mismo inconveniente. Estoy trabajando local con docker. Cargue la api tal como dice el repositorio, pero me da ese error.

qazwsx7410pl commented 1 month ago

This is my backend error message: (backend-py3.12) D:\workspaces\my\screenshot-to-code-main\backend>poetry run uvicorn main:app --reload --port 7001 INFO: Will watch for changes in these directories: ['D:\workspaces\my\screenshot-to-code-main\backend'] INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit) INFO: Started reloader process [26328] using StatReload INFO: Started server process [7428] INFO: Waiting for application startup. INFO: Application startup complete. INFO: ('127.0.0.1', 15608) - "WebSocket /generate-code" [accepted] Incoming websocket connection... INFO: connection open Received params Using openAiApiKey from client-side settings dialog Using official OpenAI URL Generating vue_tailwind code in image mode using Llm.CLAUDE_3_5_SONNET_2024_06_20... Status (variant 0): Generating code... Status (variant 1): Generating code... Error generating code. Please contact support. Traceback (most recent call last): File "D:\workspaces\my\screenshot-to-code-main\backend\llm.py", line 61, in stream_openai_response stream = await client.chat.completions.create(params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai\resources\chat\completions.py", line 1412, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai_base_client.py", line 1816, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai_base_client.py", line 1510, in request return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai_base_client.py", line 1611, in _request raise self._make_status_error_from_response(err.response) from None openai.NotFoundError: Error code: 404 - {'error': {'message': 'The model gpt-4o-2024-05-13 does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}} Traceback (most recent call last): File "D:\workspaces\my\screenshot-to-code-main\backend\llm.py", line 61, in stream_openai_response stream = await client.chat.completions.create(params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai\resources\chat\completions.py", line 1412, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai_base_client.py", line 1816, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai_base_client.py", line 1510, in request return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\openai_base_client.py", line 1611, in _request raise self._make_status_error_from_response(err.response) from None openai.NotFoundError: Error code: 404 - {'error': {'message': 'The model gpt-4o-2024-05-13 does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}} ERROR: Exception in ASGI application Traceback (most recent call last): File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-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 "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\fastapi\applications.py", line 276, in call await super().call(scope, receive, send) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\middleware\errors.py", line 149, in call await self.app(scope, receive, send) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\middleware\cors.py", line 75, in call await self.app(scope, receive, send) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call raise e File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\routing.py", line 718, in call await route.handle(scope, receive, send) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\routing.py", line 341, in handle await self.app(scope, receive, send) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\starlette\routing.py", line 82, in app await func(session) File "D:\pypoetry_cache\virtualenvs\backend-IfucQ9Js-py3.12\Lib\site-packages\fastapi\routing.py", line 289, in app await dependant.call(**values) File "D:\workspaces\my\screenshot-to-code-main\backend\routes\generate_code.py", line 331, in stream_code raise Exception("All generations failed") Exception: All generations failed INFO: connection closed

qazwsx7410pl commented 1 month ago

I seem to know the reason now, my GPT-4.0 service is not activated! I will try my GPT-4.0 again when I have time!

abi commented 1 month ago

@qazwsx7410pl yes, theres some info in the FAQ on how to get access to gpt4. Not sure if it's still accurate but I think you just need to buy $5 in credits.