Commit Graph

334 Commits (remove-git-from-cli)

Author SHA1 Message Date
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 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
Reinier van der Leer 5047fd9fce
lint(agent): Fix linting error in api_manager.py 2024-02-29 18:42:16 +01:00
edwardsp 50e5ea4e54
fix(agent/llm): Fix support for AzureOpenAI (#6927)
* Fix unmasking of `azure_endpoint` in `OpenAICredentials.get_api_access_kwargs()`
* Amend `ApiManager.get_models` to use `AzureOpenAI` client when `api_type` is set to `azure`

---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-02-29 18:35:06 +01:00
Reinier van der Leer ce45c9b267
fix(agent/security): Make CORS more restrictive and configurable
* By default, allow requests originating from http://localhost:{AP_SERVER_PORT} instead of all origins
* Allow configuring allowed CORS origins through `AP_SERVER_CORS_ALLOWED_ORIGINS`
2024-02-28 21:14:49 +01:00
Krzysztof Czerwinski 1881f4f7cd
feat(agent): Gracefully handle failure to load non-existing agent (#6938) 2024-02-28 19:18:57 +01:00
Krzysztof Czerwinski 30762c211e
fix(agent/execute_code): Disable code execution commands when Docker is unavailable (#6888) 2024-02-28 19:16:02 +01:00
Elias Hohl 5090f55eba
fix(agent/security): Mitigate shell injection vulnerabilities (#6903)
* Mitigate shell injection in `MacOSTTS._speech` implementation

* Mitigate shell command control bypassing in `execute_shell` and `execute_shell_popen` commands
   - Improve implementation and docstring of `validate_command` function

---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-02-27 13:31:23 +01:00
Reinier van der Leer 64f48df62d
chore(agent/llm): Update model alias `gpt-3.5-turbo` -> `gpt-3.5-turbo-0125` 2024-02-20 17:13:51 +01:00
Reinier van der Leer 7dd97f2f74
fix(agent/browser): Print descriptive error if ChromeDriver install fails
We have been seeing `AttributeError: 'NoneType' object has no attribute 'split'` in Sentry.
According to https://github.com/SergeyPirogov/webdriver_manager/issues/649, this occurs
when Chrome is not installed, or when no suitable ChromeDriver version is available for
the installed version of Chrome.
Instead of the `AttributeError`, we can print a better message for the agent and user to help them fix the issue.

---
Co-authored-by: kcze <kpczerwinski@gmail.com>
2024-02-20 14:04:15 +01:00
Reinier van der Leer 8e464c53a8
fix(agent/llm): Include `id` in tool_calls in prompt
OpenAI requires the `id` property on tool calls in assistant messages.
We weren't storing it in the `AssistantChatMessage` that is created from the LLM's response,
causing an error when adding those messages back to the prompt.

Fix:
* Add `id` to `AssistantToolCall` and `AssistantToolCallDict` types in model_providers/schema.py
* Amend `_tool_calls_compat_extract_calls` to generate an ID for extracted tool calls

---
Co-authored-by: kcze <kpczerwinski@gmail.com>
2024-02-20 13:28:57 +01:00
Reinier van der Leer 7689a51f53
fix(autogpt/llm): Omit `AssistantChatMessage.tool_calls` if no tool calls are present
OpenAI likes neither `tool_calls=[]` nor `tool_calls=None`. If no `tool_calls` are in the message, the key must be omitted.

This partially reverts commit 67bafa6302.

---

Co-authored-by: kcze <kpczerwinski@gmail.com>
2024-02-20 13:04:55 +01:00
Thunder Drag 49a6d68200
fix(agent/setup): Fix revising constraints and best practices (#6777)
In a `for item in list` loop, removing items from the list while iterating causes it to skip over the next item. Fix: refactor `interactively_revise_ai_settings` routine to use while loop for iterating over constraints, resources, and best practices.

---------

Co-authored-by: Kripanshu Jindal <polaris@Polaris.local>
Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-02-20 11:06:30 +01:00
Reinier van der Leer fb63bf4425
chore: Update `agbenchmark` dependency for agent and forge 2024-02-19 17:11:19 +01:00
Reinier van der Leer c339c6b54f
chore: Update `agbenchmark` dependency for agent and forge 2024-02-18 17:37:03 +01:00
Reinier van der Leer 6bc83e925c
chore: Update `agbenchmark` dependency for agent and forge 2024-02-17 15:56:33 +01:00
Reinier van der Leer 15024fb5a1
chore: Update `agbenchmark` dependency for agent and forge 2024-02-17 14:18:02 +01:00
Reinier van der Leer 5f0764b65c
chore: Update agbenchmark dependency for agent and forge 2024-02-16 19:07:37 +01:00
Reinier van der Leer 83fcd9ad16
chore: Update `agbenchmark` dependency for agent and forge 2024-02-16 18:44:58 +01:00
Reinier van der Leer 666a5a8777
feat(agent/serve): Report task cost through `Step.additional_output`
- Added `task_cumulative_cost` and `task_total_cost` attributes to the `Step.additional_output` in the `AgentProtocolServer.execute_step` endpoint.
- Updated `agbenchmark` dependency in Agent and Forge
2024-02-16 18:19:04 +01:00
Reinier van der Leer 992b8874fc
chore: Update `agbenchmark` dependency for agent and forge 2024-02-16 17:22:58 +01:00
Reinier van der Leer 650a701317
chore: Update `agbenchmark` dependency for agent and forge 2024-02-15 18:19:06 +01:00
Reinier van der Leer fd5730b04a
feat(agent/telemetry): Distinguish between `production` and `dev` environment based on VCS state
- Added a helper function `.app.utils.vcs_state_diverges_from_master()`. This function determines whether the relevant part of the codebase diverges from our `master`.
- Updated `.app.telemetry._setup_sentry()` to determine the default environment name using `vcs_state_diverges_from_master`.
2024-02-15 16:00:30 +01:00
Reinier van der Leer b7f08cd0f7
feat(agent/telemetry): Enable performance tracing & update opt-in prompt accordingly 2024-02-15 14:46:36 +01:00
Reinier van der Leer a9b7b175ff
fix(agent/profile_generator): Improve robustness by leveraging `create_chat_completion`'s parse handling 2024-02-15 11:48:07 +01:00
Reinier van der Leer 6a09a44ef7
lint(agent): Fix telemetry.py linting error & formatting 2024-02-14 23:31:35 +01:00
Toran Bruce Richards 32a627eda9 Add Privacy Policy link to telementry opt-in. 2024-02-14 16:42:34 +00:00
Reinier van der Leer 67bafa6302
fix(autogpt/llm): `AssistantChatMessage.tool_calls` default `[]` instead of `None`
OpenAI ChatCompletion calls fail when `tool_calls = None`. This issue came to light after 22aba6d.
2024-02-14 14:34:04 +01:00
Reinier van der Leer ae197fc85f
feat(agent/telemetry): Distinguish between users
This allows us to get a much better sense of how many users actually experience issues, and how issue occurrence is distributed among users.
2024-02-14 11:50:45 +01:00
Reinier van der Leer 22aba6dd8a
fix(agent/llm): Include bad response in parse-fix prompt in `OpenAIProvider.create_chat_completion`
Apparently I forgot to also append the response that caused the parse error before throwing it back to the LLM and letting it fix its mistake(s).
2024-02-14 11:20:31 +01:00
Reinier van der Leer e7698a4610
chore(agent): Update `forge` and `agbenchmark` dependencies 2024-02-14 01:32:28 +01:00
Reinier van der Leer bb7f5abc6c
fix(agent/text_processing): Fix `extract_information` LLM response parsing
OpenAI's newest models return JSON with markdown fences around it, breaking the `json.loads` parser.

This commit adds an `extract_list_from_response` function to json_utils/utilities.py and uses this function to replace `json.loads` in `_process_text`.
2024-02-13 18:28:17 +01:00
Reinier van der Leer 393d6b97e6
feat(agent): Add Sentry integration for telemetry
* Add Sentry integration for telemetry
   - Add `sentry_sdk` dependency
   - Add setup logic and config flow using `TELEMETRY_OPT_IN` environment variable
      - Add app/telemetry.py with `setup_telemetry` helper routine
      - Call `setup_telemetry` in `cli()` in app/cli.py
      - Add `TELEMETRY_OPT_IN` to .env.template
      - Add helper function `env_file_exists` and routine `set_env_config_value` to app/utils.py
         - Add unit tests for `set_env_config_value` in test_utils.py
      - Add prompt to startup to ask whether the user wants to enable telemetry if the env variable isn't set

* Add `capture_exception` statements for LLM parsing errors and command failures
2024-02-13 18:10:52 +01:00
Reinier van der Leer 3b8d63dfb6
chore(agent): Update autogpt-forge and agbenchmark dependencies to propagate dependency updates
This also indirectly updates `python-multipart` and fixes "python-multipart vulnerable to Content-Type Header ReDoS" https://github.com/Significant-Gravitas/AutoGPT/security/dependabot/57
2024-02-13 13:24:24 +01:00
Reinier van der Leer cc585a014f
chore(agent): Update aiohttp and fastapi dependencies to mitigate vulnerabilities
Addressed vulnerabilities:

- python-multipart vulnerable to Content-Type Header ReDoS - https://github.com/Significant-Gravitas/AutoGPT/security/dependabot/57
   Dependants:
   - FastAPI Content-Type Header ReDoS - https://github.com/Significant-Gravitas/AutoGPT/security/dependabot/54
   - Starlette Content-Type Header ReDoS - https://github.com/Significant-Gravitas/AutoGPT/security/dependabot/50

- aiohttp is vulnerable to directory traversal - https://github.com/Significant-Gravitas/AutoGPT/security/dependabot/44
- aiohttp's HTTP parser (the python one, not llhttp) still overly lenient about separators - https://github.com/Significant-Gravitas/AutoGPT/security/dependabot/41
2024-02-13 12:30:12 +01:00
Reinier van der Leer 250552cb3d
fix(agent/tests): Update test_config.py:test_initial_values 2024-02-12 13:26:47 +01:00
Reinier van der Leer 1d653973e9
feat(agent/llm): Use new OpenAI models as default `SMART_LLM`, `FAST_LLM`, and `EMBEDDING_MODEL`
- Change default `SMART_LLM` from `gpt-4` to `gpt-4-turbo-preview`
- Change default `FAST_LLM` from `gpt-3.5-turbo-16k` to `gpt-3.5-turbo-0125`
- Change default `EMBEDDING_MODEL` from `text-embedding-ada-002` to `text-embedding-3-small`
- Update .env.template, azure.yaml.template, and documentation accordingly
2024-02-12 13:19:37 +01:00
Reinier van der Leer 7bf9ba5502
chore(agent/llm): Update OpenAI model info
- Add `text-embedding-3-small` and `text-embedding-3-large` as `EMBEDDING_v3_S` and `EMBEDDING_v3_L` respectively
- Add `gpt-3.5-turbo-0125` as `GPT3_v4`
- Add `gpt-4-1106-vision-preview` as `GPT4_v3_VISION`
- Add GPT-4V models to info map
- Change chat model info mapping to derive info for aliases (e.g. `gpt-3.5-turbo`) from specific versions instead of the other way around
2024-02-12 13:17:20 +01:00
Reinier van der Leer 39fddb1214
fix(agent): Fix application of `extra_request_headers` in `OpenAIProvider` 2024-02-12 12:21:30 +01:00
Reinier van der Leer fe0923ba6c
feat(agent/web): Add browser extensions to deal with cookie walls and ads (#6778)
* Add `_sideload_chrome_extensions` subroutine to `open_page_in_browser` in web_selenium.py
   * Sideloads uBlock Origin and I Still Don't Care About Cookies, downloading them if necessary
* Add 2-second delay to `open_page_in_browser` to allow time for handling cookie walls
2024-02-02 18:30:37 +01:00
Reinier van der Leer dfaeda7cd5
lint(agent/tests): Fix line length in test_utils.py 2024-02-02 18:29:28 +01:00
Reinier van der Leer 9b7fee673e
fix(agent/tests): Update `test_utils.py:test_extract_json_from_response*` in accordance with 956cdc7
Commit 956cdc7 "fix(agent/json_utils): Decode as JSON rather than Python objects" broke these unit tests because they generated "JSON" by stringifying a Python object.
2024-02-02 18:21:19 +01:00
Reinier van der Leer 925269d17b
lint(agent): Fix line length in docstring of `EpisodicActionHistory.handle_compression` 2024-02-02 17:43:42 +01:00
Reinier van der Leer 66e0c87894
feat(agent): Add history compression to increase longevity and efficiency
* Compress steps in the prompt to reduce token usage, and to increase longevity when using models with limited context windows
* Move multiple copies of step formatting code to `Episode.format` method
* Add `EpisodicActionHistory.handle_compression` method to handle compression of new steps
2024-01-31 17:51:45 +01:00
Reinier van der Leer 55433f468a
feat(agent/web): Improve `read_webpage` information extraction abilities
* Implement `extract_information` function in `autogpt.processing.text` module. This function extracts pieces of information from a body of text based on a list of topics of interest.
* Add `topics_of_interest` and `get_raw_content` parameters to `read_webpage` commmand
   * Limit maximum content length if `get_raw_content=true` is specified
2024-01-31 15:08:08 +01:00
Reinier van der Leer 956cdc77fa
fix(agent/json_utils): Decode as JSON rather than Python objects
* Replace `ast.literal_eval` with `json.loads` in `extract_dict_from_response`

This fixes a bug where boolean values could not be decoded because of their required capitalization in Python.
2024-01-31 14:15:02 +01:00
Reinier van der Leer 83a0b03523
fix(agent/prompting): Fix representation of (optional) command parameters in prompt 2024-01-31 14:10:22 +01:00
Reinier van der Leer 25b9e290a5
fix(agent/json_utils): Make `extract_dict_from_response` more robust
* Accommodate for both ```json and ```JSON blocks in responses
2024-01-29 15:03:09 +01:00
Reinier van der Leer ab860981d8
feat(agent/llm): Add support for `gpt-4-0125-preview`
* Add `gpt-4-0125-preview` model to OpenAI model list
* Add `gpt-4-turbo-preview` alias to OpenAI model list
2024-01-29 11:22:32 +01:00
Reinier van der Leer fc37ffdfcf
feat(agent/llm/openai): Include compatibility tool call extraction in LLM response parse-fix loop 2024-01-19 19:23:17 +01:00
Reinier van der Leer 8c65f3c748
fix(agent/serve): Fix task cost tracking persistence in `AgentProtocolServer`
- Pydantic shallow-copies models when they are passed into a parent model, meaning they can't be updated through the original reference. This commit adds a fix for the resulting cost persistence issue.
2024-01-19 19:20:05 +01:00
Reinier van der Leer 354106be7b
feat(agent/llm): Add cost tracking and logging to `AgentProtocolServer` 2024-01-19 17:31:59 +01:00
Reinier van der Leer faf5f9e5a4
fix(agent): Fix `extract_dict_from_response` flakiness
- The `extract_dict_from_response` function, which is supposed to reliably extract a JSON object from an LLM's response, positively discriminated objects defined on a single line, causing issues.
2024-01-19 15:49:32 +01:00
Reinier van der Leer e4687e0f03
fix(agent): Fix "ChatModelResponse not subscriptable" errors in `summarize_text` and `QueryLanguageModel` ability
- `summarize_text` and `QueryLanguageModel.__call__` still tried to access `response["content"]`, which isn't possible since upgrading to the OpenAI v1 client library.
2024-01-19 15:45:31 +01:00
Reinier van der Leer c5b17851e0
fix(agent): Handle artifact modification properly
- When an Artifact's file is modified by the agent, set its `agent_created` attribute to `True` instead of registering a new Artifact
- Update the `autogpt-forge` dependency to the newest version, in which `AgentDB.update_artifact` has been implemented
2024-01-19 12:08:59 +01:00
Reinier van der Leer f2595af362
refactor(agent/openai): Upgrade OpenAI library to v1
- Update `openai` dependency from ^v0.27.10 to ^v1.7.2
- Update poetry.lock
- Update code for changed endpoints and new output types of OpenAI library
- Replace uses of `AssistantChatMessageDict` by `AssistantChatMessage`
   - Update `PromptStrategy`, `BaseAgent`, and all of their subclasses accordingly
- Update `OpenAIProvider`, `OpenAICredentials`, azure.yaml.template, .env.template and test_config.py to work with new separate `AzureOpenAI` client
- Remove `_OpenAIRetryHandler` and implement retry mechanism with `tenacity`
- Rewrite pytest fixture `cached_openai_client` (renamed from `patched_api_requestor`) for OpenAI v1 library
2024-01-17 20:11:13 +01:00
Reinier van der Leer 797c5bbc13
fix(agent/workspace): Fix GCS workspace binary file upload 2024-01-16 14:20:54 +01:00
Nicholas Tindle 97023b9a3c
feat(agent/server): Make port configurable, add documentation for Agent Protocol DB and port config (#6569)
* docs: Add documentation on how to use Agent Protocol in the template

- Added documentation on how to use Agent Protocol and its settings in the `.env.template` file.
- An explanation is provided for the `AP_SERVER_PORT` and `AP_SERVER_DB_URL` settings.
- This change aims to improve the understanding and usage of Agent Protocol in the project.

* docs: Update usage.md with information about configuring the API port

- Update the documentation for the `serve` mode in `usage.md`
- Add information about configuring the port for the API server using the `AP_SERVER_PORT` environment variable.

---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2024-01-12 14:41:43 +01:00
Reinier van der Leer 45c8476e67
fix(agent/release): Add gitpython as a direct dependency
gitpython was installed as an indirect dependency via agbenchmark. The release builds don't contain agbenchmark and thus also lack the gitpython package, which breaks the image.
2023-12-14 16:13:55 +01:00
Reinier van der Leer 21d4ce8d4b
fix(agent/release): Move auto-gpt-plugin-template to regular dependencies
- Move `auto-gpt-plugin-template` from dev dependencies to regular dependencies in `pyproject.toml`.
- Fixes #6566 - No module named 'auto_gpt_plugin_template'.
2023-12-14 13:31:57 +01:00
Reinier van der Leer efb5fed462
feat(agent/logging): Log warning when action raises error
- Add logging to capture errors raised during execution of actions in the Agent
- Move `fmt_kwargs` function from `agent_protocol_server.py` to `logs/utils.py`
2023-12-14 02:38:48 +01:00
Reinier van der Leer 167fea3f1e
test: Speed up test_gcs_file_workspace
- Change the GCS workspace fixture to module level so it is only built and torn down once. This saves 30-40s on a test run.
2023-12-14 02:31:05 +01:00
Reinier van der Leer 5107c6bbb9
lint: Remove unused `os` import in file_operations_utils.py 2023-12-14 02:27:40 +01:00
Reinier van der Leer e428130e4a
fix(agent/file_operations): Fix read_file command in GCS and S3 workspaces
- Update the `read_file` function in `file_operations.py` to pass the file's extension to the `decode_textual_file` function.
- Modify the `decode_textual_file` function in `file_operations_utils.py` to accept the file extension as an argument.
- Update the `content` property in the `FileContextItem` class in `context_item.py` to pass the file's extension to the `decode_textual_file` function.
- Update the `test_parsers` function in `test_text_file_parsers.py` to pass the file extension to the `decode_textual_file` function.
2023-12-14 02:07:22 +01:00
Reinier van der Leer 5978031f7a
lint: Remove unused import in autogpt/core/utils/json_schema.py 2023-12-13 22:53:27 +01:00
Reinier van der Leer 0e94c7b5fc
fix(agent/tty): Fix `finish` command in TTY mode
- Prevent the Agent from treating `AgentTerminated` like it would any other exception raised by a command.
- The agent should raise AgentTerminated exception to exit the loop.
2023-12-13 22:50:02 +01:00
Reinier van der Leer acf4df9f87
fix: Implement self-correction for invalid LLM responses
- Fix the parsing of invalid LLM responses by appending an error message to the prompt and allowing the LLM to fix its mistakes.
- Update the `OpenAIProvider` to handle the self-correction process and limit the number of attempts to fix parsing errors.
- Update the `BaseAgent` to profit from the new pasing and parse-fixing mechanism.

This change ensures that the system can handle and recover from errors in parsing LLM responses.

Hopefully this fixes #1407 once and for all.
2023-12-13 22:48:07 +01:00
Reinier van der Leer 6b0d0d4dc8
ci: Reset cassettes for test_dalle 2023-12-13 22:06:00 +01:00
Reinier van der Leer d41963d5fa
chore: Bump version to 0.5.0 and update bulletin
- Updated the quick links and user guide URLs in the bulletin
- Released v0.5.0 with cloud-readiness, a new UI, support for the newest Agent Protocol version, and other improvements

See the release notes on Github for more details: https://github.com/Significant-Gravitas/AutoGPT/releases
2023-12-13 19:55:08 +01:00
Reinier van der Leer 9e9142aa8e
refactor(agent): Reduce log spam in Agent Protocol mode
- Removed unnecessary print_attribute calls in configurators.py and configurator.py files
- Consolidated printing of configuration attributes in main.py for improved readability and reduced log spam in Agent Protocol mode
2023-12-13 19:47:46 +01:00
Reinier van der Leer bdc4c38d04
chore(agent): Update dependencies
- Update dependencies
- Remove `markdown` dependency after it became unused in d95e3b5b
2023-12-13 18:31:17 +01:00
Reinier van der Leer 967338193e
fix(agent/file_workspace): Fix workspace initialization and listing behavior in GCS and S3 file workspaces
- Update GCSFileWorkspace.initialize() to handle cases where the bucket doesn't exist and create it if necessary
- Add logging to S3FileWorkspace.initialize() and GCSFileWorkspace.initialize()
- Update GCSFileWorkspace.list() and S3FileWorkspace.list() to correctly handle nested paths and return the relative paths of files
- Fix tests for GCSFileWorkspace and S3FileWorkspace to account for the changes in initialization and listing behavior
- Fix S3FileWorkspace.open_file() to correctly switch between binary and text mode
- Added tests to verify the fixes in workspace initialization and listing behavior
2023-12-13 18:07:25 +01:00
Reinier van der Leer d820239a7c
chore(autogpt): Update duckduckgo-search to v4.0.0
- Fixes #6553 (`web_search` command not working)
- v3.x.x of the duckduckgo-search library no longer works, so updating to v4.0.0 unbreaks the `web_search` command
2023-12-13 15:52:33 +01:00
Nicholas Tindle b33f4cca6b
Add dependencies required to use PostgreSQL (#6558)
feat: Add dependencies required to use PostgreSQL

- Added psycopg2-binary version 2.9.9 to the dependencies in pyproject.toml
- Updated the poetry.lock file with the new package information
2023-12-12 19:06:50 -06:00
Reinier van der Leer d95e3b5b54
refactor(agent/file_operations): Refactor file opening/reading and parsing
- Update the signature of `FileWorkspace.open_file` and fix implementations in every workspace backend
- Replace `open()` with `workspace.open_file` in the `read_file` command to use the workspace's file opening functionality
- Fix the parametrization of the `test_text_file_parsers` test to correctly test text file parsers
2023-12-12 17:41:55 +01:00
Reinier van der Leer 198a0ecad6
fix(agent/file_operations): Fix path processing in file_operations.py and across workspace backend implementations
- Adjusted path processing and use of `agent.workspace` in the file_operations.py module to prevent double path resolution.
- Updated the `is_duplicate_operation` and `log_operation` functions in file_operations.py to use the `make_relative` argument of the `sanitize_path_arg` decorator.
- Refactored the `write_to_file`, `list_folder`, and `list_files` functions in file_operations.py to accept both string and Path objects as the path argument.
- Modified the GCSFileWorkspace and S3FileWorkspace classes in the file_workspace module to ensure that the root path is always an absolute path.

This commit addresses issues with path processing in the file_operations.py module and across different workspace backend implementations. The changes ensure that relative paths are correctly converted to absolute paths where necessary and that the file operations logic functions consistently handle path arguments as strings or Path objects. Additionally, the GCSFileWorkspace and S3FileWorkspace classes now enforce that the root path is always an absolute path.
2023-12-12 15:29:25 +01:00
Reinier van der Leer 3e19da1258
refactor: Remove X- prefix from API request headers
- Remove X- prefix from X-AutoGPT-UserID, X-AP-TaskID, and X-AP-StepID headers
- Refactor literal references to "ask_user" to `ask_user.__name__` in AgentProtocolServer
2023-12-12 10:52:18 +01:00
Reinier van der Leer f3faa47814
build: Reduce AutoGPT Docker image size
- Removed firefox-esr package to reduce image size
- Added --no-cache flag to poetry install steps
- Removed source code files after installation to reduce image size
2023-12-08 15:43:36 +01:00
Reinier van der Leer 2d4e16d5e1
fix(agent): Fix type issues with agent ID and apply_overrides_to_ai_settings
- Fix type annotation for `agent_id` in `BaseAgentSettings` class
- Add assertion to ensure `agent_id` is not an empty string in `AgentManager.get_agent_dir()` method
- Change type of `override_name` and `override_role` to be optional in `apply_overrides_to_ai_settings()` function
2023-12-08 14:13:59 +01:00
Reinier van der Leer fadfea2046
feat(agent/serve): Add StepID header to outgoing LLM requests
- Update `AgentProtocolServer` to include `X-AP-StepID` header in outgoing LLM requests.
2023-12-08 13:54:31 +01:00
Reinier van der Leer 6b19b78f87
feat(agent/serve): Add TaskID and UserID headers to outgoing LLM requests
- Update `AgentProtocolServer` to include `X-AP-TaskID` and `X-AutoGPT-UserID` headers in outgoing requests for Agent Protocol tasks.
- Modify `ModelProvider` and `OpenAIProvider` to allow configuring extra headers to be added to all outgoing requests.
- Fix the type of the `task_id` parameter in `AgentProtocolServer.get_task`
2023-12-08 13:41:37 +01:00
Reinier van der Leer a17f752705
fix(agent): Fix artifact download method & response
- Update the return type of the `AgentProtocolServer.get_artifact` method to `StreamingResponse`.
- Fix the Content-Disposition header in the response to include quotes around the filename.
2023-12-08 12:36:51 +01:00
Reinier van der Leer 05321c9dce
chore(agent): Update forge dependency 2023-12-08 12:17:56 +01:00
Reinier van der Leer 55fee0471f
fix(agent): Fix setup script
- Remove `poetry install` that caused uninstall+reinstall of benchmark packages on every run
2023-12-08 12:10:07 +01:00
Reinier van der Leer e2f760aef4
chore: Update forge dependency
- Update forge.sdk.schema import to forge.sdk.model in agent_protocol_server.py
- Update poetry.lock with new forge dependency reference
2023-12-08 01:06:06 +01:00