Simplify archiving process (#469)

* simplify args

* Fix tests

* Black format
This commit is contained in:
Anton Osika
2023-07-02 16:43:13 +02:00
committed by GitHub
parent 60e0a7e1dd
commit 20ea0c126a
6 changed files with 40 additions and 45 deletions

View File

@@ -1,16 +1,14 @@
import json
import logging
import os
from pathlib import Path
import typer
from gpt_engineer import steps
from gpt_engineer.ai import AI, fallback_model
from gpt_engineer.collect import collect_learnings
from gpt_engineer.db import DB, DBs
from gpt_engineer.steps import STEPS
from gpt_engineer.db import DB, DBs, archive
from gpt_engineer.steps import STEPS, Config as StepsConfig
app = typer.Typer()
@@ -20,17 +18,10 @@ def main(
project_path: str = typer.Argument("example", help="path"),
model: str = typer.Argument("gpt-4", help="model id string"),
temperature: float = 0.1,
steps_config: steps.Config = typer.Option(
steps.Config.DEFAULT, "--steps", "-s", help="decide which steps to run"
steps_config: StepsConfig = typer.Option(
StepsConfig.DEFAULT, "--steps", "-s", help="decide which steps to run"
),
verbose: bool = typer.Option(False, "--verbose", "-v"),
run_prefix: str = typer.Option(
"",
help=(
"run prefix, if you want to run multiple variants of the same project and "
"later compare them"
),
),
):
logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO)
@@ -41,20 +32,26 @@ def main(
)
input_path = Path(project_path).absolute()
memory_path = input_path / f"{run_prefix}memory"
workspace_path = input_path / f"{run_prefix}workspace"
archive_path = input_path / f"{run_prefix}archive"
memory_path = input_path / "memory"
workspace_path = input_path / "workspace"
archive_path = input_path / "archive"
initial_run = not os.path.exists(memory_path) and not os.path.exists(workspace_path)
dbs = DBs(
memory=DB(memory_path),
logs=DB(memory_path / "logs"),
input=DB(input_path),
workspace=DB(workspace_path),
preprompts=DB(Path(__file__).parent / "preprompts"),
archive=None if initial_run else DB(archive_path),
archive=DB(archive_path),
)
if steps_config not in [
StepsConfig.EXECUTE_ONLY,
StepsConfig.USE_FEEDBACK,
StepsConfig.EVALUATE,
]:
archive(dbs)
steps = STEPS[steps_config]
for step in steps:
messages = step(ai, dbs)