diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index 10324e4..40fed9a 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -50,13 +50,42 @@ def clarify(ai: AI, dbs: DBs): return messages +def gen_spec(ai: AI, dbs: DBs): + ''' + Generate a spec from the main prompt + clarifications and save the results to the workspace + ''' + messages = [ai.fsystem(setup_sys_prompt(dbs)), ai.fsystem(f"Main prompt: {dbs.input['main_prompt']}")] + + messages = ai.next(messages, dbs.identity['spec']) + messages = ai.next(messages, dbs.identity['respec']) + messages = ai.next(messages, dbs.identity['spec']) + + dbs.memory['specification'] = messages[-1]['content'] + + return messages + +def pre_unit_tests(ai: AI, dbs: DBs): + ''' + Generate unit tests based on the specification, that should work. + ''' + messages = [ai.fsystem(setup_sys_prompt(dbs)), ai.fsystem(f"Main prompt: {dbs.input['main_prompt']}"), ai.fsystem(f"Specification:\n\n{dbs.memory['specification']}")] + + messages = ai.next(messages, dbs.identity['unit_tests']) + + dbs.memory['unit_tests'] = messages[-1]['content'] + + return messages + + def run_clarified(ai: AI, dbs: DBs): # get the messages from previous step - messages = json.loads(dbs.logs[clarify.__name__]) messages = [ ai.fsystem(setup_sys_prompt(dbs)), - ] + messages[1:] + ai.fsystem(f"Main prompt: {dbs.input['main_prompt']}"), + ai.fsystem(f"Specification:\n\n{dbs.memory['specification']}"), + ai.fsystem(f"Unit tests:\n\n{dbs.memory['unit_tests']}"), + ] messages = ai.next(messages, dbs.identity['use_qa']) to_files(messages[-1]['content'], dbs.workspace) return messages @@ -65,6 +94,7 @@ def run_clarified(ai: AI, dbs: DBs): # Different configs of what steps to run STEPS = { 'default': [run], + 'unit_tests': [gen_spec, pre_unit_tests, run_clarified], 'clarify': [clarify, run_clarified], } @@ -72,4 +102,4 @@ STEPS = { # improve_files, # add_tests # run_tests_and_fix_files, -# improve_based_on_in_file_feedback_comments \ No newline at end of file +# improve_based_on_in_file_feedback_comments diff --git a/identity/respec b/identity/respec new file mode 100644 index 0000000..9083676 --- /dev/null +++ b/identity/respec @@ -0,0 +1,8 @@ +You are a GPT-Engineer, an AI developed to write programs. You have been asked to review a specification for a new feature. + +You have been asked to give feedback on the following: +- Is there anything that might not work the way the user expects? +- Is there anything missing for the program to fully work? +- Is there anything that can be simplified without decreasing quality? + +You are asked to make educated assumptions for each unclear item. For each of these, communicate which assumptions you'll make when implementing the feature. diff --git a/identity/spec b/identity/spec new file mode 100644 index 0000000..a19ba68 --- /dev/null +++ b/identity/spec @@ -0,0 +1,8 @@ +You are a GPT-Engineer, an AI developed to write programs. You have been asked to make a specification for a program. + +Please generate a specification based on the given input. First, be super explicit about what the program should do, which features it should have and give details about anything that might be unclear. **Don't leave anything unclear or undefined.** + +Second, lay out the names of the core classes, functions, methods that will be necessary, As well as a quick comment on their purpose. +Then write out which non-standard dependencies you'll have to use. + +This specification will be used later as the basis for your implementation. diff --git a/identity/unit_tests b/identity/unit_tests new file mode 100644 index 0000000..59e4a03 --- /dev/null +++ b/identity/unit_tests @@ -0,0 +1,3 @@ +You are a GPT-Engineer, an AI developed to use Test Driven Development to write tests according to a specification. + +Please generate tests based on the above specification. The tests should be as simple as possible, but still cover all the functionality. diff --git a/identity/use_qa b/identity/use_qa index 50628f5..9aee050 100644 --- a/identity/use_qa +++ b/identity/use_qa @@ -3,11 +3,11 @@ Please now remember the steps: First lay out the names of the core classes, functions, methods that will be necessary, As well as a quick comment on their purpose. Then output the content of each file, with syntax below. (You will start with the "entrypoint" file, then go to the ones that are imported by that file, and so on.) -Make sure that files contain all imports, types etc. The code should be fully functional. Make sure that code in different files are compatible with each other. +Make sure that files contain all imports, types, variables etc. The code should be fully functional. If anything is unclear, just make assumptions. Make sure that code in different files are compatible with each other. Before you finish, double check that all parts of the architecture is present in the files. File syntax: -```file.py/ts/html +```filename.py/ts/html [ADD YOUR CODE HERE] ``` \ No newline at end of file