assafelovic / gpt-researcher

GPT based autonomous agent that does online comprehensive research on any given topic
https://gptr.dev
MIT License
13.05k stars 1.61k forks source link

File name too long. Ubuntu #475

Closed joeysantana3 closed 1 month ago

joeysantana3 commented 1 month ago

I'm writing longish research prompts in order to guide the model to get what I want. At what I believe is the end of the job, when it's trying to save the output to a markdown file, i get an error that the filename is too long. Filesystem is ext4. Here is the error output. Don't mind my silly question :)

Error in converting Markdown to DOCX: [Errno 36] File name too long: "outputs/task_1715125933_Figure out what parts I need to build the following: a computer with an intel i9 with at least 12 cores, a case that supports 20 3.5 hard drives, a motherboard that has at lease 2 nvme ssd slots and 2.5gbe, enough room for an nvidia 1080 video card in both the case and the motherboard. at least 2 8x pcie slots in addition to the slots used by the video card. preferably ipmi but thats not a requirment. server grade hardware is ok, but i don't have a rack so it would sit on a desk...docx"
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 240, in run_asgi
    result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 151, in __call__
    await self.app(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/routing.py", line 373, in handle
    await self.app(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/routing.py", line 96, in app
    await wrap_app_handling_exceptions(app, session)(scope, receive, send)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/starlette/routing.py", line 94, in app
    await func(session)
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/fastapi/routing.py", line 348, in app
    await dependant.call(**values)
  File "/home/joey/Downloads/gpt-researcher/backend/server.py", line 58, in websocket_endpoint
    md_path = await write_text_to_md(report, filename)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joey/Downloads/gpt-researcher/backend/utils.py", line 32, in write_text_to_md
    await write_to_file(file_path, text)
  File "/home/joey/Downloads/gpt-researcher/backend/utils.py", line 19, in write_to_file
    async with aiofiles.open(filename, "w", encoding='utf-8') as file:
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/aiofiles/base.py", line 98, in __aenter__
    self._obj = await self._coro
                ^^^^^^^^^^^^^^^^
  File "/home/joey/Downloads/gpt-researcher/venv/lib/python3.11/site-packages/aiofiles/threadpool/__init__.py", line 94, in _open
    f = yield from loop.run_in_executor(executor, cb)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joey/.pyenv/versions/3.11.9/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 36] File name too long: "outputs/task_1715125933_Figure out what parts I need to build the following: a computer with an intel i9 with at least 12 cores, a case that supports 20 3.5 hard drives, a motherboard that has at lease 2 nvme ssd slots and 2.5gbe, enough room for an nvidia 1080 video card in both the case and the motherboard. at least 2 8x pcie slots in addition to the slots used by the video card. preferably ipmi but thats not a requirment. server grade hardware is ok, but i don't have a rack so it would sit on a desk...md"
INFO:     connection closed
joeysantana3 commented 1 month ago

as a work around, i changed this: https://github.com/assafelovic/gpt-researcher/blob/66c37425af17aa7f519470642e67e18570b206c1/backend/server.py#L50

to this: filename = f"task_{int(time.time())}_{task[:50]}"

assafelovic commented 1 month ago

Thanks @joeysantana3 . Just fixed in latest commit: https://github.com/assafelovic/gpt-researcher/commit/836fea9b763814b36c075b11fa21f0d7f2d0a1b8

Pull the latest and should work