Skip to content

Commit

Permalink
fix: remove unused mypy warnings for cleaner configuration fr fr 🧹
Browse files Browse the repository at this point in the history
- Removed `warn_return_type` and `warn_unused_configs` from mypy settings to streamline configuration
- Focused on essential type checking options for improved clarity and maintainability

no cap, just tidy mypy vibes fr fr
  • Loading branch information
UltraInstinct0x committed Jan 7, 2025
1 parent 80500f5 commit def4d55
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ known-first-party = ["smolswarms"]

[tool.mypy]
python_version = "3.10"
warn_return_type = true
warn_unused_configs = true
disallow_untyped_defs = true
check_untyped_defs = true
strict_optional = true
Expand Down
43 changes: 43 additions & 0 deletions smolswarms/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Factory for creating and configuring swarms."""

from typing import Optional

from .specs import AgentSpec
from .specs import BusinessUnit
from .swarm import Swarm


class SwarmFactory:
"""Factory class for creating and configuring swarms."""

@staticmethod
def create_swarm(name: str, description: Optional[str] = None) -> Swarm:
"""Create a new swarm with the given name and description."""
return Swarm(name=name, description=description)

@staticmethod
def create_business_unit(
name: str, description: str, objectives: list[str]
) -> BusinessUnit:
"""Create a new business unit with the given specifications."""
return BusinessUnit(
name=name,
description=description,
agents=[],
objectives=objectives,
)

@staticmethod
def create_agent(
name: str,
role: str,
capabilities: list[str],
memory_size: Optional[int] = None,
) -> AgentSpec:
"""Create a new agent with the given specifications."""
return AgentSpec(
name=name,
role=role,
capabilities=capabilities,
memory_size=memory_size if memory_size is not None else 1024,
)
21 changes: 21 additions & 0 deletions smolswarms/specs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Specifications for agents and business units in the swarm."""

from pydantic import BaseModel


class AgentSpec(BaseModel):
"""Specification for an individual agent in the swarm."""

name: str
role: str
capabilities: list[str]
memory_size: int = 1024


class BusinessUnit(BaseModel):
"""A business unit that groups agents together for a specific purpose."""

name: str
description: str
agents: list[AgentSpec]
objectives: list[str]
29 changes: 29 additions & 0 deletions smolswarms/swarm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Core swarm implementation for orchestrating agents."""

from typing import Optional

from .specs import AgentSpec
from .specs import BusinessUnit


class Swarm:
"""A swarm of agents working together to achieve objectives."""

def __init__(self, name: str, description: Optional[str] = None) -> None:
"""Initialize a new swarm with a name and optional description."""
self.name = name
self.description = description
self.business_units: list[BusinessUnit] = []
self.agents: list[AgentSpec] = []

def add_business_unit(self, unit: BusinessUnit) -> None:
"""Add a business unit to the swarm."""
self.business_units.append(unit)
self.agents.extend(unit.agents)

def get_agent(self, name: str) -> Optional[AgentSpec]:
"""Get an agent by name."""
for agent in self.agents:
if agent.name == name:
return agent
return None

0 comments on commit def4d55

Please sign in to comment.