fixed HiearchicalSwarm & cleanups !

pull/1001/head
harshalmore31 1 month ago
parent 1444a719c4
commit cf7357fd8e

@ -449,16 +449,14 @@ nav:
- Swarm Types:
- AgentRearrange: "swarms_cloud/agent_rearrange.md"
- MixtureOfAgents: "swarms_cloud/mixture_of_agents.md"
# - SpreadSheetSwarm: "swarms_cloud/spreadsheet_swarm.md"
- SequentialWorkflow: "swarms_cloud/sequential_workflow.md"
- ConcurrentWorkflow: "swarms_cloud/concurrent_workflow.md"
- GroupChat: "swarms_cloud/group_chat.md"
- MultiAgentRouter: "swarms_cloud/multi_agent_router.md"
- HierarchicalSwarm: "swarms_cloud/hierarchical_swarm.md"
- MajorityVoting: "swarms_cloud/majority_voting.md"
# - AutoSwarmBuilder: "swarms_cloud/auto_swarm_builder.md"
# - HierarchicalSwarm: "swarms_cloud/hierarchical_swarm.md"
# - Auto: "swarms_cloud/auto.md"
- MajorityVoting: "swarms_cloud/majority_voting.md"
# - MALT: "swarms_cloud/malt.md"
- Examples:
- Medical Swarm: "swarms/examples/swarms_api_medical.md"
- Finance Swarm: "swarms/examples/swarms_api_finance.md"

@ -1,12 +1,12 @@
# HierarchicalSwarm
# HiearchicalSwarm
*Implements structured, multi-level task management with clear authority*
**Swarm Type**: `HierarchicalSwarm`
**Swarm Type**: `HiearchicalSwarm`
## Overview
The HierarchicalSwarm implements a structured, multi-level approach to task management with clear lines of authority and delegation. This architecture organizes agents in a hierarchical structure where manager agents coordinate and oversee worker agents, enabling efficient task distribution and quality control.
The HiearchicalSwarm implements a structured, multi-level approach to task management with clear lines of authority and delegation. This architecture organizes agents in a hierarchical structure where manager agents coordinate and oversee worker agents, enabling efficient task distribution and quality control.
Key features:
- **Structured Hierarchy**: Clear organizational structure with managers and workers
@ -23,6 +23,212 @@ Key features:
## API Usage
### Basic HiearchicalSwarm Example
=== "Shell (curl)"
```bash
curl -X POST "https://api.swarms.world/v1/swarm/completions" \
-H "x-api-key: $SWARMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Market Research ",
"description": "Parallel market research across different sectors",
"swarm_type": "HiearchicalSwarm",
"task": "Research and analyze market opportunities in AI, healthcare, fintech, and e-commerce sectors",
"agents": [
{
"agent_name": "AI Market Analyst",
"description": "Analyzes AI market trends and opportunities",
"system_prompt": "You are an AI market analyst. Focus on artificial intelligence market trends, opportunities, key players, and growth projections.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
},
{
"agent_name": "Healthcare Market Analyst",
"description": "Analyzes healthcare market trends",
"system_prompt": "You are a healthcare market analyst. Focus on healthcare market trends, digital health opportunities, regulatory landscape, and growth areas.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
},
{
"agent_name": "Fintech Market Analyst",
"description": "Analyzes fintech market opportunities",
"system_prompt": "You are a fintech market analyst. Focus on financial technology trends, digital payment systems, blockchain opportunities, and regulatory developments.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
},
{
"agent_name": "E-commerce Market Analyst",
"description": "Analyzes e-commerce market trends",
"system_prompt": "You are an e-commerce market analyst. Focus on online retail trends, marketplace opportunities, consumer behavior, and emerging platforms.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
}
],
"max_loops": 1
}'
```
=== "Python (requests)"
```python
import requests
import json
API_BASE_URL = "https://api.swarms.world"
API_KEY = "your_api_key_here"
headers = {
"x-api-key": API_KEY,
"Content-Type": "application/json"
}
swarm_config = {
"name": "Market Research ",
"description": "Parallel market research across different sectors",
"swarm_type": "HiearchicalSwarm",
"task": "Research and analyze market opportunities in AI, healthcare, fintech, and e-commerce sectors",
"agents": [
{
"agent_name": "AI Market Analyst",
"description": "Analyzes AI market trends and opportunities",
"system_prompt": "You are an AI market analyst. Focus on artificial intelligence market trends, opportunities, key players, and growth projections.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
},
{
"agent_name": "Healthcare Market Analyst",
"description": "Analyzes healthcare market trends",
"system_prompt": "You are a healthcare market analyst. Focus on healthcare market trends, digital health opportunities, regulatory landscape, and growth areas.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
},
{
"agent_name": "Fintech Market Analyst",
"description": "Analyzes fintech market opportunities",
"system_prompt": "You are a fintech market analyst. Focus on financial technology trends, digital payment systems, blockchain opportunities, and regulatory developments.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
},
{
"agent_name": "E-commerce Market Analyst",
"description": "Analyzes e-commerce market trends",
"system_prompt": "You are an e-commerce market analyst. Focus on online retail trends, marketplace opportunities, consumer behavior, and emerging platforms.",
"model_name": "gpt-4o",
"max_loops": 1,
"temperature": 0.3
}
],
"max_loops": 1
}
response = requests.post(
f"{API_BASE_URL}/v1/swarm/completions",
headers=headers,
json=swarm_config
)
if response.status_code == 200:
result = response.json()
print("HiearchicalSwarm completed successfully!")
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
print(f"Project plan: {result['output']}")
else:
print(f"Error: {response.status_code} - {response.text}")
```
**Example Response**:
```json
{
"job_id": "swarms-JIrcIAfs2d75xrXGaAL94uWyYJ8V",
"status": "success",
"swarm_name": "Market Research Auto",
"description": "Parallel market research across different sectors",
"swarm_type": "HiearchicalSwarm",
"output": [
{
"role": "System",
"content": "These are the agents in your team. Each agent has a specific role and expertise to contribute to the team's objectives.\nTotal Agents: 4\n\nBelow is a summary of your team members and their primary responsibilities:\n| Agent Name | Description |\n|------------|-------------|\n| AI Market Analyst | Analyzes AI market trends and opportunities |\n| Healthcare Market Analyst | Analyzes healthcare market trends |\n| Fintech Market Analyst | Analyzes fintech market opportunities |\n| E-commerce Market Analyst | Analyzes e-commerce market trends |\n\nEach agent is designed to handle tasks within their area of expertise. Collaborate effectively by assigning tasks according to these roles."
},
{
"role": "Director",
"content": [
{
"role": "Director",
"content": [
{
"function": {
"arguments": "{\"plan\":\"Conduct a comprehensive analysis of market opportunities in the AI, healthcare, fintech, and e-commerce sectors. Each market analyst will focus on their respective sector, gathering data on current trends, growth opportunities, and potential challenges. The findings will be compiled into a report for strategic decision-making.\",\"orders\":[{\"agent_name\":\"AI Market Analyst\",\"task\":\"Research current trends in the AI market, identify growth opportunities, and analyze potential challenges.\"},{\"agent_name\":\"Healthcare Market Analyst\",\"task\":\"Analyze the healthcare market for emerging trends, growth opportunities, and possible challenges.\"},{\"agent_name\":\"Fintech Market Analyst\",\"task\":\"Investigate the fintech sector for current trends, identify opportunities for growth, and assess challenges.\"},{\"agent_name\":\"E-commerce Market Analyst\",\"task\":\"Examine e-commerce market trends, identify growth opportunities, and analyze potential challenges.\"}]}",
"name": "ModelMetaclass"
},
"id": "call_GxiyzIRb2oGQXokbbkeaeVry",
"type": "function"
}
]
}
]
},
{
"role": "AI Market Analyst",
"content": "### AI Market Analysis: Trends, Opportunities, and Challenges\n\n#### Current Trends in the AI Market:\n\n1. **Increased Adoption Across Industries**..."
},
{
"role": "Healthcare Market Analyst",
"content": "### Healthcare Market Analysis: Trends, Opportunities, and Challenges\n\n#### Current Trends in the Healthcare Market:\n\n1. **Telehealth Expansion**..."
},
{
"role": "Fintech Market Analyst",
"content": "### Fintech Market Analysis: Trends, Opportunities, and Challenges\n\n#### Current Trends in the Fintech Market:\n\n1. **Digital Payments Proliferation**...."
},
{
"role": "E-commerce Market Analyst",
"content": "### E-commerce Market Analysis: Trends, Opportunities, and Challenges\n\n#### Current Trends in the E-commerce Market:\n\n1. **Omnichannel Retailing**...."
},
{
"role": "Director",
"content": "### Feedback for Worker Agents\n\n#### AI Market Analyst\n\n**Strengths:**\n- Comprehensive coverage of current trends, growth opportunities, and challenges in the AI market.\n- Clear categorization of insights, making it easy to follow and understand.\n\n**Weaknesses....."
},
{
"role": "System",
"content": "--- Loop 1/1 completed ---"
}
],
"number_of_agents": 4,
"service_tier": "standard",
"execution_time": 94.07934331893921,
"usage": {
"input_tokens": 35,
"output_tokens": 3827,
"total_tokens": 3862,
"billing_info": {
"cost_breakdown": {
"agent_cost": 0.04,
"input_token_cost": 0.000105,
"output_token_cost": 0.057405,
"token_counts": {
"total_input_tokens": 35,
"total_output_tokens": 3827,
"total_tokens": 3862
},
"num_agents": 4,
"service_tier": "standard",
"night_time_discount_applied": false
},
"total_cost": 0.09751,
"discount_active": false,
"discount_type": "none",
"discount_percentage": 0
}
}
}
```
## Configuration Options

@ -1,40 +0,0 @@
# MALT
*Specialized framework for complex language-based tasks and processing*
**Swarm Type**: `MALT`
## Overview
MALT (Multi-Agent Language Task) is a specialized framework optimized for complex language-based tasks, optimizing agent collaboration for sophisticated language processing operations. This architecture excels at tasks requiring deep linguistic analysis, natural language understanding, and complex text generation workflows.
Key features:
- **Language Optimization**: Specifically designed for natural language tasks
- **Linguistic Collaboration**: Agents work together on complex language operations
- **Text Processing Pipeline**: Structured approach to language task workflows
- **Advanced NLP**: Optimized for sophisticated language understanding tasks
## Use Cases
- Complex document analysis and processing
- Multi-language translation and localization
- Advanced content generation and editing
- Linguistic research and analysis tasks
## API Usage
```
## Best Practices
- Use MALT for sophisticated language processing tasks
- Design agents with complementary linguistic analysis capabilities
- Ideal for tasks requiring deep language understanding
- Consider multiple levels of linguistic analysis (syntax, semantics, pragmatics)
## Related Swarm Types
- [SequentialWorkflow](sequential_workflow.md) - For ordered language processing
- [MixtureOfAgents](mixture_of_agents.md) - For diverse linguistic expertise
- [HierarchicalSwarm](hierarchical_swarm.md) - For structured language analysis

@ -1,41 +0,0 @@
# SpreadSheetSwarm
*Structured approach to data management and operations in spreadsheet-like format*
**Swarm Type**: `SpreadSheetSwarm`
## Overview
The SpreadSheetSwarm provides a structured approach to data management and operations, ideal for tasks involving data analysis, transformation, and systematic processing in a spreadsheet-like structure. This architecture organizes agents to work on data in a tabular format with clear rows, columns, and processing workflows.
Key features:
- **Structured Data Processing**: Organizes work in spreadsheet-like rows and columns
- **Systematic Operations**: Sequential and methodical data handling
- **Data Transformation**: Efficient processing of structured datasets
- **Collaborative Analysis**: Multiple agents working on different data aspects
## Use Cases
- Financial data analysis and reporting
- Customer data processing and segmentation
- Inventory management and tracking
- Research data compilation and analysis
## API Usage
### Basic SpreadSheetSwarm Example
## Best Practices
- Structure data in clear, logical formats before processing
- Use systematic, step-by-step analysis approaches
- Ideal for quantitative analysis and reporting tasks
- Ensure data validation before proceeding with analysis
## Related Swarm Types
- [SequentialWorkflow](sequential_workflow.md) - For ordered data processing
- [ConcurrentWorkflow](concurrent_workflow.md) - For parallel data analysis
- [HierarchicalSwarm](hierarchical_swarm.md) - For complex data projects

@ -9,15 +9,14 @@ Each multi-agent architecture type is designed for specific use cases and can be
| SequentialWorkflow | Executes tasks in a strict, predefined order. Perfect for workflows where each step depends on the completion of the previous one. | [Learn More](sequential_workflow.md) |
| ConcurrentWorkflow | Runs independent tasks in parallel, significantly reducing processing time for complex operations. Ideal for tasks that can be processed simultaneously. | [Learn More](concurrent_workflow.md) |
| GroupChat | Enables dynamic collaboration between agents through a chat-based interface, facilitating real-time information sharing and decision-making. | [Learn More](group_chat.md) |
| HierarchicalSwarm | Implements a structured, multi-level approach to task management, with clear lines of authority and delegation. | [Learn More](hierarchical_swarm.md) |
| MultiAgentRouter | Acts as an intelligent task dispatcher, distributing work across agents based on their capabilities and current workload. | [Learn More](multi_agent_router.md) |
| MajorityVoting | Implements robust decision-making through consensus, ideal for tasks requiring collective intelligence or verification. | [Learn More](majority_voting.md) |
<!-- | SpreadSheetSwarm | Provides a structured approach to data management and operations, ideal for tasks involving data analysis, transformation, and systematic processing in a spreadsheet-like structure. | [Learn More](spreadsheet_swarm.md) | -->
<!-- | AutoSwarmBuilder | Automatically configures agent architectures based on task requirements and performance metrics, simplifying swarm creation. | [Learn More](auto_swarm_builder.md) |
| HierarchicalSwarm | Implements a structured, multi-level approach to task management, with clear lines of authority and delegation. | [Learn More](hierarchical_swarm.md) | -->
<!-- | Auto | Intelligently selects the most effective swarm architecture for a given task based on context. | [Learn More](auto.md) | -->
<!-- | MALT | Specialized framework for language-based tasks, optimizing agent collaboration for complex language processing operations. | [Learn More](malt.md) | -->
# Learn More

Loading…
Cancel
Save