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

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,