Bodge BaseAgent.file_manager type to get rid of type errors everywhere

pull/5612/head
Reinier van der Leer 2023-10-17 16:33:30 -07:00
parent 7efd62233e
commit 4a3f052b3a
No known key found for this signature in database
GPG Key ID: CDC1180FDAE06193
1 changed files with 6 additions and 3 deletions

View File

@ -9,7 +9,6 @@ from auto_gpt_plugin_template import AutoGPTPluginTemplate
from pydantic import Field, validator
if TYPE_CHECKING:
from autogpt.config import Config
from autogpt.core.prompting.base import PromptStrategy
from autogpt.core.resource.model_providers.schema import (
@ -183,11 +182,11 @@ class BaseAgent(Configurable[BaseAgentSettings], ABC):
self.legacy_config = legacy_config
"""LEGACY: Monolithic application configuration."""
self.file_manager = (
self.file_manager: AgentFileManager = (
AgentFileManager(settings.agent_data_dir)
if settings.agent_data_dir
else None
)
) # type: ignore
self.llm_provider = llm_provider
@ -239,6 +238,10 @@ class BaseAgent(Configurable[BaseAgentSettings], ABC):
Returns:
The command name and arguments, if any, and the agent's thoughts.
"""
assert self.file_manager, (
f"Agent has no FileManager: call {__class__.__name__}.attach_fs()"
" before trying to run the agent."
)
# Scratchpad as surrogate PromptGenerator for plugin hooks
self._prompt_scratchpad = PromptScratchpad()