forked from Significant-Gravitas/AutoGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agent): Fully abstracted file storage access with
FileStorage
(S…
…ignificant-Gravitas#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
- Loading branch information
Showing
38 changed files
with
1,677 additions
and
1,343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
from typing import TYPE_CHECKING | ||
from __future__ import annotations | ||
|
||
if TYPE_CHECKING: | ||
from autogpt.agents.agent import Agent | ||
from autogpt.config import Config | ||
from autogpt.core.resource.model_providers.schema import ChatModelProvider | ||
from typing import TYPE_CHECKING | ||
|
||
from autogpt.config.ai_directives import AIDirectives | ||
from autogpt.file_storage.base import FileStorage | ||
|
||
from .configurators import _configure_agent | ||
from .profile_generator import generate_agent_profile_for_task | ||
|
||
if TYPE_CHECKING: | ||
from autogpt.agents.agent import Agent | ||
from autogpt.config import Config | ||
from autogpt.core.resource.model_providers.schema import ChatModelProvider | ||
|
||
|
||
async def generate_agent_for_task( | ||
agent_id: str, | ||
task: str, | ||
app_config: "Config", | ||
llm_provider: "ChatModelProvider", | ||
) -> "Agent": | ||
app_config: Config, | ||
file_storage: FileStorage, | ||
llm_provider: ChatModelProvider, | ||
) -> Agent: | ||
base_directives = AIDirectives.from_file(app_config.prompt_settings_file) | ||
ai_profile, task_directives = await generate_agent_profile_for_task( | ||
task=task, | ||
app_config=app_config, | ||
llm_provider=llm_provider, | ||
) | ||
return _configure_agent( | ||
agent_id=agent_id, | ||
task=task, | ||
ai_profile=ai_profile, | ||
directives=base_directives + task_directives, | ||
app_config=app_config, | ||
file_storage=file_storage, | ||
llm_provider=llm_provider, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.