|
|
@ -10,34 +10,39 @@ The `SwarmRouter` class is a flexible routing system designed to manage differen
|
|
|
|
|
|
|
|
|
|
|
|
A Pydantic model for capturing log entries.
|
|
|
|
A Pydantic model for capturing log entries.
|
|
|
|
|
|
|
|
|
|
|
|
#### Attributes:
|
|
|
|
| Attribute | Type | Description |
|
|
|
|
- `id` (str): Unique identifier for the log entry.
|
|
|
|
| --- | --- | --- |
|
|
|
|
- `timestamp` (datetime): Time of log creation.
|
|
|
|
| `id` | str | Unique identifier for the log entry. |
|
|
|
|
- `level` (str): Log level (e.g., "info", "error").
|
|
|
|
| `timestamp` | datetime | Time of log creation. |
|
|
|
|
- `message` (str): Log message content.
|
|
|
|
| `level` | str | Log level (e.g., "info", "error"). |
|
|
|
|
- `swarm_type` (SwarmType): Type of swarm associated with the log.
|
|
|
|
| `message` | str | Log message content. |
|
|
|
|
- `task` (str): Task being performed (optional).
|
|
|
|
| `swarm_type` | SwarmType | Type of swarm associated with the log. |
|
|
|
|
- `metadata` (Dict[str, Any]): Additional metadata (optional).
|
|
|
|
| `task` | str | Task being performed (optional). |
|
|
|
|
|
|
|
|
| `metadata` | Dict[str, Any] | Additional metadata (optional). |
|
|
|
|
|
|
|
|
|
|
|
|
### SwarmRouter
|
|
|
|
### SwarmRouter
|
|
|
|
|
|
|
|
|
|
|
|
Main class for routing tasks to different swarm types.
|
|
|
|
Main class for routing tasks to different swarm types.
|
|
|
|
|
|
|
|
|
|
|
|
#### Attributes:
|
|
|
|
| Attribute | Type | Description |
|
|
|
|
- `name` (str): Name of the SwarmRouter instance.
|
|
|
|
| --- | --- | --- |
|
|
|
|
- `description` (str): Description of the SwarmRouter instance.
|
|
|
|
| `name` | str | Name of the SwarmRouter instance. |
|
|
|
|
- `max_loops` (int): Maximum number of loops to perform.
|
|
|
|
| `description` | str | Description of the SwarmRouter instance. |
|
|
|
|
- `agents` (List[Agent]): List of Agent objects to be used in the swarm.
|
|
|
|
| `max_loops` | int | Maximum number of loops to perform. |
|
|
|
|
- `swarm_type` (SwarmType): Type of swarm to be used.
|
|
|
|
| `agents` | List[Agent] | List of Agent objects to be used in the swarm. |
|
|
|
|
- `swarm` (Union[AgentRearrange, MixtureOfAgents, SpreadSheetSwarm, SequentialWorkflow, ConcurrentWorkflow]): Instantiated swarm object.
|
|
|
|
| `swarm_type` | SwarmType | Type of swarm to be used. |
|
|
|
|
- `logs` (List[SwarmLog]): List of log entries captured during operations.
|
|
|
|
| `swarm` | Union[AgentRearrange, MixtureOfAgents, SpreadSheetSwarm, SequentialWorkflow, ConcurrentWorkflow] | Instantiated swarm object. |
|
|
|
|
|
|
|
|
| `logs` | List[SwarmLog] | List of log entries captured during operations. |
|
|
|
|
|
|
|
|
|
|
|
|
#### Methods:
|
|
|
|
#### Methods:
|
|
|
|
- `__init__(self, name: str, description: str, max_loops: int, agents: List[Agent], swarm_type: SwarmType, *args, **kwargs)`: Initialize the SwarmRouter.
|
|
|
|
|
|
|
|
- `_create_swarm(self, *args, **kwargs)`: Create and return the specified swarm type.
|
|
|
|
| Method | Parameters | Description |
|
|
|
|
- `_log(self, level: str, message: str, task: str, metadata: Dict[str, Any])`: Create a log entry and add it to the logs list.
|
|
|
|
| --- | --- | --- |
|
|
|
|
- `run(self, task: str, *args, **kwargs)`: Run the specified task on the selected swarm.
|
|
|
|
| `__init__` | `self, name: str, description: str, max_loops: int, agents: List[Agent], swarm_type: SwarmType, *args, **kwargs` | Initialize the SwarmRouter. |
|
|
|
|
- `get_logs(self)`: Retrieve all logged entries.
|
|
|
|
| `_create_swarm` | `self, *args, **kwargs` | Create and return the specified swarm type. |
|
|
|
|
|
|
|
|
| `_log` | `self, level: str, message: str, task: str, metadata: Dict[str, Any]` | Create a log entry and add it to the logs list. |
|
|
|
|
|
|
|
|
| `run` | `self, task: str, *args, **kwargs` | Run the specified task on the selected swarm. |
|
|
|
|
|
|
|
|
| `get_logs` | `self` | Retrieve all logged entries. |
|
|
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
|
|