Add cleanup & move projects to their own directory

- Add optional argument to clean and delete the working directories of the project before running the prompt
- Add `.gitignore` entry to ignore all possible projects
- Update readme
This commit is contained in:
Enzo Martin
2023-06-18 10:05:45 +02:00
parent c4c1203fc0
commit b97563726f
4 changed files with 18 additions and 7 deletions

3
.gitignore vendored
View File

@@ -36,3 +36,6 @@ archive
# any log file
*log.txt
# ignore all project files
projects

View File

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

View File

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