gpt-engineer-org / gpt-engineer

Platform to experiment with the AI Software Engineer. Terminal based. NOTE: Very different from https://gptengineer.app
MIT License
52.54k stars 6.83k forks source link

Issue writing to a file (commit hash : 6ccd05ab65dcd83d6057c6c068a3f5290ab09176) #282

Closed kit678 closed 1 year ago

kit678 commented 1 year ago

Expected Behavior

Trying to get a very simple html written, that renders a button which displays some text when pressed

Current Behavior

Seems like it at least codes the html properly, but fails to write the file. specific error message: [Errno 22] Invalid argument: 'C:\Users\Kit\PycharmProjects\gpt-engineer\projects\test\workspace\file:'

Failure Information (for bugs)

Traceback (most recent call last):

File "C:\Users\Kit\miniconda3\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None,

File "C:\Users\Kit\miniconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals)

File "C:\Users\Kit\PycharmProjects\gpt-engineer\venv\Scripts\gpt-engineer.exe__main__.py", line 7, in sys.exit(app())

File "C:\Users\Kit\PycharmProjects\gpt-engineer\gpt_engineer\main.py", line 61, in main messages = step(ai, dbs)

File "C:\Users\Kit\PycharmProjects\gpt-engineer\gpt_engineer\steps.py", line 123, in gen_clarified_code to_files(messages[-1]["content"], dbs.workspace)

File "C:\Users\Kit\PycharmProjects\gpt-engineer\gpt_engineer\chat_to_files.py", line 42, in to_files workspace[file_name] = file_content

File "C:\Users\Kit\PycharmProjects\gpt-engineer\gpt_engineer\db.py", line 27, in setitem full_path.write_text(val, encoding="utf-8")

File "C:\Users\Kit\miniconda3\lib\pathlib.py", line 1255, in write_text with self.open(mode='w', encoding=encoding, errors=errors) as f:

File "C:\Users\Kit\miniconda3\lib\pathlib.py", line 1222, in open return io.open(self, mode, buffering, encoding, errors, newline,

File "C:\Users\Kit\miniconda3\lib\pathlib.py", line 1078, in _opener return self._accessor.open(self, flags, mode)

OSError: [Errno 22] Invalid argument: 'C:\Users\Kit\PycharmProjects\gpt-engineer\projects\test\workspace\file:'

all_output.txt

FlorianSchepers commented 1 year ago

I had a similar problem.

The problem seems to be that gpt adds a block at the end of its message explaining how to run the code (in my case, the tests), e.g.: """ To run the tests, run the following command in the terminal:

```bash pytest test_game_controller.py test_game_model.py test_game_view.py ``` """ The regex identifies it as another file named "terminal:" and it goes south from here.

Quick fix: Add if ':' not in path: before files.append((path, code)) in the parse_chat() function.

The better solution would probably be to customize the prompt to avoid this issue at all.

patillacode commented 1 year ago

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