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

ERROR: Exception in ASGI application when using Screen Recording to prototype #278

Open
yumlii33 opened this issue Mar 21, 2024 · 10 comments

Comments

@yumlii33
Copy link

When I use other functions, everything is normal. But when I uploaded the screen recording, the error was as follows:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/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 "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 149, in __call__
    await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/middleware/cors.py", line 75, in __call__
    await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 341, in handle
    await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 82, in app
    await func(session)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 289, in app
    await dependant.call(**values)
  File "/root/Workspace/screenshot-to-code/backend/routes/generate_code.py", line 64, in stream_code
    params: Dict[str, str] = await websocket.receive_json()
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/websockets.py", line 133, in receive_json
    self._raise_on_disconnect(message)
  File "/root/.cache/pypoetry/virtualenvs/backend-1Rb1d6GZ-py3.10/lib/python3.10/site-packages/starlette/websockets.py", line 105, in _raise_on_disconnect
    raise WebSocketDisconnect(message["code"])
starlette.websockets.WebSocketDisconnect: CloseCode.ABNORMAL_CLOSURE
INFO:     connection closed
@abi
Copy link
Owner

abi commented Mar 21, 2024

How long is your video?

@nelloloujh
Copy link

nelloloujh commented Mar 23, 2024

Same ASGI error, but it was happened when use a screenshot. My error is as follows:

Traceback (most recent call last):
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/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 "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 149, in __call__
    await self.app(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/middleware/cors.py", line 75, in __call__
    await self.app(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 341, in handle
    await self.app(scope, receive, send)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 82, in app
    await func(session)
  File "/home/ljh/.cache/pypoetry/virtualenvs/backend-86_ny3-v-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 289, in app
    await dependant.call(**values)
  File "/home/ljh/Softwares/screenshot-to-code/backend/routes/generate_code.py", line 260, in stream_code
    completion = await stream_openai_response(
  File "/home/ljh/Softwares/screenshot-to-code/backend/llm.py", line 54, in stream_openai_response
    content = chunk.choices[0].delta.content or ""
IndexError: list index out of range

@abi
Copy link
Owner

abi commented Mar 23, 2024

@nelloloujh are you getting that error when you do video or just a screenshot?

@nelloloujh
Copy link

@abi Just use a screenshot.

@abi
Copy link
Owner

abi commented Mar 25, 2024

Hard to debug with just that information. This error

"content = chunk.choices[0].delta.content or ""
IndexError: list index out of range"

usually indicates the Open AI has not given a response. Are you using a screenshot that might trigger moderation blocking?

Does this error happen no matter what the screenshot is? Can you try a simple screenshot like one of google.com?

Repository owner deleted a comment from hoanghohotel Mar 28, 2024
@sh731928441
Copy link

@abi Could it be caused by the OpenAI Key being unavailable?

@abi
Copy link
Owner

abi commented Apr 2, 2024

@sh731928441 im not sure. Please open a separate ticket and share your logs.

@eefeng
Copy link

eefeng commented May 6, 2024

same issue

@darshansharma
Copy link

darshansharma commented May 13, 2024

I got the same error, I had valid key with credits inside it but I keep getting the same error: Exception in AGSI. I tried using to run via Docker too but on docker got the same error.

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/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 "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/fastapi/applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 149, in __call__
    await self.app(scope, receive, send)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/middleware/cors.py", line 75, in __call__
    await self.app(scope, receive, send)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 341, in handle
    await self.app(scope, receive, send)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 82, in app
    await func(session)
  File "/Users/darshan/Library/Caches/pypoetry/virtualenvs/backend-z9_R7sxo-py3.11/lib/python3.11/site-packages/fastapi/routing.py", line 289, in app
    await dependant.call(**values)

@MuazAshraf
Copy link

I am slecting calude sonnet model for rescord screen and got the same error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 285, in ffmpeg_parse_infos
line = [l for l in lines if keyword in l][index]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\mojosolo_projects\screenshottocode.venv\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:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\fastapi\applications.py", line 276, in call
await super().call(scope, receive, send)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\middleware\errors.py", line 149, in call
await self.app(scope, receive, send)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\middleware\cors.py", line 75, in call
await self.app(scope, receive, send)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in call
raise exc
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call
raise e
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\routing.py", line 718, in call
await route.handle(scope, receive, send)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\routing.py", line 341, in handle
await self.app(scope, receive, send)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\starlette\routing.py", line 82, in app
await func(session)
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\fastapi\routing.py", line 289, in app
await dependant.call(**values)
File "D:\mojosolo_projects\screenshottocode\screenshot-to-code\backend\routes\generate_code.py", line 210, in stream_code
prompt_messages = await assemble_claude_prompt_video(video_data_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\mojosolo_projects\screenshottocode\screenshot-to-code\backend\video\utils.py", line 21, in assemble_claude_prompt_video
images = split_video_into_screenshots(video_data_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\mojosolo_projects\screenshottocode\screenshot-to-code\backend\video\utils.py", line 79, in split_video_into_screenshots
clip = VideoFileClip(temp_video_file.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\moviepy\video\io\VideoFileClip.py", line 88, in init
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 35, in init
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\mojosolo_projects\screenshottocode.venv\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 289, in ffmpeg_parse_infos
raise IOError(("MoviePy error: failed to read the duration of file %s.\n"
OSError: MoviePy error: failed to read the duration of file C:\Users\MUAZ\AppData\Local\Temp\tmpr286buta.webm.
Here are the file infos returned by ffmpeg:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
C:\Users\MUAZ\AppData\Local\Temp\tmpr286buta.webm: Permission denied

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

7 participants