Commit Graph

448 Commits (release-autogpt-v0.5.x)

Author SHA1 Message Date
Reinier van der Leer 26324f2984
fix(agent): Update .env.template to match changes in 370615e 2024-04-26 19:35:09 +02:00
Reinier van der Leer ba5d0c8627
feat(agent): Add support for new `gpt-4-turbo` model and set as default `SMART_LLM` 2024-04-26 19:35:01 +02:00
Reinier van der Leer 7d727d1b54
fix(agent): Fix `OneShotAgentPromptStrategy` parser when using functions/tools API
Also:
- Improve error message when the LLM doesn't call any tools
2024-04-26 19:34:49 +02:00
Reinier van der Leer d2260bec5a
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-26 19:34:44 +02:00
Reinier van der Leer a88d5fca86
chore(agent): Update `duckduckgo-search` to v5.3.0 2024-04-26 19:33:32 +02:00
Reinier van der Leer 0ecb233101
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-26 19:33:25 +02:00
Nicholas Tindle 27e92dad4f
fix(agent/setup): Fix installing ONNXRuntime on macOS on some architectures (#7022)
Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-04-26 19:33:15 +02:00
Fullstop000 7430e011f1
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-26 19:33:08 +02:00
Reinier van der Leer 706bff4778
fix(agent): Full fix for CLI breakage introduced in cf00c33 2024-04-26 19:31:38 +02:00
Reinier van der Leer 3d10637a5d
Merge commit '6ff02677d2b30bec8edd5bafcb35e399e33217da' into release-autogpt-v0.5.x 2024-04-26 19:29:34 +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
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 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
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 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
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
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
Krzysztof Czerwinski fd2c26188f
fix(agent): Handle `action_history`-related exceptions gracefully (#6990)
Fix resume-related exceptions

- CLI: prevent resumed agent to register action on already existing one
- Server: prevent trying to json() command without result
2024-03-12 23:05:30 +01:00
Krzysztof Czerwinski 89cf0154f4
feat(autogpt/forge): Send exception details in agent protocol endpoints (#7005)
Send exception details in agent protocol endpoints

Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co>
2024-03-12 17:39:03 +01:00
Krzysztof Czerwinski cb1297ec74
fix(autogpt): Fix GCS and S3 root path issue (#7010)
Fix root path issue
2024-03-12 17:34:12 +01:00
Krzysztof Czerwinski 37904a0f80
feat(agent): Fully abstracted file storage access with `FileStorage` (#6931)
* Rename `FileWorkspace` to `FileStorage`
   - `autogpt.file_workspace` -> `autogpt.file_storage`
   - `LocalFileWorkspace` -> `LocalFileStorage`
   - `S3FileWorkspace` -> `S3FileStorage`
   - `GCSFileWorkspace` -> `GCSFileStorage`

* Rename `WORKSPACE_BACKEND` to `FILE_STORAGE_BACKEND`
* Rename `WORKSPACE_STORAGE_BUCKET` to `STORAGE_BUCKET`

* Rewrite `AgentManager` to use `FileStorage` rather than direct local file access
* Rename `AgentManager.retrieve_state(..)` method to `load_agent_state`
* Add docstrings to `AgentManager`

* Create `AgentFileManagerMixin` to replace `AgentFileManager`, `FileWorkspaceMixin`, `BaseAgent.attach_fs(..)`
* Replace `BaseAgentSettings.save_to_json_file(..)` method by `AgentFileManagerMixin.save_state()`
* Replace `BaseAgent.set_id(..)` method by `AgentFileManagerMixin.change_agent_id(..)`
* Remove `BaseAgentSettings.load_from_json_file(..)`
* Remove `AgentSettings.agent_data_dir`

* Update `AgentProtocolServer` to work with the new `FileStorage` system and `AgentFileManagerMixin`

* Make `agent_id` and `file_storage` parameters for creating an Agent:
   - `create_agent`, `configure_agent_with_state`, `_configure_agent`, `create_agent_state` in `autogpt.agent_factory.configurators`
   - `generate_agent_for_task` in `autogpt.agent_factory.generators`
   - `Agent.__init__(..)`
   - `BaseAgent.__init__(..)`
   - Initialize and pass in `file_storage` in `autogpt.app.main.run_auto_gpt(..)` and `autogpt.app.main.run_auto_gpt_server(..)`

* Add `clone_with_subroot` to `FileStorage`
* Add `exists`, `make_dir`, `delete_dir`, `rename`, `list_files`, `list_folders` methods to `FileStorage`

* Update `autogpt.commands.file_operations` to use `FileStorage` and `AgentFileManagerMixin` features

* Update tests for `FileStorage` implementations and usages
* Rename `workspace` fixture to `storage`
   * Update conftest.py
2024-03-11 22:26:14 +01:00
Reinier van der Leer 40f98f0f38
chore: Change `agbenchmark` to directory dependency in `autogpt` and `forge` (#6946)
Poetry recently released v1.8.x containing a fix for the issue we were having earlier:
https://github.com/python-poetry/poetry/issues/8548

This means unavailable optional directory dependencies no longer break the docker build.
2024-02-29 19:17:16 +01:00
Krzysztof Czerwinski 2c96f6125f
feat(agent): Catch & disallow duplicate commands in LLM response parser (#6937)
Raise in `parse_and_process_response` if the proposed operation is the same as the last executed one.
2024-02-29 18:51:13 +01:00