From 4a3f052b3a9e09b9e25b8720b366fa9740f84f87 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Tue, 17 Oct 2023 16:33:30 -0700 Subject: [PATCH] Bodge BaseAgent.file_manager type to get rid of type errors everywhere --- autogpts/autogpt/autogpt/agents/base.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/autogpts/autogpt/autogpt/agents/base.py b/autogpts/autogpt/autogpt/agents/base.py index 547f7d5f..1dd9ac49 100644 --- a/autogpts/autogpt/autogpt/agents/base.py +++ b/autogpts/autogpt/autogpt/agents/base.py @@ -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()