From a038117efa6bbba98a00430cf42ba247fdd60949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Thom=C3=A9?= Date: Sun, 18 Jun 2023 15:12:36 +0200 Subject: [PATCH 1/8] Drop Python 3.8 and 3.9 Code assumes Python 3.10 features, so drop 3.8 and 3.9 from testing. --- .github/workflows/ci.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1c7f02b..aeff382 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,8 +12,6 @@ jobs: strategy: matrix: python-version: - - "3.8" - - "3.9" - "3.10" steps: - uses: actions/checkout@v3 From 2e4baf7fe12ce2eb374bc7062b537069a312d57e Mon Sep 17 00:00:00 2001 From: Anton Osika Date: Sun, 18 Jun 2023 15:16:20 +0200 Subject: [PATCH 2/8] Update benchmarking --- gpt_engineer/steps.py | 4 ++-- scripts/benchmark.py | 53 +++++++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index c368f34..1798a30 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -142,9 +142,9 @@ def execute_entrypoint(ai, dbs): print() print(command) print() - print('If yes, type "yes". If no, press enter.') + print('If yes, press enter. Otherwise, type "no"') print() - if input().lower() != "yes": + if input() != "": print("Ok, not executing the code.") return [] print("Executing the code...") diff --git a/scripts/benchmark.py b/scripts/benchmark.py index 8a00fe8..3ff4b23 100644 --- a/scripts/benchmark.py +++ b/scripts/benchmark.py @@ -13,36 +13,55 @@ from typer import run def main( n_benchmarks: int | None = None, ): - processes = [] - files = [] path = Path("benchmark") + folders = path.iterdir() + if n_benchmarks: - benchmarks = islice(path.iterdir(), n_benchmarks) + folders = islice(folders, n_benchmarks) - for folder in benchmarks: - if os.path.isdir(folder): - print("Running benchmark for {}".format(folder)) + benchmarks = [] + for bench_folder in folders: + if os.path.isdir(bench_folder): + print("Running benchmark for {}".format(bench_folder)) - log_path = folder / "log.txt" + log_path = bench_folder / "log.txt" log_file = open(log_path, "w") - processes.append( - subprocess.Popen( - ["python", "-m", "gpt_engineer.main", folder], - stdout=log_file, - stderr=log_file, - bufsize=0, - ) + process = subprocess.Popen( + [ + "python", + "-u", # Unbuffered output + "-m", + "gpt_engineer.main", + bench_folder, + "--steps-config", + "benchmark", + ], + stdout=log_file, + stderr=log_file, + bufsize=0, ) - files.append(log_file) + benchmarks.append((bench_folder, process, log_file)) print("You can stream the log file by running: tail -f {}".format(log_path)) - for process, file in zip(processes, files): + for bench_folder, process, file in benchmarks: process.wait() - print("process finished with code", process.returncode) file.close() + print("process", bench_folder.name, "finished with code", process.returncode) + print('Running it. Original benchmark prompt:') + print() + with open(bench_folder / "main_prompt") as f: + print(f.read()) + print() + + try: + subprocess.run( + ['python', "-m", "gpt_engineer.main", bench_folder, "--steps-config", "execute_only"], + ) + except KeyboardInterrupt: + pass if __name__ == "__main__": run(main) From 5c4a92e2507b3bfb19b2bad002edc50dd5551f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Thom=C3=A9?= Date: Sun, 18 Jun 2023 15:18:44 +0200 Subject: [PATCH 3/8] Ignore pytest, ruff, coverage intermediate files --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 32c67cc..2a876e0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,11 @@ ENV/ *.pyo *.pyd +# Python testing +.pytest_cache/ +.ruff_cache/ +.coverage + # macOS specific files .DS_Store From 5d0a1fb922426ddfb282933dc2003c48a6df7f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Thom=C3=A9?= Date: Sun, 18 Jun 2023 15:19:39 +0200 Subject: [PATCH 4/8] Ignore everything under projects/ except the example --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2a876e0..2d408f3 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,4 @@ todo # Ignore GPT Engineer files projects -my-new-project/ +!projects/example From 48228ff6a3169fa95719b08a99165561293984b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Ahlb=C3=A4ck?= Date: Sun, 18 Jun 2023 15:26:42 +0200 Subject: [PATCH 5/8] fix code outputting placeholders --- identity/generate | 7 ++++--- identity/use_qa | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/identity/generate b/identity/generate index 4e3f2bc..401934e 100644 --- a/identity/generate +++ b/identity/generate @@ -2,14 +2,15 @@ You will get instructions for code to write. Following best practices and formatting for a README.md file, you will write a very long answer, make sure to provide the instructions on how to run the code. 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. +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. Before you start outputting the code, you will output a seperator in the form of a line containing "*CODEBLOCKSBELOW*" -Make sure to create any appropriate module dependency or package manager dependency definition file. -Then you will reformat and output the content of each file strictly following a markdown code block format, where the following tokens should be replaced such that [FILENAME] is the lowercase file name including the file extension, [LANG] is the markup code block language for the code's language, and [CODE] is the comments and code: +Make sure to create any appropriate module dependency or package manager dependency definition file. +Then you will format and output the content, including ALL code, of each file strictly following a markdown code block format, where the following tokens should be replaced such that [FILENAME] is the lowercase file name including the file extension, [LANG] is the markup code block language for the code's language, and [CODE] is the code: [FILENAME] ```[LANG] [CODE] ``` +Please note that the code should be fully functional. No placeholders. You will start with the "entrypoint" file, then go to the ones that are imported by that file, and so on. Follow a language and framework appropriate best practice file naming convention. diff --git a/identity/use_qa b/identity/use_qa index 47a5b3b..c1bac29 100644 --- a/identity/use_qa +++ b/identity/use_qa @@ -4,11 +4,12 @@ First lay out the names of the core classes, functions, methods that will be nec Make sure to provide instructions for running the code. Before you start outputting the code, you will output a seperator in the form of a line containing "*CODEBLOCKSBELOW*" Make sure to create any appropriate module dependency or package manager dependency definition file. -Then you will reformat and output the content of each file strictly following a markdown code block format, where the following tokens should be replaced such that [FILENAME] is the lowercase file name including the file extension, [LANG] is the markup code block language for the code's language, and [CODE] is the comments and code: +Then you will reformat and output the content of each file strictly following a markdown code block format, where the following tokens should be replaced such that [FILENAME] is the lowercase file name including the file extension, [LANG] is the markup code block language for the code's language, and [CODE] is the code: [FILENAME] ```[LANG] [CODE] ``` +Please note that the code should be fully functional. No placeholders. You will start with the "entrypoint" file, then go to the ones that are imported by that file, and so on. Follow a language and framework appropriate best practice file naming convention. From 66cd09c789bfcae57e144fcaea86050b97230f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Ahlb=C3=A4ck?= Date: Sun, 18 Jun 2023 15:26:54 +0200 Subject: [PATCH 6/8] fix tuple error --- gpt_engineer/main.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gpt_engineer/main.py b/gpt_engineer/main.py index 09faa46..e0dff9c 100644 --- a/gpt_engineer/main.py +++ b/gpt_engineer/main.py @@ -18,10 +18,7 @@ def chat( delete_existing: str = typer.Argument(None, help="delete existing files"), run_prefix: str = typer.Option( "", - help=( - "run prefix, if you want to run multiple variants of the same project and " - "later compare them", - ), + 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, From d237c175cdccda59e9db4351e9d1e66a24f5536d Mon Sep 17 00:00:00 2001 From: Junlin Liu Date: Sun, 18 Jun 2023 21:36:45 +0800 Subject: [PATCH 7/8] fix docstring #150 (#152) --- gpt_engineer/main.py | 5 ++++- identity/generate | 2 +- scripts/benchmark.py | 14 +++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gpt_engineer/main.py b/gpt_engineer/main.py index e0dff9c..059f754 100644 --- a/gpt_engineer/main.py +++ b/gpt_engineer/main.py @@ -18,7 +18,10 @@ def chat( delete_existing: str = typer.Argument(None, help="delete existing files"), run_prefix: str = typer.Option( "", - help="run prefix, if you want to run multiple variants of the same project and later compare them", + 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, diff --git a/identity/generate b/identity/generate index 401934e..1c1ac62 100644 --- a/identity/generate +++ b/identity/generate @@ -4,7 +4,7 @@ Make sure that every detail of the architecture is, in the end, implemented as c 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. Before you start outputting the code, you will output a seperator in the form of a line containing "*CODEBLOCKSBELOW*" -Make sure to create any appropriate module dependency or package manager dependency definition file. +Make sure to create any appropriate module dependency or package manager dependency definition file. Then you will format and output the content, including ALL code, of each file strictly following a markdown code block format, where the following tokens should be replaced such that [FILENAME] is the lowercase file name including the file extension, [LANG] is the markup code block language for the code's language, and [CODE] is the code: [FILENAME] ```[LANG] diff --git a/scripts/benchmark.py b/scripts/benchmark.py index 3ff4b23..c07c9f2 100644 --- a/scripts/benchmark.py +++ b/scripts/benchmark.py @@ -30,7 +30,7 @@ def main( process = subprocess.Popen( [ "python", - "-u", # Unbuffered output + "-u", # Unbuffered output "-m", "gpt_engineer.main", bench_folder, @@ -50,7 +50,7 @@ def main( file.close() print("process", bench_folder.name, "finished with code", process.returncode) - print('Running it. Original benchmark prompt:') + print("Running it. Original benchmark prompt:") print() with open(bench_folder / "main_prompt") as f: print(f.read()) @@ -58,10 +58,18 @@ def main( try: subprocess.run( - ['python', "-m", "gpt_engineer.main", bench_folder, "--steps-config", "execute_only"], + [ + "python", + "-m", + "gpt_engineer.main", + bench_folder, + "--steps-config", + "execute_only", + ], ) except KeyboardInterrupt: pass + if __name__ == "__main__": run(main) From e1ebe43cbc23fd209ef951c5c2cce48d05d56926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Thom=C3=A9?= Date: Sun, 18 Jun 2023 15:36:56 +0200 Subject: [PATCH 8/8] Create release.yaml --- .github/workflows/release.yaml | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..30f61d2 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,52 @@ +name: Build and publish Python packages to PyPI + +on: + workflow_dispatch: + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: + - "3.10" + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: pip + + - name: Install build tool + run: pip install build + + - name: Build package + run: python -m build + + - name: Upload package as build artifact + uses: actions/upload-artifact@v3 + with: + name: package + path: dist/ + + publish: + runs-on: ubuntu-latest + needs: build + environment: + name: pypi + url: https://pypi.org/p/gpt-engineer + permissions: + id-token: write + steps: + - name: Collect packages to release + uses: actions/download-artifact@v3 + with: + name: package + path: dist/ + + - name: Publish packages to PyPI + uses: pypa/gh-action-pypi-publish@release/v1