Building AI agents, atomically
Updated docstrings and comments for clarity and consistency in the base tool components and sort imports
KennyVaneetveldedc5f4ad61980
diff --git a/atomic-agents/atomic_agents/agents/base_agent.py b/atomic-agents/atomic_agents/agents/base_agent.pyindex 44d4042..c95bd9e 100644--- a/atomic-agents/atomic_agents/agents/base_agent.py+++ b/atomic-agents/atomic_agents/agents/base_agent.py@@ -1,9 +1,8 @@-from pydantic import BaseModel, Field-from typing import Optional, Typeimport inspect-import instructor+from pydantic import BaseModel, Fieldfrom rich.json import JSON+from typing import Optional, Typefrom atomic_agents.lib.components.agent_memory import AgentMemoryfrom atomic_agents.lib.components.system_prompt_generator import SystemPromptContextProviderBase, SystemPromptGeneratordiff --git a/atomic-agents/atomic_agents/lib/tools/base_tool.py b/atomic-agents/atomic_agents/lib/base/base_tool.pysimilarity index 51%rename from atomic-agents/atomic_agents/lib/tools/base_tool.pyrename to atomic-agents/atomic_agents/lib/base/base_tool.pyindex 7a24325..657489d 100644--- a/atomic-agents/atomic_agents/lib/tools/base_tool.py+++ b/atomic-agents/atomic_agents/lib/base/base_tool.py@@ -1,5 +1,4 @@from typing import Optional, Type-from pydantic import BaseModelfrom atomic_agents.agents.base_agent import BaseIOSchema@@ -7,11 +6,11 @@ from atomic_agents.agents.base_agent import BaseIOSchemaclass BaseToolConfig(BaseModel):"""- Tool configuration class.+ Configuration for a tool.Attributes:- title (Optional[str]): Override the title of the tool.- description (Optional[str]): Override the description of the tool.+ title (Optional[str]): Overrides the default title of the tool.+ description (Optional[str]): Overrides the default description of the tool."""title: Optional[str] = None@@ -20,14 +19,13 @@ class BaseToolConfig(BaseModel):class BaseTool:"""- Base class for all tools in the Atomic Agents framework.+ Base class for tools within the Atomic Agents framework.Attributes:- input_schema (Type[BaseIOSchema]): The schema for the input data.- output_schema (Type[BaseIOSchema]): The schema for the output data.+ input_schema (Type[BaseIOSchema]): Schema defining the input data.+ output_schema (Type[BaseIOSchema]): Schema defining 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.+ tool_description (str): Description of the tool, derived from the input schema's description or overridden by the user."""input_schema: Type[BaseIOSchema]@@ -35,23 +33,23 @@ class BaseTool:def __init__(self, config: BaseToolConfig = BaseToolConfig()):"""- Initializes the BaseTool with an optional description override.+ Initializes the BaseTool with an optional configuration override.Args:- config (BaseToolConfig): Configuration for the tool, including optional title and description overrides.+ config (BaseToolConfig, optional): Configuration for the tool, including optional title and description overrides."""self.tool_name = config.title or self.input_schema.model_json_schema()["title"]self.tool_description = config.description or self.input_schema.model_json_schema()["description"]def run(self, params: Type[BaseIOSchema]) -> BaseIOSchema:"""- Runs the tool with the given parameters. This method should be implemented by subclasses.+ Executes the tool with the provided parameters.Args:- params (BaseIOSchema): The input parameters for the tool, adhering to the input schema.+ params (BaseIOSchema): Input parameters adhering to the input schema.Returns:- BaseIOSchema: The output of the tool, adhering to the output schema.+ BaseIOSchema: Output resulting from executing the tool, adhering to the output schema.Raises:NotImplementedError: If the method is not implemented by a subclass.diff --git a/atomic-agents/atomic_agents/lib/components/agent_memory.py b/atomic-agents/atomic_agents/lib/components/agent_memory.pyindex 00962bf..4e72fa3 100644--- a/atomic-agents/atomic_agents/lib/components/agent_memory.py+++ b/atomic-agents/atomic_agents/lib/components/agent_memory.py@@ -1,6 +1,6 @@import uuid-from typing import Dict, List, Optional, Union+from typing import Dict, List, Optional, Unionfrom pydantic import BaseModel, ValidationErrordiff --git a/atomic-agents/atomic_agents/lib/utils/format_tool_message.py b/atomic-agents/atomic_agents/lib/utils/format_tool_message.pyindex ae8ada2..c3dd947 100644--- a/atomic-agents/atomic_agents/lib/utils/format_tool_message.py+++ b/atomic-agents/atomic_agents/lib/utils/format_tool_message.py@@ -1,8 +1,7 @@-import uuidimport json-from typing import Dict, Optional, Type-+import uuidfrom pydantic import BaseModel+from typing import Dict, Optional, Typedef format_tool_message(tool_call: Type[BaseModel], tool_id: Optional[str] = None) -> Dict: