From 633291e3d5f33bce1367bfc74ed7ff22cf8e2dc8 Mon Sep 17 00:00:00 2001 From: PatillaCode Date: Fri, 16 Jun 2023 15:33:46 +0200 Subject: [PATCH 01/18] added a minimal makefile --- Makefile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c70379c --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +SHELL := /bin/bash + +.PHONY: help install dev-install + +.DEFAULT_GOAL := help + +.SILENT: + +help: + @echo "Please use 'make ' where is one of the following:" + @echo " help Return this message with usage instructions." + @echo " install Will install the dependencies and create a virtual environment." + @echo " dev-install Will install the dev dependencies too." + +dev-install:create-venv install-dev-dependencies install-pre-commit + +install: create-venv install-dependencies farewell + +install-dependencies: + @echo "Installing dependencies..." && \ + pip install . >> /dev/null + +create-venv: + @echo "Creating virtual environment..." && \ + python -m venv venv && \ + source venv/bin/activate && \ + pip install --upgrade pip + +install-dev-dependencies: + @echo "Installing dependencies..." && \ + source venv/bin/activate && \ + pip install -r requirements.txt + +install-pre-commit: + @echo "Installing pre-commit hooks..." && \ + source venv/bin/activate && \ + pre-commit install From bdcad97585e7af4370301f9610411e6a214d7274 Mon Sep 17 00:00:00 2001 From: PatillaCode Date: Sat, 17 Jun 2023 16:39:22 +0200 Subject: [PATCH 02/18] tweaking Makefile + gitignore entry --- .gitignore | 1 + Makefile | 42 +++++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 2e6f48e..a00eb93 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ build/ # Virtual environments .env +.env.sh venv/ ENV/ diff --git a/Makefile b/Makefile index c70379c..49e9bb8 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,49 @@ SHELL := /bin/bash -.PHONY: help install dev-install +# Color codes +COLOR_RESET=\033[0m +COLOR_CYAN=\033[1;36m +COLOR_GREEN=\033[1;32m + +.PHONY: help install dev-install run .DEFAULT_GOAL := help .SILENT: +name := $(word 2,$(MAKECMDGOALS)) + help: @echo "Please use 'make ' where is one of the following:" - @echo " help Return this message with usage instructions." - @echo " install Will install the dependencies and create a virtual environment." - @echo " dev-install Will install the dev dependencies too." + @echo " help Return this message with usage instructions." + @echo " install Will install the dependencies and create a virtual environment." + @echo " dev-install Will install the dev dependencies too." + @echo " run Runs GPT Engineer on the folder with the given name." -dev-install:create-venv install-dev-dependencies install-pre-commit +dev-install: create-venv install-dependencies install-pre-commit farewell install: create-venv install-dependencies farewell -install-dependencies: - @echo "Installing dependencies..." && \ - pip install . >> /dev/null - create-venv: - @echo "Creating virtual environment..." && \ + @echo -e "$(COLOR_CYAN)Creating virtual environment...$(COLOR_RESET)" && \ python -m venv venv && \ source venv/bin/activate && \ - pip install --upgrade pip + pip install --upgrade pip >> /dev/null -install-dev-dependencies: - @echo "Installing dependencies..." && \ +install-dependencies: + @echo -e "$(COLOR_CYAN)Installing dependencies...$(COLOR_RESET)" && \ source venv/bin/activate && \ - pip install -r requirements.txt + pip install -r requirements.txt >> /dev/null install-pre-commit: - @echo "Installing pre-commit hooks..." && \ + @echo -e "$(COLOR_CYAN)Installing pre-commit hooks...$(COLOR_RESET)" && \ source venv/bin/activate && \ pre-commit install + +farewell: + @echo -e "$(COLOR_GREEN)All done!$(COLOR_RESET)" + +run: + @echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \ + source venv/bin/activate && \ + python -m gpt_engineer.main $(name) From 6d43a6a972abe21feaf2a55dcad2994481fc76c5 Mon Sep 17 00:00:00 2001 From: PatillaCode Date: Sat, 17 Jun 2023 17:20:16 +0200 Subject: [PATCH 03/18] pretty --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 49e9bb8..cdbfb5b 100644 --- a/Makefile +++ b/Makefile @@ -20,13 +20,16 @@ help: @echo " dev-install Will install the dev dependencies too." @echo " run Runs GPT Engineer on the folder with the given name." -dev-install: create-venv install-dependencies install-pre-commit farewell +dev-install: create-venv upgrade-pip install-dependencies install-pre-commit farewell -install: create-venv install-dependencies farewell +install: create-venv upgrade-pip install-dependencies farewell create-venv: @echo -e "$(COLOR_CYAN)Creating virtual environment...$(COLOR_RESET)" && \ - python -m venv venv && \ + python -m venv venv + +upgrade-pip: + @echo -e "$(COLOR_CYAN)Upgrading pip...$(COLOR_RESET)" && \ source venv/bin/activate && \ pip install --upgrade pip >> /dev/null @@ -47,3 +50,4 @@ run: @echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \ source venv/bin/activate && \ python -m gpt_engineer.main $(name) + From 31b00de247171a3c13ab46f8dba1d5bbaaec6d67 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 19:52:22 +0200 Subject: [PATCH 04/18] Improve prompts --- gpt_engineer/steps.py | 2 +- identity/{setup => generate} | 3 ++- identity/qa | 2 +- identity/respec | 5 ++++- identity/spec | 13 ++++++++----- identity/unit_tests | 2 +- identity/use_qa | 3 ++- 7 files changed, 19 insertions(+), 11 deletions(-) rename identity/{setup => generate} (83%) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index 60fea23..d6bf3fd 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -8,7 +8,7 @@ from gpt_engineer.chat_to_files import parse_chat def setup_sys_prompt(dbs): - return dbs.identity["setup"] + "\nUseful to know:\n" + dbs.identity["philosophy"] + return dbs.identity["generate"] + "\nUseful to know:\n" + dbs.identity["philosophy"] def run(ai: AI, dbs: DBs): diff --git a/identity/setup b/identity/generate similarity index 83% rename from identity/setup rename to identity/generate index 4917945..8e5f427 100644 --- a/identity/setup +++ b/identity/generate @@ -1,7 +1,8 @@ You will get instructions for code to write. You will write a very long answer. Make sure that every detail of the architecture is, in the end, implemented as code. -You will first lay out the names of the core classes, functions, methods that will be necessary, As well as a quick comment on their purpose. +Think step by step and reason yourself to the right decisions to make sure we get it right. +You will 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 you will 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. Make sure that code in different files are compatible with each other. diff --git a/identity/qa b/identity/qa index f4f9934..58c3508 100644 --- a/identity/qa +++ b/identity/qa @@ -1,3 +1,3 @@ You will read instructions and not carry them out, only seek to clarify them. Specifically you will first summarise a list of super short bullets of areas that need clarification. -Then you will pick one clarifying question, and wait for an answer from the user. +Then you will pick one clarifying question, and wait for an answer from the user. \ No newline at end of file diff --git a/identity/respec b/identity/respec index 00b16b0..0ffc318 100644 --- a/identity/respec +++ b/identity/respec @@ -5,4 +5,7 @@ You have been asked to give feedback on the following: - 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. +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. + +Think step by step to make sure we don't miss anything. \ No newline at end of file diff --git a/identity/spec b/identity/spec index 90c1d0d..540d13b 100644 --- a/identity/spec +++ b/identity/spec @@ -1,8 +1,11 @@ -You are a super smart developer and an AI developed to write programs. You have been asked to make a specification for a program. +You are a super smart developer. 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.** +Think step by step to make sure we get a high quality specification and we don't miss anything. +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. +Second, lay out the names of the core classes, functions, methods that will be necessary, +as well as a quick comment on their purpose. +Finally list all non-standard dependencies you'll have to use. -This specification will be used later as the basis for your implementation. +This specification will be used later as the basis for the implementation. \ No newline at end of file diff --git a/identity/unit_tests b/identity/unit_tests index d21997e..4c9534b 100644 --- a/identity/unit_tests +++ b/identity/unit_tests @@ -1,3 +1,3 @@ -You are a super smart developer and an AI developed to use Test Driven Development to write tests according to a specification. +You are a super smart developer using 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 9aee050..a8b1f73 100644 --- a/identity/use_qa +++ b/identity/use_qa @@ -1,6 +1,7 @@ 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. +Think step by step and reason yourself to the right decisions to make sure we get it right. +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, 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. From a3cb4964e9024e85841a520f9430d0841bc9b1c0 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 19:52:48 +0200 Subject: [PATCH 05/18] Remove automatic execution for now --- 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 d6bf3fd..dcec0c2 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -125,7 +125,7 @@ def execute_workspace(ai: AI, dbs: DBs): # Different configs of what steps to run STEPS = { - 'default': [gen_spec, pre_unit_tests, run_clarified, execute_workspace], + 'default': [gen_spec, pre_unit_tests, run_clarified], 'simple': [run, execute_workspace], 'clarify': [clarify, run_clarified], } From e8f47c1e702f901cd058d888cd0932b35323b8ab Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 20:36:51 +0200 Subject: [PATCH 06/18] improve execution step --- gpt_engineer/steps.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index dcec0c2..676159b 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -56,7 +56,7 @@ 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.fsystem(setup_sys_prompt(dbs)), ai.fsystem(f"Instructions: {dbs.input['main_prompt']}")] messages = ai.next(messages, dbs.identity['spec']) messages = ai.next(messages, dbs.identity['respec']) @@ -97,10 +97,11 @@ def run_clarified(ai: AI, dbs: DBs): def execute_workspace(ai: AI, dbs: DBs): messages = ai.start( system=( - f"You will get infomation about a codebase that is currently on disk in the folder {dbs.workspace.path}.\n" + f"You will get information about a codebase that is currently on disk in the current folder.\n" "From this you will answer with one code block that includes all the necessary macos terminal commands to " "a) install dependencies " - "b) run the necessary parts of the codebase to try it.\n" + "b) run all necessary parts of the codebase (in parallell if necessary).\n" + "Do not install globally. Do not use sudo.\n" "Do not explain the code, just give the commands.\n" ), user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"], @@ -109,6 +110,8 @@ def execute_workspace(ai: AI, dbs: DBs): [[lang, command]] = parse_chat(messages[-1]['content']) assert lang in ['', 'bash', 'sh'] + dbs.workspace['run.sh'] = command + print('Do you want to execute this code?') print(command) print() @@ -119,7 +122,9 @@ def execute_workspace(ai: AI, dbs: DBs): return messages print('Executing the code...') print() - subprocess.run(command, shell=True) + + # Run the subprocess in dbs.workspace.path + subprocess.run('bash run.sh', shell=True, cwd=dbs.workspace.path) return messages @@ -128,6 +133,7 @@ STEPS = { 'default': [gen_spec, pre_unit_tests, run_clarified], 'simple': [run, execute_workspace], 'clarify': [clarify, run_clarified], + 'execute_only': [execute_workspace], } # Future steps that can be added: From 4a9ab4647e6398d6901d68a1131352a6848ecd01 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 20:39:18 +0200 Subject: [PATCH 07/18] Execute per default --- 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 676159b..b3f9486 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -130,7 +130,7 @@ def execute_workspace(ai: AI, dbs: DBs): # Different configs of what steps to run STEPS = { - 'default': [gen_spec, pre_unit_tests, run_clarified], + 'default': [gen_spec, pre_unit_tests, run_clarified, execute_workspace], 'simple': [run, execute_workspace], 'clarify': [clarify, run_clarified], 'execute_only': [execute_workspace], From 903a8905cb449dce79b2d634f19c3e9f0e419c95 Mon Sep 17 00:00:00 2001 From: Philipp Kohler <39829783+Snoup97@users.noreply.github.com> Date: Sat, 17 Jun 2023 20:53:04 +0200 Subject: [PATCH 08/18] fixed the DB import in the pytest file (#116) --- tests/test_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_db.py b/tests/test_db.py index 5dea240..0843a21 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -1,4 +1,4 @@ -from ..db import DB +from gpt_engineer.db import DB def test_db(): From 8ac2cd81b9e19ac90fd2204fcd546e1e84d48f51 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 21:01:30 +0200 Subject: [PATCH 09/18] Always generate entrypoint --- .gitignore | 1 + gpt_engineer/steps.py | 45 ++++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 1c41f42..debee41 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ archive # any log file *log.txt +todo diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index b3f9486..ef08214 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -95,6 +95,29 @@ def run_clarified(ai: AI, dbs: DBs): def execute_workspace(ai: AI, dbs: DBs): + messages = gen_entrypoint(ai, dbs) + execute_entrypoint(ai, dbs) + return messages + + +def execute_entrypoint(ai, dbs): + command = dbs.workspace['run.sh'] + + print('Do you want to execute this code?') + print() + print(command) + print() + print('If yes, press enter. If no, type "no"') + print() + if input() == 'no': + print('Ok, not executing the code.') + print('Executing the code...') + print() + subprocess.run('bash run.sh', shell=True, cwd=dbs.workspace.path) + return [] + + +def gen_entrypoint(ai, dbs): messages = ai.start( system=( f"You will get information about a codebase that is currently on disk in the current folder.\n" @@ -106,34 +129,20 @@ def execute_workspace(ai: AI, dbs: DBs): ), user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"], ) - + print() [[lang, command]] = parse_chat(messages[-1]['content']) assert lang in ['', 'bash', 'sh'] - dbs.workspace['run.sh'] = command - - print('Do you want to execute this code?') - print(command) - print() - print('If yes, press enter. If no, type "no"') - print() - if input() == 'no': - print('Ok, not executing the code.') - return messages - print('Executing the code...') - print() - - # Run the subprocess in dbs.workspace.path - subprocess.run('bash run.sh', shell=True, cwd=dbs.workspace.path) return messages # Different configs of what steps to run STEPS = { 'default': [gen_spec, pre_unit_tests, run_clarified, execute_workspace], + 'benchmark': [gen_spec, pre_unit_tests, run_clarified, gen_entrypoint], 'simple': [run, execute_workspace], - 'clarify': [clarify, run_clarified], - 'execute_only': [execute_workspace], + 'clarify': [clarify, run_clarified, gen_entrypoint], + 'execute_only': [execute_entrypoint], } # Future steps that can be added: From a4019fb82fcd85edbc11ea7bba7c8df46d913e37 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 21:32:46 +0200 Subject: [PATCH 10/18] Black --- gpt_engineer/steps.py | 64 ++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index ef08214..c414a5f 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -30,7 +30,7 @@ def clarify(ai: AI, dbs: DBs): while True: messages = ai.next(messages, user) - if messages[-1]['content'].strip().lower().startswith("no"): + if messages[-1]["content"].strip().lower().startswith("no"): break print() @@ -53,29 +53,37 @@ def clarify(ai: AI, dbs: DBs): 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"Instructions: {dbs.input['main_prompt']}")] + """ + messages = [ + ai.fsystem(setup_sys_prompt(dbs)), + ai.fsystem(f"Instructions: {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']) + 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'] + 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.fuser(f"Instructions: {dbs.input['main_prompt']}"), ai.fuser(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']) + messages = ai.next(messages, dbs.identity["unit_tests"]) - dbs.memory['unit_tests'] = messages[-1]['content'] - to_files(dbs.memory['unit_tests'], dbs.workspace) + dbs.memory["unit_tests"] = messages[-1]["content"] + to_files(dbs.memory["unit_tests"], dbs.workspace) return messages @@ -101,19 +109,19 @@ def execute_workspace(ai: AI, dbs: DBs): def execute_entrypoint(ai, dbs): - command = dbs.workspace['run.sh'] + command = dbs.workspace["run.sh"] - print('Do you want to execute this code?') + print("Do you want to execute this code?") print() print(command) print() print('If yes, press enter. If no, type "no"') print() - if input() == 'no': - print('Ok, not executing the code.') - print('Executing the code...') + if input() == "no": + print("Ok, not executing the code.") + print("Executing the code...") print() - subprocess.run('bash run.sh', shell=True, cwd=dbs.workspace.path) + subprocess.run("bash run.sh", shell=True, cwd=dbs.workspace.path) return [] @@ -130,19 +138,19 @@ def gen_entrypoint(ai, dbs): user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"], ) print() - [[lang, command]] = parse_chat(messages[-1]['content']) - assert lang in ['', 'bash', 'sh'] - dbs.workspace['run.sh'] = command + [[lang, command]] = parse_chat(messages[-1]["content"]) + assert lang in ["", "bash", "sh"] + dbs.workspace["run.sh"] = command return messages # Different configs of what steps to run STEPS = { - 'default': [gen_spec, pre_unit_tests, run_clarified, execute_workspace], - 'benchmark': [gen_spec, pre_unit_tests, run_clarified, gen_entrypoint], - 'simple': [run, execute_workspace], - 'clarify': [clarify, run_clarified, gen_entrypoint], - 'execute_only': [execute_entrypoint], + "default": [gen_spec, pre_unit_tests, run_clarified, execute_workspace], + "benchmark": [gen_spec, pre_unit_tests, run_clarified, gen_entrypoint], + "simple": [run, execute_workspace], + "clarify": [clarify, run_clarified, gen_entrypoint], + "execute_only": [execute_entrypoint], } # Future steps that can be added: From 0d186e22e6e3ff904f4295a0088a7bdf1b31aea9 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 21:54:11 +0200 Subject: [PATCH 11/18] Skip the respec by default, fix that it changed application --- gpt_engineer/steps.py | 47 ++++++++++++++++++++++++++++++++++--------- identity/respec | 9 +++++---- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index c414a5f..b82af8a 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -11,7 +11,7 @@ def setup_sys_prompt(dbs): return dbs.identity["generate"] + "\nUseful to know:\n" + dbs.identity["philosophy"] -def run(ai: AI, dbs: DBs): +def simple_gen(ai: AI, dbs: DBs): """Run the AI on the main prompt and save the results""" messages = ai.start( setup_sys_prompt(dbs), @@ -61,16 +61,31 @@ def gen_spec(ai: AI, dbs: DBs): ai.fsystem(f"Instructions: {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 respec(ai: AI, dbs: DBs): + messages = dbs.logs[gen_spec.__name__] + messages += [ai.fsystem(dbs.identity["respec"])] -def pre_unit_tests(ai: AI, dbs: DBs): + messages = ai.next(messages) + messages = ai.next( + messages, + ( + 'Based on the conversation so far, please reiterate the specification for the program. ' + 'If there are things that can be improved, please incorporate the improvements. ' + "If you are satisfied with the specification, just write out the specification word by word again." + ) + ) + + dbs.memory["specification"] = messages[-1]["content"] + return messages + + +def gen_unit_tests(ai: AI, dbs: DBs): """ Generate unit tests based on the specification, that should work. """ @@ -88,7 +103,20 @@ def pre_unit_tests(ai: AI, dbs: DBs): return messages -def run_clarified(ai: AI, dbs: DBs): +def gen_clarified_code(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:] + messages = ai.next(messages, dbs.identity["use_qa"]) + + to_files(messages[-1]["content"], dbs.workspace) + return messages + +def gen_code(ai: AI, dbs: DBs): # get the messages from previous step messages = [ @@ -146,10 +174,11 @@ def gen_entrypoint(ai, dbs): # Different configs of what steps to run STEPS = { - "default": [gen_spec, pre_unit_tests, run_clarified, execute_workspace], - "benchmark": [gen_spec, pre_unit_tests, run_clarified, gen_entrypoint], - "simple": [run, execute_workspace], - "clarify": [clarify, run_clarified, gen_entrypoint], + "default": [gen_spec, gen_unit_tests, gen_code, execute_workspace], + "benchmark": [gen_spec, gen_unit_tests, gen_code, gen_entrypoint], + "simple": [simple_gen, execute_workspace], + "clarify": [clarify, gen_clarified_code, execute_workspace], + "respec": [gen_spec, respec, gen_unit_tests, gen_code, execute_workspace], "execute_only": [execute_entrypoint], } diff --git a/identity/respec b/identity/respec index 0ffc318..ac907d7 100644 --- a/identity/respec +++ b/identity/respec @@ -1,9 +1,10 @@ -You are a pragmatic principal engineer at Google. 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 by a previous version of yourself 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? +- Is there anything that might not work the way intended by the instructions? +- Is there anything in the specification missing for the program to work as expected? +- Is there anything that can be simplified without significant drawback? 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. From 90cd00560768be171278200712cc1a74fdffde96 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 22:21:10 +0200 Subject: [PATCH 12/18] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 40899bb..4bc6be0 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,6 @@ GPT Engineer is made to be easy to adapt, extend, and make your agent learn how - Simplicity, all computation is "resumable" and persisted to the filesystem - -![output](https://github.com/AntonOsika/gpt-engineer/assets/4467025/a6938d43-2ac1-4cf1-98d1-93eea1bdfce4) - - ## Usage **Setup**: From f44bd838f45d7fbd07675bc71404b8e816b55aae Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 22:22:59 +0200 Subject: [PATCH 13/18] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bc6be0..728568e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # GPT Engineer **Specify what you want it to build, the AI asks for clarification, and then builds it.** -GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. +GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. [Demo](https://twitter.com/antonosika/status/1667641038104674306). ## Project philosophy - Simple to get value From e0137261b1f7d1b992676310e3b1c9eeee17e7ee Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 22:23:55 +0200 Subject: [PATCH 14/18] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 728568e..2088d9a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # GPT Engineer **Specify what you want it to build, the AI asks for clarification, and then builds it.** -GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. [Demo](https://twitter.com/antonosika/status/1667641038104674306). +GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt: [demo](https://twitter.com/antonosika/status/1667641038104674306) πŸ‘ΆπŸ€– ## Project philosophy - Simple to get value From ed486aed74e2679b835f0c6e6df16900299ae0d6 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 22:24:08 +0200 Subject: [PATCH 15/18] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2088d9a..4766c30 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # GPT Engineer **Specify what you want it to build, the AI asks for clarification, and then builds it.** -GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt: [demo](https://twitter.com/antonosika/status/1667641038104674306) πŸ‘ΆπŸ€– +GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. + +[Demo](https://twitter.com/antonosika/status/1667641038104674306) πŸ‘ΆπŸ€– ## Project philosophy - Simple to get value From d20f086a9b4bb7e3c781619f40072ec4407f3116 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 22:24:38 +0200 Subject: [PATCH 16/18] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4766c30..f16ddee 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. -[Demo](https://twitter.com/antonosika/status/1667641038104674306) πŸ‘ΆπŸ€– - ## Project philosophy - Simple to get value - Flexible and easy to add new own "AI steps". See `steps.py`. @@ -14,6 +12,7 @@ GPT Engineer is made to be easy to adapt, extend, and make your agent learn how - Fast handovers back and forth between AI and human - Simplicity, all computation is "resumable" and persisted to the filesystem +[Demo](https://twitter.com/antonosika/status/1667641038104674306) πŸ‘ΆπŸ€– ## Usage From fa7585f900d8ccecc4653005778369a7ba8da87a Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sat, 17 Jun 2023 22:50:52 +0200 Subject: [PATCH 17/18] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f16ddee..4766c30 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. +[Demo](https://twitter.com/antonosika/status/1667641038104674306) πŸ‘ΆπŸ€– + ## Project philosophy - Simple to get value - Flexible and easy to add new own "AI steps". See `steps.py`. @@ -12,7 +14,6 @@ GPT Engineer is made to be easy to adapt, extend, and make your agent learn how - Fast handovers back and forth between AI and human - Simplicity, all computation is "resumable" and persisted to the filesystem -[Demo](https://twitter.com/antonosika/status/1667641038104674306) πŸ‘ΆπŸ€– ## Usage From c6b6ca14488361182a7c35f1aed0862a713c3905 Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sun, 18 Jun 2023 08:36:07 +0200 Subject: [PATCH 18/18] Fix not generating bash commands --- gpt_engineer/ai.py | 3 +++ gpt_engineer/steps.py | 21 ++++++++++++++++++--- identity/use_feedback | 0 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 identity/use_feedback diff --git a/gpt_engineer/ai.py b/gpt_engineer/ai.py index 10351a6..619bda0 100644 --- a/gpt_engineer/ai.py +++ b/gpt_engineer/ai.py @@ -26,6 +26,9 @@ class AI: def fuser(self, msg): return {"role": "user", "content": msg} + def fassistant(self, msg): + return {"role": "assistant", "content": msg} + def next(self, messages: list[dict[str, str]], prompt=None): if prompt: diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index b82af8a..88115da 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -166,9 +166,23 @@ def gen_entrypoint(ai, dbs): user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"], ) print() - [[lang, command]] = parse_chat(messages[-1]["content"]) - assert lang in ["", "bash", "sh"] - dbs.workspace["run.sh"] = command + + blocks = parse_chat(messages[-1]["content"]) + for lang, _ in blocks: + assert lang in ["", "bash", "sh"], "Generated entrypoint command that was not bash" + + dbs.workspace["run.sh"] = "\n".join(block for lang, block in blocks) + return messages + +def use_feedback(ai: AI, dbs: DBs): + messages = [ + ai.fsystem(setup_sys_prompt(dbs)), + ai.fuser(f"Instructions: {dbs.input['main_prompt']}"), + ai.fassistant(dbs.workspace["all_output.txt"]), + ai.fsystem(dbs.identity["use_feedback"]), + ] + messages = ai.next(messages, dbs.memory['feedback']) + to_files(messages[-1]["content"], dbs.workspace) return messages @@ -180,6 +194,7 @@ STEPS = { "clarify": [clarify, gen_clarified_code, execute_workspace], "respec": [gen_spec, respec, gen_unit_tests, gen_code, execute_workspace], "execute_only": [execute_entrypoint], + "use_feedback": [use_feedback], } # Future steps that can be added: diff --git a/identity/use_feedback b/identity/use_feedback new file mode 100644 index 0000000..e69de29