swarms
swarms copied to clipboard
feat: add swarm output schemas and agent fixes
Unified Swarm Output Schema
for harshals ui
Changes Made
-
Created a new unified schema system in
swarms/schemas/swarm_output_schemas.py
that standardizes output across all swarm types:- Base
SwarmOutput
schema for common fields - Specialized schemas for each swarm type (MixtureOfAgents, SpreadsheetSwarm, AgentRearrange, etc.)
- Each schema includes type-safe Pydantic models with proper field validation
- Base
-
Added specialized output classes for different swarm types:
-
AgentRearrangeOutput
: For agent rearrangement workflows -
ConcurrentWorkflowOutput
: For parallel execution stats -
SequentialWorkflowOutput
: For workflow chain tracking -
AutoSwarmOutput
: For auto-selected strategy details -
MixtureOfAgentsOutput
: For aggregated agent summaries -
SpreadsheetSwarmOutput
: For CSV data handling
-
-
Enhanced the Agent class with a unified
create_swarm_output
method that:- Creates standardized output for all swarm types
- Handles metadata appropriately for each type
- Provides consistent formatting
Benefits
- Consistent output structure across all swarm types
- Type safety through Pydantic models
- Simplified UI parsing with built-in formatting methods
- Easier maintenance and extensibility
- Reduced code duplication
- Better error handling and validation
Breaking Changes
None. This is a new feature that enhances existing functionality without breaking existing implementations.
📚 Documentation preview 📚: https://swarms--742.org.readthedocs.build/en/742/