gpt-engineer icon indicating copy to clipboard operation
gpt-engineer copied to clipboard

KeyError: 'generate'

Open meetkool opened this issue 2 years ago • 31 comments

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'

meetkool avatar Jun 19 '23 13:06 meetkool

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

truonghoangnguyen avatar Jun 19 '23 13:06 truonghoangnguyen

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

mgcollie avatar Jun 19 '23 13:06 mgcollie

Same

r04nx avatar Jun 19 '23 13:06 r04nx

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

mgcollie avatar Jun 19 '23 13:06 mgcollie

Seeing the same error

lexabu avatar Jun 19 '23 13:06 lexabu

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.

gdespirito avatar Jun 19 '23 14:06 gdespirito

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

mgcollie avatar Jun 19 '23 14:06 mgcollie

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.

bannsec avatar Jun 19 '23 14:06 bannsec

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)

mgcollie avatar Jun 19 '23 14:06 mgcollie

Same issue

mandgie avatar Jun 19 '23 16:06 mandgie

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

git clone [email protected]:AntonOsika/gpt-engineer.git
cd gpt-engineer
make install
source venv/bin/activate
gpt-engineer projects/example # rewrite the prompt here

ghodsizadeh avatar Jun 19 '23 18:06 ghodsizadeh

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

git clone [email protected]:AntonOsika/gpt-engineer.git
cd gpt-engineer
make install
source venv/bin/activate
gpt-engineer projects/example # rewrite the prompt here

It worked! Thanks 👍

lectair avatar Jun 19 '23 20:06 lectair

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.

huntersinclairtiv avatar Jun 19 '23 21:06 huntersinclairtiv

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

pitermarx avatar Jun 19 '23 21:06 pitermarx

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

This worked for me.

diogobernini avatar Jun 19 '23 23:06 diogobernini

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

alistairwalsh avatar Jun 20 '23 00:06 alistairwalsh

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

mgcollie avatar Jun 20 '23 01:06 mgcollie

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: @.***>

bannsec avatar Jun 20 '23 01:06 bannsec

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'

mgcollie avatar Jun 20 '23 01:06 mgcollie

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

zlace0x avatar Jun 20 '23 04:06 zlace0x

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.

jtabox avatar Jun 20 '23 04:06 jtabox

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"

DataQub3 avatar Jun 20 '23 08:06 DataQub3

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?

tjb4578 avatar Jun 20 '23 17:06 tjb4578

@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.

mgcollie avatar Jun 20 '23 17:06 mgcollie

@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

danbatiste avatar Jun 20 '23 17:06 danbatiste

@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 avatar Jun 20 '23 17:06 mgcollie

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.

mgcollie avatar Jun 20 '23 18:06 mgcollie

@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.

raygpt avatar Jun 20 '23 18:06 raygpt

invite sent @raygpt

mgcollie avatar Jun 20 '23 18:06 mgcollie

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.

mgcollie avatar Jun 20 '23 20:06 mgcollie