mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-09 15:17:59 -05:00
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>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from abc import ABC
|
|
from typing import Callable, TypeVar
|
|
|
|
T = TypeVar("T", bound="AgentComponent")
|
|
|
|
|
|
class AgentComponent(ABC):
|
|
"""Base class for all agent components."""
|
|
|
|
_run_after: list[type[AgentComponent]] = []
|
|
_enabled: Callable[[], bool] | bool = True
|
|
_disabled_reason: str = ""
|
|
|
|
@property
|
|
def enabled(self) -> bool:
|
|
if callable(self._enabled):
|
|
return self._enabled()
|
|
return self._enabled
|
|
|
|
@property
|
|
def disabled_reason(self) -> str:
|
|
"""Return the reason this component is disabled."""
|
|
return self._disabled_reason
|
|
|
|
def run_after(self: T, *components: type[AgentComponent] | AgentComponent) -> T:
|
|
"""Set the components that this component should run after."""
|
|
for component in components:
|
|
t = component if isinstance(component, type) else type(component)
|
|
if t not in self._run_after and t is not self.__class__:
|
|
self._run_after.append(t)
|
|
return self
|
|
|
|
|
|
class ComponentEndpointError(Exception):
|
|
"""Error of a single protocol method on a component."""
|
|
|
|
def __init__(self, message: str = ""):
|
|
self.message = message
|
|
super().__init__(message)
|
|
|
|
|
|
class EndpointPipelineError(ComponentEndpointError):
|
|
"""Error of an entire pipline of one endpoint."""
|
|
|
|
|
|
class ComponentSystemError(EndpointPipelineError):
|
|
"""Error of a group of pipelines;
|
|
multiple different enpoints."""
|