fix(agent): Fix type issues with agent ID and apply_overrides_to_ai_settings

- Fix type annotation for `agent_id` in `BaseAgentSettings` class
- Add assertion to ensure `agent_id` is not an empty string in `AgentManager.get_agent_dir()` method
- Change type of `override_name` and `override_role` to be optional in `apply_overrides_to_ai_settings()` function
This commit is contained in:
Reinier van der Leer
2023-12-08 14:13:32 +01:00
parent fadfea2046
commit 2d4e16d5e1
3 changed files with 4 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ class AgentManager:
]
def get_agent_dir(self, agent_id: str, must_exist: bool = False) -> Path:
assert len(agent_id) > 0
agent_dir = self.agents_dir / agent_id
if must_exist and not agent_dir.exists():
raise FileNotFoundError(f"No agent with ID '{agent_id}'")

View File

@@ -124,7 +124,7 @@ class BaseAgentConfiguration(SystemConfiguration):
class BaseAgentSettings(SystemSettings):
agent_id: Optional[str] = None
agent_id: str = ""
agent_data_dir: Optional[Path] = None
ai_profile: AIProfile = Field(default_factory=lambda: AIProfile(ai_name="AutoGPT"))

View File

@@ -12,8 +12,8 @@ logger = logging.getLogger(__name__)
def apply_overrides_to_ai_settings(
ai_profile: AIProfile,
directives: AIDirectives,
override_name: str = "",
override_role: str = "",
override_name: Optional[str] = "",
override_role: Optional[str] = "",
replace_directives: bool = False,
resources: Optional[list[str]] = None,
constraints: Optional[list[str]] = None,