Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/add-cassettes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Merge and Commit Cassettes

on:
pull_request_target:
types:
- closed

jobs:
update-cassettes:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # This is necessary to fetch all branches and tags

- name: Download diff artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: Python CI
name: cassette-diff
path: .
pr: ${{ github.event.pull_request.number }}
34 changes: 24 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -43,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:
Expand All @@ -58,6 +53,8 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand All @@ -71,9 +68,26 @@ 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: Stage new files
run: |
git add .

- name: Create diff and save to file
run: |
git diff --cached > cassette-diff-${{ github.run_number }}-${{ github.sha }}.txt || echo "No diff to create"

- 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


- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
2 changes: 2 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ jobs:

run: .github/workflows/scripts/docker-release-summary.sh >> $GITHUB_STEP_SUMMARY
continue-on-error: true
# rand
# rand
4 changes: 1 addition & 3 deletions autogpt/prompts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

CFG = Config()

DEFAULT_TRIGGERING_PROMPT = (
"Determine 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:
Expand Down
116 changes: 116 additions & 0 deletions cassette-diff-353-f75fcc72ce20b5cacc240db20e6d35c07c1724bf.txt
Original file line number Diff line number Diff line change
@@ -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\":
+ \"<filename>\", \"text\": \"<text>\"\n2. delete_file: Delete file, args: \"filename\":
+ \"<filename>\"\n3. list_files: List Files in Directory, args: \"directory\":
+ \"<directory>\"\n4. read_file: Read file, args: \"filename\": \"<filename>\"\n5.
+ write_to_file: Write to file, args: \"filename\": \"<filename>\", \"text\":
+ \"<text>\"\n6. delete_agent: Delete GPT Agent, args: \"key\": \"<key>\"\n7.
+ get_hyperlinks: Get text summary, args: \"url\": \"<url>\"\n8. get_text_summary:
+ Get text summary, args: \"url\": \"<url>\", \"question\": \"<question>\"\n9.
+ list_agents: List GPT Agents, args: () -> str\n10. message_agent: Message GPT
+ Agent, args: \"key\": \"<key>\", \"message\": \"<message>\"\n11. start_agent:
+ Start GPT Agent, args: \"name\": \"<name>\", \"task\": \"<short_task_desc>\",
+ \"prompt\": \"<prompt>\"\n12. task_complete: Task Complete (Shutdown), args:
+ \"reason\": \"<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
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path

import pytest
Expand All @@ -9,6 +10,8 @@

pytest_plugins = ["tests.integration.agent_factory"]

PROXY = os.environ.get("PROXY")


@pytest.fixture()
def workspace_root(tmp_path: Path) -> Path:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/agent_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import openai
import pytest

from tests.conftest import PROXY
from tests.vcr.vcr_filter import before_record_request, before_record_response


Expand All @@ -17,5 +19,25 @@ 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
Loading