From fa1df72bf3dc302b13e31e195d5b7feabfca6782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Ahlb=C3=A4ck?= Date: Sat, 17 Jun 2023 13:37:45 +0200 Subject: [PATCH 1/5] add unit_tests and spec/respec --- gpt_engineer/steps.py | 36 +++++++++++++++++++++++++++++++++--- identity/respec | 8 ++++++++ identity/spec | 8 ++++++++ identity/unit_tests | 3 +++ identity/use_qa | 4 ++-- 5 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 identity/respec create mode 100644 identity/spec create mode 100644 identity/unit_tests 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 From d30e07957166c7acea58bb022202550d1ba8b64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Ahlb=C3=A4ck?= Date: Sat, 17 Jun 2023 13:39:56 +0200 Subject: [PATCH 2/5] add unit_tests files --- gpt_engineer/steps.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index 40fed9a..d0145cf 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -73,6 +73,7 @@ def pre_unit_tests(ai: AI, dbs: DBs): messages = ai.next(messages, dbs.identity['unit_tests']) dbs.memory['unit_tests'] = messages[-1]['content'] + to_files(dbs.memory['unit_tests'], dbs.workspace) return messages From 7f6cab7aa2ce9615652fcb0dd8a462ed31ecacb9 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 13:45:03 +0200 Subject: [PATCH 3/5] Update gpt_engineer/steps.py --- gpt_engineer/steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index d0145cf..939abd2 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -68,7 +68,7 @@ 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.fsystem(setup_sys_prompt(dbs)), ai.fuser(f"Instructions: {dbs.input['main_prompt']}"), ai.fuser(f"Specification:\n\n{dbs.memory['specification']}")] messages = ai.next(messages, dbs.identity['unit_tests']) From 6715359ba173e99c6612653030289975cc661cb7 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 13:49:00 +0200 Subject: [PATCH 4/5] Update identity/respec --- identity/respec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identity/respec b/identity/respec index 9083676..00b16b0 100644 --- a/identity/respec +++ b/identity/respec @@ -1,4 +1,4 @@ -You are a GPT-Engineer, an AI developed to write programs. You have been asked to review a specification for a new feature. +You are a pragmatic principal engineer at Google. 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? From e2e094269042e9442ff154318343d4107434b1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Ahlb=C3=A4ck?= Date: Sat, 17 Jun 2023 13:49:37 +0200 Subject: [PATCH 5/5] fsystem -> fuser, main prompt -> instructions --- gpt_engineer/steps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index 939abd2..a084056 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -83,9 +83,9 @@ def run_clarified(ai: AI, dbs: DBs): 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']}"), - ai.fsystem(f"Unit tests:\n\n{dbs.memory['unit_tests']}"), + ai.fuser(f"Instructions: {dbs.input['main_prompt']}"), + ai.fuser(f"Specification:\n\n{dbs.memory['specification']}"), + ai.fuser(f"Unit tests:\n\n{dbs.memory['unit_tests']}"), ] messages = ai.next(messages, dbs.identity['use_qa']) to_files(messages[-1]['content'], dbs.workspace)