diff --git a/.gitignore b/.gitignore index 1c41f42..5a39df8 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ archive # any log file *log.txt + +# ignore all project files +projects \ No newline at end of file diff --git a/README.md b/README.md index 40899bb..6fff452 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,13 @@ GPT Engineer is made to be easy to adapt, extend, and make your agent learn how - `export OPENAI_API_KEY=[your api key]` with a key that has GPT4 access **Run**: -- Create a new empty folder with a `main_prompt` file (or copy the example folder `cp -r example/ my-new-project`) +- Create a new empty folder with a `main_prompt` file in the `projects` folder (or copy the example folder `cp -r projects/example/ projects/my-new-project`) - Fill in the `main_prompt` in your new folder - Run `python -m gpt_engineer.main my-new-project` + - Optionally pass in `true` to delete the working files before running **Results**: -- Check the generated files in my-new-project/workspace +- Check the generated files in projects/my-new-project/workspace ### Limitations Implementing additional chain of thought prompting, e.g. [Reflexion](https://github.com/noahshinn024/reflexion), should be able to make it more reliable and not miss requested functionality in the main prompt. diff --git a/gpt_engineer/main.py b/gpt_engineer/main.py index c03ed7f..1aeabc2 100644 --- a/gpt_engineer/main.py +++ b/gpt_engineer/main.py @@ -2,8 +2,9 @@ import os import json import pathlib import typer +import shutil + -from gpt_engineer.chat_to_files import to_files from gpt_engineer.ai import AI from gpt_engineer.steps import STEPS from gpt_engineer.db import DB, DBs @@ -14,7 +15,8 @@ app = typer.Typer() @app.command() def chat( - project_path: str = typer.Argument(str(pathlib.Path(os.path.curdir) / "example"), help="path"), + project_path: str = typer.Argument("example", help="path"), + delete_existing: str = typer.Argument(None, help="delete existing files"), run_prefix: str = typer.Option( "", help="run prefix, if you want to run multiple variants of the same project and later compare them", @@ -24,9 +26,14 @@ def chat( steps_config: str = "default", ): app_dir = pathlib.Path(os.path.curdir) - input_path = project_path - memory_path = pathlib.Path(project_path) / (run_prefix + "memory") - workspace_path = pathlib.Path(project_path) / (run_prefix + "workspace") + input_path = pathlib.Path(app_dir / "projects" / project_path) + memory_path = input_path / (run_prefix + "memory") + workspace_path = input_path / (run_prefix + "workspace") + + if delete_existing == 'true': + # Delete files and subdirectories in paths + shutil.rmtree(memory_path, ignore_errors=True) + shutil.rmtree(workspace_path, ignore_errors=True) ai = AI( model=model, diff --git a/example/main_prompt b/projects/example/main_prompt similarity index 100% rename from example/main_prompt rename to projects/example/main_prompt