gpt-engineer-org / gpt-engineer

Specify what you want it to build, the AI asks for clarification, and then builds it.
MIT License
51.38k stars 6.68k forks source link

KeyError: 'generate' #204

Closed meetkool closed 1 year ago

meetkool commented 1 year ago

Traceback (most recent call last):

File "/home/meet/random/gpt-engineer/gpt_engineer/main.py", line 63, in app()

File "/home/meet/random/gpt-engineer/gpt_engineer/main.py", line 58, in main messages = step(ai, dbs)

File "/home/meet/random/gpt-engineer/gpt_engineer/steps.py", line 61, in gen_spec ai.fsystem(setup_sys_prompt(dbs)),

File "/home/meet/random/gpt-engineer/gpt_engineer/steps.py", line 11, in setup_sys_prompt return dbs.identity["generate"] + "\nUseful to know:\n" + dbs.identity["philosophy"]

File "/home/meet/random/gpt-engineer/gpt_engineer/db.py", line 21, in getitem raise KeyError(key)

KeyError: 'generate'

truonghoangnguyen commented 1 year ago

may be your run on wrong folder, my command: >python3 gpt_engineer/main.py projects/my-new-project

mgcollie commented 1 year ago

I have the exact same problem. windows 10. python 3.11.4

r04nx commented 1 year ago

Same

mgcollie commented 1 year ago

looks like the bug was possibly introduced on the 17th. The "setup_sys_prompt" function was changed and it expects that the DB class has a property or member variables called "generate" and "philosophy" which it does not. @AntonOsika

lexabu commented 1 year ago

Seeing the same error

gdespirito commented 1 year ago

Same here.

image

I created a empty gpte folder, then cd on that folder, then created an empty app folder on gpte. I created a gpte/app/main_prompt file and run gpt-engineer app and it throws that error.

mgcollie commented 1 year ago

I've got a fix for this in my local checkout. will make a pull request soon. just need to familiarize myself with the contribution guidelines first

bannsec commented 1 year ago

Looks to be an assumption about cwd when starting the script. I was doing the following when getting the error:

gpt-engineer app

However, when i start with the following (as per the readme), it seems to work:

gpt-engineer projects/app

The program should be updated to better handle paths, but for now it seems you can run in the appropriate directory to get it working.

mgcollie commented 1 year ago

spoke too soon. seems the project assumes you're operating in linux. see line 153 in steps.py

    subprocess.run("bash run.sh", shell=True, cwd=dbs.workspace.path)
mandgie commented 1 year ago

Same issue

ghodsizadeh commented 1 year ago

I had the same issue using pip install gpt-engineer. I used the dev approach it worked:

git clone git@github.com:AntonOsika/gpt-engineer.git
cd gpt-engineer
make install
source venv/bin/activate
gpt-engineer projects/example # rewrite the prompt here
lectair commented 1 year ago

I had the same issue using pip install gpt-engineer. I used the dev approach it worked:

git clone git@github.com:AntonOsika/gpt-engineer.git
cd gpt-engineer
make install
source venv/bin/activate
gpt-engineer projects/example # rewrite the prompt here

It worked! Thanks 👍

huntersinclairtiv commented 1 year ago

I finally got past this - you need to make sure to run the python gpt_engineer/main.py projects/example from the root folder since I think it expects to be able to access other files in the identity folder relative to where you run from.

pitermarx commented 1 year ago

if you installed via pip and did not checkout the repository you need to have the identity folder in your cwd.

diogobernini commented 1 year ago

may be your run on wrong folder, my command: >python3 gpt_engineer/main.py projects/my-new-project

This worked for me.

alistairwalsh commented 1 year ago

had the same error with the 'generate' key. Got it working by giving the path as stated above. run 'python gpt_engineer/main.py projects/example' from the git cloned 'gpt-engineer' folder. It also was within the venv environment

mgcollie commented 1 year ago

For the people here who are having success with this, what operating system, and what version of python are you using?

bannsec commented 1 year ago

Without making manual changes for typing, I think it requires 3.10+

On Mon, Jun 19, 2023, 21:38 Matt Collie @.***> wrote:

For the people here who are having success with this, what operating system, and what version of python are you using?

— Reply to this email directly, view it on GitHub https://github.com/AntonOsika/gpt-engineer/issues/204#issuecomment-1597998391, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2HPYAOH35WXHG67UARYULXMD5HTANCNFSM6AAAAAAZL5UMRA . You are receiving this because you commented.Message ID: @.***>

mgcollie commented 1 year ago

I'm using ubuntu 22.04.2, python 3.10.8. latest problem is that after it starts to execute the code it's not writing the requirements.txt file to disk

ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

zlace0x commented 1 year ago

Fixed by copying the original identity folder into cwd cp -r ../gpt-engineer/identity/ identity/

jtabox commented 1 year ago

For us mortals who just installed this via pip in a windows machine, where are we supposed to run the script from? Also, don't we need to run the gpt-engineer.exe ? I ran python main.py from inside the gpt_engineer folder in the .venv environment's Lib\site-packages, and from various levels outside of it, up to python .venv\Lib\site-packages\gpt_engineer\main.py projects\example. Also copied the example folder and file inside .venv\Scripts and ran gpt-engineer.exe projects\example. But still getting the same KeyError: 'generate'. Python 3.11.3 and Win 11 Pro.

DataQub3 commented 1 year ago

Same error for me when running the pip version.

I got it running in Windows by following the README.md instructions but just cloning the Github repo, set OPENAI_API_KEY=xyz, and running "python gpt_engineer/main.py --model gpt-3.5-turbo project/example"

tjb4578 commented 1 year ago

So just to be clear, the stable release (pip install gpt-engineer method) is currently broken because it is expecting an identity folder. The only way to get this running is cloning the repo and following the dev instructions?

mgcollie commented 1 year ago

@tjb4578 I'm working on a pull request for that particular problem but I'm having other issues. there are dependencies that aren't covered in the README. such as the hardcoding of the bash shell at line 153 in steps.py

I've not yet been able to have a single successful run of the program at all.

danbatiste commented 1 year ago

@mgcollie Found a solution on Windows that gets past this error.

The problem seems to be that when gpt_engineer is pip installed, the database never gets the identity attribute set. The identify attribute is composed of each of the files in /identity in this repo. So if this /identity folder is missing from whatever your CWD is, the program will get this KeyError.

The solution that finally worked for me, after trying every one in this thread, is to clone the repo and work out of that clone. This would look like the following:

  1. git clone https://github.com/AntonOsika/gpt-engineer/
  2. cd gpt-engineer
  3. py gpt_engineer/main.py /projects/{create your project folder here}

Hopefully this works for you, cheers

Edit: I had to manually run the code instead of using the automatic execution since the run.sh obviously will not run on Windows

I also had to manually create requirements.txt for some reason

mgcollie commented 1 year ago

@danbatiste I'm not able to replicate your's (or anyone else's ) success. from what I can tell there is a bug where it expects that there are particular folders/files on disk. at least with regards to this particular issue. I can get around this by modifying db.py's implementation of the getitem dunder:

image

this gets past the problems with this particular issue, but I still encounter others downstream in certain environments. such as the assumption that a bash shell is available at line 153 of steps.py

mgcollie commented 1 year ago

Is anyone here who is able to run this without issue willing to hop on a quick call with me? It would be helpful for me to continue debugging this. I'm not doubting anyone's success, just need to further investigate what the delta's between your runtime environment(s) and my own so I can figure out what I'm missing.

raygpt commented 1 year ago

@mgcollie if you mean the local dev setup, I've been able to get it running without issue. Happy to hop on a call—— just email me the link.

mgcollie commented 1 year ago

invite sent @raygpt

mgcollie commented 1 year ago

big thanks to @raygpt for hopping on a call with me. for everyone else the only delta we noticed was with regards to our operating systems. I was trying this on Windows 10 and Ubuntu 22.04.2 LTS, whereas @raygpt was having success using macos. for me I can get past the main problem noted in this thread by changing the dp.py __get_item__ implementation to always write the full_path if it doesn't exist. but I can't get a full end to end successful run of the program. it never writes out the 'requirements.txt' file to disk, so when executing run.sh at line 153 of steps.py it always fails.

clickbrain commented 1 year ago

Path changed to main.py which is now in a gpt-engineer subdirectory of the main directory.

I am still getting KeyError: 'generate' when I try to run from cloning.

Running on MacOS

ghost commented 1 year ago

on windows, using python gpt_engineer/main.py projects gives me the openai.error.AuthenticationError

Traceback (most recent call last):

File "C:*****\PROJECTS\gpt-engineer\gpt_engineer\main.py", line 66, in app()

File "C:*****\Desktop\PROJECTS\gpt-engineer\gpt_engineer\main.py", line 47, in main ai = AI( ^^^

File "C:\Python311\Lib\site-packages\gpt_engineer\ai.py", line 15, in init openai.Model.retrieve(model)

File "C:\Python311\Lib\site-packages\openai\api_resources\abstract\api_resource.py", line 20, in retrieve instance.refresh(request_id=request_id, request_timeout=request_timeout)

File "C:\Python311\Lib\site-packages\openai\api_resources\abstract\api_resource.py", line 32, in refresh self.request(

File "C:\Python311\Lib\site-packages\openai\openai_object.py", line 172, in request requestor = api_requestor.APIRequestor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 138, in init self.api_key = key or util.default_api_key() ^^^^^^^^^^^^^^^^^^^^^^

File "C:\Python311\Lib\site-packages\openai\util.py", line 188, in default_api_key raise openai.error.AuthenticationError(

openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '.

mxcl commented 1 year ago

Our version has the fix from this thread: https://tea.xyz/+github.com/antonosika/gpt-engineer/

Install tea and type gpt-engineer to use it. We auto update on new releases.

patillacode commented 1 year ago

If you wish to reopen the issue please do following the new issue template.

myn commented 1 year ago

Our version has the fix from this thread: https://tea.xyz/+github.com/antonosika/gpt-engineer/

Install tea and type gpt-engineer to use it. We auto update on new releases.

What if you don't use Tea and install using the method documented in the readme.md?