zylon-ai / private-gpt

Interact with your documents using the power of GPT, 100% privately, no data leaks
https://docs.privategpt.dev
Apache License 2.0
53.13k stars 7.13k forks source link

[Errno 2] No such file or directory: .... avatar-bot.ico #1575

Open Dariusz1989 opened 5 months ago

Dariusz1989 commented 5 months ago

Hey Fresh install & run >

16:47:28.129 [INFO    ] private_gpt.components.embedding.embedding_component - Initializing the embedding model in mode=local
16:47:32.606 [INFO    ] llama_index.indices.loading - Loading all indices.
Traceback (most recent call last):
  File "S:\01_Code\AI\privateGPT\privateGPT\private_gpt\ui\ui.py", line 281, in _build_ui_blocks
    chatbot=gr.Chatbot(
            ^^^^^^^^^^^
  File "S:\01_Code\AI\privateGPT\venvPrivateGPT\Lib\site-packages\gradio\component_meta.py", line 155, in wrapper
    return fn(self, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "S:\01_Code\AI\privateGPT\venvPrivateGPT\Lib\site-packages\gradio\components\chatbot.py", line 134, in __init__
    processing_utils.move_resource_to_block_cache(avatar_images[1], self),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "S:\01_Code\AI\privateGPT\venvPrivateGPT\Lib\site-packages\gradio\processing_utils.py", line 234, in move_resource_to_block_cache
    return block.move_resource_to_block_cache(url_or_file_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "S:\01_Code\AI\privateGPT\venvPrivateGPT\Lib\site-packages\gradio\blocks.py", line 257, in move_resource_to_block_cache
    temp_file_path = processing_utils.save_file_to_cache(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "S:\01_Code\AI\privateGPT\venvPrivateGPT\Lib\site-packages\gradio\processing_utils.py", line 170, in save_file_to_cache
    temp_dir = hash_file(file_path)
               ^^^^^^^^^^^^^^^^^^^^
  File "S:\01_Code\AI\privateGPT\venvPrivateGPT\Lib\site-packages\gradio\processing_utils.py", line 102, in hash_file
    with open(file_path, "rb") as f:
         ^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'S:\\01_Code\\AI\\privateGPT\\privateGPT\\private_gpt\\private_gpt\\ui\\avatar-bot.ico'

Something seems broken?

Im running it in pycharm via "run" main.py function, with envi arguments sent in config logic. Seems like paths don't resolve properly? image

AshutoshUpadhya commented 5 months ago

I am also having the same issue. Took fresh pull and it gave this path error. While debugging on my windows machine I found:

  1. The issue occurs while calculating Path.resolve(). It is providing an extra 'private_gpt' in the path
    Example : Its generating F:\my_projects*privateGPT\private_gpt\private_gpt*ui\avatar-bot.ico instead of F:\my_projects*privateGPT\private_gpt*ui\avatar-bot.ico.

I thought this could be a bug in Path module but on running on command prompt for a sample, its giving correct output. Pls see below image

Essentially the issue is with PathLib module generating incorrect paths here on Windows (Atleast) machine

Pls comment if anyone resolved this

AshutoshUpadhya commented 5 months ago

I resolved it. You may update line 28 of ui.py to AVATAR_BOT = Path(file).parent.relative_to(Path(file).parents[1]) / "avatar-bot.ico" image

The issue was to remove additional folder name as it was an i ssue while resolving path using Pathlib through gradle blocks. so, I am sending just the file'sparent and so it working for me @imartinez : Do you find this good for a PR? so will raise one.