refactor(agent, forge): Move library code from autogpt to forge (#7106)

Moved from `autogpt` to `forge`:
- `autogpt.config`          -> `forge.config`
- `autogpt.processing`      -> `forge.content_processing`
- `autogpt.file_storage`    -> `forge.file_storage`
- `autogpt.logs`            -> `forge.logging`
- `autogpt.speech`          -> `forge.speech`
- `autogpt.agents.(base|components|protocols)`  -> `forge.agent.*`
- `autogpt.command_decorator`                   -> `forge.command.decorator`
- `autogpt.models.(command|command_parameter)`  -> `forge.command.(command|parameter)`
- `autogpt.(commands|components|features)`      -> `forge.components`
- `autogpt.core.utils.json_utils`           -> `forge.json.parsing`
- `autogpt.prompts.utils`                   -> `forge.llm.prompting.utils`
- `autogpt.core.prompting.(base|schema|utils)`    -> `forge.llm.prompting.*`
- `autogpt.core.resource.model_providers`   -> `forge.llm.providers`
- `autogpt.llm.providers.openai` + `autogpt.core.resource.model_providers.utils`
                                            -> `forge.llm.providers.utils`
- `autogpt.models.action_history:Action*`   -> `forge.models.action`
- `autogpt.core.configuration.schema`       -> `forge.models.config`
- `autogpt.core.utils.json_schema`          -> `forge.models.json_schema`
- `autogpt.core.resource.schema`            -> `forge.models.providers`
- `autogpt.models.utils`                    -> `forge.models.utils`
- `forge.sdk.(errors|utils)` + `autogpt.utils.(exceptions|file_operations_utils|validators)`
                        -> `forge.utils.(exceptions|file_operations|url_validator)`
- `autogpt.utils.utils` -> `forge.utils.const` + `forge.utils.yaml_validator`

Moved within `forge`:
- forge/prompts/* -> forge/llm/prompting/*

The rest are mostly import updates, and some sporadic removals and necessary updates (for example to fix circular deps):
- Changed `CommandOutput = Any` to remove coupling with `ContextItem` (no longer needed)
- Removed unused `Singleton` class
- Reluctantly moved `speech` to forge due to coupling (tts needs to be changed into component)
- Moved `function_specs_from_commands` and `core/resource/model_providers` to `llm/providers` (resources were a `core` thing and are no longer relevant)
- Keep tests in `autogpt` to reduce changes in this PR
- Removed unused memory-related code from tests
- Removed duplicated classes: `FancyConsoleFormatter`, `BelowLevelFilter`
- `prompt_settings.yaml` is in both `autogpt` and `forge` because for some reason doesn't work when placed in just one dir (need to be taken care of)
- Removed `config` param from `clean_input`, it wasn't used and caused circular dependency
- Renamed `BaseAgentActionProposal` to `ActionProposal`
- Updated `pyproject.toml` in `forge` and `autogpt`
- Moved `Action*` models from `forge/components/action_history/model.py` to `forge/models/action.py` as those are relevant to the entire agent and not just `EventHistoryComponent` + to reduce coupling
- Renamed `DEFAULT_ASK_COMMAND` to `ASK_COMMAND` and `DEFAULT_FINISH_COMMAND` to `FINISH_COMMAND`
- Renamed `AutoGptFormatter` to `ForgeFormatter` and moved to `forge`

Includes changes from PR https://github.com/Significant-Gravitas/AutoGPT/pull/7148
---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
This commit is contained in:
Krzysztof Czerwinski
2024-05-15 23:37:53 +01:00
committed by GitHub
parent 4f81246fd4
commit e8d7dfa386
188 changed files with 2069 additions and 1223 deletions

View File

@@ -1,11 +0,0 @@
# Advanced Components
## General
Debugging may be easier because we can inspect the exact components that were called and where the pipeline failed (current WIP pipeline):
![Modular Pipeline](../../imgs/modular-pipeline.png)
Also that makes it possible to call component/pipeline/function again when failed and recover.
If it's necessary to get a component in a random place, agent provides generic, type safe `get_component(type[T]) -> T | None`

View File

@@ -1 +0,0 @@
../../../../autogpts/autogpt/autogpt/commands/README.md

View File

@@ -46,7 +46,7 @@ Lets the agent execute non-interactive Shell commands and Python code. Python ex
- `execute_python_code` execute Python code
- `execute_python_file` execute Python file
## `EventHistoryComponent`
## `ActionHistoryComponent`
Keeps track of agent's actions and their outcomes. Provides their summary to the prompt.
@@ -112,4 +112,4 @@ Adds ability to keep up-to-date file and folder content in the prompt.
Watches if agent is looping and switches to smart mode if necessary.
**AfterParse**
- Investigates what happened and switches to smart mode if necessary
- Investigates what happened and switches to smart mode if necessary

View File

@@ -0,0 +1 @@
../../../../autogpts/forge/forge/components/README.md

View File

@@ -48,10 +48,9 @@ The easiest way to provide a command is to use `command` decorator on a componen
**Example** Calculator component that can perform multiplication. Agent is able to call this command if it's relevant to a current task and will see the returned result.
```py
from autogpt.agents.components import Component
from autogpt.agents.protocols import CommandProvider
from autogpt.core.utils.json_schema import JSONSchema
from autogpt.utils.command_decorator import command
from forge.agent import CommandProvider, Component
from forge.command import command
from forge.models.json_schema import JSONSchema
class CalculatorComponent(CommandProvider):
@@ -163,4 +162,4 @@ class AfterExecute(AgentComponent):
class LoggerComponent(AfterExecute):
def after_execute(self, result: ActionResult) -> None:
logger.info(f"Result: {result}")
```
```

View File

@@ -16,15 +16,6 @@ nav:
- Search: AutoGPT/configuration/search.md
- Voice: AutoGPT/configuration/voice.md
- Image Generation: AutoGPT/configuration/imagegen.md
- Components:
- Introduction: AutoGPT/components/introduction.md
- Agents: AutoGPT/components/agents.md
- Components: AutoGPT/components/components.md
- Protocols: AutoGPT/components/protocols.md
- Commands: AutoGPT/components/commands.md
- Built in Components: AutoGPT/components/built-in-components.md
- Creating Components: AutoGPT/components/creating-components.md
- Advanced: AutoGPT/components/advanced.md
- Usage: AutoGPT/usage.md
- Help us improve AutoGPT:
- Share your debug logs with us: AutoGPT/share-your-logs.md
@@ -37,6 +28,14 @@ nav:
- Forge:
- Introduction: forge/get-started.md
- Components:
- Introduction: forge/components/introduction.md
- Agents: forge/components/agents.md
- Components: forge/components/components.md
- Protocols: forge/components/protocols.md
- Commands: forge/components/commands.md
- Built in Components: forge/components/built-in-components.md
- Creating Components: forge/components/creating-components.md
- Frontend:
- Readme: https://github.com/Significant-Gravitas/AutoGPT/blob/master/frontend/README.md