Commit Graph

5249 Commits

Author SHA1 Message Date
Nicholas Tindle
5e89b8c6d1 Add all the new component docs to the site and do a tidy up of docs (#7098)
* feat: add all the new component docs to the site

* fix(docs): relative links and markdown warnings

* feat(docs): How to contribute to the docs as a docs section

* fix(docs): missed docs page for developer setup

* fix(docs): re-add configurations options

* fix(docs): bad link to components fixed

* fix(docs): bad link to components fixed

* ref(docs): reorder some items to make more sense

* fix(docs): bad indentation and duplicate block

* fix(docs): warning about out of date markdown extension

* fix(docs): broken links fixed

* fix(docs): markdown formatter complaints
2024-04-23 08:49:07 -05:00
Nicholas Tindle
fd3f8fa5fc fix(agent/setup): Fix installing ONNXRuntime on macOS on some architectures (#7022)
Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-04-23 12:35:56 +02:00
Fullstop000
86bdbb82b1 fix(agent): Support OpenAI Project API keys (#7099)
Amend regex expression in config.py that OpenAI API keys are validated against

Signed-off-by: Fullstop000 <fullstop1005@gmail.com>
2024-04-23 12:29:12 +02:00
Reinier van der Leer
898317c16c fix(agent): Full fix for CLI breakage introduced in cf00c33 2024-04-22 23:54:08 +02:00
Krzysztof Czerwinski
0704404344 fix(agent): Logging hotfix (#7096)
Fix cf00c33f90
2024-04-22 20:24:11 +02:00
Krzysztof Czerwinski
a74548d3cd feat(agent): Component-based Agents (#7054)
This incremental re-architecture unifies Agent code and plugins, so everything is component-based.

## Breaking changes

- Removed command categories and `DISABLED_COMMAND_CATEGORIES` environment variable. Use `DISABLED_COMMANDS` environment variable to disable individual commands.
- Changed `command` decorator; old-style commands are no longer supported. Implement `CommandProvider` on components instead.
- Removed `CommandRegistry`, now all commands are provided by components implementing `CommandProvider`.
- Removed `prompt_config` from `AgentSettings`.
- Removed plugin support: old plugins will no longer be loaded and executed.
- Removed `PromptScratchpad`, it was used by plugins and is no longer needed.
- Changed `ThoughtProcessOutput` from tuple to pydantic `BaseModel`.

## Other changes

- Created `AgentComponent`, protocols and logic to execute them.
- `BaseAgent` and `Agent` is now composed of components.
- Moved some logic from `BaseAgent` to `Agent`.
- Moved agent features and commands to components.
- Removed check if the same operation is about to be executed twice in a row.
- Removed file logging from `FileManagerComponent` (formerly `AgentFileManagerMixin`)
- Updated tests
- Added docs

See [Introduction](https://github.com/kcze/AutoGPT/blob/kpczerwinski/open-440-modular-agents/docs/content/AutoGPT/component%20agent/introduction.md) for more information.
2024-04-22 19:20:01 +02:00
Reinier van der Leer
6ff02677d2 fix(agent/core): Set OpenAIProvider._configuration.retries_per_request to 7 by default
10 was too much, caused multi-minute timeouts between retries
2024-04-22 18:46:28 +02:00
Reinier van der Leer
4db4ca08b2 refactor(agent): Tweak model_providers.schema for easier use
- Set default values for `ProviderBudget` / `ModelProviderBudget` fields
- Remove redundant field redefinitions on `ModelProviderBudget` class
- Change `ModelProviderUsage.update_usage(..)` and `ModelProviderBudget.update_usage_and_cost(..)` signatures for easier use
- Change `ModelProviderBudget.usage` from `ModelProviderUsage` to `defaultdict[str, ModelProviderUsage]` for per-model usage tracking
- Fix `ChatModelInfo`/`EmbeddingModelInfo` `service` attribute: rename from `llm_service` to match base class and fix types.
  This makes it unnecessary to specify the `service` field when creating a `ChatModelInfo` or `EmbeddingModelInfo` object.
- Use `defaultdict(ModelProviderBudget)` for task budget tracking in agent_protocol_server.py
2024-04-22 18:40:48 +02:00
Reinier van der Leer
7bb7c30842 feat(agent/core): Add max_output_tokens parameter to create_chat_completion interface 2024-04-22 17:47:15 +02:00
Reinier van der Leer
35ebb10378 refactor(agent): Add ChatModelProvider.get_available_models() and remove ApiManager 2024-04-22 17:44:49 +02:00
Reinier van der Leer
b77451bb3a fix(agent/tests): Remove useless tests in test_config.py 2024-04-22 17:26:02 +02:00
Reinier van der Leer
cf00c33f90 fix(agent): Fix debug logging & amend configure_logging for easier use 2024-04-22 17:14:22 +02:00
Reinier van der Leer
61adf58f4f lint(agent): Remove unused os import in file_storage/s3.py 2024-04-21 22:22:10 +02:00
Reinier van der Leer
452df39a52 feat(agent/core): Allow zero-argument instantiation of OpenAIProvider 2024-04-18 21:35:11 +02:00
Reinier van der Leer
49a08ba7db refactor(agent): Remove redundant parsing functions in config classes
Pydantic has built-in typecasting logic, so converting to Python builtin types and enums is done automatically.
2024-04-18 20:01:39 +02:00
Reinier van der Leer
7082e63b11 refactor(agent): Refactor & improve create_chat_completion (#7082)
* refactor(agent/core): Rearrange and split up `OpenAIProvider.create_chat_completion`
   - Rearrange to reduce complexity, improve separation/abstraction of concerns, and allow multiple points of failure during parsing
   - Move conversion from `ChatMessage` to `openai.types.ChatCompletionMessageParam` to `_get_chat_completion_args`
   - Move token usage and cost tracking boilerplate code to `_create_chat_completion`
   - Move tool call conversion/parsing to `_parse_assistant_tool_calls` (new)

* fix(agent/core): Handle decoding of function call arguments in `create_chat_completion`
   - Amend `model_providers.schema`: change type of `arguments` from `str` to `dict[str, Any]` on `AssistantFunctionCall` and `AssistantFunctionCallDict`
   - Implement robust and transparent parsing in `OpenAIProvider._parse_assistant_tool_calls`
   - Remove now unnecessary `json_loads` calls throughout codebase

* feat(agent/utils): Improve conditions and errors in `json_loads`
   - Include all decoding errors when raising a ValueError on decode failure
   - Use errors returned by `return_errors` instead of an error buffer
   - Fix check for decode failure
2024-04-16 10:38:49 +02:00
Reinier van der Leer
d7f00a996f feat(agent): Improve feedback in create_chat_completion parse-fix mechanism
Include error type in feedback message
2024-04-12 20:13:15 +02:00
Reinier van der Leer
cf033504c2 refactor(agent/utils): Clean up JSONSchema.validate_object signature & docstring 2024-04-12 20:11:20 +02:00
Krzysztof Czerwinski
e866a4ba04 fix(agent): Make Agent.save_state behave like save as (#7025)
* Make `Agent.save_state` behave like "save as"
   - Leave previously saved state untouched
   - Save agent state in new folder corresponding to new `agent_id`
   - Copy over workspace contents to new folder

* Add `copy` method to `FileStorage`

---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-04-12 12:41:02 +02:00
Reinier van der Leer
90f3c5e2d9 fix(ci): Disable annoying "PR too big" auto-message 2024-04-10 17:49:31 +02:00
Krzysztof Czerwinski
fb8ed0b46b fix(agent, forge): Conform web_search.py to duckduckgo_search v5 (#7046)
Update web_search command for both autogpt and forge to adjust for breaking change in v5 of duckduckgo_search,
update duckduckgo_search to ^5.0.0

---------

Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co>
2024-03-25 21:10:13 +01:00
Krzysztof Czerwinski
12640f7092 fix(agent, forge): Conform web_search.py to duckduckgo_search v5 (#7045)
Update `web_search` command for both autogpt and forge to adjust for breaking change in v5 of `duckduckgo_search`
2024-03-25 19:50:26 +01:00
Reinier van der Leer
5f9cc585b1 fix(agent): Fix type issue in test_s3_file_storage.py 2024-03-22 17:09:31 +01:00
Krzysztof Czerwinski
262771a69c fix(agent): Fix check when loading an existing agent (#7026)
Now the check also ensures the chosen agent number is within proper range
2024-03-22 14:55:49 +01:00
Matheus Oliveira
a1ffe15142 security(agent): Replace unsafe pyyaml loader with SafeLoader (#7035)
Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
2024-03-22 14:45:07 +01:00
Reinier van der Leer
30bc761391 ci(agent): Add macOS on M1 to AutoGPT CI matrix (#7041)
Use a `macos-14` runner to cover macOS on M1/arm64

- Add `macos-arm64` to `platform-os` matrix, and map it to `macos-14` runner
2024-03-22 14:26:16 +01:00
Reinier van der Leer
2a0e087461 ci(agent): Disable Python dependency caching on Windows
On Windows, unpacking cached dependencies takes longer than just installing them with `poetry install`. :')
2024-03-22 14:15:43 +01:00
Reinier van der Leer
828b81e5ef ci(agent): Fix Python dependency caching on macOS 2024-03-22 14:13:22 +01:00
Reinier van der Leer
fe3f835b3e fix(cli): Add timeout to agent start command
- Add `timeout` parameter (default 30) to `wait_until_conn_ready(..)` function
- Apply `isort` and `black` formatting
2024-03-22 13:25:23 +01:00
Reinier van der Leer
6dd76afad5 test(agent): Fix VCRpy request header filter for cross-platform cassette reuse (#7040)
- Move filtering logic from tests/vcr/__init__.py to tests/vcr/vcr_filter.py
- Ignore all `X-Stainless-*` headers for cassette matching, e.g. `X-Stainless-OS` and `X-Stainless-Runtime-Version`
- Remove deprecated OpenAI proxy logic
- Reorder methods in vcr_filter.py for readability
2024-03-22 13:08:15 +01:00
Reinier van der Leer
20041d65bf ci(agent): Fix Docker CI for PR runs from forks (vol. 2)
- Fix docker image tag format error when `secrets.DOCKER_USER` is not set
2024-03-22 12:57:29 +01:00
Krzysztof Czerwinski
028d2c319f feat(autogpt): Handle OpenAI API key exceptions gracefully (#6992)
* Better handle no API keys or invalid ones
* Handle exception and exit when invalid key is provided
* Handle any APIError exception when trying to get OpenAI models and exit

---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-03-22 12:55:40 +01:00
Reinier van der Leer
9e39937072 ci(agent): Fix Docker CI for PR runs from forks
- Disable 'Log in to Docker hub' step for `pull_request` runs
2024-03-22 12:50:58 +01:00
Reinier van der Leer
07a3c1848c test(agent): Update VCRpy cassettes
Add new entries for `test_dalle`
2024-03-22 11:24:29 +01:00
Reinier van der Leer
dde0c70a81 ci(agent): Matrix CI tests across Linux, macOS and Windows (#7029)
* Matrix the AutoGPT Python CI's `test` job across Ubuntu, macOS and Windows

   - Set up MinIO in a step rather than specifying it under `jobs[test].services`, because services are only supported on Linux runners

   - Add Windows version of step to install Poetry

   - Add macOS compatibility patches to 'Install Poetry (Unix)' and `setup_git_auth` steps
  
   **Caveats:**
   - **No Docker on macOS or Windows**
      * Windows comes with Docker but only supports running Windows containers, while we're mainly interested in using Linux containers for code execution and/or running auxiliary services.
      * [The macOS runner doesn't come with Docker](https://github.com/actions/runner-images/issues/17). Setting it up is possible but takes ~3-4 minutes, and the performance of the Colima engine is poor: a `docker pull` that takes 2 seconds on Linux takes 45 seconds on macOS.

   - **No S3 service available on Windows**
   It seems that running a background process [isn't possible on Windows](https://github.com/actions/runner/issues/598#issuecomment-2011890429), and neither is running Linux-based Docker containers.

* Add `autogpt-agent` and OS-specific flags to Codecov upload step

* Improve caching of Python dependencies in CI by changing the cache key
   - Include hash of `poetry.lock` instead of `pyproject.toml` in key
   - Remove date component from key; it was included to avoid getting stuck to old cached versions of packages when we were still using `requirements.txt`. With `poetry.lock` that is no longer a concern.

* Fix skip check in test_s3_file_storage.py
2024-03-21 21:15:46 +01:00
Krzysztof Czerwinski
76d6e61941 feat(agent): Implement more fault tolerant json_loads function (#7016)
* Implement syntax fault tolerant `json_loads` function using `dem3json`
   - Add `dem3json` dependency

* Replace `json.loads` by `json_loads` in places where malformed JSON may occur

* Move `json_utils.py` to `autogpt/core/utils`

* Add tests for `json_utils`

---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-03-21 18:11:36 +01:00
Reinier van der Leer
bca50310f6 fix(agent): Add check for Linux container support to is_docker_available 2024-03-20 21:46:09 +01:00
Reinier van der Leer
632686cfa5 fix(agent): Replace PromptToolkit with click.prompt
- Replace `session.prompt_async(..)` with `click.prompt(..)` in `clean_input` (autogpt/app/utils.py)
- Convert `clean_input` back to a synchronous function (and amend its usages accordingly)
- Remove `prompt-toolkit` dependency

This mitigates issues crashes in some shell environments on Windows.
2024-03-20 17:51:10 +01:00
Reinier van der Leer
1262b72f5c feat(agent): Allow boolean values for available param on @command 2024-03-20 17:24:11 +01:00
Reinier van der Leer
e985f7c105 test(agent): Add skip statements to test_execute_code.py for when Docker is not available 2024-03-20 17:23:14 +01:00
Reinier van der Leer
596487b9ad fix(agent): Windows-proof file_operations
Make file_operations and test_file_operations behave more consistently between Unix and Windows
2024-03-20 17:13:47 +01:00
Reinier van der Leer
a7c0440e9b fix(agent): Fix and windows-proof scan_plugins
- Improve error output for failure to load plugin
- Fix logic to determine qualified module name
- Use `importlib` rather than `__import__` magic function

This unbreaks `scan_plugins` on Windows.
2024-03-20 17:10:03 +01:00
Reinier van der Leer
03ffb50dcf ci(docs): Fix Netlify build ignore check 2024-03-20 11:49:41 +01:00
Krzysztof Czerwinski
e201f57861 feat(autogpt/cli): Display info if code execution is enabled (#6997)
Display if code execution is enabled or not on CLI startup, depending if Docker is available.
2024-03-18 20:09:56 +01:00
Krzysztof Czerwinski
fea62a77bc feat(autogpt/cli): Check if port is available before running server (#6996) 2024-03-16 12:10:43 +01:00
Sukka
dfad535dea fix(docs): Replace polyfill.io by Cloudflare mirror (#6952) 2024-03-15 13:01:30 +01:00
Nicholas Tindle
fa14865163 docs: Redirect AutoGPT users from Forge tutorial with warning (#7014)
Update forge/get-started.md
2024-03-15 11:38:52 +01:00
Krzysztof Czerwinski
ef35028ecb fix(autogpt/cli): Loop until non-empty task is provided by the user (#6995) 2024-03-14 18:06:58 +01:00
Reinier van der Leer
fb97e15e4b lint(agent): Remove unused import in autogpt/agents/base.py 2024-03-13 20:56:45 +01:00
Reinier van der Leer
da4f013a5d fix(agent): Fix & improve agent self-termination and resumption mechanism
- Add `AgentFinished` exception (subclass of `AgentTerminated`)
- Raise `AgentFinished` instead of `AgentTerminated` in `finish` method
- Remove resumption patch from PR #6990 in `BaseAgent`
- Clean up implementation of `finish` in `AgentProtocolServer`
- Add resumption mechanism in `run_auto_gpt` (main.py)
2024-03-13 20:42:12 +01:00