loevlie/GPT4Readability

FileNotFoundError: 'readme_prompt.txt' resource not found in 'GPT4Readability.prompts'

jossefaz opened this issue ยท 6 comments

I tried on my own repo called my-project. All my files are under a folder called my-folder and I ran the command from it.

Here is the command that I ran :

 gpt4readability .  --function readme --output_readme MyAwesomeREADME.md --model gpt-4  

I get this error :

[INFO] Commencing README generation using gpt-4. Initiating a detailed search and understanding of your codebase. This may take a while depending on the size of your codebase.

Traceback (most recent call last):
  File "/user/test/.pyenv/versions/3.9.12/lib/python3.9/importlib/resources.py", line 97, in open_binary
    return open(full_path, mode='rb')
FileNotFoundError: [Errno 2] No such file or directory: '/users/test/projects/my-project/my-folder/readme_prompt.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/user/test/.pyenv/versions/factories/bin/gpt4readability", line 8, in <module>
    sys.exit(main())
  File "/user/test/.pyenv/versions/3.9.12/envs/factories/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/user/test/.pyenv/versions/3.9.12/envs/factories/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/user/testy/.pyenv/versions/3.9.12/envs/factories/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/user/test/.pyenv/versions/3.9.12/envs/factories/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/user/test/.pyenv/versions/3.9.12/envs/factories/lib/python3.9/site-packages/GPT4Readability/__main__.py", line 31, in main
    generate_readme(path, output_readme, model)
  File "/user/test/.pyenv/versions/3.9.12/envs/factories/lib/python3.9/site-packages/GPT4Readability/readme_gen.py", line 17, in generate_readme
    with open_text('GPT4Readability.prompts', 'readme_prompt.txt') as f:
  File "/user/test/.pyenv/versions/3.9.12/lib/python3.9/importlib/resources.py", line 121, in open_text
    open_binary(package, resource), encoding=encoding, errors=errors)
  File "/user/test/.pyenv/versions/3.9.12/lib/python3.9/importlib/resources.py", line 111, in open_binary
    raise FileNotFoundError(message)
FileNotFoundError: 'readme_prompt.txt' resource not found in 'GPT4Readability.prompts'

Hi @jossefaz I would like to fix this bug but I cannot replicate it locally. One quick fix (although I doubt the solution to this problem) is the package should be run in the "my-project" folder (the root of your git repo) and it will then recursively find your files inside that repo (the ones in my-folder).

To help me replicate the issue can you please answer a few quick questions:

  1. Did you install version 0.0.5?
    If not please run:
pip uninstall GPT4Readability
pip install GPT4Readability==0.0.5
  1. Are you running mac/windows/linux?

This problem may be due to the prompt txt files not being included when the package is built. I will try and make this fix and release a new version "0.0.6" once I replicate the issue!

Thanks you for reporting this error and I hope to get this fixed soon!

I came here to say also this. Exactly the same in version 0.0.5 :-)

I've replicated the issue and know the fix. It'll be updated in a new release tonight! Thanks for catching this!!

@jossefaz @fchevallieratecna please try installing version 0.0.7 and let me know if you have the same issues! This fixed the issue for me locally and I hope it does for everyone else! :-)

Hey !
Well, it has been fixed but now I have another error :

Traceback (most recent call last):
  File "/Users/test/.pyenv/versions/3.9.7/bin/gpt4readability", line 8, in <module>
    sys.exit(main())
  File "/Users/test/.pyenv/versions/3.9.7/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/test/.pyenv/versions/3.9.7/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/test/.pyenv/versions/3.9.7/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/test/.pyenv/versions/3.9.7/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/test/.pyenv/versions/3.9.7/lib/python3.9/site-packages/GPT4Readability/__main__.py", line 31, in main
    generate_readme(path, output_readme, model)
  File "/Users/test/.pyenv/versions/3.9.7/lib/python3.9/site-packages/GPT4Readability/readme_gen.py", line 29, in generate_readme
    username, reponame = get_github_info_from_local_repo(root_dir)
  File "/Users/test/.pyenv/versions/3.9.7/lib/python3.9/site-packages/GPT4Readability/utils.py", line 190, in get_github_info_from_local_repo
    raise ValueError("URL provided is not a GitHub URL")
ValueError: URL provided is not a GitHub URL

@fchevallieratecna GPT4Readability only works on local git repos that are hosted on GitHub (that's where I get your username and repo name for the badges on the top of the README). I can make it so it works with git repos that aren't hosted on GitHub by checking and if not just removing the badges!

That change will be in the next version. I will get that done ASAP. Thanks for your patience!