From 72c44f25c05aede40776d824bc18aed985193ff9 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 15:31:59 -0700 Subject: [PATCH 01/26] basic proxy --- .github/workflows/ci.yml | 4 +- autogpt/prompts/prompt.py | 2 +- tests/conftest.py | 2 + tests/integration/agent_factory.py | 2 +- .../test_information_retrieval_challenge_a.py | 2 +- .../memory/test_memory_challenge_a.py | 2 +- .../memory/test_memory_challenge_b.py | 2 +- .../memory/test_memory_challenge_c.py | 2 +- tests/integration/conftest.py | 24 +++++++++++- .../goal_oriented/test_browse_website.py | 2 +- .../goal_oriented/test_write_file.py | 7 +++- tests/integration/test_llm_utils.py | 2 +- tests/integration/test_local_cache.py | 2 +- tests/integration/test_memory_management.py | 2 +- tests/integration/test_setup.py | 8 ++-- tests/test_image_gen.py | 2 +- tests/unit/test_commands.py | 2 +- tests/utils.py | 10 ++--- tests/vcr/vcr_filter.py | 39 ++++++++++++++++--- 19 files changed, 86 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a08ecb02114b..044208f5e6c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,9 +71,11 @@ jobs: - name: Run unittest tests with coverage run: | - pytest --cov=autogpt --cov-report term-missing --cov-branch --cov-report xml --cov-report term + pytest -s tests/integration/goal_oriented/test_write_file.py env: CI: true + PROXY: https://us-central1-prod-benchmarks-core.cloudfunctions.net/proxy_function + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 diff --git a/autogpt/prompts/prompt.py b/autogpt/prompts/prompt.py index 5da01c44ffea..7f740ef1f185 100644 --- a/autogpt/prompts/prompt.py +++ b/autogpt/prompts/prompt.py @@ -11,7 +11,7 @@ CFG = Config() DEFAULT_TRIGGERING_PROMPT = ( - "Determine which next command to use, and respond using the format specified above:" + "Determindfsdfse which next command to use, and respond using the format specified above:" ) diff --git a/tests/conftest.py b/tests/conftest.py index da00058b7fe2..880151e837a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +import os from pathlib import Path import pytest @@ -9,6 +10,7 @@ pytest_plugins = ["tests.integration.agent_factory"] +PROXY = os.environ.get("PROXY") @pytest.fixture() def workspace_root(tmp_path: Path) -> Path: diff --git a/tests/integration/agent_factory.py b/tests/integration/agent_factory.py index b6168034aae0..24ee38ea9ffb 100644 --- a/tests/integration/agent_factory.py +++ b/tests/integration/agent_factory.py @@ -89,7 +89,7 @@ def writer_agent(agent_test_config, memory_none: NoMemory, workspace: Workspace) ai_goals=[ "Use the write_to_file command to write 'Hello World' into a file named \"hello_world.txt\".", "Use the task_complete command to complete the task.", - "Do not use any other commands.", + "Do not use andfsfdsy other commands.", ], ) ai_config.command_registry = command_registry diff --git a/tests/integration/challenges/information_retrieval/test_information_retrieval_challenge_a.py b/tests/integration/challenges/information_retrieval/test_information_retrieval_challenge_a.py index a5f8fb4ce33b..b96e811adb9d 100644 --- a/tests/integration/challenges/information_retrieval/test_information_retrieval_challenge_a.py +++ b/tests/integration/challenges/information_retrieval/test_information_retrieval_challenge_a.py @@ -26,7 +26,7 @@ def input_generator(input_sequence: list) -> Generator[str, None, None]: @requires_api_key("OPENAI_API_KEY") @run_multiple_times(3) def test_information_retrieval_challenge_a( - get_company_revenue_agent, monkeypatch + get_company_revenue_agent, monkeypatch, patched_api_requestor ) -> None: """ Test the challenge_a function in a given agent by mocking user inputs and checking the output file content. diff --git a/tests/integration/challenges/memory/test_memory_challenge_a.py b/tests/integration/challenges/memory/test_memory_challenge_a.py index 895fc8febe3e..ab859a6c0914 100644 --- a/tests/integration/challenges/memory/test_memory_challenge_a.py +++ b/tests/integration/challenges/memory/test_memory_challenge_a.py @@ -13,7 +13,7 @@ @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") def test_memory_challenge_a( - memory_management_agent: Agent, user_selected_level: int + memory_management_agent: Agent, user_selected_level: int, patched_api_requestor ) -> None: """ The agent reads a file containing a task_id. Then, it reads a series of other files. diff --git a/tests/integration/challenges/memory/test_memory_challenge_b.py b/tests/integration/challenges/memory/test_memory_challenge_b.py index 628b49893f90..21d46b38d6a8 100644 --- a/tests/integration/challenges/memory/test_memory_challenge_b.py +++ b/tests/integration/challenges/memory/test_memory_challenge_b.py @@ -14,7 +14,7 @@ @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") def test_memory_challenge_b( - memory_management_agent: Agent, user_selected_level: int + memory_management_agent: Agent, user_selected_level: int, patched_api_requestor ) -> None: """ The agent reads a series of files, each containing a task_id and noise. After reading 'n' files, diff --git a/tests/integration/challenges/memory/test_memory_challenge_c.py b/tests/integration/challenges/memory/test_memory_challenge_c.py index edd3efe00ab8..634a24a3e5d5 100644 --- a/tests/integration/challenges/memory/test_memory_challenge_c.py +++ b/tests/integration/challenges/memory/test_memory_challenge_c.py @@ -14,7 +14,7 @@ @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") def test_memory_challenge_c( - memory_management_agent: Agent, user_selected_level: int + memory_management_agent: Agent, user_selected_level: int, patched_api_requestor ) -> None: """ Instead of reading task Ids from files as with the previous challenges, the agent now must remember diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 009287021338..0bdcf33e8ec7 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -2,8 +2,9 @@ import pytest +from tests.conftest import PROXY from tests.vcr.vcr_filter import before_record_request, before_record_response - +import openai @pytest.fixture(scope="session") def vcr_config(): @@ -17,5 +18,24 @@ def vcr_config(): "X-OpenAI-Client-User-Agent", "User-Agent", ], - "match_on": ["method", "uri", "body"], + "match_on": ["method", "body"], } + + +def patch_api_base(requestor): + new_api_base = f"{PROXY}/v1" + requestor.api_base = new_api_base + return requestor + +@pytest.fixture +def patched_api_requestor(mocker): + original_init = openai.api_requestor.APIRequestor.__init__ + + def patched_init(requestor, *args, **kwargs): + original_init(requestor, *args, **kwargs) + patch_api_base(requestor) + + if PROXY: + mocker.patch("openai.api_requestor.APIRequestor.__init__", new=patched_init) + + return mocker diff --git a/tests/integration/goal_oriented/test_browse_website.py b/tests/integration/goal_oriented/test_browse_website.py index ca433d80f99e..3ce85689f924 100644 --- a/tests/integration/goal_oriented/test_browse_website.py +++ b/tests/integration/goal_oriented/test_browse_website.py @@ -8,7 +8,7 @@ @requires_api_key("OPENAI_API_KEY") @pytest.mark.vcr -def test_browse_website(browser_agent: Agent) -> None: +def test_browse_website(browser_agent: Agent, patched_api_requestor) -> None: file_path = browser_agent.workspace.get_path("browse_website.txt") try: run_interaction_loop(browser_agent, 120) diff --git a/tests/integration/goal_oriented/test_write_file.py b/tests/integration/goal_oriented/test_write_file.py index da67235a8397..55db3f4a99a2 100644 --- a/tests/integration/goal_oriented/test_write_file.py +++ b/tests/integration/goal_oriented/test_write_file.py @@ -1,3 +1,6 @@ +import os + +import openai import pytest from autogpt.agent import Agent @@ -8,10 +11,10 @@ @requires_api_key("OPENAI_API_KEY") @pytest.mark.vcr -def test_write_file(writer_agent: Agent) -> None: +def test_write_file(writer_agent: Agent, patched_api_requestor) -> None: file_path = str(writer_agent.workspace.get_path("hello_world.txt")) try: - run_interaction_loop(writer_agent, 40) + run_interaction_loop(writer_agent, 200) # catch system exit exceptions except SystemExit: # the agent returns an exception when it shuts down content = read_file(file_path) diff --git a/tests/integration/test_llm_utils.py b/tests/integration/test_llm_utils.py index 553d369947f6..20c77342286e 100644 --- a/tests/integration/test_llm_utils.py +++ b/tests/integration/test_llm_utils.py @@ -41,7 +41,7 @@ def spy_create_embedding(mocker: MockerFixture): @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") def test_get_ada_embedding( - config: Config, api_manager: ApiManager, spy_create_embedding: MagicMock + config: Config, api_manager: ApiManager, spy_create_embedding: MagicMock, patched_api_requestor ): token_cost = COSTS[config.embedding_model]["prompt"] llm_utils.get_ada_embedding("test") diff --git a/tests/integration/test_local_cache.py b/tests/integration/test_local_cache.py index 5200e026e708..808f119a73ed 100644 --- a/tests/integration/test_local_cache.py +++ b/tests/integration/test_local_cache.py @@ -91,7 +91,7 @@ def test_get(LocalCache, config, mock_embed_with_ada): @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") -def test_get_relevant(LocalCache, config) -> None: +def test_get_relevant(LocalCache, config, patched_api_requestor) -> None: cache = LocalCache(config) text1 = "Sample text 1" text2 = "Sample text 2" diff --git a/tests/integration/test_memory_management.py b/tests/integration/test_memory_management.py index c9ab9fc94818..6a8451b9dca3 100644 --- a/tests/integration/test_memory_management.py +++ b/tests/integration/test_memory_management.py @@ -52,7 +52,7 @@ def expected_permanent_memory() -> str: @requires_api_key("OPENAI_API_KEY") @pytest.mark.vcr def test_save_memory_trimmed_from_context_window( - message_history_fixture, expected_permanent_memory, config: Config + message_history_fixture, expected_permanent_memory, config: Config, patched_api_requestor ): next_message_to_add_index = len(message_history_fixture) - 1 memory = get_memory(config, init=True) diff --git a/tests/integration/test_setup.py b/tests/integration/test_setup.py index b649bb14f157..444d94747f12 100644 --- a/tests/integration/test_setup.py +++ b/tests/integration/test_setup.py @@ -13,7 +13,7 @@ @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") -def test_generate_aiconfig_automatic_default(): +def test_generate_aiconfig_automatic_default(patched_api_requestor): user_inputs = [""] with patch("builtins.input", side_effect=user_inputs): ai_config = prompt_user() @@ -26,7 +26,7 @@ def test_generate_aiconfig_automatic_default(): @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") -def test_generate_aiconfig_automatic_typical(): +def test_generate_aiconfig_automatic_typical(patched_api_requestor): user_prompt = "Help me create a rock opera about cybernetic giraffes" ai_config = generate_aiconfig_automatic(user_prompt) @@ -38,7 +38,7 @@ def test_generate_aiconfig_automatic_typical(): @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") -def test_generate_aiconfig_automatic_fallback(): +def test_generate_aiconfig_automatic_fallback(patched_api_requestor): user_inputs = [ "T&GF£OIBECC()!*", "Chef-GPT", @@ -59,7 +59,7 @@ def test_generate_aiconfig_automatic_fallback(): @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") -def test_prompt_user_manual_mode(): +def test_prompt_user_manual_mode(patched_api_requestor): user_inputs = [ "--manual", "Chef-GPT", diff --git a/tests/test_image_gen.py b/tests/test_image_gen.py index 546cc758d7e8..33e6fa738594 100644 --- a/tests/test_image_gen.py +++ b/tests/test_image_gen.py @@ -19,7 +19,7 @@ def image_size(request): reason="The image is too big to be put in a cassette for a CI pipeline. We're looking into a solution." ) @requires_api_key("OPENAI_API_KEY") -def test_dalle(config, workspace, image_size): +def test_dalle(config, workspace, image_size, patched_api_requestor): """Test DALL-E image generation.""" generate_and_validate( config, diff --git a/tests/unit/test_commands.py b/tests/unit/test_commands.py index e3b874fb9470..12f407389463 100644 --- a/tests/unit/test_commands.py +++ b/tests/unit/test_commands.py @@ -10,7 +10,7 @@ @pytest.mark.vcr @pytest.mark.integration_test @requires_api_key("OPENAI_API_KEY") -def test_make_agent() -> None: +def test_make_agent(patched_api_requestor) -> None: """Test that an agent can be created""" # Use the mock agent manager to avoid creating a real agent with patch("openai.ChatCompletion.create") as mock: diff --git a/tests/utils.py b/tests/utils.py index 2a0d25d81821..2603dfe48de7 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -24,11 +24,11 @@ def requires_api_key(env_var): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): - if not os.environ.get(env_var) and env_var == "OPENAI_API_KEY": - with dummy_openai_api_key(): - return func(*args, **kwargs) - else: - return func(*args, **kwargs) + if env_var == "OPENAI_API_KEY": + if not os.environ.get(env_var) and env_var == "OPENAI_API_KEY": + with dummy_openai_api_key(): + return func(*args, **kwargs) + return func(*args, **kwargs) return wrapper diff --git a/tests/vcr/vcr_filter.py b/tests/vcr/vcr_filter.py index 892b8021fb6a..b399638c5eed 100644 --- a/tests/vcr/vcr_filter.py +++ b/tests/vcr/vcr_filter.py @@ -1,7 +1,10 @@ import json +import os import re from typing import Any, Dict, List +from tests.conftest import PROXY + REPLACEMENTS: List[Dict[str, str]] = [ { "regex": r"\w{3} \w{3} {1,2}\d{1,2} \d{2}:\d{2}:\d{2} \d{4}", @@ -13,6 +16,20 @@ }, ] +ALLOWED_HOSTNAMES: List[str] = [ + "api.openai.com", + "localhost:50337", +] + +if PROXY: + ALLOWED_HOSTNAMES.append(PROXY) + ORIGINAL_URL = PROXY +else: + ORIGINAL_URL = "no_ci" + +NEW_URL = "api.openai.com" + + def replace_message_content(content: str, replacements: List[Dict[str, str]]) -> str: for replacement in replacements: @@ -53,6 +70,8 @@ def before_record_response(response: Dict[str, Any]) -> Dict[str, Any]: def before_record_request(request: Any) -> Any: + request = replace_request_hostname(request, PROXY, NEW_URL) + filtered_request = filter_hostnames(request) filtered_request_without_dynamic_data = replace_timestamp_in_request( filtered_request @@ -60,14 +79,22 @@ def before_record_request(request: Any) -> Any: return filtered_request_without_dynamic_data -def filter_hostnames(request: Any) -> Any: - allowed_hostnames: List[str] = [ - "api.openai.com", - "localhost:50337", - ] +from urllib.parse import urlparse, urlunparse +def replace_request_hostname(request: Any, original_url: str, new_hostname: str) -> Any: + parsed_url = urlparse(request.uri) + + if parsed_url.hostname in original_url: + new_path = parsed_url.path.replace('/proxy_function', '') + request.uri = urlunparse(parsed_url._replace(netloc=new_hostname, path=new_path, scheme="https")) + + return request + + + +def filter_hostnames(request: Any) -> Any: # Add your implementation here for filtering hostnames - if any(hostname in request.url for hostname in allowed_hostnames): + if any(hostname in request.url for hostname in ALLOWED_HOSTNAMES): return request else: return None From eb807616c2c5bdfaf1e2c63ea8ac699ffd30bb4d Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 15:38:52 -0700 Subject: [PATCH 02/26] basic proxy --- autogpt/prompts/prompt.py | 4 +--- tests/conftest.py | 1 + tests/integration/conftest.py | 4 +++- tests/integration/test_llm_utils.py | 5 ++++- tests/integration/test_memory_management.py | 5 ++++- tests/vcr/vcr_filter.py | 11 ++++++----- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/autogpt/prompts/prompt.py b/autogpt/prompts/prompt.py index 7f740ef1f185..b20bd5a1a8ee 100644 --- a/autogpt/prompts/prompt.py +++ b/autogpt/prompts/prompt.py @@ -10,9 +10,7 @@ CFG = Config() -DEFAULT_TRIGGERING_PROMPT = ( - "Determindfsdfse which next command to use, and respond using the format specified above:" -) +DEFAULT_TRIGGERING_PROMPT = "Determindfsdfse which next command to use, and respond using the format specified above:" def build_default_prompt_generator() -> PromptGenerator: diff --git a/tests/conftest.py b/tests/conftest.py index 880151e837a1..6e6f0ad380af 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,6 +12,7 @@ PROXY = os.environ.get("PROXY") + @pytest.fixture() def workspace_root(tmp_path: Path) -> Path: return tmp_path / "home/users/monty/auto_gpt_workspace" diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 0bdcf33e8ec7..2ff867cf8509 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,10 +1,11 @@ import os +import openai import pytest from tests.conftest import PROXY from tests.vcr.vcr_filter import before_record_request, before_record_response -import openai + @pytest.fixture(scope="session") def vcr_config(): @@ -27,6 +28,7 @@ def patch_api_base(requestor): requestor.api_base = new_api_base return requestor + @pytest.fixture def patched_api_requestor(mocker): original_init = openai.api_requestor.APIRequestor.__init__ diff --git a/tests/integration/test_llm_utils.py b/tests/integration/test_llm_utils.py index 20c77342286e..fefc239c1ada 100644 --- a/tests/integration/test_llm_utils.py +++ b/tests/integration/test_llm_utils.py @@ -41,7 +41,10 @@ def spy_create_embedding(mocker: MockerFixture): @pytest.mark.vcr @requires_api_key("OPENAI_API_KEY") def test_get_ada_embedding( - config: Config, api_manager: ApiManager, spy_create_embedding: MagicMock, patched_api_requestor + config: Config, + api_manager: ApiManager, + spy_create_embedding: MagicMock, + patched_api_requestor, ): token_cost = COSTS[config.embedding_model]["prompt"] llm_utils.get_ada_embedding("test") diff --git a/tests/integration/test_memory_management.py b/tests/integration/test_memory_management.py index 6a8451b9dca3..22ade7b0be0f 100644 --- a/tests/integration/test_memory_management.py +++ b/tests/integration/test_memory_management.py @@ -52,7 +52,10 @@ def expected_permanent_memory() -> str: @requires_api_key("OPENAI_API_KEY") @pytest.mark.vcr def test_save_memory_trimmed_from_context_window( - message_history_fixture, expected_permanent_memory, config: Config, patched_api_requestor + message_history_fixture, + expected_permanent_memory, + config: Config, + patched_api_requestor, ): next_message_to_add_index = len(message_history_fixture) - 1 memory = get_memory(config, init=True) diff --git a/tests/vcr/vcr_filter.py b/tests/vcr/vcr_filter.py index b399638c5eed..3a58bee98633 100644 --- a/tests/vcr/vcr_filter.py +++ b/tests/vcr/vcr_filter.py @@ -30,7 +30,6 @@ NEW_URL = "api.openai.com" - def replace_message_content(content: str, replacements: List[Dict[str, str]]) -> str: for replacement in replacements: pattern = re.compile(replacement["regex"]) @@ -70,7 +69,7 @@ def before_record_response(response: Dict[str, Any]) -> Dict[str, Any]: def before_record_request(request: Any) -> Any: - request = replace_request_hostname(request, PROXY, NEW_URL) + request = replace_request_hostname(request, ORIGINAL_URL, NEW_URL) filtered_request = filter_hostnames(request) filtered_request_without_dynamic_data = replace_timestamp_in_request( @@ -81,17 +80,19 @@ def before_record_request(request: Any) -> Any: from urllib.parse import urlparse, urlunparse + def replace_request_hostname(request: Any, original_url: str, new_hostname: str) -> Any: parsed_url = urlparse(request.uri) if parsed_url.hostname in original_url: - new_path = parsed_url.path.replace('/proxy_function', '') - request.uri = urlunparse(parsed_url._replace(netloc=new_hostname, path=new_path, scheme="https")) + new_path = parsed_url.path.replace("/proxy_function", "") + request.uri = urlunparse( + parsed_url._replace(netloc=new_hostname, path=new_path, scheme="https") + ) return request - def filter_hostnames(request: Any) -> Any: # Add your implementation here for filtering hostnames if any(hostname in request.url for hostname in ALLOWED_HOSTNAMES): From 051b990c8694d8ff66cf3a1628cb62fbec189b47 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 15:43:33 -0700 Subject: [PATCH 03/26] commit cassette --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 044208f5e6c7..2838a2ac0a9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,15 @@ jobs: CI: true PROXY: https://us-central1-prod-benchmarks-core.cloudfunctions.net/proxy_function - - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 + + - name: Commit changes + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "github-actions-bot@users.noreply.github.com" + git fetch + git checkout "${{ github.head_ref }}" || echo "Changes already committed" + git add -A + git commit -m "Update cassettes" || echo "No changes to commit" + git push || echo "Changes already committed" From 0310bd7b427c74ba8b8efb76ad2c4ff83583bd67 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 15:48:36 -0700 Subject: [PATCH 04/26] basic proxy --- tests/conftest.py | 4 +- .../test_write_file/test_write_file.yaml | 200 ++++++++++++++++++ 2 files changed, 202 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6e6f0ad380af..33a3f483fef9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,8 +10,8 @@ pytest_plugins = ["tests.integration.agent_factory"] -PROXY = os.environ.get("PROXY") - +# PROXY = os.environ.get("PROXY") +PROXY = "https://us-central1-prod-benchmarks-core.cloudfunctions.net/proxy_function" @pytest.fixture() def workspace_root(tmp_path: Path) -> Path: diff --git a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml index 42160ea2b382..406aef99db04 100644 --- a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml +++ b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml @@ -573,4 +573,204 @@ interactions: status: code: 200 message: OK +- request: + body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You + are write_to_file-GPT, an AI designed to use the write_to_file command to write + ''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete + command to complete the task.\nYour decisions must always be made independently + without seeking user assistance. Play to your strengths as an LLM and pursue + simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file + command to write ''Hello World'' into a file named \"hello_world.txt\".\n2. + Use the task_complete command to complete the task.\n3. Do not use andfsfdsy + other commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. + Your short term memory is short, so immediately save important information to + files.\n2. If you are unsure how you previously did something or want to recall + past events, thinking about similar events will help you remember.\n3. No user + assistance\n4. Exclusively use the commands listed in double quotes e.g. \"command + name\"\n\nCommands:\n1. append_to_file: Append to file, args: \"filename\": + \"\", \"text\": \"\"\n2. delete_file: Delete file, args: \"filename\": + \"\"\n3. list_files: List Files in Directory, args: \"directory\": + \"\"\n4. read_file: Read file, args: \"filename\": \"\"\n5. + write_to_file: Write to file, args: \"filename\": \"\", \"text\": + \"\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"\"\n7. + get_hyperlinks: Get text summary, args: \"url\": \"\"\n8. get_text_summary: + Get text summary, args: \"url\": \"\", \"question\": \"\"\n9. + list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT + Agent, args: \"key\": \"\", \"message\": \"\"\n11. start_agent: + Start GPT Agent, args: \"name\": \"\", \"task\": \"\", + \"prompt\": \"\"\n12. task_complete: Task Complete (Shutdown), args: + \"reason\": \"\"\n\nResources:\n1. Internet access for searches and + information gathering.\n2. Long Term memory management.\n3. GPT-3.5 powered + Agents for delegation of simple tasks.\n4. File output.\n\nPerformance Evaluation:\n1. + Continuously review and analyze your actions to ensure you are performing to + the best of your abilities.\n2. Constructively self-criticize your big-picture + behavior constantly.\n3. Reflect on past decisions and strategies to refine + your approach.\n4. Every command has a cost, so be smart and efficient. Aim + to complete tasks in the least number of steps.\n5. Write all code to a file.\n\nYou + should only respond in JSON format as described below \nResponse Format: \n{\n \"thoughts\": + {\n \"text\": \"thought\",\n \"reasoning\": \"reasoning\",\n \"plan\": + \"- short bulleted\\n- list that conveys\\n- long-term plan\",\n \"criticism\": + \"constructive self-criticism\",\n \"speak\": \"thoughts summary to say + to user\"\n },\n \"command\": {\n \"name\": \"command name\",\n \"args\": + {\n \"arg name\": \"value\"\n }\n }\n} \nEnsure the response + can be parsed by Python json.loads"}, {"role": "system", "content": "The current + time and date is Tue Jan 1 00:00:00 2000"}, {"role": "user", "content": "Determine + which next command to use, and respond using the format specified above:"}], + "temperature": 0, "max_tokens": 0}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '3412' + Content-Type: + - application/json + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: '{"id":"chatcmpl-7F9LTgQAKxOSiGUYtOWMO1X7bMfFp","object":"chat.completion","created":1683845199,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":763,"completion_tokens":221,"total_tokens":984},"choices":[{"message":{"role":"assistant","content":"{\n \"thoughts\": + {\n \"text\": \"I need to write ''Hello World'' into a file named ''hello_world.txt'' + and then complete the task. The ''write_to_file'' command is the best option + for this task.\",\n \"reasoning\": \"I chose the ''write_to_file'' + command because it is the most straightforward way to write text to a file.\",\n \"plan\": + \"- Use the ''write_to_file'' command to write ''Hello World'' into a file + named ''hello_world.txt''.\\n- Use the ''task_complete'' command to complete + the task.\",\n \"criticism\": \"I don''t see any issues with my plan + at this time.\",\n \"speak\": \"I will use the ''write_to_file'' command + to write ''Hello World'' into a file named ''hello_world.txt'' and then complete + the task.\"\n },\n \"command\": {\n \"name\": \"write_to_file\",\n \"args\": + {\n \"filename\": \"hello_world.txt\",\n \"text\": \"Hello + World\"\n }\n }\n}"},"finish_reason":"stop","index":0}]}' + headers: + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + Content-Length: + - '1223' + Content-Type: + - application/json + Date: + - Thu, 11 May 2023 22:46:51 GMT + Function-Execution-Id: + - bmswwoa1o96u + Server: + - Google Frontend + X-Cloud-Trace-Context: + - cd3704e4af2682d57c6230b0393b9946;o=1 + X-Powered-By: + - Express + status: + code: 200 + message: OK +- request: + body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You + are write_to_file-GPT, an AI designed to use the write_to_file command to write + ''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete + command to complete the task.\nYour decisions must always be made independently + without seeking user assistance. Play to your strengths as an LLM and pursue + simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file + command to write ''Hello World'' into a file named \"hello_world.txt\".\n2. + Use the task_complete command to complete the task.\n3. Do not use andfsfdsy + other commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. + Your short term memory is short, so immediately save important information to + files.\n2. If you are unsure how you previously did something or want to recall + past events, thinking about similar events will help you remember.\n3. No user + assistance\n4. Exclusively use the commands listed in double quotes e.g. \"command + name\"\n\nCommands:\n1. append_to_file: Append to file, args: \"filename\": + \"\", \"text\": \"\"\n2. delete_file: Delete file, args: \"filename\": + \"\"\n3. list_files: List Files in Directory, args: \"directory\": + \"\"\n4. read_file: Read file, args: \"filename\": \"\"\n5. + write_to_file: Write to file, args: \"filename\": \"\", \"text\": + \"\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"\"\n7. + get_hyperlinks: Get text summary, args: \"url\": \"\"\n8. get_text_summary: + Get text summary, args: \"url\": \"\", \"question\": \"\"\n9. + list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT + Agent, args: \"key\": \"\", \"message\": \"\"\n11. start_agent: + Start GPT Agent, args: \"name\": \"\", \"task\": \"\", + \"prompt\": \"\"\n12. task_complete: Task Complete (Shutdown), args: + \"reason\": \"\"\n\nResources:\n1. Internet access for searches and + information gathering.\n2. Long Term memory management.\n3. GPT-3.5 powered + Agents for delegation of simple tasks.\n4. File output.\n\nPerformance Evaluation:\n1. + Continuously review and analyze your actions to ensure you are performing to + the best of your abilities.\n2. Constructively self-criticize your big-picture + behavior constantly.\n3. Reflect on past decisions and strategies to refine + your approach.\n4. Every command has a cost, so be smart and efficient. Aim + to complete tasks in the least number of steps.\n5. Write all code to a file.\n\nYou + should only respond in JSON format as described below \nResponse Format: \n{\n \"thoughts\": + {\n \"text\": \"thought\",\n \"reasoning\": \"reasoning\",\n \"plan\": + \"- short bulleted\\n- list that conveys\\n- long-term plan\",\n \"criticism\": + \"constructive self-criticism\",\n \"speak\": \"thoughts summary to say + to user\"\n },\n \"command\": {\n \"name\": \"command name\",\n \"args\": + {\n \"arg name\": \"value\"\n }\n }\n} \nEnsure the response + can be parsed by Python json.loads"}, {"role": "system", "content": "The current + time and date is Tue Jan 1 00:00:00 2000"}, {"role": "system", "content": "This + reminds you of these events from your past: \nI was created and nothing new + has happened."}, {"role": "user", "content": "Determine which next command to + use, and respond using the format specified above:"}, {"role": "assistant", + "content": "{\n \"thoughts\": {\n \"text\": \"I need to write ''Hello + World'' into a file named ''hello_world.txt'' and then complete the task. The + ''write_to_file'' command is the best option for this task.\",\n \"reasoning\": + \"I chose the ''write_to_file'' command because it is the most straightforward + way to write text to a file.\",\n \"plan\": \"- Use the ''write_to_file'' + command to write ''Hello World'' into a file named ''hello_world.txt''.\\n- + Use the ''task_complete'' command to complete the task.\",\n \"criticism\": + \"I don''t see any issues with my plan at this time.\",\n \"speak\": + \"I will use the ''write_to_file'' command to write ''Hello World'' into a file + named ''hello_world.txt'' and then complete the task.\"\n },\n \"command\": + {\n \"name\": \"write_to_file\",\n \"args\": {\n \"filename\": + \"hello_world.txt\",\n \"text\": \"Hello World\"\n }\n }\n}"}, + {"role": "system", "content": "Command write_to_file returned: File written + to successfully."}, {"role": "user", "content": "Determine which next command + to use, and respond using the format specified above:"}], "temperature": 0, + "max_tokens": 0}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '4725' + Content-Type: + - application/json + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: '{"id":"chatcmpl-7F9LnjaUWKZsf2nOaFDOSTXAruTBx","object":"chat.completion","created":1683845219,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":1051,"completion_tokens":156,"total_tokens":1207},"choices":[{"message":{"role":"assistant","content":"{\n \"thoughts\": + {\n \"text\": \"Now that the file has been written, I need to complete + the task using the ''task_complete'' command.\",\n \"reasoning\": \"The + ''task_complete'' command is the best option for completing the task because + it is specifically designed for this purpose.\",\n \"plan\": \"- Use + the ''task_complete'' command to complete the task.\",\n \"criticism\": + \"I don''t see any issues with my plan at this time.\",\n \"speak\": + \"I will use the ''task_complete'' command to complete the task.\"\n },\n \"command\": + {\n \"name\": \"task_complete\",\n \"args\": {\n \"reason\": + \"The task has been completed successfully.\"\n }\n }\n}"},"finish_reason":"stop","index":0}]}' + headers: + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + Content-Length: + - '1012' + Content-Type: + - application/json + Date: + - Thu, 11 May 2023 22:47:07 GMT + Function-Execution-Id: + - bmswgsjx9zp3 + Server: + - Google Frontend + X-Cloud-Trace-Context: + - 6bc109f2f7d1b324f714012bb5233fd9;o=1 + X-Powered-By: + - Express + status: + code: 200 + message: OK version: 1 From 4347d52f478256b6c2eef8cdfe1b2df64a9a0366 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 15:53:34 -0700 Subject: [PATCH 05/26] add files --- tests/conftest.py | 1 + .../test_write_file/test_write_file.yaml | 200 ------------------ 2 files changed, 1 insertion(+), 200 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 33a3f483fef9..54c09521aa8c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,6 +13,7 @@ # PROXY = os.environ.get("PROXY") PROXY = "https://us-central1-prod-benchmarks-core.cloudfunctions.net/proxy_function" + @pytest.fixture() def workspace_root(tmp_path: Path) -> Path: return tmp_path / "home/users/monty/auto_gpt_workspace" diff --git a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml index 406aef99db04..42160ea2b382 100644 --- a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml +++ b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml @@ -573,204 +573,4 @@ interactions: status: code: 200 message: OK -- request: - body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You - are write_to_file-GPT, an AI designed to use the write_to_file command to write - ''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete - command to complete the task.\nYour decisions must always be made independently - without seeking user assistance. Play to your strengths as an LLM and pursue - simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file - command to write ''Hello World'' into a file named \"hello_world.txt\".\n2. - Use the task_complete command to complete the task.\n3. Do not use andfsfdsy - other commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. - Your short term memory is short, so immediately save important information to - files.\n2. If you are unsure how you previously did something or want to recall - past events, thinking about similar events will help you remember.\n3. No user - assistance\n4. Exclusively use the commands listed in double quotes e.g. \"command - name\"\n\nCommands:\n1. append_to_file: Append to file, args: \"filename\": - \"\", \"text\": \"\"\n2. delete_file: Delete file, args: \"filename\": - \"\"\n3. list_files: List Files in Directory, args: \"directory\": - \"\"\n4. read_file: Read file, args: \"filename\": \"\"\n5. - write_to_file: Write to file, args: \"filename\": \"\", \"text\": - \"\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"\"\n7. - get_hyperlinks: Get text summary, args: \"url\": \"\"\n8. get_text_summary: - Get text summary, args: \"url\": \"\", \"question\": \"\"\n9. - list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT - Agent, args: \"key\": \"\", \"message\": \"\"\n11. start_agent: - Start GPT Agent, args: \"name\": \"\", \"task\": \"\", - \"prompt\": \"\"\n12. task_complete: Task Complete (Shutdown), args: - \"reason\": \"\"\n\nResources:\n1. Internet access for searches and - information gathering.\n2. Long Term memory management.\n3. GPT-3.5 powered - Agents for delegation of simple tasks.\n4. File output.\n\nPerformance Evaluation:\n1. - Continuously review and analyze your actions to ensure you are performing to - the best of your abilities.\n2. Constructively self-criticize your big-picture - behavior constantly.\n3. Reflect on past decisions and strategies to refine - your approach.\n4. Every command has a cost, so be smart and efficient. Aim - to complete tasks in the least number of steps.\n5. Write all code to a file.\n\nYou - should only respond in JSON format as described below \nResponse Format: \n{\n \"thoughts\": - {\n \"text\": \"thought\",\n \"reasoning\": \"reasoning\",\n \"plan\": - \"- short bulleted\\n- list that conveys\\n- long-term plan\",\n \"criticism\": - \"constructive self-criticism\",\n \"speak\": \"thoughts summary to say - to user\"\n },\n \"command\": {\n \"name\": \"command name\",\n \"args\": - {\n \"arg name\": \"value\"\n }\n }\n} \nEnsure the response - can be parsed by Python json.loads"}, {"role": "system", "content": "The current - time and date is Tue Jan 1 00:00:00 2000"}, {"role": "user", "content": "Determine - which next command to use, and respond using the format specified above:"}], - "temperature": 0, "max_tokens": 0}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '3412' - Content-Type: - - application/json - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: '{"id":"chatcmpl-7F9LTgQAKxOSiGUYtOWMO1X7bMfFp","object":"chat.completion","created":1683845199,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":763,"completion_tokens":221,"total_tokens":984},"choices":[{"message":{"role":"assistant","content":"{\n \"thoughts\": - {\n \"text\": \"I need to write ''Hello World'' into a file named ''hello_world.txt'' - and then complete the task. The ''write_to_file'' command is the best option - for this task.\",\n \"reasoning\": \"I chose the ''write_to_file'' - command because it is the most straightforward way to write text to a file.\",\n \"plan\": - \"- Use the ''write_to_file'' command to write ''Hello World'' into a file - named ''hello_world.txt''.\\n- Use the ''task_complete'' command to complete - the task.\",\n \"criticism\": \"I don''t see any issues with my plan - at this time.\",\n \"speak\": \"I will use the ''write_to_file'' command - to write ''Hello World'' into a file named ''hello_world.txt'' and then complete - the task.\"\n },\n \"command\": {\n \"name\": \"write_to_file\",\n \"args\": - {\n \"filename\": \"hello_world.txt\",\n \"text\": \"Hello - World\"\n }\n }\n}"},"finish_reason":"stop","index":0}]}' - headers: - Alt-Svc: - - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 - - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 - Content-Length: - - '1223' - Content-Type: - - application/json - Date: - - Thu, 11 May 2023 22:46:51 GMT - Function-Execution-Id: - - bmswwoa1o96u - Server: - - Google Frontend - X-Cloud-Trace-Context: - - cd3704e4af2682d57c6230b0393b9946;o=1 - X-Powered-By: - - Express - status: - code: 200 - message: OK -- request: - body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You - are write_to_file-GPT, an AI designed to use the write_to_file command to write - ''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete - command to complete the task.\nYour decisions must always be made independently - without seeking user assistance. Play to your strengths as an LLM and pursue - simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file - command to write ''Hello World'' into a file named \"hello_world.txt\".\n2. - Use the task_complete command to complete the task.\n3. Do not use andfsfdsy - other commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. - Your short term memory is short, so immediately save important information to - files.\n2. If you are unsure how you previously did something or want to recall - past events, thinking about similar events will help you remember.\n3. No user - assistance\n4. Exclusively use the commands listed in double quotes e.g. \"command - name\"\n\nCommands:\n1. append_to_file: Append to file, args: \"filename\": - \"\", \"text\": \"\"\n2. delete_file: Delete file, args: \"filename\": - \"\"\n3. list_files: List Files in Directory, args: \"directory\": - \"\"\n4. read_file: Read file, args: \"filename\": \"\"\n5. - write_to_file: Write to file, args: \"filename\": \"\", \"text\": - \"\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"\"\n7. - get_hyperlinks: Get text summary, args: \"url\": \"\"\n8. get_text_summary: - Get text summary, args: \"url\": \"\", \"question\": \"\"\n9. - list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT - Agent, args: \"key\": \"\", \"message\": \"\"\n11. start_agent: - Start GPT Agent, args: \"name\": \"\", \"task\": \"\", - \"prompt\": \"\"\n12. task_complete: Task Complete (Shutdown), args: - \"reason\": \"\"\n\nResources:\n1. Internet access for searches and - information gathering.\n2. Long Term memory management.\n3. GPT-3.5 powered - Agents for delegation of simple tasks.\n4. File output.\n\nPerformance Evaluation:\n1. - Continuously review and analyze your actions to ensure you are performing to - the best of your abilities.\n2. Constructively self-criticize your big-picture - behavior constantly.\n3. Reflect on past decisions and strategies to refine - your approach.\n4. Every command has a cost, so be smart and efficient. Aim - to complete tasks in the least number of steps.\n5. Write all code to a file.\n\nYou - should only respond in JSON format as described below \nResponse Format: \n{\n \"thoughts\": - {\n \"text\": \"thought\",\n \"reasoning\": \"reasoning\",\n \"plan\": - \"- short bulleted\\n- list that conveys\\n- long-term plan\",\n \"criticism\": - \"constructive self-criticism\",\n \"speak\": \"thoughts summary to say - to user\"\n },\n \"command\": {\n \"name\": \"command name\",\n \"args\": - {\n \"arg name\": \"value\"\n }\n }\n} \nEnsure the response - can be parsed by Python json.loads"}, {"role": "system", "content": "The current - time and date is Tue Jan 1 00:00:00 2000"}, {"role": "system", "content": "This - reminds you of these events from your past: \nI was created and nothing new - has happened."}, {"role": "user", "content": "Determine which next command to - use, and respond using the format specified above:"}, {"role": "assistant", - "content": "{\n \"thoughts\": {\n \"text\": \"I need to write ''Hello - World'' into a file named ''hello_world.txt'' and then complete the task. The - ''write_to_file'' command is the best option for this task.\",\n \"reasoning\": - \"I chose the ''write_to_file'' command because it is the most straightforward - way to write text to a file.\",\n \"plan\": \"- Use the ''write_to_file'' - command to write ''Hello World'' into a file named ''hello_world.txt''.\\n- - Use the ''task_complete'' command to complete the task.\",\n \"criticism\": - \"I don''t see any issues with my plan at this time.\",\n \"speak\": - \"I will use the ''write_to_file'' command to write ''Hello World'' into a file - named ''hello_world.txt'' and then complete the task.\"\n },\n \"command\": - {\n \"name\": \"write_to_file\",\n \"args\": {\n \"filename\": - \"hello_world.txt\",\n \"text\": \"Hello World\"\n }\n }\n}"}, - {"role": "system", "content": "Command write_to_file returned: File written - to successfully."}, {"role": "user", "content": "Determine which next command - to use, and respond using the format specified above:"}], "temperature": 0, - "max_tokens": 0}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '4725' - Content-Type: - - application/json - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: '{"id":"chatcmpl-7F9LnjaUWKZsf2nOaFDOSTXAruTBx","object":"chat.completion","created":1683845219,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":1051,"completion_tokens":156,"total_tokens":1207},"choices":[{"message":{"role":"assistant","content":"{\n \"thoughts\": - {\n \"text\": \"Now that the file has been written, I need to complete - the task using the ''task_complete'' command.\",\n \"reasoning\": \"The - ''task_complete'' command is the best option for completing the task because - it is specifically designed for this purpose.\",\n \"plan\": \"- Use - the ''task_complete'' command to complete the task.\",\n \"criticism\": - \"I don''t see any issues with my plan at this time.\",\n \"speak\": - \"I will use the ''task_complete'' command to complete the task.\"\n },\n \"command\": - {\n \"name\": \"task_complete\",\n \"args\": {\n \"reason\": - \"The task has been completed successfully.\"\n }\n }\n}"},"finish_reason":"stop","index":0}]}' - headers: - Alt-Svc: - - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 - - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 - Content-Length: - - '1012' - Content-Type: - - application/json - Date: - - Thu, 11 May 2023 22:47:07 GMT - Function-Execution-Id: - - bmswgsjx9zp3 - Server: - - Google Frontend - X-Cloud-Trace-Context: - - 6bc109f2f7d1b324f714012bb5233fd9;o=1 - X-Powered-By: - - Express - status: - code: 200 - message: OK version: 1 From 5c9554227d5fcc4b293f50ff52533d7d296304d5 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 15:57:42 -0700 Subject: [PATCH 06/26] add files --- tests/conftest.py | 4 +- .../test_write_file/test_write_file.yaml | 117 ++++++++++++++++++ 2 files changed, 118 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 54c09521aa8c..880151e837a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,9 +10,7 @@ pytest_plugins = ["tests.integration.agent_factory"] -# PROXY = os.environ.get("PROXY") -PROXY = "https://us-central1-prod-benchmarks-core.cloudfunctions.net/proxy_function" - +PROXY = os.environ.get("PROXY") @pytest.fixture() def workspace_root(tmp_path: Path) -> Path: diff --git a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml index 42160ea2b382..ef390a58a1d6 100644 --- a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml +++ b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml @@ -573,4 +573,121 @@ interactions: status: code: 200 message: OK +- request: + body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You + are write_to_file-GPT, an AI designed to use the write_to_file command to write + ''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete + command to complete the task.\nYour decisions must always be made independently + without seeking user assistance. Play to your strengths as an LLM and pursue + simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file + command to write ''Hello World'' into a file named \"hello_world.txt\".\n2. + Use the task_complete command to complete the task.\n3. Do not use andfsfdsy + other commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. + Your short term memory is short, so immediately save important information to + files.\n2. If you are unsure how you previously did something or want to recall + past events, thinking about similar events will help you remember.\n3. No user + assistance\n4. Exclusively use the commands listed in double quotes e.g. \"command + name\"\n\nCommands:\n1. append_to_file: Append to file, args: \"filename\": + \"\", \"text\": \"\"\n2. delete_file: Delete file, args: \"filename\": + \"\"\n3. list_files: List Files in Directory, args: \"directory\": + \"\"\n4. read_file: Read file, args: \"filename\": \"\"\n5. + write_to_file: Write to file, args: \"filename\": \"\", \"text\": + \"\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"\"\n7. + get_hyperlinks: Get text summary, args: \"url\": \"\"\n8. get_text_summary: + Get text summary, args: \"url\": \"\", \"question\": \"\"\n9. + list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT + Agent, args: \"key\": \"\", \"message\": \"\"\n11. start_agent: + Start GPT Agent, args: \"name\": \"\", \"task\": \"\", + \"prompt\": \"\"\n12. task_complete: Task Complete (Shutdown), args: + \"reason\": \"\"\n\nResources:\n1. Internet access for searches and + information gathering.\n2. Long Term memory management.\n3. GPT-3.5 powered + Agents for delegation of simple tasks.\n4. File output.\n\nPerformance Evaluation:\n1. + Continuously review and analyze your actions to ensure you are performing to + the best of your abilities.\n2. Constructively self-criticize your big-picture + behavior constantly.\n3. Reflect on past decisions and strategies to refine + your approach.\n4. Every command has a cost, so be smart and efficient. Aim + to complete tasks in the least number of steps.\n5. Write all code to a file.\n\nYou + should only respond in JSON format as described below \nResponse Format: \n{\n \"thoughts\": + {\n \"text\": \"thought\",\n \"reasoning\": \"reasoning\",\n \"plan\": + \"- short bulleted\\n- list that conveys\\n- long-term plan\",\n \"criticism\": + \"constructive self-criticism\",\n \"speak\": \"thoughts summary to say + to user\"\n },\n \"command\": {\n \"name\": \"command name\",\n \"args\": + {\n \"arg name\": \"value\"\n }\n }\n} \nEnsure the response + can be parsed by Python json.loads"}, {"role": "system", "content": "The current + time and date is Tue Jan 1 00:00:00 2000"}, {"role": "user", "content": "Determine + which next command to use, and respond using the format specified above:"}], + "temperature": 0, "max_tokens": 0}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '3412' + Content-Type: + - application/json + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: !!binary | + H4sIAAAAAAAAA7yTS2/bMBCE7/0Vi734Qht2lTiObj00aC69NA+0UWEw1NpiTXFVclW7MPTfC0l+ + JCp6KtrrzmjmI7nao80xRVNoMWXlxlc31w/F44+Pn1Y3Pz9v3s3py/urGLZ3tngI96iQn7+RkcMX + E8Nl5Ugse1RoAmmhHNPZfJEsLi4XSaKw5JwcpriuZJxMLsdSh2ceT5PpDBXWUa8J0z1WgctKlsIb + 8hHTq3mi8Jx9mr+dzhQKi3an0fX8olFoCraGIqZPeywpHmMDO8IUdYw2ivbSQrIX8u0B9pkHAMhQ + Cq7XhcQMUzgMDwLtpB1meAueKAdhqCOBFATbYIWWwsuVdQSGy1L7ztAJMPpAzjE8cnD5CKwXBg2d + 1euSchgVrb7ctvpEdjKaZKhedgfSkb316x7griAQHTcQ6HttA0Uo6S/aFHS0fzyHjZ2oqypwFayW + s7TiAFK0Bh03Q+rKad8Dj+H+P92UCVassbEcPhX5WIeWQQvcnh7OcAhk5FzRXwXt5Mwk3Flby7At + VqQ3x6atde5fbkRf3Kjjph5Cf1vUNqFnegUxQNdhPdzxXmi954gBx6uQ4X/x4kxH2o74AJ75BhuF + K+ttLJb9SmOKUbhChdbntMN02nxt3vwCAAD//wMApFuuI4cEAAA= + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 7c5e050a3e7497eb-SJC + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 11 May 2023 22:57:24 GMT + Server: + - cloudflare + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400, h3-29=":443"; ma=86400 + openai-model: + - gpt-3.5-turbo-0301 + openai-organization: + - user-adtx4fhfg1qsiyzdoaxciooj + openai-processing-ms: + - '11428' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '3500' + x-ratelimit-limit-tokens: + - '90000' + x-ratelimit-remaining-requests: + - '3499' + x-ratelimit-remaining-tokens: + - '86497' + x-ratelimit-reset-requests: + - 17ms + x-ratelimit-reset-tokens: + - 2.335s + x-request-id: + - 9418ad50ca3fd9b6f08757827e32f729 + status: + code: 200 + message: OK version: 1 From 80e891d9487da40ccc2125b2c0ca9fe43c4e1005 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 16:02:31 -0700 Subject: [PATCH 07/26] add files --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index 880151e837a1..6e6f0ad380af 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,6 +12,7 @@ PROXY = os.environ.get("PROXY") + @pytest.fixture() def workspace_root(tmp_path: Path) -> Path: return tmp_path / "home/users/monty/auto_gpt_workspace" From 4e81b5d00debd552280ed7c54ecc102541fc9fe8 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 16:04:56 -0700 Subject: [PATCH 08/26] add files --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2838a2ac0a9f..6a105281410f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,9 @@ jobs: git config --global user.name "GitHub Actions Bot" git config --global user.email "github-actions-bot@users.noreply.github.com" git fetch - git checkout "${{ github.head_ref }}" || echo "Changes already committed" + branch_name="$(git symbolic-ref --short HEAD || echo ${GITHUB_REF#refs/heads/})" + git checkout "$branch_name" || echo "Changes already committed" git add -A git commit -m "Update cassettes" || echo "No changes to commit" git push || echo "Changes already committed" + From c24c3a066fa1d57d22a42c47624e3cf37d6d26a9 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 16:08:10 -0700 Subject: [PATCH 09/26] add files --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a105281410f..4559397a5905 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,9 +84,15 @@ jobs: git config --global user.name "GitHub Actions Bot" git config --global user.email "github-actions-bot@users.noreply.github.com" git fetch - branch_name="$(git symbolic-ref --short HEAD || echo ${GITHUB_REF#refs/heads/})" - git checkout "$branch_name" || echo "Changes already committed" + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + branch_name="${{ github.head_ref }}" + git checkout "$branch_name" || echo "Changes already committed" + else + branch_name="$(git symbolic-ref --short HEAD || echo ${GITHUB_REF#refs/heads/})" + git checkout "$branch_name" || echo "Changes already committed" + fi git add -A git commit -m "Update cassettes" || echo "No changes to commit" git push || echo "Changes already committed" + From 184a8a511a170fa8a80c23ca2ffcc790257f057c Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 16:11:57 -0700 Subject: [PATCH 10/26] add files --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4559397a5905..c42352b6dce7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,8 @@ jobs: git fetch if [[ "${{ github.event_name }}" == "pull_request" ]]; then branch_name="${{ github.head_ref }}" - git checkout "$branch_name" || echo "Changes already committed" + git fetch origin "$branch_name" + git checkout -b "$branch_name" "FETCH_HEAD" || echo "Changes already committed" else branch_name="$(git symbolic-ref --short HEAD || echo ${GITHUB_REF#refs/heads/})" git checkout "$branch_name" || echo "Changes already committed" @@ -95,4 +96,5 @@ jobs: git commit -m "Update cassettes" || echo "No changes to commit" git push || echo "Changes already committed" + From 7825d5f3101662e630b2caab7708a5f989bc5194 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 16:35:54 -0700 Subject: [PATCH 11/26] upload artifacts --- .github/workflows/ci.yml | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c42352b6dce7..c443735d1f23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,22 +79,8 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 - - name: Commit changes - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "github-actions-bot@users.noreply.github.com" - git fetch - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - branch_name="${{ github.head_ref }}" - git fetch origin "$branch_name" - git checkout -b "$branch_name" "FETCH_HEAD" || echo "Changes already committed" - else - branch_name="$(git symbolic-ref --short HEAD || echo ${GITHUB_REF#refs/heads/})" - git checkout "$branch_name" || echo "Changes already committed" - fi - git add -A - git commit -m "Update cassettes" || echo "No changes to commit" - git push || echo "Changes already committed" - - - + - name: Upload cassettes as artifact + uses: actions/upload-artifact@v2 + with: + name: cassettes + path: '**/cassettes/**/*.yaml' From a8c02966df079c08285fb29fd9601dd5b70f5735 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 16:43:57 -0700 Subject: [PATCH 12/26] basic-proxy-test --- .github/workflows/add-cassettes.yml | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/add-cassettes.yml diff --git a/.github/workflows/add-cassettes.yml b/.github/workflows/add-cassettes.yml new file mode 100644 index 000000000000..1d27402819ea --- /dev/null +++ b/.github/workflows/add-cassettes.yml @@ -0,0 +1,34 @@ +name: Merge and Commit Cassettes + +on: + pull_request: + types: + - closed + +jobs: + update-cassettes: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 # This is necessary to fetch all branches and tags + + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: cassettes + path: . # Extract the artifact in the current working directory + + - name: Configure Git + run: | + git config user.name "GitHub Actions Bot" + git config user.email "" + + - name: Commit and push + run: | + git add '**/cassettes/**/*.yaml' + git commit -m "Update cassettes" || echo "No changes to commit" + git push || echo "No changes to push" From 9f58553519e645a7bc45e04ea015d5d70fe08eb8 Mon Sep 17 00:00:00 2001 From: merwanehamadi Date: Thu, 11 May 2023 16:54:06 -0700 Subject: [PATCH 13/26] basic-proxy-test (#13) --- .github/workflows/docker-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index e066641f04fb..824fc6d45c64 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -79,3 +79,4 @@ jobs: run: .github/workflows/scripts/docker-release-summary.sh >> $GITHUB_STEP_SUMMARY continue-on-error: true +# rand From 597464ee5768110bfc0497ba89cc50d12cef4ace Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 18:29:19 -0700 Subject: [PATCH 14/26] ci --- .github/workflows/ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c443735d1f23..f69390c51d1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,12 +3,12 @@ name: Python CI on: push: branches: [ master ] - pull_request: + pull_request_target: branches: [ master, stable ] concurrency: group: ${{ format('ci-{0}', github.head_ref && format('pr-{0}', github.event.pull_request.number) || github.sha) }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} + cancel-in-progress: ${{ github.event_name == 'pull_request_target' }} jobs: lint: @@ -19,6 +19,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Set up Python ${{ env.min-python-version }} uses: actions/setup-python@v2 @@ -58,6 +60,8 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 @@ -78,9 +82,3 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 - - - name: Upload cassettes as artifact - uses: actions/upload-artifact@v2 - with: - name: cassettes - path: '**/cassettes/**/*.yaml' From 75db1ca2545436e1ea9d726cd5de7f3cac092def Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 18:30:48 -0700 Subject: [PATCH 15/26] ci --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f69390c51d1f..a119fd57ac17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,3 +82,9 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 + + - name: Upload cassettes as artifact + uses: actions/upload-artifact@v2 + with: + name: cassettes + path: '**/cassettes/**/*.yaml' From ca0891c57f97fe41da595824a58a44752e44547c Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 18:42:53 -0700 Subject: [PATCH 16/26] ci --- .github/workflows/add-cassettes.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/add-cassettes.yml b/.github/workflows/add-cassettes.yml index 1d27402819ea..e93be400497c 100644 --- a/.github/workflows/add-cassettes.yml +++ b/.github/workflows/add-cassettes.yml @@ -17,8 +17,10 @@ jobs: fetch-depth: 0 # This is necessary to fetch all branches and tags - name: Download artifact - uses: actions/download-artifact@v2 + uses: dawidd6/action-download-artifact@v2 with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: Python CI name: cassettes path: . # Extract the artifact in the current working directory From d2623f0c0b75935740805a1dbaa8bc168fd4cef1 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 18:57:19 -0700 Subject: [PATCH 17/26] ci --- .github/workflows/add-cassettes.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/add-cassettes.yml b/.github/workflows/add-cassettes.yml index e93be400497c..60bca57419f7 100644 --- a/.github/workflows/add-cassettes.yml +++ b/.github/workflows/add-cassettes.yml @@ -22,7 +22,9 @@ jobs: github_token: ${{secrets.GITHUB_TOKEN}} workflow: Python CI name: cassettes - path: . # Extract the artifact in the current working directory + path: . + pr: ${{ github.event.pull_request.number }} + - name: Configure Git run: | From bf0fbaeef189bc27a54852ee27a67ed3ff7d7330 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 19:05:21 -0700 Subject: [PATCH 18/26] ci --- .github/workflows/add-cassettes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-cassettes.yml b/.github/workflows/add-cassettes.yml index 60bca57419f7..a955f4b7cba6 100644 --- a/.github/workflows/add-cassettes.yml +++ b/.github/workflows/add-cassettes.yml @@ -1,7 +1,7 @@ name: Merge and Commit Cassettes on: - pull_request: + pull_request_target: types: - closed From a7a129e7fe89298213329c299933580f9c57fb39 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 19:24:33 -0700 Subject: [PATCH 19/26] ci --- .github/workflows/add-cassettes.yml | 3 ++- .github/workflows/ci.yml | 2 +- .github/workflows/docker-release.yml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-cassettes.yml b/.github/workflows/add-cassettes.yml index a955f4b7cba6..8a530ebe2eb2 100644 --- a/.github/workflows/add-cassettes.yml +++ b/.github/workflows/add-cassettes.yml @@ -21,11 +21,12 @@ jobs: with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: Python CI - name: cassettes + name: cassettes-${{ github.event.pull_request.number }} path: . pr: ${{ github.event.pull_request.number }} + - name: Configure Git run: | git config user.name "GitHub Actions Bot" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a119fd57ac17..17ee15157059 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,5 +86,5 @@ jobs: - name: Upload cassettes as artifact uses: actions/upload-artifact@v2 with: - name: cassettes + name: cassettes-${{ github.event.pull_request.number }} path: '**/cassettes/**/*.yaml' diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 824fc6d45c64..9af6680cf5be 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -80,3 +80,4 @@ jobs: run: .github/workflows/scripts/docker-release-summary.sh >> $GITHUB_STEP_SUMMARY continue-on-error: true # rand +# rand From f8c13796a241c15013d99047c873226b6ae5443b Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 19:40:36 -0700 Subject: [PATCH 20/26] basic proxy --- .github/workflows/add-cassettes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-cassettes.yml b/.github/workflows/add-cassettes.yml index 8a530ebe2eb2..c224be3d24c3 100644 --- a/.github/workflows/add-cassettes.yml +++ b/.github/workflows/add-cassettes.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 # This is necessary to fetch all branches and tags From 275b0f365aa8394ec473099cb53280121d3a8ff1 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Thu, 11 May 2023 20:30:31 -0700 Subject: [PATCH 21/26] ci --- .github/workflows/add-cassettes.yml | 17 ++--------------- .github/workflows/ci.yml | 12 ++++++++---- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.github/workflows/add-cassettes.yml b/.github/workflows/add-cassettes.yml index c224be3d24c3..cbb548626797 100644 --- a/.github/workflows/add-cassettes.yml +++ b/.github/workflows/add-cassettes.yml @@ -16,24 +16,11 @@ jobs: with: fetch-depth: 0 # This is necessary to fetch all branches and tags - - name: Download artifact + - name: Download diff artifact uses: dawidd6/action-download-artifact@v2 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: Python CI - name: cassettes-${{ github.event.pull_request.number }} + name: cassette-diff path: . pr: ${{ github.event.pull_request.number }} - - - - - name: Configure Git - run: | - git config user.name "GitHub Actions Bot" - git config user.email "" - - - name: Commit and push - run: | - git add '**/cassettes/**/*.yaml' - git commit -m "Update cassettes" || echo "No changes to commit" - git push || echo "No changes to push" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17ee15157059..54a9a7d6f697 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,8 +83,12 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 - - name: Upload cassettes as artifact - uses: actions/upload-artifact@v2 + - name: Create diff and save to file + run: | + git diff HEAD^ HEAD > cassette-diff-${{ github.event.pull_request.number }}-${{ github.sha }}.txt + + - name: Upload diff as artifact + uses: actions/upload-artifact@v3 with: - name: cassettes-${{ github.event.pull_request.number }} - path: '**/cassettes/**/*.yaml' + name: cassette-diff + path: cassette-diff-${{ github.event.pull_request.number }}-${{ github.sha }}.txt From 94479eed2cf445049e78a9818a13b3541b43173f Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Fri, 12 May 2023 05:45:35 -0700 Subject: [PATCH 22/26] ci --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54a9a7d6f697..bb9e7ff7eabb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,12 @@ jobs: - name: Create diff and save to file run: | - git diff HEAD^ HEAD > cassette-diff-${{ github.event.pull_request.number }}-${{ github.sha }}.txt + if GIT_SHA_PARENT=$(git rev-parse HEAD^ 2>/dev/null); then + git diff $GIT_SHA_PARENT HEAD > cassette-diff-${{ github.event.pull_request.number }}-${{ github.sha }}.txt + else + echo "No parent commit to diff against. Skipping diff generation." + fi + - name: Upload diff as artifact uses: actions/upload-artifact@v3 From 1091fd629a98498dffdf6cf5b01cebc1721c5f64 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Fri, 12 May 2023 05:56:59 -0700 Subject: [PATCH 23/26] ci --- .github/workflows/ci.yml | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb9e7ff7eabb..4fd379b3d3ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - name: Set up Python ${{ env.min-python-version }} uses: actions/setup-python@v2 @@ -45,12 +43,7 @@ jobs: test: permissions: - # Gives the action the necessary permissions for publishing new - # comments in pull requests. pull-requests: write - # Gives the action the necessary permissions for pushing data to the - # python-coverage-comment-action branch, and for editing existing - # comments (to avoid publishing multiple comments in the same PR) contents: write runs-on: ubuntu-latest strategy: @@ -61,7 +54,7 @@ jobs: - name: Check out repository uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 @@ -80,20 +73,16 @@ jobs: CI: true PROXY: https://us-central1-prod-benchmarks-core.cloudfunctions.net/proxy_function - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + - name: Stage new files + run: | + git add . - name: Create diff and save to file run: | - if GIT_SHA_PARENT=$(git rev-parse HEAD^ 2>/dev/null); then - git diff $GIT_SHA_PARENT HEAD > cassette-diff-${{ github.event.pull_request.number }}-${{ github.sha }}.txt - else - echo "No parent commit to diff against. Skipping diff generation." - fi - + git diff --cached > cassette-diff-${{ github.run_number }}-${{ github.sha }}.txt || echo "No diff to create" - name: Upload diff as artifact uses: actions/upload-artifact@v3 with: name: cassette-diff - path: cassette-diff-${{ github.event.pull_request.number }}-${{ github.sha }}.txt + path: cassette-diff-${{ github.run_number }}-${{ github.sha }}.txt From 2f7c3224b3b032945f6f380140a6e3ad155b9b61 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Fri, 12 May 2023 06:07:10 -0700 Subject: [PATCH 24/26] basic proxy --- .github/workflows/ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fd379b3d3ba..ace002a8e62b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,8 +81,10 @@ jobs: run: | git diff --cached > cassette-diff-${{ github.run_number }}-${{ github.sha }}.txt || echo "No diff to create" - - name: Upload diff as artifact - uses: actions/upload-artifact@v3 - with: - name: cassette-diff - path: cassette-diff-${{ github.run_number }}-${{ github.sha }}.txt + - name: Create new branch and commit changes + run: | + git checkout -b Auto-GPT-cassettes || git checkout Auto-GPT-cassettes + git add cassette-diff-${{ github.run_number }}-${{ github.sha }}.txt + git commit -m "Add cassette diff" + git push origin Auto-GPT-cassettes + From f75fcc72ce20b5cacc240db20e6d35c07c1724bf Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Fri, 12 May 2023 06:12:35 -0700 Subject: [PATCH 25/26] basic proxy --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ace002a8e62b..e1d63f15c795 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,10 @@ jobs: - name: Create new branch and commit changes run: | git checkout -b Auto-GPT-cassettes || git checkout Auto-GPT-cassettes + git config user.email "github-actions@github.com" + git config user.name "GitHub Actions" git add cassette-diff-${{ github.run_number }}-${{ github.sha }}.txt git commit -m "Add cassette diff" git push origin Auto-GPT-cassettes + From 7d3196af75e3eea30aa299161ebae1c4a892a6fb Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 12 May 2023 13:14:04 +0000 Subject: [PATCH 26/26] Add cassette diff --- ...5fcc72ce20b5cacc240db20e6d35c07c1724bf.txt | 116 ++++++++++++++++++ .../test_write_file/test_write_file.yaml | 107 ++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100644 cassette-diff-353-f75fcc72ce20b5cacc240db20e6d35c07c1724bf.txt diff --git a/cassette-diff-353-f75fcc72ce20b5cacc240db20e6d35c07c1724bf.txt b/cassette-diff-353-f75fcc72ce20b5cacc240db20e6d35c07c1724bf.txt new file mode 100644 index 000000000000..d10fb8375c11 --- /dev/null +++ b/cassette-diff-353-f75fcc72ce20b5cacc240db20e6d35c07c1724bf.txt @@ -0,0 +1,116 @@ +diff --git a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml +index ef390a5..2bde595 100644 +--- a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml ++++ b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml +@@ -690,4 +690,111 @@ interactions: + status: + code: 200 + message: OK ++- request: ++ body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You ++ are write_to_file-GPT, an AI designed to use the write_to_file command to write ++ ''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete ++ command to complete the task.\nYour decisions must always be made independently ++ without seeking user assistance. Play to your strengths as an LLM and pursue ++ simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file ++ command to write ''Hello World'' into a file named \"hello_world.txt\".\n2. ++ Use the task_complete command to complete the task.\n3. Do not use andfsfdsy ++ other commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. ++ Your short term memory is short, so immediately save important information to ++ files.\n2. If you are unsure how you previously did something or want to recall ++ past events, thinking about similar events will help you remember.\n3. No user ++ assistance\n4. Exclusively use the commands listed in double quotes e.g. \"command ++ name\"\n\nCommands:\n1. append_to_file: Append to file, args: \"filename\": ++ \"\", \"text\": \"\"\n2. delete_file: Delete file, args: \"filename\": ++ \"\"\n3. list_files: List Files in Directory, args: \"directory\": ++ \"\"\n4. read_file: Read file, args: \"filename\": \"\"\n5. ++ write_to_file: Write to file, args: \"filename\": \"\", \"text\": ++ \"\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"\"\n7. ++ get_hyperlinks: Get text summary, args: \"url\": \"\"\n8. get_text_summary: ++ Get text summary, args: \"url\": \"\", \"question\": \"\"\n9. ++ list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT ++ Agent, args: \"key\": \"\", \"message\": \"\"\n11. start_agent: ++ Start GPT Agent, args: \"name\": \"\", \"task\": \"\", ++ \"prompt\": \"\"\n12. task_complete: Task Complete (Shutdown), args: ++ \"reason\": \"\"\n\nResources:\n1. Internet access for searches and ++ information gathering.\n2. Long Term memory management.\n3. GPT-3.5 powered ++ Agents for delegation of simple tasks.\n4. File output.\n\nPerformance Evaluation:\n1. ++ Continuously review and analyze your actions to ensure you are performing to ++ the best of your abilities.\n2. Constructively self-criticize your big-picture ++ behavior constantly.\n3. Reflect on past decisions and strategies to refine ++ your approach.\n4. Every command has a cost, so be smart and efficient. Aim ++ to complete tasks in the least number of steps.\n5. Write all code to a file.\n\nYou ++ should only respond in JSON format as described below \nResponse Format: \n{\n \"thoughts\": ++ {\n \"text\": \"thought\",\n \"reasoning\": \"reasoning\",\n \"plan\": ++ \"- short bulleted\\n- list that conveys\\n- long-term plan\",\n \"criticism\": ++ \"constructive self-criticism\",\n \"speak\": \"thoughts summary to say ++ to user\"\n },\n \"command\": {\n \"name\": \"command name\",\n \"args\": ++ {\n \"arg name\": \"value\"\n }\n }\n} \nEnsure the response ++ can be parsed by Python json.loads"}, {"role": "system", "content": "The current ++ time and date is Tue Jan 1 00:00:00 2000"}, {"role": "system", "content": "This ++ reminds you of these events from your past: \nI was created and nothing new ++ has happened."}, {"role": "user", "content": "Determine which next command to ++ use, and respond using the format specified above:"}, {"role": "assistant", ++ "content": "{\n \"thoughts\": {\n \"text\": \"I need to use the write_to_file ++ command to write ''Hello World'' into a file named ''hello_world.txt''.\",\n \"reasoning\": ++ \"The task requires me to write ''Hello World'' into a file named ''hello_world.txt'', ++ and the write_to_file command is the appropriate command for this task.\",\n \"plan\": ++ \"- Use the write_to_file command to write ''Hello World'' into a file named ++ ''hello_world.txt''.\",\n \"criticism\": \"I need to ensure that I use ++ the correct file name and text to write to the file.\",\n \"speak\": ++ \"I will use the write_to_file command to write ''Hello World'' into a file ++ named ''hello_world.txt''.\"\n },\n \"command\": {\n \"name\": ++ \"write_to_file\",\n \"args\": {\n \"filename\": \"hello_world.txt\",\n \"text\": ++ \"Hello World\"\n }\n }\n}"}, {"role": "system", "content": "Command ++ write_to_file returned: File written to successfully."}, {"role": "user", "content": ++ "Determine which next command to use, and respond using the format specified ++ above:"}], "temperature": 0, "max_tokens": 0}' ++ headers: ++ Accept: ++ - '*/*' ++ Accept-Encoding: ++ - gzip, deflate ++ Connection: ++ - keep-alive ++ Content-Length: ++ - '4660' ++ Content-Type: ++ - application/json ++ method: POST ++ uri: https://api.openai.com/v1/chat/completions ++ response: ++ body: ++ string: '{"id":"chatcmpl-7FMsZlCgaqEI6ebydODAT47LprpFA","object":"chat.completion","created":1683897223,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":1031,"completion_tokens":201,"total_tokens":1232},"choices":[{"message":{"role":"assistant","content":"{\n \"thoughts\": ++ {\n \"text\": \"I have successfully written ''Hello World'' into a ++ file named ''hello_world.txt''. The next step is to use the task_complete ++ command to complete the task.\",\n \"reasoning\": \"The task requires ++ me to write ''Hello World'' into a file named ''hello_world.txt'' and then ++ complete the task. Since I have successfully written to the file, the next ++ step is to use the task_complete command to complete the task.\",\n \"plan\": ++ \"- Use the task_complete command to complete the task.\",\n \"criticism\": ++ \"I need to ensure that I provide a valid reason for completing the task.\",\n \"speak\": ++ \"I will use the task_complete command to complete the task.\"\n },\n \"command\": ++ {\n \"name\": \"task_complete\",\n \"args\": {\n \"reason\": ++ \"I have successfully written ''Hello World'' into a file named ''hello_world.txt''.\"\n }\n }\n}"},"finish_reason":"stop","index":0}]}' ++ headers: ++ Alt-Svc: ++ - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 ++ - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 ++ Content-Length: ++ - '1221' ++ Content-Type: ++ - application/json ++ Date: ++ - Fri, 12 May 2023 13:14:02 GMT ++ Function-Execution-Id: ++ - ea42yneiu06g ++ Server: ++ - Google Frontend ++ X-Cloud-Trace-Context: ++ - 78cd3f6b10f6ed7cdd88e530a2abe3ee;o=1 ++ X-Powered-By: ++ - Express ++ status: ++ code: 200 ++ message: OK + version: 1 diff --git a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml index ef390a58a1d6..2bde595d7774 100644 --- a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml +++ b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml @@ -690,4 +690,111 @@ interactions: status: code: 200 message: OK +- request: + body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You + are write_to_file-GPT, an AI designed to use the write_to_file command to write + ''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete + command to complete the task.\nYour decisions must always be made independently + without seeking user assistance. Play to your strengths as an LLM and pursue + simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file + command to write ''Hello World'' into a file named \"hello_world.txt\".\n2. + Use the task_complete command to complete the task.\n3. Do not use andfsfdsy + other commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. + Your short term memory is short, so immediately save important information to + files.\n2. If you are unsure how you previously did something or want to recall + past events, thinking about similar events will help you remember.\n3. No user + assistance\n4. Exclusively use the commands listed in double quotes e.g. \"command + name\"\n\nCommands:\n1. append_to_file: Append to file, args: \"filename\": + \"\", \"text\": \"\"\n2. delete_file: Delete file, args: \"filename\": + \"\"\n3. list_files: List Files in Directory, args: \"directory\": + \"\"\n4. read_file: Read file, args: \"filename\": \"\"\n5. + write_to_file: Write to file, args: \"filename\": \"\", \"text\": + \"\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"\"\n7. + get_hyperlinks: Get text summary, args: \"url\": \"\"\n8. get_text_summary: + Get text summary, args: \"url\": \"\", \"question\": \"\"\n9. + list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT + Agent, args: \"key\": \"\", \"message\": \"\"\n11. start_agent: + Start GPT Agent, args: \"name\": \"\", \"task\": \"\", + \"prompt\": \"\"\n12. task_complete: Task Complete (Shutdown), args: + \"reason\": \"\"\n\nResources:\n1. Internet access for searches and + information gathering.\n2. Long Term memory management.\n3. GPT-3.5 powered + Agents for delegation of simple tasks.\n4. File output.\n\nPerformance Evaluation:\n1. + Continuously review and analyze your actions to ensure you are performing to + the best of your abilities.\n2. Constructively self-criticize your big-picture + behavior constantly.\n3. Reflect on past decisions and strategies to refine + your approach.\n4. Every command has a cost, so be smart and efficient. Aim + to complete tasks in the least number of steps.\n5. Write all code to a file.\n\nYou + should only respond in JSON format as described below \nResponse Format: \n{\n \"thoughts\": + {\n \"text\": \"thought\",\n \"reasoning\": \"reasoning\",\n \"plan\": + \"- short bulleted\\n- list that conveys\\n- long-term plan\",\n \"criticism\": + \"constructive self-criticism\",\n \"speak\": \"thoughts summary to say + to user\"\n },\n \"command\": {\n \"name\": \"command name\",\n \"args\": + {\n \"arg name\": \"value\"\n }\n }\n} \nEnsure the response + can be parsed by Python json.loads"}, {"role": "system", "content": "The current + time and date is Tue Jan 1 00:00:00 2000"}, {"role": "system", "content": "This + reminds you of these events from your past: \nI was created and nothing new + has happened."}, {"role": "user", "content": "Determine which next command to + use, and respond using the format specified above:"}, {"role": "assistant", + "content": "{\n \"thoughts\": {\n \"text\": \"I need to use the write_to_file + command to write ''Hello World'' into a file named ''hello_world.txt''.\",\n \"reasoning\": + \"The task requires me to write ''Hello World'' into a file named ''hello_world.txt'', + and the write_to_file command is the appropriate command for this task.\",\n \"plan\": + \"- Use the write_to_file command to write ''Hello World'' into a file named + ''hello_world.txt''.\",\n \"criticism\": \"I need to ensure that I use + the correct file name and text to write to the file.\",\n \"speak\": + \"I will use the write_to_file command to write ''Hello World'' into a file + named ''hello_world.txt''.\"\n },\n \"command\": {\n \"name\": + \"write_to_file\",\n \"args\": {\n \"filename\": \"hello_world.txt\",\n \"text\": + \"Hello World\"\n }\n }\n}"}, {"role": "system", "content": "Command + write_to_file returned: File written to successfully."}, {"role": "user", "content": + "Determine which next command to use, and respond using the format specified + above:"}], "temperature": 0, "max_tokens": 0}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '4660' + Content-Type: + - application/json + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: '{"id":"chatcmpl-7FMsZlCgaqEI6ebydODAT47LprpFA","object":"chat.completion","created":1683897223,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":1031,"completion_tokens":201,"total_tokens":1232},"choices":[{"message":{"role":"assistant","content":"{\n \"thoughts\": + {\n \"text\": \"I have successfully written ''Hello World'' into a + file named ''hello_world.txt''. The next step is to use the task_complete + command to complete the task.\",\n \"reasoning\": \"The task requires + me to write ''Hello World'' into a file named ''hello_world.txt'' and then + complete the task. Since I have successfully written to the file, the next + step is to use the task_complete command to complete the task.\",\n \"plan\": + \"- Use the task_complete command to complete the task.\",\n \"criticism\": + \"I need to ensure that I provide a valid reason for completing the task.\",\n \"speak\": + \"I will use the task_complete command to complete the task.\"\n },\n \"command\": + {\n \"name\": \"task_complete\",\n \"args\": {\n \"reason\": + \"I have successfully written ''Hello World'' into a file named ''hello_world.txt''.\"\n }\n }\n}"},"finish_reason":"stop","index":0}]}' + headers: + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + Content-Length: + - '1221' + Content-Type: + - application/json + Date: + - Fri, 12 May 2023 13:14:02 GMT + Function-Execution-Id: + - ea42yneiu06g + Server: + - Google Frontend + X-Cloud-Trace-Context: + - 78cd3f6b10f6ed7cdd88e530a2abe3ee;o=1 + X-Powered-By: + - Express + status: + code: 200 + message: OK version: 1