Skip to content

Commit

Permalink
Merge branch 'master' into draft-llamafile-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts authored Jul 3, 2024
2 parents 74923f1 + ecb054a commit 760d3a5
Show file tree
Hide file tree
Showing 116 changed files with 4,679 additions and 1,797 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/autogpt-builder-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: AutoGPT Builder CI

on:
push:
branches: [ master ]
paths:
- '.github/workflows/autogpt-builder-ci.yml'
- 'rnd/autogpt_builder/**'
pull_request:
paths:
- '.github/workflows/autogpt-builder-ci.yml'
- 'rnd/autogpt_builder/**'

defaults:
run:
shell: bash
working-directory: rnd/autogpt_builder

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '21'

- name: Install dependencies
run: |
npm install
- name: Run lint
run: |
npm run lint
2 changes: 1 addition & 1 deletion .github/workflows/autogpt-server-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: autogptserver-AppImage-${{ matrix.platform-os }}
path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.AppImage
path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/dist/*.AppImage
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ agbenchmark/reports/

# Nodejs
package-lock.json
package.json


# Allow for locally private items
# private
pri*
# ignore
ig*
.github_access_token
LICENSE.rtf
rnd/autogpt_server/settings.py
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ repos:
alias: pyright-benchmark
entry: poetry -C benchmark run pyright
args: [-p, benchmark, benchmark]
files: ^benchmark/(agbenchmark|tests)/
files: ^benchmark/(agbenchmark/|tests/|poetry\.lock$)
types: [file]
language: system
pass_filenames: false
Expand Down
32 changes: 16 additions & 16 deletions QUICKSTART.md → FORGE-QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

> For the complete getting started [tutorial series](https://aiedge.medium.com/autogpt-forge-e3de53cc58ec) <- click here
Welcome to the Quickstart Guide! This guide will walk you through the process of setting up and running your own AutoGPT agent. Whether you're a seasoned AI developer or just starting out, this guide will provide you with the necessary steps to jumpstart your journey in the world of AI development with AutoGPT.
Welcome to the Quickstart Guide! This guide will walk you through setting up, building, and running your own AutoGPT agent. Whether you're a seasoned AI developer or just starting out, this guide will provide you with the steps to jumpstart your journey in AI development with AutoGPT.

## System Requirements

This project supports Linux (Debian based), Mac, and Windows Subsystem for Linux (WSL). If you are using a Windows system, you will need to install WSL. You can find the installation instructions for WSL [here](https://learn.microsoft.com/en-us/windows/wsl/).
This project supports Linux (Debian-based), Mac, and Windows Subsystem for Linux (WSL). If you use a Windows system, you must install WSL. You can find the installation instructions for WSL [here](https://learn.microsoft.com/en-us/windows/wsl/).


## Getting Setup
Expand All @@ -18,11 +18,11 @@ This project supports Linux (Debian based), Mac, and Windows Subsystem for Linux
- In the top-right corner of the page, click Fork.

![Create Fork UI](docs/content/imgs/quickstart/002_fork.png)
- On the next page, select your GitHub account to create the fork under.
- On the next page, select your GitHub account to create the fork.
- Wait for the forking process to complete. You now have a copy of the repository in your GitHub account.

2. **Clone the Repository**
To clone the repository, you need to have Git installed on your system. If you don't have Git installed, you can download it from [here](https://git-scm.com/downloads). Once you have Git installed, follow these steps:
To clone the repository, you need to have Git installed on your system. If you don't have Git installed, download it from [here](https://git-scm.com/downloads). Once you have Git installed, follow these steps:
- Open your terminal.
- Navigate to the directory where you want to clone the repository.
- Run the git clone command for the fork you just created
Expand All @@ -34,11 +34,11 @@ This project supports Linux (Debian based), Mac, and Windows Subsystem for Linux
![Open the Project in your IDE](docs/content/imgs/quickstart/004_ide.png)

4. **Setup the Project**
Next we need to setup the required dependencies. We have a tool for helping you do all the tasks you need to on the repo.
Next, we need to set up the required dependencies. We have a tool to help you perform all the tasks on the repo.
It can be accessed by running the `run` command by typing `./run` in the terminal.

The first command you need to use is `./run setup` This will guide you through the process of setting up your system.
Initially you will get instructions for installing flutter, chrome and setting up your github access token like the following image:
The first command you need to use is `./run setup.` This will guide you through setting up your system.
Initially, you will get instructions for installing Flutter and Chrome and setting up your GitHub access token like the following image:

![Setup the Project](docs/content/imgs/quickstart/005_setup.png)

Expand All @@ -47,7 +47,7 @@ This project supports Linux (Debian based), Mac, and Windows Subsystem for Linux
If you're a Windows user and experience issues after installing WSL, follow the steps below to resolve them.

#### Update WSL
Run the following command in Powershell or Command Prompt to:
Run the following command in Powershell or Command Prompt:
1. Enable the optional WSL and Virtual Machine Platform components.
2. Download and install the latest Linux kernel.
3. Set WSL 2 as the default.
Expand All @@ -73,7 +73,7 @@ dos2unix ./run
After executing the above commands, running `./run setup` should work successfully.

#### Store Project Files within the WSL File System
If you continue to experience issues, consider storing your project files within the WSL file system instead of the Windows file system. This method avoids issues related to path translations and permissions and provides a more consistent development environment.
If you continue to experience issues, consider storing your project files within the WSL file system instead of the Windows file system. This method avoids path translations and permissions issues and provides a more consistent development environment.

You can keep running the command to get feedback on where you are up to with your setup.
When setup has been completed, the command will return an output like this:
Expand All @@ -83,7 +83,7 @@ When setup has been completed, the command will return an output like this:
## Creating Your Agent

After completing the setup, the next step is to create your agent template.
Execute the command `./run agent create YOUR_AGENT_NAME`, where `YOUR_AGENT_NAME` should be replaced with a name of your choosing.
Execute the command `./run agent create YOUR_AGENT_NAME`, where `YOUR_AGENT_NAME` should be replaced with your chosen name.

Tips for naming your agent:
* Give it its own unique name, or name it after yourself
Expand All @@ -101,21 +101,21 @@ This starts the agent on the URL: `http://localhost:8000/`

![Start the Agent](docs/content/imgs/quickstart/009_start_agent.png)

The frontend can be accessed from `http://localhost:8000/`, you will first need to login using either a google account or your github account.
The front end can be accessed from `http://localhost:8000/`; first, you must log in using either a Google account or your GitHub account.

![Login](docs/content/imgs/quickstart/010_login.png)

Upon logging in you will get a page that looks something like this. With your task history down the left hand side of the page and the 'chat' window to send tasks to your agent.
Upon logging in, you will get a page that looks something like this: your task history down the left-hand side of the page, and the 'chat' window to send tasks to your agent.

![Login](docs/content/imgs/quickstart/011_home.png)

When you have finished with your agent, or if you just need to restart it, use Ctl-C to end the session then you can re-run the start command.
When you have finished with your agent or just need to restart it, use Ctl-C to end the session. Then, you can re-run the start command.

If you are having issues and want to ensure the agent has been stopped there is a `./run agent stop` command which will kill the process using port 8000, which should be the agent.
If you are having issues and want to ensure the agent has been stopped, there is a `./run agent stop` command, which will kill the process using port 8000, which should be the agent.

## Benchmarking your Agent

The benchmarking system can also be accessed using the cli too:
The benchmarking system can also be accessed using the CLI too:

```bash
agpt % ./run benchmark
Expand Down Expand Up @@ -163,7 +163,7 @@ The benchmark has been split into different categories of skills you can test yo
![Login](docs/content/imgs/quickstart/012_tests.png)


Finally you can run the benchmark with
Finally, you can run the benchmark with

```bash
./run benchmark start YOUR_AGENT_NAME
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Be part of the revolution! **AutoGPT** is here to stay, at the forefront of AI i
&ensp;|&ensp;
**🚀 [Contributing](CONTRIBUTING.md)**
&ensp;|&ensp;
**🛠️ [Build your own Agent - Quickstart](QUICKSTART.md)**
**🛠️ [Build your own Agent - Quickstart](FORGE-QUICKSTART.md)**

## 🧱 Building blocks

Expand Down
Binary file added assets/gpt_dark_RGB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion autogpt/autogpt/agent_factory/configurators.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ def create_agent_state(
allow_fs_access=not app_config.restrict_to_workspace,
use_functions_api=app_config.openai_functions,
),
history=Agent.default_settings.history.copy(deep=True),
history=Agent.default_settings.history.model_copy(deep=True),
)
6 changes: 3 additions & 3 deletions autogpt/autogpt/agent_factory/profile_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class AgentProfileGeneratorConfiguration(SystemConfiguration):
required=True,
),
},
).dict()
).model_dump()
)


Expand All @@ -156,7 +156,7 @@ def __init__(
self._model_classification = model_classification
self._system_prompt_message = system_prompt
self._user_prompt_template = user_prompt_template
self._create_agent_function = CompletionModelFunction.parse_obj(
self._create_agent_function = CompletionModelFunction.model_validate(
create_agent_function
)

Expand Down Expand Up @@ -222,7 +222,7 @@ async def generate_agent_profile_for_task(
AIConfig: The AIConfig object tailored to the user's input
"""
agent_profile_generator = AgentProfileGenerator(
**AgentProfileGenerator.default_configuration.dict() # HACK
**AgentProfileGenerator.default_configuration.model_dump() # HACK
)

prompt = agent_profile_generator.build_prompt(task)
Expand Down
26 changes: 16 additions & 10 deletions autogpt/autogpt/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def __init__(
super().__init__(settings)

self.llm_provider = llm_provider
prompt_config = OneShotAgentPromptStrategy.default_configuration.copy(deep=True)
prompt_config = OneShotAgentPromptStrategy.default_configuration.model_copy(
deep=True
)
prompt_config.use_functions_api = (
settings.config.use_functions_api
# Anthropic currently doesn't support tools + prefilling :(
Expand All @@ -111,14 +113,18 @@ def __init__(

# Components
self.system = SystemComponent()
self.history = ActionHistoryComponent(
settings.history,
lambda x: self.llm_provider.count_tokens(x, self.llm.name),
llm_provider,
ActionHistoryConfiguration(
model_name=app_config.fast_llm, max_tokens=self.send_token_limit
),
).run_after(WatchdogComponent)
self.history = (
ActionHistoryComponent(
settings.history,
lambda x: self.llm_provider.count_tokens(x, self.llm.name),
llm_provider,
ActionHistoryConfiguration(
model_name=app_config.fast_llm, max_tokens=self.send_token_limit
),
)
.run_after(WatchdogComponent)
.run_after(SystemComponent)
)
if not app_config.noninteractive_mode:
self.user_interaction = UserInteractionComponent()
self.file_manager = FileManagerComponent(file_storage, settings)
Expand Down Expand Up @@ -156,7 +162,7 @@ async def propose_action(self) -> OneShotAgentActionProposal:
constraints = await self.run_pipeline(DirectiveProvider.get_constraints)
best_practices = await self.run_pipeline(DirectiveProvider.get_best_practices)

directives = self.state.directives.copy(deep=True)
directives = self.state.directives.model_copy(deep=True)
directives.resources += resources
directives.constraints += constraints
directives.best_practices += best_practices
Expand Down
25 changes: 14 additions & 11 deletions autogpt/autogpt/agents/prompt_strategies/one_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@

class AssistantThoughts(ModelWithSummary):
observations: str = Field(
..., description="Relevant observations from your last action (if any)"
description="Relevant observations from your last action (if any)"
)
text: str = Field(..., description="Thoughts")
reasoning: str = Field(..., description="Reasoning behind the thoughts")
self_criticism: str = Field(..., description="Constructive self-criticism")
plan: list[str] = Field(
..., description="Short list that conveys the long-term plan"
)
speak: str = Field(..., description="Summary of thoughts, to say to user")
text: str = Field(description="Thoughts")
reasoning: str = Field(description="Reasoning behind the thoughts")
self_criticism: str = Field(description="Constructive self-criticism")
plan: list[str] = Field(description="Short list that conveys the long-term plan")
speak: str = Field(description="Summary of thoughts, to say to user")

def summary(self) -> str:
return self.text
Expand Down Expand Up @@ -96,7 +94,9 @@ def __init__(
logger: Logger,
):
self.config = configuration
self.response_schema = JSONSchema.from_dict(OneShotAgentActionProposal.schema())
self.response_schema = JSONSchema.from_dict(
OneShotAgentActionProposal.model_json_schema()
)
self.logger = logger

@property
Expand Down Expand Up @@ -182,7 +182,7 @@ def build_system_prompt(
)

def response_format_instruction(self, use_functions_api: bool) -> tuple[str, str]:
response_schema = self.response_schema.copy(deep=True)
response_schema = self.response_schema.model_copy(deep=True)
assert response_schema.properties
if use_functions_api and "use_tool" in response_schema.properties:
del response_schema.properties["use_tool"]
Expand Down Expand Up @@ -274,5 +274,8 @@ def parse_response_content(
raise InvalidAgentResponseError("Assistant did not use a tool")
assistant_reply_dict["use_tool"] = response.tool_calls[0].function

parsed_response = OneShotAgentActionProposal.parse_obj(assistant_reply_dict)
parsed_response = OneShotAgentActionProposal.model_validate(
assistant_reply_dict
)
parsed_response.raw_message = response.copy()
return parsed_response
10 changes: 6 additions & 4 deletions autogpt/autogpt/app/agent_protocol_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Ste
""
if tool_result is None
else (
orjson.loads(tool_result.json())
orjson.loads(tool_result.model_dump_json())
if not isinstance(tool_result, ActionErrorResult)
else {
"error": str(tool_result.error),
Expand All @@ -327,7 +327,7 @@ async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Ste
if last_proposal and tool_result
else {}
),
**assistant_response.dict(),
**assistant_response.model_dump(),
}

task_cumulative_cost = agent.llm_provider.get_incurred_cost()
Expand Down Expand Up @@ -451,15 +451,17 @@ def _get_task_llm_provider(self, task: Task, step_id: str = "") -> MultiProvider
"""
task_llm_budget = self._task_budgets[task.task_id]

task_llm_provider_config = self.llm_provider._configuration.copy(deep=True)
task_llm_provider_config = self.llm_provider._configuration.model_copy(
deep=True
)
_extra_request_headers = task_llm_provider_config.extra_request_headers
_extra_request_headers["AP-TaskID"] = task.task_id
if step_id:
_extra_request_headers["AP-StepID"] = step_id
if task.additional_input and (user_id := task.additional_input.get("user_id")):
_extra_request_headers["AutoGPT-UserID"] = user_id

settings = self.llm_provider._settings.copy()
settings = self.llm_provider._settings.model_copy()
settings.budget = task_llm_budget
settings.configuration = task_llm_provider_config
task_llm_provider = self.llm_provider.__class__(
Expand Down
14 changes: 7 additions & 7 deletions autogpt/autogpt/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import os
import re
from pathlib import Path
from typing import Any, Optional, Union
from typing import Optional, Union

import forge
from forge.config.base import BaseConfig
from forge.llm.providers import CHAT_MODELS, ModelName
from forge.llm.providers.openai import OpenAICredentials, OpenAIModelName
from forge.logging.config import LoggingConfig
from forge.models.config import Configurable, UserConfigurable
from pydantic import SecretStr, validator
from pydantic import SecretStr, ValidationInfo, field_validator

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -91,15 +91,15 @@ class AppConfig(BaseConfig):
default=AZURE_CONFIG_FILE, from_env="AZURE_CONFIG_FILE"
)

@validator("openai_functions")
def validate_openai_functions(cls, v: bool, values: dict[str, Any]):
if v:
smart_llm = values["smart_llm"]
@field_validator("openai_functions")
def validate_openai_functions(cls, value: bool, info: ValidationInfo):
if value:
smart_llm = info.data["smart_llm"]
assert CHAT_MODELS[smart_llm].has_function_call_api, (
f"Model {smart_llm} does not support tool calling. "
"Please disable OPENAI_FUNCTIONS or choose a suitable model."
)
return v
return value


class ConfigBuilder(Configurable[AppConfig]):
Expand Down
Loading

0 comments on commit 760d3a5

Please sign in to comment.