Skip to content

Building AI agents, atomically

refactor: Update BaseTool class to use BaseAgentIO for input and output schemas

KennyVaneetvelde1f32919fd96b
diff --git a/atomic_agents/lib/tools/base.py b/atomic_agents/lib/tools/base.py
index e23fa49..734ff2e 100644
--- a/atomic_agents/lib/tools/base.py
+++ b/atomic_agents/lib/tools/base.py
@@ -2,6 +2,8 @@ from typing import Type, Optional
from pydantic import BaseModel
from dataclasses import dataclass
+from atomic_agents.agents.base_chat_agent import BaseAgentIO
+
class BaseToolConfig(BaseModel):
title: Optional[str] = None
description: Optional[str] = None
@@ -11,14 +13,14 @@ class BaseTool:
Base class for all tools in the Atomic Agents framework.
Attributes:
- input_schema (Type[BaseModel]): The schema for the input data.
- output_schema (Type[BaseModel]): The schema for the output data.
+ input_schema (Type[BaseAgentIO]): The schema for the input data.
+ output_schema (Type[BaseAgentIO]): The schema for the output data.
tool_name (str): The name of the tool, derived from the input schema's title.
tool_description (str): The description of the tool, derived from the input schema's description or overridden by the user.
"""
- input_schema: Type[BaseModel]
- output_schema: Type[BaseModel]
+ input_schema: Type[BaseAgentIO]
+ output_schema: Type[BaseAgentIO]
def __init__(self, config: BaseToolConfig = BaseToolConfig()):
"""
@@ -30,15 +32,15 @@ class BaseTool:
self.tool_name = config.title or self.input_schema.Config.title
self.tool_description = config.description or self.input_schema.Config.description
- def run(self, params: Type[BaseModel]) -> BaseModel:
+ def run(self, params: Type[BaseAgentIO]) -> BaseAgentIO:
"""
Runs the tool with the given parameters. This method should be implemented by subclasses.
Args:
- params (BaseModel): The input parameters for the tool, adhering to the input schema.
+ params (BaseAgentIO): The input parameters for the tool, adhering to the input schema.
Returns:
- BaseModel: The output of the tool, adhering to the output schema.
+ BaseAgentIO: The output of the tool, adhering to the output schema.
Raises:
NotImplementedError: If the method is not implemented by a subclass.