Skip to content

Commit a36e299

Browse files
authored
Merge pull request #320 from AntonOsika/ao/fix-pip
Dont require to be in the same folder as the repo to run, v0.0.5
2 parents ffd3aca + 8062d90 commit a36e299

File tree

13 files changed

+22
-14
lines changed

13 files changed

+22
-14
lines changed

gpt_engineer/db.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ def __init__(self, path):
1111

1212
self.path.mkdir(parents=True, exist_ok=True)
1313

14+
def __contains__(self, key):
15+
return (self.path / key).is_file()
16+
1417
def __getitem__(self, key):
1518
full_path = self.path / key
1619

@@ -35,6 +38,6 @@ def __setitem__(self, key, val):
3538
class DBs:
3639
memory: DB
3740
logs: DB
38-
identity: DB
41+
preprompts: DB
3942
input: DB
4043
workspace: DB

gpt_engineer/main.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22
import logging
3-
import os
43
import shutil
54

65
from pathlib import Path
@@ -54,7 +53,7 @@ def main(
5453
logs=DB(memory_path / "logs"),
5554
input=DB(input_path),
5655
workspace=DB(workspace_path),
57-
identity=DB(Path(os.path.curdir) / "identity"),
56+
preprompts=DB(Path(__file__).parent / "preprompts"),
5857
)
5958

6059
for step in STEPS[steps_config]:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

gpt_engineer/steps.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
import subprocess
44

55
from enum import Enum
6+
from typing import Callable, TypeVar
67

78
from gpt_engineer.ai import AI
89
from gpt_engineer.chat_to_files import to_files
910
from gpt_engineer.db import DBs
1011

1112

1213
def setup_sys_prompt(dbs):
13-
return dbs.identity["generate"] + "\nUseful to know:\n" + dbs.identity["philosophy"]
14+
return (
15+
dbs.preprompts["generate"] + "\nUseful to know:\n" + dbs.preprompts["philosophy"]
16+
)
17+
18+
19+
Step = TypeVar("Step", bound=Callable[[AI, DBs], list[dict]])
1420

1521

1622
def simple_gen(ai: AI, dbs: DBs):
@@ -27,7 +33,7 @@ def clarify(ai: AI, dbs: DBs):
2733
"""
2834
Ask the user if they want to clarify anything and save the results to the workspace
2935
"""
30-
messages = [ai.fsystem(dbs.identity["qa"])]
36+
messages = [ai.fsystem(dbs.preprompts["qa"])]
3137
user = dbs.input["main_prompt"]
3238
while True:
3339
messages = ai.next(messages, user)
@@ -64,7 +70,7 @@ def gen_spec(ai: AI, dbs: DBs):
6470
ai.fsystem(f"Instructions: {dbs.input['main_prompt']}"),
6571
]
6672

67-
messages = ai.next(messages, dbs.identity["spec"])
73+
messages = ai.next(messages, dbs.preprompts["spec"])
6874

6975
dbs.memory["specification"] = messages[-1]["content"]
7076

@@ -73,7 +79,7 @@ def gen_spec(ai: AI, dbs: DBs):
7379

7480
def respec(ai: AI, dbs: DBs):
7581
messages = json.loads(dbs.logs[gen_spec.__name__])
76-
messages += [ai.fsystem(dbs.identity["respec"])]
82+
messages += [ai.fsystem(dbs.preprompts["respec"])]
7783

7884
messages = ai.next(messages)
7985
messages = ai.next(
@@ -102,7 +108,7 @@ def gen_unit_tests(ai: AI, dbs: DBs):
102108
ai.fuser(f"Specification:\n\n{dbs.memory['specification']}"),
103109
]
104110

105-
messages = ai.next(messages, dbs.identity["unit_tests"])
111+
messages = ai.next(messages, dbs.preprompts["unit_tests"])
106112

107113
dbs.memory["unit_tests"] = messages[-1]["content"]
108114
to_files(dbs.memory["unit_tests"], dbs.workspace)
@@ -118,7 +124,7 @@ def gen_clarified_code(ai: AI, dbs: DBs):
118124
messages = [
119125
ai.fsystem(setup_sys_prompt(dbs)),
120126
] + messages[1:]
121-
messages = ai.next(messages, dbs.identity["use_qa"])
127+
messages = ai.next(messages, dbs.preprompts["use_qa"])
122128

123129
to_files(messages[-1]["content"], dbs.workspace)
124130
return messages
@@ -133,7 +139,7 @@ def gen_code(ai: AI, dbs: DBs):
133139
ai.fuser(f"Specification:\n\n{dbs.memory['specification']}"),
134140
ai.fuser(f"Unit tests:\n\n{dbs.memory['unit_tests']}"),
135141
]
136-
messages = ai.next(messages, dbs.identity["use_qa"])
142+
messages = ai.next(messages, dbs.preprompts["use_qa"])
137143
to_files(messages[-1]["content"], dbs.workspace)
138144
return messages
139145

@@ -170,7 +176,7 @@ def gen_entrypoint(ai, dbs):
170176
"From this you will answer with code blocks that includes all the necessary "
171177
"unix terminal commands to "
172178
"a) install dependencies "
173-
"b) run all necessary parts of the codebase (in parallel if necessary).\n"
179+
"b) run all necessary parts of the codebase (in parallell if necessary).\n"
174180
"Do not install globally. Do not use sudo.\n"
175181
"Do not explain the code, just give the commands.\n"
176182
"Do not use placeholders, use example values (like . for a folder argument) "
@@ -191,7 +197,7 @@ def use_feedback(ai: AI, dbs: DBs):
191197
ai.fsystem(setup_sys_prompt(dbs)),
192198
ai.fuser(f"Instructions: {dbs.input['main_prompt']}"),
193199
ai.fassistant(dbs.workspace["all_output.txt"]),
194-
ai.fsystem(dbs.identity["use_feedback"]),
200+
ai.fsystem(dbs.preprompts["use_feedback"]),
195201
]
196202
messages = ai.next(messages, dbs.input["feedback"])
197203
to_files(messages[-1]["content"], dbs.workspace)
@@ -204,7 +210,7 @@ def fix_code(ai: AI, dbs: DBs):
204210
ai.fsystem(setup_sys_prompt(dbs)),
205211
ai.fuser(f"Instructions: {dbs.input['main_prompt']}"),
206212
ai.fuser(code_output),
207-
ai.fsystem(dbs.identity["fix_code"]),
213+
ai.fsystem(dbs.preprompts["fix_code"]),
208214
]
209215
messages = ai.next(messages, "Please fix any errors in the code above.")
210216
to_files(messages[-1]["content"], dbs.workspace)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
33

44
[project]
55
name = "gpt-engineer"
6-
version = "0.0.4"
6+
version = "0.0.5"
77
description = "Specify what you want it to build, the AI asks for clarification, and then builds it."
88
readme = "README.md"
99
requires-python = ">=3"

0 commit comments

Comments
 (0)