Commit Graph

5468 Commits (6ffa644fb636b196ae3154276c4f099b0d244534)

Author SHA1 Message Date
Reinier van der Leer 9bac6f4ce2
feat(agent/scripts): Add git_log_to_release_notes.py
This script asks the user to choose two git refs, and then writes release notes for the diff between those two refs.
2024-05-04 20:55:42 +02:00
Reinier van der Leer 39c46ef6be
feat(agent/core): Add Anthropic Claude 3 support (#7085)
- feat(agent/core): Add `AnthropicProvider`
  - Add `ANTHROPIC_API_KEY` to .env.template and docs

  Notable differences in logic compared to `OpenAIProvider`:
  - Merges subsequent user messages in `AnthropicProvider._get_chat_completion_args`
  - Merges and extracts all system messages into `system` parameter in `AnthropicProvider._get_chat_completion_args`
  - Supports prefill; merges prefill content (if any) into generated response

- Prompt changes to improve compatibility with `AnthropicProvider`
  Anthropic has a slightly different API compared to OpenAI, and has much stricter input validation. E.g. Anthropic only supports a single `system` prompt, where OpenAI allows multiple `system` messages. Anthropic also forbids sequences of multiple `user` or `assistant` messages and requires that messages alternate between roles.
  - Move response format instruction from separate message into main system prompt
  - Fix clock message format
  - Add pre-fill to `OneShot` generated prompt

- refactor(agent/core): Tweak `model_providers.schema`
  - Simplify `ModelProviderUsage`
     - Remove attribute `total_tokens` as it is always equal to `prompt_tokens + completion_tokens`
     - Modify signature of `update_usage(..)`; no longer requires a full `ModelResponse` object as input
  - Improve `ModelProviderBudget`
     - Change type of attribute `usage` to `defaultdict[str, ModelProviderUsage]` -> allow per-model usage tracking
     - Modify signature of `update_usage_and_cost(..)`; no longer requires a full `ModelResponse` object as input
     - Allow `ModelProviderBudget` zero-argument instantiation
  - Fix type of `AssistantChatMessage.role` to match `ChatMessage.role` (str -> `ChatMessage.Role`)
  - Add shared attributes and constructor to `ModelProvider` base class
  - Add `max_output_tokens` parameter to `create_chat_completion` interface
  - Add pre-filling as a global feature
    - Add `prefill_response` field to `ChatPrompt` model
    - Add `prefill_response` parameter to `create_chat_completion` interface
  - Add `ChatModelProvider.get_available_models()` and remove `ApiManager`
  - Remove unused `OpenAIChatParser` typedef in openai.py
  - Remove redundant `budget` attribute definition on `OpenAISettings`
  - Remove unnecessary `usage` in `OpenAIProvider` > `default_settings` > `budget`

- feat(agent): Allow use of any available LLM provider through `MultiProvider`
  - Add `MultiProvider` (`model_providers.multi`)
  - Replace all references to / uses of `OpenAIProvider` with `MultiProvider`
  - Change type of `Config.smart_llm` and `Config.fast_llm` from `str` to `ModelName`

- feat(agent/core): Validate function call arguments in `create_chat_completion`
    - Add `validate_call` method to `CompletionModelFunction` in `model_providers.schema`
    - Add `validate_tool_calls` utility function in `model_providers.utils`
    - Add tool call validation step to `create_chat_completion` in `OpenAIProvider` and `AnthropicProvider`
    - Remove (now redundant) command argument validation logic in agent.py and models/command.py

- refactor(agent): Rename `get_openai_command_specs` to `function_specs_from_commands`
2024-05-04 20:33:25 +02:00
Nicholas Tindle 78d83bb3ce
Create .pr_agent.toml 2024-05-04 09:38:37 -05:00
Reinier van der Leer d57ccf7ec9
fix(agent): Fix `open_file` and `open_folder` commands
They weren't ported properly to the new component-based architecture: the `@sanitize_path` decorator was removed, causing path handling issues.
2024-05-02 02:41:03 +02:00
Reinier van der Leer ada2e19829
refactor(agent)!: Use Pydantic models for `Agent` process output (#7116)
* Introduce `BaseAgentActionProposal`, `OneShotAgentActionProposal`, and `AssistantThoughts` models to replace `ThoughtProcessResponse`, `DEFAULT_RESPONSE_SCHEMA`
* Refactor and clean up code because now we don't need to do as much type checking everywhere
* Tweak `OneShot` response format instruction

Granular:

* `autogpt.agents.prompt_strategies.one_shot`
  * Replace ThoughtProcessResponse`, `DEFAULT_RESPONSE_SCHEMA` and parsing logic by `AssistantThoughts` and `OneShotAgentActionProposal`
  * (TANGENTIAL) Move response format instruction into main system prompt message
  * (TANGENTIAL) Adjust response format instruction

* `autogpt.agents.base`
  * Add `BaseAgentActionProposal` base model -> replace `ThoughtProcessOutput`
  * Change signature of `execute` method to accept `BaseAgentActionProposal` instead of separate `command_name` and `command_args`
  * Add `do_not_execute(proposal, feedback)` abstract method, replacing `execute("human_feedback", ..., feedback)`

* Move `history` definition from `BaseAgentSettings` to `AgentSettings` (the only place where it's used anyway)

* `autogpt.models`
  * Add `.utils` > `ModelWithSummary` base model
  * Make the models in `.action_history` (`Episode`, `EpisodicActionHistory`) generic with a type parameter for the type of `Episode.action`

* `autogpt.core.resource.model_providers.schema`
  * Add `__str__` to `AssistantFunctionCall` which pretty-prints the function call

All other changes are a direct result of the changes above.

## BREAKING CHANGE:
* Due to the change in `autogpt.models.action_history`, the application after this change will be unable to load/resume agents from before this change and vice versa.
* The `additional_output` field in the response of `execute_step` has changed slightly:
  * Type of `.thoughts.plan` has changed from `str` to `list[str]`
  * `.command` -> `.use_tool`
  * `.command.args` -> `.use_tool.arguments`
2024-05-02 00:43:11 +02:00
Reinier van der Leer a7c7a5e18b
fix(agent): Fix `execute_python_file` on local storage
It's still broken for remote/cloud storage.
2024-04-30 15:26:41 +02:00
Reinier van der Leer 180de0c9a9
feat(agent/core): Support referenced types in `JSONSchema.from_dict` 2024-04-30 12:23:15 +02:00
Reinier van der Leer 8f0d5c73b3
fix(agent/core): Format parse errors for log statement in `OpenAIProvider.create_chat_completion` 2024-04-30 11:59:34 +02:00
王苏云 3b00e8229c
Fix ImportError for validate_yaml_file function (#7110)
* Fix ImportError for validate_yaml_file function

* Fix ImportError for validate_yaml_file function

---------

Co-authored-by: suyun <sylearn@foxmail.com>
Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co>
2024-04-29 10:41:30 -05:00
Krzysztof Czerwinski e97726cde3
fix(autogpt): Revert line in `poetry.lock` (#7113)
Revert line in `poetry.lock` to from before https://github.com/Significant-Gravitas/AutoGPT/pull/7097
2024-04-29 17:37:20 +02:00
Krzysztof Czerwinski d38e8b8f6c
clean(autogpt): Remove old plugin system (#7097)
### Background

Follow up after merging https://github.com/Significant-Gravitas/AutoGPT/pull/7054, old plugins will no longer be used.

### Changes 🏗️

- Removed all dead code needed to load and use plugins.
- Removed `auto-gpt-plugin-template` dependency
- Removed `rev=` from `autogpt-forge` dependency (the set `rev` had incompatible `duckduckgo-search` versions)
- Kept `--install-plugin-deps` CLI option and dead code associated (may be needed for new plugins)
2024-04-28 21:10:53 +02:00
Reinier van der Leer 0014e2ac14
fix(agent): Update .env.template to match changes in 370615e 2024-04-26 19:25:33 +02:00
Reinier van der Leer 370615e5e4
feat(agent): Add support for new `gpt-4-turbo` model and set as default `SMART_LLM` 2024-04-26 19:15:00 +02:00
Reinier van der Leer f93c743d03
fix(agent): Fix `OneShotAgentPromptStrategy` parser when using functions/tools API
Also:
- Improve error message when the LLM doesn't call any tools
2024-04-24 18:59:13 +02:00
Reinier van der Leer 6add645597
fix(agent): Expand failure check in `json_loads(..)`
Not only check if the resulting object is `demjson3.undefined`, but also `demjson3.syntax_error`.
2024-04-24 18:57:50 +02:00
Reinier van der Leer bdda3a6698
fix(agent): Omit `EventHistory` progress message if empty
Also add a heading to the progress section
2024-04-24 18:56:43 +02:00
Reinier van der Leer 126aacb2e3
feat(agent/cli): Speed up loading of saved agents
O(n) to O(1) by removing individual `.exists(dir / "state.json")` calls and using `.list_files()` instead of `.list_folders()`
2024-04-24 18:54:24 +02:00
Reinier van der Leer 1afc8e40df
chore(agent): Update `duckduckgo-search` to v5.3.0 2024-04-24 17:57:32 +02:00
Reinier van der Leer 9543e5d6ac
fix(agent): Fix crash when `LOG_FORMAT=structured_google_cloud`
Another piece of fallout from cf00c33 - fix(agent): Fix debug logging & amend configure_logging for easier use
2024-04-24 13:56:35 +02:00
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