-
-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add swarm output schemas and agent fixes #742
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,79 @@ | |||
from typing import List, Dict, Any, Optional | |||
from pydantic import BaseModel, Field |
Check failure
Code scanning / Pyre
Undefined import Error
from pydantic import BaseModel, Field | ||
from datetime import datetime | ||
|
||
class AgentStep(BaseModel): |
Check failure
Code scanning / Pyre
Undefined or invalid type Error
input_config = SwarmInput( | ||
swarm_id=swarm_id, | ||
name=swarm_type, | ||
flow=flow or "->".join([out["agent_name"] for out in agent_outputs]), | ||
) |
Check failure
Code scanning / Pyre
Unexpected keyword Error
formatted_outputs = [] | ||
for agent_out in agent_outputs: | ||
steps = [ | ||
AgentStep(role=step["role"], content=step["content"]) |
Check failure
Code scanning / Pyre
Unexpected keyword Error
AgentOutput( | ||
agent_name=agent_out["agent_name"], | ||
steps=steps, | ||
metadata=agent_out.get("metadata") | ||
) |
Check failure
Code scanning / Pyre
Unexpected keyword Error
return MixtureOfAgentsOutput( | ||
input=input_config, | ||
outputs=formatted_outputs, | ||
time=time.time(), | ||
execution_time=execution_time, | ||
metadata=metadata, | ||
aggregator_summary=metadata.get("aggregator_summary") if metadata else None | ||
) |
Check failure
Code scanning / Pyre
Unexpected keyword Error
return SpreadsheetSwarmOutput( | ||
input=input_config, | ||
outputs=formatted_outputs, | ||
time=time.time(), | ||
execution_time=execution_time, | ||
metadata=metadata, | ||
csv_data=metadata.get("csv_data", []) if metadata else [] | ||
) |
Check failure
Code scanning / Pyre
Unexpected keyword Error
return SwarmOutput( | ||
input=input_config, | ||
outputs=formatted_outputs, | ||
time=time.time(), | ||
execution_time=execution_time, | ||
metadata=metadata | ||
) |
Check failure
Code scanning / Pyre
Unexpected keyword Error
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:SwarmOutput
schema for common fieldsAdded specialized output classes for different swarm types:
AgentRearrangeOutput
: For agent rearrangement workflowsConcurrentWorkflowOutput
: For parallel execution statsSequentialWorkflowOutput
: For workflow chain trackingAutoSwarmOutput
: For auto-selected strategy detailsMixtureOfAgentsOutput
: For aggregated agent summariesSpreadsheetSwarmOutput
: For CSV data handlingEnhanced the Agent class with a unified
create_swarm_output
method that:Benefits
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/