Skip to content

Building AI agents, atomically

Simplify mainguard & ignore C901 in main guards

KennyVaneetveldeb3fa5bf05b8f
diff --git a/.flake8 b/.flake8
index 8f36406..67d5c32 100644
--- a/.flake8
+++ b/.flake8
@@ -4,3 +4,8 @@ max-complexity = 10
count = true
statistics = true
ignore = E203
+
+per-file-ignores =
+ */__main__.py:C901
+ */*:C901
+
diff --git a/atomic-agents/atomic_agents/agents/base_agent.py b/atomic-agents/atomic_agents/agents/base_agent.py
index 046d942..c33157e 100644
--- a/atomic-agents/atomic_agents/agents/base_agent.py
+++ b/atomic-agents/atomic_agents/agents/base_agent.py
@@ -281,37 +281,35 @@ if __name__ == "__main__":
from rich.live import Live
import json
- def display_agent_info(agent: BaseAgent):
- """Display information about the agent's configuration and schemas."""
- console = Console()
- console.print(
- Panel.fit(
- "[bold blue]Agent Information[/bold blue]",
- border_style="blue",
- padding=(1, 1),
- )
- )
+ def _create_schema_table(title: str, schema: Type[BaseModel]) -> Table:
+ """Create a table displaying schema information.
- input_schema_table = Table(title="Input Schema", box=box.ROUNDED)
- input_schema_table.add_column("Field", style="cyan")
- input_schema_table.add_column("Type", style="magenta")
- input_schema_table.add_column("Description", style="green")
+ Args:
+ title (str): Title of the table
+ schema (Type[BaseModel]): Schema to display
- for field_name, field in agent.input_schema.model_fields.items():
- input_schema_table.add_row(field_name, str(field.annotation), field.description or "")
+ Returns:
+ Table: Rich table containing schema information
+ """
+ schema_table = Table(title=title, box=box.ROUNDED)
+ schema_table.add_column("Field", style="cyan")
+ schema_table.add_column("Type", style="magenta")
+ schema_table.add_column("Description", style="green")
- console.print(input_schema_table)
+ for field_name, field in schema.model_fields.items():
+ schema_table.add_row(field_name, str(field.annotation), field.description or "")
- output_schema_table = Table(title="Output Schema", box=box.ROUNDED)
- output_schema_table.add_column("Field", style="cyan")
- output_schema_table.add_column("Type", style="magenta")
- output_schema_table.add_column("Description", style="green")
+ return schema_table
- for field_name, field in agent.output_schema.model_fields.items():
- output_schema_table.add_row(field_name, str(field.annotation), field.description or "")
+ def _create_config_table(agent: BaseAgent) -> Table:
+ """Create a table displaying agent configuration.
- console.print(output_schema_table)
+ Args:
+ agent (BaseAgent): Agent instance
+ Returns:
+ Table: Rich table containing configuration information
+ """
info_table = Table(title="Agent Configuration", box=box.ROUNDED)
info_table.add_column("Property", style="cyan")
info_table.add_column("Value", style="yellow")
@@ -320,8 +318,32 @@ if __name__ == "__main__":
info_table.add_row("Memory", str(type(agent.memory).__name__))
info_table.add_row("System Prompt Generator", str(type(agent.system_prompt_generator).__name__))
+ return info_table
+
+ def display_agent_info(agent: BaseAgent):
+ """Display information about the agent's configuration and schemas."""
+ console = Console()
+ console.print(
+ Panel.fit(
+ "[bold blue]Agent Information[/bold blue]",
+ border_style="blue",
+ padding=(1, 1),
+ )
+ )
+
+ # Display input schema
+ input_schema_table = _create_schema_table("Input Schema", agent.input_schema)
+ console.print(input_schema_table)
+
+ # Display output schema
+ output_schema_table = _create_schema_table("Output Schema", agent.output_schema)
+ console.print(output_schema_table)
+
+ # Display configuration
+ info_table = _create_config_table(agent)
console.print(info_table)
+ # Display system prompt
system_prompt = agent.system_prompt_generator.generate_prompt()
console.print(
Panel(