forked from AntonOsika/gpt-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (39 loc) · 1.21 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import json
import os
import pathlib
from typing import Optional
import openai
from chat_to_files import to_files
from ai import AI
from steps import STEPS
from db import DB, DBs
import typer
app = typer.Typer()
@app.command()
def chat(
project_path: str = typer.Argument(None, help="path"),
run_prefix: str = typer.Option("", help="run prefix, if you want to run multiple variants of the same project and later compare them"),
model: str = "gpt-4",
temperature: float = 0.1,
):
if project_path is None:
project_path = str(pathlib.Path(__file__).parent / "example")
input_path = project_path
memory_path = pathlib.Path(project_path) / (run_prefix + "memory")
workspace_path = pathlib.Path(project_path) / (run_prefix + "workspace")
ai = AI(
model=model,
temperature=temperature,
)
dbs = DBs(
memory=DB(memory_path),
logs=DB(pathlib.Path(memory_path) / "logs"),
input=DB(input_path),
workspace=DB(workspace_path),
identity=DB(pathlib.Path(__file__).parent / "identity"),
)
for step in STEPS:
messages = step(ai, dbs)
dbs.logs[step.__name__] = json.dumps(messages)
if __name__ == "__main__":
app()