From 152cfdfda79eac919b57b81e55906261abb9c40e Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 10:16:19 +0200 Subject: [PATCH 01/26] Adding official agent protocol test to ci + github badge --- .github/workflows/ci.yaml | 11 ++++++++++- README.md | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4c19c4feae..7acaf5a90e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Pip install and pytest +name: Pip install, pytest and protocol test on: pull_request: branches: [main] @@ -28,3 +28,12 @@ jobs: - name: Run unit tests run: pytest --cov=gpt_engineer + + - name: Install agent protocol + run: pip install agent-protocol + + - name: Run agent + run: python gpt_engineer/api.py + + - name: Validate agent protocol compliance + run: agent-protocol test --url http://127.0.0.1:8000 diff --git a/README.md b/README.md index 4894d3ae40..9763d5e3ff 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![Discord Follow](https://dcbadge.vercel.app/api/server/8tcDQ89Ej2?style=flat)](https://discord.gg/8tcDQ89Ej2) [![GitHub Repo stars](https://img.shields.io/github/stars/AntonOsika/gpt-engineer?style=social)](https://github.com/AntonOsika/gpt-engineer) [![Twitter Follow](https://img.shields.io/twitter/follow/antonosika?style=social)](https://twitter.com/AntonOsika) +![Agent protocol](https://github.com/AntonOsika/gpt-engineer/actions/workflows/ci.yaml/badge.svg) + **Specify what you want it to build, the AI asks for clarification, and then builds it.** From 65dd7e19c6932eedcf558a4770aba9980082dfeb Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 10:33:22 +0200 Subject: [PATCH 02/26] removed comma from workflow name --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7acaf5a90e..7c256030aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Pip install, pytest and protocol test +name: Pip install pytest and protocol test on: pull_request: branches: [main] From 0be5a8407c4b3a4ab4f1101fa8d5501e2c9cde2c Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 10:38:54 +0200 Subject: [PATCH 03/26] Made protocol validation a separate workflow --- .github/workflows/ci.yaml | 2 +- .github/workflows/validate_agent_protocol.yml | 33 +++++++++++++++++++ README.md | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/validate_agent_protocol.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7c256030aa..7acaf5a90e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Pip install pytest and protocol test +name: Pip install, pytest and protocol test on: pull_request: branches: [main] diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml new file mode 100644 index 0000000000..c577adcf52 --- /dev/null +++ b/.github/workflows/validate_agent_protocol.yml @@ -0,0 +1,33 @@ +name: Validate agent protocol compliance +on: + pull_request: + branches: [ main ] + paths: + - "**.py" + push: + branches: [ main ] + paths: + - "**.py" + + +jobs: + publish: + name: Validate agent protocol compliance + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install agent protocol + run: pip install agent-protocol + + - name: Run agent + run: python gpt-engineer/api.py + + - name: Validate agent protocol compliance + run: agent-protocol test --url http://127.0.0.1:8000 diff --git a/README.md b/README.md index 9763d5e3ff..c4f0a0d674 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Discord Follow](https://dcbadge.vercel.app/api/server/8tcDQ89Ej2?style=flat)](https://discord.gg/8tcDQ89Ej2) [![GitHub Repo stars](https://img.shields.io/github/stars/AntonOsika/gpt-engineer?style=social)](https://github.com/AntonOsika/gpt-engineer) [![Twitter Follow](https://img.shields.io/twitter/follow/antonosika?style=social)](https://twitter.com/AntonOsika) -![Agent protocol](https://github.com/AntonOsika/gpt-engineer/actions/workflows/ci.yaml/badge.svg) +![Agent protocol](https://github.com/AntonOsika/gpt-engineer/actions/workflows/validate_agent_protocol.yaml/badge.svg) **Specify what you want it to build, the AI asks for clarification, and then builds it.** From cbe7a5fc32e413cda4f49d3077faff48e21ba87f Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 10:49:43 +0200 Subject: [PATCH 04/26] Reverted the ci.yml properly, should have been in the previous commit --- .github/workflows/ci.yaml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7acaf5a90e..14cfb37b49 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,11 +1,11 @@ -name: Pip install, pytest and protocol test +name: Pip install and pytest on: pull_request: - branches: [main] + branches: [ main ] paths: - "**.py" push: - branches: [main] + branches: [ main ] paths: - "**.py" @@ -28,12 +28,3 @@ jobs: - name: Run unit tests run: pytest --cov=gpt_engineer - - - name: Install agent protocol - run: pip install agent-protocol - - - name: Run agent - run: python gpt_engineer/api.py - - - name: Validate agent protocol compliance - run: agent-protocol test --url http://127.0.0.1:8000 From 06a4cd41ac6f5c08a6244109ac6940a906b3ce79 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 16:25:19 +0200 Subject: [PATCH 05/26] adding yaml as a trigger for the ci.yaml and validate_agent_protocol ci --- .github/workflows/ci.yaml | 7 ++++++- .github/workflows/validate_agent_protocol.yml | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 14cfb37b49..e953cfa7fe 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,11 +4,16 @@ on: branches: [ main ] paths: - "**.py" + - "**.yaml" + - "**.yml" + - "**.json" push: branches: [ main ] paths: - "**.py" - + - "**.yaml" + - "**.yml" + - "**.json" jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index c577adcf52..898d7526dd 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -4,10 +4,16 @@ on: branches: [ main ] paths: - "**.py" + - "**.yaml" + - "**.yml" + - "**.json" push: branches: [ main ] paths: - "**.py" + - "**.yaml" + - "**.yml" + - "**.json" jobs: From 8754aecf53f27034e7dfaf4f8d24671cae6a6287 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 16:25:51 +0200 Subject: [PATCH 06/26] adding yaml as a trigger for the ci.yaml and validate_agent_protocol ci --- .github/workflows/ci.yaml | 3 +-- .github/workflows/validate_agent_protocol.yml | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e953cfa7fe..ed044f9c7a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,14 +6,13 @@ on: - "**.py" - "**.yaml" - "**.yml" - - "**.json" push: branches: [ main ] paths: - "**.py" - "**.yaml" - "**.yml" - - "**.json" + jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 898d7526dd..1c55a72d8f 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -6,15 +6,12 @@ on: - "**.py" - "**.yaml" - "**.yml" - - "**.json" push: branches: [ main ] paths: - "**.py" - "**.yaml" - "**.yml" - - "**.json" - jobs: publish: From 5bcc3ed3957ef7d665d83e493ff2505bd920096f Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 16:28:43 +0200 Subject: [PATCH 07/26] fixing path to api.py script in ci workflow --- .github/workflows/validate_agent_protocol.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 1c55a72d8f..9b3d6939b8 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -30,7 +30,7 @@ jobs: run: pip install agent-protocol - name: Run agent - run: python gpt-engineer/api.py + run: python api.py - name: Validate agent protocol compliance run: agent-protocol test --url http://127.0.0.1:8000 From a6560adaecf56bbdfc10bd0661cbfa248740717f Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 20:08:07 +0200 Subject: [PATCH 08/26] debug commit to establish correct path --- .github/workflows/validate_agent_protocol.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 9b3d6939b8..bd614345aa 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -29,6 +29,12 @@ jobs: - name: Install agent protocol run: pip install agent-protocol + - name: Print current working directory + run: pwd + + - name: List directory contents + run: ls -al + - name: Run agent run: python api.py From edce46dc36ad52caa891e02bb948c1cc95e382b9 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 20:10:19 +0200 Subject: [PATCH 09/26] removing debug prints and adding correct path --- .github/workflows/validate_agent_protocol.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index bd614345aa..fdd32d3bb7 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -29,14 +29,8 @@ jobs: - name: Install agent protocol run: pip install agent-protocol - - name: Print current working directory - run: pwd - - - name: List directory contents - run: ls -al - - name: Run agent - run: python api.py + run: python gpt_engineer/api.py - name: Validate agent protocol compliance run: agent-protocol test --url http://127.0.0.1:8000 From c9c90d74c8d8cc179f9f9c05b446686dcea9c454 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 20:14:44 +0200 Subject: [PATCH 10/26] Installing gpt_engineer into protocol validation test environment --- .github/workflows/validate_agent_protocol.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index fdd32d3bb7..19ebae2ad0 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -29,6 +29,9 @@ jobs: - name: Install agent protocol run: pip install agent-protocol + - name: Install gpt-engineer + run: pip install . + - name: Run agent run: python gpt_engineer/api.py From 0202b0561faec0303799351ed594fbc177904762 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 20:15:13 +0200 Subject: [PATCH 11/26] -e flag for previous commit --- .github/workflows/validate_agent_protocol.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 19ebae2ad0..d67e4ecf83 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -30,7 +30,7 @@ jobs: run: pip install agent-protocol - name: Install gpt-engineer - run: pip install . + run: pip install -e . - name: Run agent run: python gpt_engineer/api.py From c8e781aff4edbd78bbca00267bbdcfac6cbbd101 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 20:21:12 +0200 Subject: [PATCH 12/26] starting the server in a separate process --- .github/workflows/validate_agent_protocol.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index d67e4ecf83..9c3fb2110c 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -33,7 +33,10 @@ jobs: run: pip install -e . - name: Run agent - run: python gpt_engineer/api.py + run: python gpt_engineer/api.py & + + - name: Wait for server to start + run: sleep 10 - name: Validate agent protocol compliance run: agent-protocol test --url http://127.0.0.1:8000 From 2e651d4adb2e1d5c91d12e9d3c8908966482731a Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 20:25:30 +0200 Subject: [PATCH 13/26] reducing sleep time --- .github/workflows/validate_agent_protocol.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 9c3fb2110c..8d1fd632c7 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -36,7 +36,7 @@ jobs: run: python gpt_engineer/api.py & - name: Wait for server to start - run: sleep 10 + run: sleep 1 - name: Validate agent protocol compliance run: agent-protocol test --url http://127.0.0.1:8000 From b70cb88c74baeaf2581bfa26333d76df07f42206 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Fri, 15 Sep 2023 20:43:19 +0200 Subject: [PATCH 14/26] adding OPENAI_API_KEY to testing environment via github secret --- .github/workflows/validate_agent_protocol.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 8d1fd632c7..22b9ae4f47 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -34,6 +34,8 @@ jobs: - name: Run agent run: python gpt_engineer/api.py & + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Wait for server to start run: sleep 1 From 38aec1b6f8c44b37833c1efddd68d1f212b069c9 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Mon, 25 Sep 2023 21:13:00 +0200 Subject: [PATCH 15/26] updated validation flow --- .github/workflows/validate_agent_protocol.yml | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 22b9ae4f47..1b387742f2 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -26,19 +26,10 @@ jobs: with: python-version: '3.10' - - name: Install agent protocol - run: pip install agent-protocol + - name: Install agent requirements + run: pip install -r requirements.txt - - name: Install gpt-engineer - run: pip install -e . - - - name: Run agent - run: python gpt_engineer/api.py & - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - - - name: Wait for server to start - run: sleep 1 - - - name: Validate agent protocol compliance - run: agent-protocol test --url http://127.0.0.1:8000 + - name: Run agent and validate compliance + run: | + & # Make sure to use the ampersand to detach your agent + URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://agentprotocol.ai/test.sh)" From e90f998f56978a6b60497a0f49a5873b20dec998 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Mon, 25 Sep 2023 21:19:03 +0200 Subject: [PATCH 16/26] changing requirements install --- .github/workflows/validate_agent_protocol.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 1b387742f2..365d31b9f8 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -27,7 +27,7 @@ jobs: python-version: '3.10' - name: Install agent requirements - run: pip install -r requirements.txt + run: pip install agent-protocol - name: Run agent and validate compliance run: | From e14d00f1200766cca83d727a488f29ec90d47bb5 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Mon, 25 Sep 2023 21:25:47 +0200 Subject: [PATCH 17/26] starting api --- .github/workflows/validate_agent_protocol.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index 365d31b9f8..e67554da8f 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -27,9 +27,9 @@ jobs: python-version: '3.10' - name: Install agent requirements - run: pip install agent-protocol + run: pip install . - name: Run agent and validate compliance run: | - & # Make sure to use the ampersand to detach your agent + python gpt_engineer/api.py & # Make sure to use the ampersand to detach your agent URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://agentprotocol.ai/test.sh)" From 8b6f2906a7701ca1932faa9e3cb97af7162e8dda Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Mon, 25 Sep 2023 21:29:39 +0200 Subject: [PATCH 18/26] added agent-protocol dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index fbafd9bc9a..3e9c6fb78f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ dependencies = [ 'tabulate == 0.9.0', 'python-dotenv >= 0.21.0', 'langchain >=0.0.240', + 'agent-protocol==1.0.1', ] classifiers = [ From be1b4ba6cf0cf5cd82e59580c8c9e059889eabda Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 09:41:18 +0200 Subject: [PATCH 19/26] bugfix in api.py when __root__ is undefined --- gpt_engineer/api.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gpt_engineer/api.py b/gpt_engineer/api.py index 66fc7546bb..b74baef894 100644 --- a/gpt_engineer/api.py +++ b/gpt_engineer/api.py @@ -37,13 +37,16 @@ async def task_handler(task: Task) -> None: ) # pass options onto additional_properties + additional_input = dict() + if hasattr(task, "additional_input"): + if hasattr(task.additional_input, "__root__"): + additional_input = task.additional_input.__root__ + await Agent.db.create_step( task_id=task.task_id, name="create_code", is_last=True, - additional_properties=task.additional_input.__root__ - if task.additional_input is not None - else {}, + additional_properties=additional_input, ) From d108774cdfe186e8218bedfbb4b2bfcddc84f279 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 09:44:21 +0200 Subject: [PATCH 20/26] re-adding API key --- .github/workflows/validate_agent_protocol.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index e67554da8f..afe9a0438b 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -33,3 +33,5 @@ jobs: run: | python gpt_engineer/api.py & # Make sure to use the ampersand to detach your agent URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://agentprotocol.ai/test.sh)" + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From ee0b2475692914c1c7772234839aaea4f5e8291c Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 09:52:59 +0200 Subject: [PATCH 21/26] restoring env formulation --- .github/workflows/validate_agent_protocol.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index afe9a0438b..eb12befc1c 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -29,9 +29,10 @@ jobs: - name: Install agent requirements run: pip install . - - name: Run agent and validate compliance - run: | - python gpt_engineer/api.py & # Make sure to use the ampersand to detach your agent - URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://agentprotocol.ai/test.sh)" + - name: Run agent + run: python gpt_engineer/api.py & env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + + - name: Run agent and validate compliance + run: URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://agentprotocol.ai/test.sh)" From 184bd077926c20fd4b8cd60552e458d6ba08184e Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 10:43:30 +0200 Subject: [PATCH 22/26] checking existence of API KEY --- .github/workflows/validate_agent_protocol.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate_agent_protocol.yml b/.github/workflows/validate_agent_protocol.yml index eb12befc1c..55d4c27417 100644 --- a/.github/workflows/validate_agent_protocol.yml +++ b/.github/workflows/validate_agent_protocol.yml @@ -29,10 +29,19 @@ jobs: - name: Install agent requirements run: pip install . - - name: Run agent - run: python gpt_engineer/api.py & + - name: Check existence of OPENAI_API_KEY + run: | + if [[ -z "${OPENAI_API_KEY}" ]]; then + echo "OPENAI_API_KEY is empty" + else + echo "OPENAI_API_KEY has a length of ${#OPENAI_API_KEY}" + fi env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Run agent and validate compliance - run: URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://agentprotocol.ai/test.sh)" + run: | + python gpt_engineer/api.py & # Make sure to use the ampersand to detach your agent + URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://agentprotocol.ai/test.sh)" + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From 91220d9e20ca488db19f7c784ecc24c09992e053 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 17:14:06 +0200 Subject: [PATCH 23/26] Adding dummy step additions to pass the compliance test --- gpt_engineer/api.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/gpt_engineer/api.py b/gpt_engineer/api.py index b74baef894..8039caa9a1 100644 --- a/gpt_engineer/api.py +++ b/gpt_engineer/api.py @@ -2,7 +2,7 @@ from pathlib import Path -from agent_protocol import Agent, Step, Task +from agent_protocol import Agent, Step, Task, models from gpt_engineer.db import DB from gpt_engineer.main import main @@ -57,16 +57,27 @@ async def step_handler(step: Step) -> Step: Improve code mode is not yet supported, but it would not be much work to support it. A list of 'focus' files would need to be submitted in: task.additional_input. """ - - main( - f"projects/{step.task_id}", # we could also make this an option - step.additional_properties.get("model", "gpt-4"), - step.additional_properties.get("temperature", 0.1), - "benchmark", # this needs to be headless mode - False, - step.additional_properties.get("azure_endpoint", ""), - step.additional_properties.get("verbose", False), - ) + if not step.name == "Dummy step": + main( + f"projects/{step.task_id}", # we could also make this an option + step.additional_properties.get("model", "gpt-4"), + step.additional_properties.get("temperature", 0.1), + "benchmark", # this needs to be headless mode + False, + step.additional_properties.get("azure_endpoint", ""), + step.additional_properties.get("verbose", False), + ) + + # if we have exhausted all tasks, create dummy task to not run out of tasks. + if step.is_last: + await Agent.db.create_step( + step.task_id, + name=f"Dummy step", + input=f"Creating dummy step to not run out of steps after {step.name}", + is_last=True, + additional_properties={}, + ) + step.is_last = False return step From 6a4d3e3de514d2477c03a49f241b4634677667cc Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 18:45:59 +0200 Subject: [PATCH 24/26] catching openai authentication error --- gpt_engineer/api.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/gpt_engineer/api.py b/gpt_engineer/api.py index 8039caa9a1..96aa1fb414 100644 --- a/gpt_engineer/api.py +++ b/gpt_engineer/api.py @@ -7,6 +7,8 @@ from gpt_engineer.db import DB from gpt_engineer.main import main +from openai.error import AuthenticationError + async def task_handler(task: Task) -> None: """task_handler should create initial steps based on the input. @@ -58,15 +60,18 @@ async def step_handler(step: Step) -> Step: A list of 'focus' files would need to be submitted in: task.additional_input. """ if not step.name == "Dummy step": - main( - f"projects/{step.task_id}", # we could also make this an option - step.additional_properties.get("model", "gpt-4"), - step.additional_properties.get("temperature", 0.1), - "benchmark", # this needs to be headless mode - False, - step.additional_properties.get("azure_endpoint", ""), - step.additional_properties.get("verbose", False), - ) + try: + main( + f"projects/{step.task_id}", # we could also make this an option + step.additional_properties.get("model", "gpt-4"), + step.additional_properties.get("temperature", 0.1), + "benchmark", # this needs to be headless mode + False, + step.additional_properties.get("azure_endpoint", ""), + step.additional_properties.get("verbose", False), + ) + except AuthenticationError: + print("The agent lacks a valid OPENAI_API_KEY to execute the requested step.") # if we have exhausted all tasks, create dummy task to not run out of tasks. if step.is_last: From 8b6bc4bdfdc5761b8fb98d10d62baf998e6e4f7e Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 19:03:21 +0200 Subject: [PATCH 25/26] API agent defaults to tempdir --- gpt_engineer/api.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/gpt_engineer/api.py b/gpt_engineer/api.py index 96aa1fb414..5a2611a67e 100644 --- a/gpt_engineer/api.py +++ b/gpt_engineer/api.py @@ -9,6 +9,8 @@ from openai.error import AuthenticationError +import tempfile + async def task_handler(task: Task) -> None: """task_handler should create initial steps based on the input. @@ -23,7 +25,17 @@ async def task_handler(task: Task) -> None: if task.input is None: raise Exception("No input prompt in the 'input' field.") - workspace = DB(f"projects/{task.task_id}") + # pass options onto additional_properties + additional_input = dict() + if hasattr(task, "additional_input"): + if hasattr(task.additional_input, "__root__"): + additional_input = task.additional_input.__root__ + + # set up the root directory for the agent, default to temp + root_dir = additional_input.get("root_dir", tempfile.gettempdir()) + additional_input["root_dir"] = root_dir + + workspace = DB(os.path.join(root_dir, task.task_id)) # write prompt to a file workspace["prompt"] = f"{task.input}\n" @@ -34,16 +46,10 @@ async def task_handler(task: Task) -> None: await Agent.db.create_artifact( task_id=task.task_id, - relative_path="projects/", - file_name=f"projects/{task.task_id}", + relative_path=root_dir, + file_name=os.path.join(root_dir, task.task_id), ) - # pass options onto additional_properties - additional_input = dict() - if hasattr(task, "additional_input"): - if hasattr(task.additional_input, "__root__"): - additional_input = task.additional_input.__root__ - await Agent.db.create_step( task_id=task.task_id, name="create_code", @@ -62,7 +68,9 @@ async def step_handler(step: Step) -> Step: if not step.name == "Dummy step": try: main( - f"projects/{step.task_id}", # we could also make this an option + os.path.join( + step.additional_properties["root_dir"], step.task_id + ), # we could also make this an option step.additional_properties.get("model", "gpt-4"), step.additional_properties.get("temperature", 0.1), "benchmark", # this needs to be headless mode From f833c08a68b3c211f4977bca5925dc510b0ba7a7 Mon Sep 17 00:00:00 2001 From: Axel Theorell Date: Tue, 26 Sep 2023 19:06:12 +0200 Subject: [PATCH 26/26] Automatic update of comments --- gpt_engineer/api.py | 57 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/gpt_engineer/api.py b/gpt_engineer/api.py index 5a2611a67e..cd382859d9 100644 --- a/gpt_engineer/api.py +++ b/gpt_engineer/api.py @@ -1,46 +1,53 @@ import os - from pathlib import Path - from agent_protocol import Agent, Step, Task, models - from gpt_engineer.db import DB from gpt_engineer.main import main - from openai.error import AuthenticationError - import tempfile async def task_handler(task: Task) -> None: - """task_handler should create initial steps based on the input. + """ + Process the given task to set up the initial steps based on the task input. - The project is set up here. + Parameters: + - task (Task): An object containing task details, including the input prompt. - The prompt will be sent as task.input. - We will create a working directory in projects/. + Behavior: + - Checks if the task has valid input. + - Reads additional input properties and sets up a workspace directory. + - Writes the prompt to a file. + - Registers the workspace directory as an artifact. + - Creates an initial step named "create_code". + + Exceptions: + - Raises an exception if no input prompt is provided in the 'input' field of the task. + + Returns: + - None """ - # make sure we have a prompt or bail. + # Validate that we have a prompt or terminate. if task.input is None: raise Exception("No input prompt in the 'input' field.") - # pass options onto additional_properties + # Extract additional properties from the task if available. additional_input = dict() if hasattr(task, "additional_input"): if hasattr(task.additional_input, "__root__"): additional_input = task.additional_input.__root__ - # set up the root directory for the agent, default to temp + # Set up the root directory for the agent, defaulting to a temporary directory. root_dir = additional_input.get("root_dir", tempfile.gettempdir()) additional_input["root_dir"] = root_dir workspace = DB(os.path.join(root_dir, task.task_id)) - # write prompt to a file + # Write prompt to a file in the workspace. workspace["prompt"] = f"{task.input}\n" - # write to consent file so we avoid hanging for a prompt + # Ensure no prompt hang by writing to the consent file. consent_file = Path(os.getcwd()) / ".gpte_consent" consent_file.write_text("false") @@ -60,20 +67,27 @@ async def task_handler(task: Task) -> None: async def step_handler(step: Step) -> Step: """ - The code generation is run here. Any options are passed via task.additional_input. + Handle the provided step by triggering code generation or other operations. + + Parameters: + - step (Step): An object containing step details and properties. - Improve code mode is not yet supported, but it would not be much work to support it. - A list of 'focus' files would need to be submitted in: task.additional_input. + Behavior: + - If not a dummy step, triggers the main code generation process. + - Handles potential authentication errors during code generation. + - Creates a dummy step if it's the last step to ensure continuity. + + Returns: + - step (Step): Returns the processed step, potentially with modifications. """ + if not step.name == "Dummy step": try: main( - os.path.join( - step.additional_properties["root_dir"], step.task_id - ), # we could also make this an option + os.path.join(step.additional_properties["root_dir"], step.task_id), step.additional_properties.get("model", "gpt-4"), step.additional_properties.get("temperature", 0.1), - "benchmark", # this needs to be headless mode + "benchmark", False, step.additional_properties.get("azure_endpoint", ""), step.additional_properties.get("verbose", False), @@ -81,7 +95,6 @@ async def step_handler(step: Step) -> Step: except AuthenticationError: print("The agent lacks a valid OPENAI_API_KEY to execute the requested step.") - # if we have exhausted all tasks, create dummy task to not run out of tasks. if step.is_last: await Agent.db.create_step( step.task_id,