Skip to content

Commit

Permalink
Merge branch 'master' into feature/extract_dict_from_response-metho…
Browse files Browse the repository at this point in the history
…d's-update
  • Loading branch information
Pwuts authored Nov 16, 2023
2 parents 6ae8b76 + 787c71a commit 4fbf241
Show file tree
Hide file tree
Showing 53 changed files with 766 additions and 409 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ exclude =
.venv/*,
reports/*,
dist/*,
data/*,
4 changes: 2 additions & 2 deletions .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/stale@v8
with:
operations-per-run: 5000
# operations-per-run: 5000
stale-issue-message: >
This issue has automatically been marked as _stale_ because it has not had
any activity in the last 50 days. You can _unstale_ it by commenting or
Expand All @@ -28,7 +28,7 @@ jobs:
days-before-stale: 50
days-before-close: 10
# Do not touch meta issues:
exempt-issue-labels: meta
exempt-issue-labels: meta,fridge,project management
# Do not affect pull requests:
days-before-pr-stale: -1
days-before-pr-close: -1
63 changes: 57 additions & 6 deletions .github/workflows/hackathon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,29 @@ on:
agents:
description: "Agents to run (comma-separated)"
required: false
default: "ZEROAGPT_03" # Default agents if none are specified
default: "autogpt" # Default agents if none are specified

jobs:
matrix-setup:
runs-on: ubuntu-latest
# Service containers to run with `matrix-setup`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
env-name: ${{ steps.set-matrix.outputs.env-name }}
Expand All @@ -20,15 +38,15 @@ jobs:
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "::set-output name=env-name::production"
echo "::set-output name=matrix::[ 'ZEROAGPT_03', 'evo-ninja', 'gpt-engineer']"
echo "::set-output name=matrix::[ 'irrelevant']"
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
IFS=',' read -ra matrix_array <<< "${{ github.event.inputs.agents }}"
matrix_string="[ \"$(echo "${matrix_array[@]}" | sed 's/ /", "/g')\" ]"
echo "::set-output name=env-name::production"
echo "::set-output name=matrix::$matrix_string"
else
echo "::set-output name=env-name::testing"
echo "::set-output name=matrix::[ 'mini-agi' ]"
echo "::set-output name=matrix::[ 'irrelevant' ]"
fi
tests:
Expand All @@ -39,6 +57,23 @@ jobs:
min-python-version: "3.10"
name: "${{ matrix.agent-name }}"
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
timeout-minutes: 50
strategy:
fail-fast: false
Expand All @@ -49,6 +84,10 @@ jobs:
run: |
echo "Matrix Setup Environment Name: ${{ needs.matrix-setup.outputs.env-name }}"
- name: Check Docker Container
id: check
run: docker ps

- name: Checkout repository
uses: actions/checkout@v3
with:
Expand All @@ -70,16 +109,28 @@ jobs:
run: |
curl -sSL https://install.python-poetry.org | python -
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: v18.15

- name: Run benchmark
run: |
link=$(jq -r '.["github_repo_url"]' arena/$AGENT_NAME.json)
branch=$(jq -r '.["branch_to_benchmark"]' arena/$AGENT_NAME.json)
git clone "$link" -b "$branch" "$AGENT_NAME"
cd $AGENT_NAME
cp ./autogpts/$AGENT_NAME/.env.example ./autogpts/$AGENT_NAME/.env || echo "file not found"
./run agent start $AGENT_NAME
cd benchmark
cd ../benchmark
poetry install
poetry run agbenchmark
poetry run agbenchmark --no_dep
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AGENT_NAME: ${{ matrix.agent-name }}
SERP_API_KEY: ${{ secrets.SERP_API_KEY }}
SERPAPI_API_KEY: ${{ secrets.SERP_API_KEY }}
WEAVIATE_API_KEY: ${{ secrets.WEAVIATE_API_KEY }}
WEAVIATE_URL: ${{ secrets.WEAVIATE_URL }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GOOGLE_CUSTOM_SEARCH_ENGINE_ID: ${{ secrets.GOOGLE_CUSTOM_SEARCH_ENGINE_ID }}
AGENT_NAME: ${{ matrix.agent-name }}
4 changes: 2 additions & 2 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ If you continue to experience issues, consider storing your project files within

![Create an Agent](docs/content/imgs/quickstart/007_create_agent.png)

Upon creating your agent its time to offically enter the Arena!
Upon creating your agent its time to officially enter the Arena!
Do so by running `./run arena enter YOUR_AGENT_NAME`

![Enter the Arena](docs/content/imgs/quickstart/008_enter_arena.png)

> Note: for adavanced yours, create a new branch and create a file called YOUR_AGENT_NAME.json in the arena directory. Then commit this and create a PR to merge into the main repo. Only single file entries will be permitted. The json file needs the following format.
> Note: for advanced users, create a new branch and create a file called YOUR_AGENT_NAME.json in the arena directory. Then commit this and create a PR to merge into the main repo. Only single file entries will be permitted. The json file needs the following format.
```json
{
"github_repo_url": "https://github.com/Swiftyos/YourAgentName",
Expand Down
6 changes: 6 additions & 0 deletions arena/AGENT_JARVIS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/filipjakubowski/AutoGPT",
"timestamp": "2023-11-04T10:13:11.039444",
"commit_hash_to_benchmark": "78e92234d63a69b5471da0c0e62ce820a9109dd4",
"branch_to_benchmark": "master"
}
6 changes: 6 additions & 0 deletions arena/Ahmad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/JawadAbu/AutoGPT.git",
"timestamp": "2023-11-05T12:35:35.352028",
"commit_hash_to_benchmark": "a1d60878141116641ea864ef6de7ca6142e9534c",
"branch_to_benchmark": "master"
}
6 changes: 6 additions & 0 deletions arena/Susan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/CodeZeno/Susan",
"timestamp": "2023-11-03T11:29:28.704822",
"commit_hash_to_benchmark": "82fecfae1b4fb5d64050eefa77d8f028292aa8f3",
"branch_to_benchmark": "master"
}
6 changes: 6 additions & 0 deletions arena/autogpt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/Significant-Gravitas/AutoGPT",
"timestamp": "2023-11-15T07:22:09.723393",
"commit_hash_to_benchmark": "fa357dd13928baa4d1e30054bc75edc5d68b08f1",
"branch_to_benchmark": "master"
}
6 changes: 6 additions & 0 deletions arena/autogptagent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/YasienDwieb/AutoGPT",
"timestamp": "2023-11-04T21:13:17.223261",
"commit_hash_to_benchmark": "0b55de62dc61a33ccf944d80b6d55c730286e07d",
"branch_to_benchmark": "master"
}
6 changes: 6 additions & 0 deletions arena/bingoTesting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/bingotyty/AutoGPT",
"timestamp": "2023-11-06T04:16:38.612948",
"commit_hash_to_benchmark": "a1d60878141116641ea864ef6de7ca6142e9534c",
"branch_to_benchmark": "master"
}
6 changes: 6 additions & 0 deletions arena/qinghu3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/QingHu1227/AutoGPT.git",
"timestamp": "2023-11-06T04:11:34.227212",
"commit_hash_to_benchmark": "a1d60878141116641ea864ef6de7ca6142e9534c",
"branch_to_benchmark": "master"
}
6 changes: 6 additions & 0 deletions arena/songyalei.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github_repo_url": "https://github.com/songyalei/AutoGPT",
"timestamp": "2023-11-16T07:11:39.746384",
"commit_hash_to_benchmark": "fa357dd13928baa4d1e30054bc75edc5d68b08f1",
"branch_to_benchmark": "master"
}
13 changes: 9 additions & 4 deletions autogpts/autogpt/autogpt/agent_factory/profile_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class AgentProfileGeneratorConfiguration(SystemConfiguration):
"\n"
"Example Input:\n"
'"""Help me with marketing my business"""\n\n'
"Example Function Call:\n"
"Example Call:\n"
"```\n"
"{"
"[" # tool_calls
'{"type": "function", "function": {'
'"name": "create_agent",'
' "arguments": {'
'"name": "CMOGPT",'
Expand All @@ -65,7 +66,9 @@ class AgentProfileGeneratorConfiguration(SystemConfiguration):
"]" # constraints
"}" # directives
"}" # arguments
"}\n"
"}" # function
"}" # tool call
"]\n" # tool_calls
"```"
)
)
Expand Down Expand Up @@ -172,7 +175,9 @@ def parse_response_content(
"""
try:
arguments = json_loads(response_content["function_call"]["arguments"])
arguments = json_loads(
response_content["tool_calls"][0]["function"]["arguments"]
)
ai_profile = AIProfile(
ai_name=arguments.get("name"),
ai_role=arguments.get("description"),
Expand Down
13 changes: 7 additions & 6 deletions autogpts/autogpt/autogpt/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ def parse_and_process_response(
NEXT_ACTION_FILE_NAME,
)

self.event_history.register_action(
Action(
name=command_name,
args=arguments,
reasoning=assistant_reply_dict["thoughts"]["reasoning"],
if command_name:
self.event_history.register_action(
Action(
name=command_name,
args=arguments,
reasoning=assistant_reply_dict["thoughts"]["reasoning"],
)
)
)

return command_name, arguments, assistant_reply_dict

Expand Down
2 changes: 1 addition & 1 deletion autogpts/autogpt/autogpt/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BaseAgentConfiguration(SystemConfiguration):
default_cycle_instruction: str = DEFAULT_TRIGGERING_PROMPT
"""The default instruction passed to the AI for a thinking cycle."""

big_brain: bool = UserConfigurable(default=False)
big_brain: bool = UserConfigurable(default=True)
"""
Whether this agent uses the configured smart LLM (default) to think,
as opposed to the configured fast LLM. Enabling this disables hybrid mode.
Expand Down
30 changes: 20 additions & 10 deletions autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class OneShotAgentPromptConfiguration(SystemConfiguration):
"{resources}\n"
"\n"
"## Commands\n"
"You have access to the following commands:\n"
"These are the ONLY commands you can use."
" Any action you perform must be possible through one of these commands:\n"
"{commands}\n"
"\n"
"## Best practices\n"
Expand All @@ -62,6 +63,13 @@ class OneShotAgentPromptConfiguration(SystemConfiguration):
type=JSONSchema.Type.OBJECT,
required=True,
properties={
"observations": JSONSchema(
description=(
"Relevant observations from your last action (if any)"
),
type=JSONSchema.Type.STRING,
required=False,
),
"text": JSONSchema(
description="Thoughts",
type=JSONSchema.Type.STRING,
Expand All @@ -71,13 +79,13 @@ class OneShotAgentPromptConfiguration(SystemConfiguration):
type=JSONSchema.Type.STRING,
required=True,
),
"plan": JSONSchema(
description="Short markdown-style bullet list that conveys the long-term plan",
"self_criticism": JSONSchema(
description="Constructive self-criticism",
type=JSONSchema.Type.STRING,
required=True,
),
"criticism": JSONSchema(
description="Constructive self-criticism",
"plan": JSONSchema(
description="Short markdown-style bullet list that conveys the long-term plan",
type=JSONSchema.Type.STRING,
required=True,
),
Expand Down Expand Up @@ -308,7 +316,7 @@ def response_format_instruction(self, use_functions_api: bool) -> str:
)

return (
f"Respond strictly with a JSON object{' containing your thoughts, and a function_call specifying the next command to use' if use_functions_api else ''}. "
f"Respond strictly with a JSON object{' containing your thoughts, and a tool_call specifying the next command to use' if use_functions_api else ''}. "
"The JSON object should be compatible with the TypeScript type `Response` from the following:\n"
f"{response_format}"
)
Expand Down Expand Up @@ -423,11 +431,13 @@ def extract_command(
Exception: If any other error occurs
"""
if use_openai_functions_api:
if "function_call" not in assistant_reply:
raise InvalidAgentResponseError("No 'function_call' in assistant reply")
if not assistant_reply.get("tool_calls"):
raise InvalidAgentResponseError("No 'tool_calls' in assistant reply")
assistant_reply_json["command"] = {
"name": assistant_reply["function_call"]["name"],
"args": json.loads(assistant_reply["function_call"]["arguments"]),
"name": assistant_reply["tool_calls"][0]["function"]["name"],
"args": json.loads(
assistant_reply["tool_calls"][0]["function"]["arguments"]
),
}
try:
if not isinstance(assistant_reply_json, dict):
Expand Down
12 changes: 5 additions & 7 deletions autogpts/autogpt/autogpt/app/agent_protocol_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ async def start(self, port: int = 8000, router: APIRouter = base_router):

# Add CORS middleware
origins = [
"http://localhost:5000",
"http://127.0.0.1:5000",
"http://localhost:8000",
"http://127.0.0.1:8000",
"http://localhost:8080",
"http://127.0.0.1:8080",
"*",
# Add any other origins you want to whitelist
]

Expand Down Expand Up @@ -226,6 +221,8 @@ async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Ste
if execute_command == ask_user.__name__: # HACK
execute_result = ActionSuccessResult(outputs=user_input)
agent.event_history.register_result(execute_result)
elif not execute_command:
execute_result = None
elif execute_approved:
step = await self.db.update_step(
task_id=task_id,
Expand Down Expand Up @@ -262,7 +259,8 @@ async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Ste
output = (
(
f"Command `{execute_command}({fmt_kwargs(execute_command_args)})` returned:"
f" {execute_result}\n\n"
+ ("\n\n" if "\n" in str(execute_result) else " ")
+ f"{execute_result}\n\n"
)
if execute_command_args and execute_command != "ask_user"
else ""
Expand Down
Loading

0 comments on commit 4fbf241

Please sign in to comment.