parent
0ceba80c60
commit
117f49c3b2
@ -0,0 +1,176 @@
|
||||
# AgentRearrange
|
||||
|
||||
*Dynamically reorganizes agents to optimize task performance and efficiency*
|
||||
|
||||
**Swarm Type**: `AgentRearrange`
|
||||
|
||||
## Overview
|
||||
|
||||
The AgentRearrange swarm type dynamically reorganizes the workflow between agents based on task requirements and performance metrics. This architecture is particularly useful when the effectiveness of agents depends on their sequence or arrangement, allowing for optimal task distribution and execution flow.
|
||||
|
||||
Key features:
|
||||
- **Dynamic Reorganization**: Automatically adjusts agent order based on task needs
|
||||
- **Performance Optimization**: Optimizes workflow for maximum efficiency
|
||||
- **Adaptive Sequencing**: Learns from execution patterns to improve arrangement
|
||||
- **Flexible Task Distribution**: Distributes work based on agent capabilities
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Complex workflows where task order matters
|
||||
- Multi-step processes requiring optimization
|
||||
- Tasks where agent performance varies by sequence
|
||||
- Adaptive workflow management systems
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic AgentRearrange 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": "Document Processing Rearrange",
|
||||
"description": "Process documents with dynamic agent reorganization",
|
||||
"swarm_type": "AgentRearrange",
|
||||
"task": "Analyze this legal document and extract key insights, then summarize findings and identify action items",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Document Analyzer",
|
||||
"description": "Analyzes document content and structure",
|
||||
"system_prompt": "You are an expert document analyst. Extract key information, themes, and insights from documents.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Legal Expert",
|
||||
"description": "Provides legal context and interpretation",
|
||||
"system_prompt": "You are a legal expert. Analyze documents for legal implications, risks, and compliance issues.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Summarizer",
|
||||
"description": "Creates concise summaries and action items",
|
||||
"system_prompt": "You are an expert at creating clear, actionable summaries from complex information.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
}
|
||||
],
|
||||
"rearrange_flow": "Optimize agent sequence based on document complexity and required output quality",
|
||||
"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": "Document Processing Rearrange",
|
||||
"description": "Process documents with dynamic agent reorganization",
|
||||
"swarm_type": "AgentRearrange",
|
||||
"task": "Analyze this legal document and extract key insights, then summarize findings and identify action items",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Document Analyzer",
|
||||
"description": "Analyzes document content and structure",
|
||||
"system_prompt": "You are an expert document analyst. Extract key information, themes, and insights from documents.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Legal Expert",
|
||||
"description": "Provides legal context and interpretation",
|
||||
"system_prompt": "You are a legal expert. Analyze documents for legal implications, risks, and compliance issues.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Summarizer",
|
||||
"description": "Creates concise summaries and action items",
|
||||
"system_prompt": "You are an expert at creating clear, actionable summaries from complex information.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
}
|
||||
],
|
||||
"rearrange_flow": "Optimize agent sequence based on document complexity and required output quality",
|
||||
"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("AgentRearrange swarm completed successfully!")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Output: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "document-processing-rearrange",
|
||||
"swarm_type": "AgentRearrange",
|
||||
"task": "Analyze this legal document and extract key insights, then summarize findings and identify action items",
|
||||
"output": {
|
||||
"analysis": "Document analysis results...",
|
||||
"legal_insights": "Legal implications and risks...",
|
||||
"summary": "Concise summary of findings...",
|
||||
"action_items": ["Action 1", "Action 2", "Action 3"]
|
||||
},
|
||||
"metadata": {
|
||||
"agent_sequence": ["Legal Expert", "Document Analyzer", "Summarizer"],
|
||||
"rearrangement_reason": "Optimized for legal document analysis workflow",
|
||||
"execution_time_seconds": 18.2,
|
||||
"billing_info": {
|
||||
"total_cost": 0.045
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration Options
|
||||
|
||||
| Parameter | Type | Description | Default |
|
||||
|-----------|------|-------------|---------|
|
||||
| `rearrange_flow` | string | Instructions for how agents should be rearranged | None |
|
||||
| `agents` | Array<AgentSpec> | List of agents to be dynamically arranged | Required |
|
||||
| `max_loops` | integer | Maximum rearrangement iterations | 1 |
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Provide clear `rearrange_flow` instructions for optimal reorganization
|
||||
- Design agents with complementary but flexible roles
|
||||
- Use when task complexity requires adaptive sequencing
|
||||
- Monitor execution patterns to understand rearrangement decisions
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [SequentialWorkflow](sequential_workflow.md) - For fixed sequential processing
|
||||
- [AutoSwarmBuilder](auto_swarm_builder.md) - For automatic swarm construction
|
||||
- [HierarchicalSwarm](hierarchical_swarm.md) - For structured agent hierarchies
|
@ -0,0 +1,203 @@
|
||||
# Auto
|
||||
|
||||
*Intelligently selects the most effective swarm architecture for a given task*
|
||||
|
||||
**Swarm Type**: `auto` (or `Auto`)
|
||||
|
||||
## Overview
|
||||
|
||||
The Auto swarm type intelligently selects the most effective swarm architecture for a given task based on context analysis and task requirements. This intelligent system evaluates the task description and automatically chooses the optimal swarm type from all available architectures, ensuring maximum efficiency and effectiveness.
|
||||
|
||||
Key features:
|
||||
- **Intelligent Selection**: Automatically chooses the best swarm type for each task
|
||||
- **Context Analysis**: Analyzes task requirements to make optimal decisions
|
||||
- **Adaptive Architecture**: Adapts to different types of problems automatically
|
||||
- **Zero Configuration**: No manual architecture selection required
|
||||
|
||||
## Use Cases
|
||||
|
||||
- When unsure about which swarm type to use
|
||||
- General-purpose task automation
|
||||
- Rapid prototyping and experimentation
|
||||
- Simplified API usage for non-experts
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic Auto 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": "Auto Content Creation",
|
||||
"description": "Let the system choose the best approach for content creation",
|
||||
"swarm_type": "auto",
|
||||
"task": "Create a comprehensive blog post about sustainable investing, including research, writing, editing, and SEO optimization",
|
||||
"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": "Auto Content Creation",
|
||||
"description": "Let the system choose the best approach for content creation",
|
||||
"swarm_type": "auto",
|
||||
"task": "Create a comprehensive blog post about sustainable investing, including research, writing, editing, and SEO optimization",
|
||||
"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("Auto swarm completed successfully!")
|
||||
print(f"Selected architecture: {result['metadata']['selected_swarm_type']}")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Content: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "auto-content-creation",
|
||||
"swarm_type": "SequentialWorkflow",
|
||||
"task": "Create a comprehensive blog post about sustainable investing, including research, writing, editing, and SEO optimization",
|
||||
"output": {
|
||||
"research_phase": {
|
||||
"key_findings": "Sustainable investing has grown 42% in the past two years...",
|
||||
"market_trends": "ESG funds outperformed traditional funds by 3.2%...",
|
||||
"statistics": "Global sustainable investment assets reached $35.3 trillion..."
|
||||
},
|
||||
"writing_phase": {
|
||||
"title": "The Future of Sustainable Investing: A Guide to ESG Strategies",
|
||||
"content": "Comprehensive blog post with introduction, main sections, and conclusion...",
|
||||
"word_count": 1850
|
||||
},
|
||||
"editing_phase": {
|
||||
"improvements": "Enhanced clarity, improved flow, corrected grammar",
|
||||
"readability_score": "Grade 8 level - accessible to general audience",
|
||||
"final_content": "Polished blog post ready for publication..."
|
||||
},
|
||||
"seo_optimization": {
|
||||
"target_keywords": ["sustainable investing", "ESG funds", "green finance"],
|
||||
"meta_description": "Discover the future of sustainable investing...",
|
||||
"optimized_content": "SEO-optimized version with strategic keyword placement"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"auto_selection": {
|
||||
"selected_swarm_type": "SequentialWorkflow",
|
||||
"reasoning": "Task requires step-by-step content creation process where each phase builds on the previous",
|
||||
"analysis": {
|
||||
"task_complexity": "Medium-High",
|
||||
"sequential_dependencies": true,
|
||||
"parallel_opportunities": false,
|
||||
"collaboration_needs": "Low"
|
||||
}
|
||||
},
|
||||
"generated_agents": [
|
||||
"Research Specialist",
|
||||
"Content Writer",
|
||||
"Editor",
|
||||
"SEO Optimizer"
|
||||
],
|
||||
"execution_time_seconds": 43.2,
|
||||
"billing_info": {
|
||||
"total_cost": 0.087
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Advanced Auto Usage
|
||||
|
||||
You can provide additional context to help the Auto selection:
|
||||
|
||||
=== "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": "Auto Business Analysis",
|
||||
"description": "Automatic swarm selection for business analysis",
|
||||
"swarm_type": "auto",
|
||||
"task": "Analyze market opportunities for a new AI startup in healthcare",
|
||||
"rules": "Need multiple perspectives from different business functions, time-sensitive analysis required",
|
||||
"max_loops": 1
|
||||
}'
|
||||
```
|
||||
|
||||
=== "Python (requests)"
|
||||
```python
|
||||
swarm_config = {
|
||||
"name": "Auto Business Analysis",
|
||||
"description": "Automatic swarm selection for business analysis",
|
||||
"swarm_type": "auto",
|
||||
"task": "Analyze market opportunities for a new AI startup in healthcare",
|
||||
"rules": "Need multiple perspectives from different business functions, time-sensitive analysis required",
|
||||
"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(f"Auto selected: {result['metadata']['auto_selection']['selected_swarm_type']}")
|
||||
print(f"Reasoning: {result['metadata']['auto_selection']['reasoning']}")
|
||||
```
|
||||
|
||||
## Selection Logic
|
||||
|
||||
The Auto swarm type analyzes various factors to make its selection:
|
||||
|
||||
| Factor | Consideration |
|
||||
|--------|---------------|
|
||||
| **Task Complexity** | Simple → Single agent, Complex → Multi-agent |
|
||||
| **Sequential Dependencies** | Dependencies → SequentialWorkflow |
|
||||
| **Parallel Opportunities** | Independent subtasks → ConcurrentWorkflow |
|
||||
| **Collaboration Needs** | Discussion required → GroupChat |
|
||||
| **Expertise Diversity** | Multiple domains → MixtureOfAgents |
|
||||
| **Management Needs** | Oversight required → HierarchicalSwarm |
|
||||
| **Routing Requirements** | Task distribution → MultiAgentRouter |
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Provide detailed task descriptions for better selection
|
||||
- Use `rules` parameter to guide selection criteria
|
||||
- Review the selected architecture in response metadata
|
||||
- Ideal for users new to swarm architectures
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
Since Auto can select any swarm type, it's related to all architectures:
|
||||
- [AutoSwarmBuilder](auto_swarm_builder.md) - For automatic agent generation
|
||||
- [SequentialWorkflow](sequential_workflow.md) - Often selected for linear tasks
|
||||
- [ConcurrentWorkflow](concurrent_workflow.md) - For parallel processing needs
|
||||
- [MixtureOfAgents](mixture_of_agents.md) - For diverse expertise requirements
|
@ -0,0 +1,195 @@
|
||||
# AutoSwarmBuilder
|
||||
|
||||
*Automatically configures optimal swarm architectures based on task requirements*
|
||||
|
||||
**Swarm Type**: `AutoSwarmBuilder`
|
||||
|
||||
## Overview
|
||||
|
||||
The AutoSwarmBuilder automatically configures optimal agent architectures based on task requirements and performance metrics, simplifying swarm creation. This intelligent system analyzes the given task and automatically generates the most suitable agent configuration, eliminating the need for manual swarm design.
|
||||
|
||||
Key features:
|
||||
- **Intelligent Configuration**: Automatically designs optimal swarm structures
|
||||
- **Task-Adaptive**: Adapts architecture based on specific task requirements
|
||||
- **Performance Optimization**: Selects configurations for maximum efficiency
|
||||
- **Simplified Setup**: Eliminates manual agent configuration complexity
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Quick prototyping and experimentation
|
||||
- Unknown or complex task requirements
|
||||
- Automated swarm optimization
|
||||
- Simplified swarm creation for non-experts
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic AutoSwarmBuilder 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": "Auto Marketing Campaign",
|
||||
"description": "Automatically build optimal swarm for marketing campaign creation",
|
||||
"swarm_type": "AutoSwarmBuilder",
|
||||
"task": "Create a comprehensive digital marketing campaign for a new sustainable fashion brand targeting Gen Z consumers",
|
||||
"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": "Auto Marketing Campaign",
|
||||
"description": "Automatically build optimal swarm for marketing campaign creation",
|
||||
"swarm_type": "AutoSwarmBuilder",
|
||||
"task": "Create a comprehensive digital marketing campaign for a new sustainable fashion brand targeting Gen Z consumers",
|
||||
"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("AutoSwarmBuilder completed successfully!")
|
||||
print(f"Generated swarm architecture: {result['metadata']['generated_architecture']}")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Campaign output: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "auto-marketing-campaign",
|
||||
"swarm_type": "AutoSwarmBuilder",
|
||||
"task": "Create a comprehensive digital marketing campaign for a new sustainable fashion brand targeting Gen Z consumers",
|
||||
"output": {
|
||||
"campaign_strategy": {
|
||||
"brand_positioning": "Authentic, sustainable fashion for conscious Gen Z consumers",
|
||||
"key_messaging": "Style that makes a difference - fashion with purpose",
|
||||
"target_demographics": "Ages 18-26, environmentally conscious, social media active"
|
||||
},
|
||||
"content_strategy": {
|
||||
"social_platforms": ["TikTok", "Instagram", "Pinterest"],
|
||||
"content_pillars": ["Sustainability education", "Style inspiration", "Behind-the-scenes"],
|
||||
"posting_schedule": "Daily posts across platforms with peak engagement timing"
|
||||
},
|
||||
"influencer_strategy": {
|
||||
"tier_1": "Micro-influencers (10K-100K followers) focused on sustainability",
|
||||
"tier_2": "Fashion nano-influencers (1K-10K followers) for authentic engagement",
|
||||
"collaboration_types": ["Product partnerships", "Brand ambassador programs"]
|
||||
},
|
||||
"paid_advertising": {
|
||||
"platforms": ["Instagram Ads", "TikTok Ads", "Google Ads"],
|
||||
"budget_allocation": "40% social media, 30% search, 30% video content",
|
||||
"targeting_strategy": "Interest-based and lookalike audiences"
|
||||
},
|
||||
"metrics_and_kpis": {
|
||||
"awareness": "Brand mention volume, reach, impressions",
|
||||
"engagement": "Comments, shares, saves, time spent",
|
||||
"conversion": "Website traffic, email signups, sales"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"generated_architecture": {
|
||||
"selected_swarm_type": "MixtureOfAgents",
|
||||
"generated_agents": [
|
||||
"Brand Strategy Expert",
|
||||
"Gen Z Marketing Specialist",
|
||||
"Social Media Content Creator",
|
||||
"Influencer Marketing Manager",
|
||||
"Digital Advertising Strategist"
|
||||
],
|
||||
"reasoning": "Complex marketing campaign requires diverse expertise working collaboratively"
|
||||
},
|
||||
"auto_optimization": {
|
||||
"task_complexity": "High",
|
||||
"required_expertise_areas": 5,
|
||||
"optimal_architecture": "Collaborative with specialized agents"
|
||||
},
|
||||
"execution_time_seconds": 28.6,
|
||||
"billing_info": {
|
||||
"total_cost": 0.071
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
You can provide additional guidance to the AutoSwarmBuilder:
|
||||
|
||||
=== "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": "Auto Research Project",
|
||||
"description": "Auto-build research swarm with specific constraints",
|
||||
"swarm_type": "AutoSwarmBuilder",
|
||||
"task": "Conduct comprehensive research on the impact of AI on healthcare outcomes",
|
||||
"rules": "Focus on peer-reviewed sources, include cost-benefit analysis, ensure balanced perspective on risks and benefits",
|
||||
"max_loops": 1
|
||||
}'
|
||||
```
|
||||
|
||||
=== "Python (requests)"
|
||||
```python
|
||||
swarm_config = {
|
||||
"name": "Auto Research Project",
|
||||
"description": "Auto-build research swarm with specific constraints",
|
||||
"swarm_type": "AutoSwarmBuilder",
|
||||
"task": "Conduct comprehensive research on the impact of AI on healthcare outcomes",
|
||||
"rules": "Focus on peer-reviewed sources, include cost-benefit analysis, ensure balanced perspective on risks and benefits",
|
||||
"max_loops": 1
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
f"{API_BASE_URL}/v1/swarm/completions",
|
||||
headers=headers,
|
||||
json=swarm_config
|
||||
)
|
||||
```
|
||||
|
||||
## Configuration Options
|
||||
|
||||
| Parameter | Type | Description | Default |
|
||||
|-----------|------|-------------|---------|
|
||||
| `task` | string | Task description for automatic optimization | Required |
|
||||
| `rules` | string | Additional constraints and guidelines | None |
|
||||
| `max_loops` | integer | Maximum execution rounds | 1 |
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Provide detailed, specific task descriptions for better optimization
|
||||
- Use `rules` parameter to guide the automatic configuration
|
||||
- Ideal for rapid prototyping and experimentation
|
||||
- Review generated architecture in response metadata
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [Auto](auto.md) - For automatic swarm type selection
|
||||
- [MixtureOfAgents](mixture_of_agents.md) - Often selected by AutoSwarmBuilder
|
||||
- [HierarchicalSwarm](hierarchical_swarm.md) - For complex structured tasks
|
@ -0,0 +1,198 @@
|
||||
# ConcurrentWorkflow
|
||||
|
||||
*Runs independent tasks in parallel for faster processing*
|
||||
|
||||
**Swarm Type**: `ConcurrentWorkflow`
|
||||
|
||||
## Overview
|
||||
|
||||
The ConcurrentWorkflow swarm type runs independent tasks in parallel, significantly reducing processing time for complex operations. This architecture is ideal for tasks that can be processed simultaneously without dependencies, allowing multiple agents to work on different aspects of a problem at the same time.
|
||||
|
||||
Key features:
|
||||
- **Parallel Execution**: Multiple agents work simultaneously
|
||||
- **Reduced Processing Time**: Faster completion through parallelization
|
||||
- **Independent Tasks**: Agents work on separate, non-dependent subtasks
|
||||
- **Scalable Performance**: Performance scales with the number of agents
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Independent data analysis tasks
|
||||
- Parallel content generation
|
||||
- Multi-source research projects
|
||||
- Distributed problem solving
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic ConcurrentWorkflow 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 Concurrent",
|
||||
"description": "Parallel market research across different sectors",
|
||||
"swarm_type": "ConcurrentWorkflow",
|
||||
"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 Concurrent",
|
||||
"description": "Parallel market research across different sectors",
|
||||
"swarm_type": "ConcurrentWorkflow",
|
||||
"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("ConcurrentWorkflow swarm completed successfully!")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Parallel results: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "market-research-concurrent",
|
||||
"swarm_type": "ConcurrentWorkflow",
|
||||
"task": "Research and analyze market opportunities in AI, healthcare, fintech, and e-commerce sectors",
|
||||
"output": {
|
||||
"ai_market_analysis": {
|
||||
"market_size": "$150B by 2025",
|
||||
"growth_rate": "25% CAGR",
|
||||
"key_opportunities": ["Generative AI", "Edge AI", "AI Infrastructure"]
|
||||
},
|
||||
"healthcare_analysis": {
|
||||
"market_size": "$350B by 2025",
|
||||
"growth_rate": "12% CAGR",
|
||||
"key_opportunities": ["Telemedicine", "AI Diagnostics", "Digital Therapeutics"]
|
||||
},
|
||||
"fintech_analysis": {
|
||||
"market_size": "$200B by 2025",
|
||||
"growth_rate": "18% CAGR",
|
||||
"key_opportunities": ["DeFi", "Digital Banking", "Payment Infrastructure"]
|
||||
},
|
||||
"ecommerce_analysis": {
|
||||
"market_size": "$8T by 2025",
|
||||
"growth_rate": "14% CAGR",
|
||||
"key_opportunities": ["Social Commerce", "B2B Marketplaces", "Sustainable Commerce"]
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"parallel_execution": true,
|
||||
"agents_completed_simultaneously": 4,
|
||||
"execution_time_seconds": 12.8,
|
||||
"billing_info": {
|
||||
"total_cost": 0.052
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Design independent tasks that don't require sequential dependencies
|
||||
- Use for tasks that can be parallelized effectively
|
||||
- Ensure agents have distinct, non-overlapping responsibilities
|
||||
- Ideal for time-sensitive analysis requiring multiple perspectives
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [SequentialWorkflow](sequential_workflow.md) - For ordered execution
|
||||
- [MixtureOfAgents](mixture_of_agents.md) - For collaborative analysis
|
||||
- [MultiAgentRouter](multi_agent_router.md) - For intelligent task distribution
|
@ -0,0 +1,204 @@
|
||||
# GroupChat
|
||||
|
||||
*Enables dynamic collaboration through chat-based interaction*
|
||||
|
||||
**Swarm Type**: `GroupChat`
|
||||
|
||||
## Overview
|
||||
|
||||
The GroupChat swarm type enables dynamic collaboration between agents through a chat-based interface, facilitating real-time information sharing and decision-making. Agents participate in a conversational workflow where they can build upon each other's contributions, debate ideas, and reach consensus through natural dialogue.
|
||||
|
||||
Key features:
|
||||
- **Interactive Dialogue**: Agents communicate through natural conversation
|
||||
- **Dynamic Collaboration**: Real-time information sharing and building upon ideas
|
||||
- **Consensus Building**: Agents can debate and reach decisions collectively
|
||||
- **Flexible Participation**: Agents can contribute when relevant to the discussion
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Brainstorming and ideation sessions
|
||||
- Multi-perspective problem analysis
|
||||
- Collaborative decision-making processes
|
||||
- Creative content development
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic GroupChat 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": "Product Strategy Discussion",
|
||||
"description": "Collaborative chat to develop product strategy",
|
||||
"swarm_type": "GroupChat",
|
||||
"task": "Discuss and develop a go-to-market strategy for a new AI-powered productivity tool targeting small businesses",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Product Manager",
|
||||
"description": "Leads product strategy and development",
|
||||
"system_prompt": "You are a senior product manager. Focus on product positioning, features, user needs, and market fit. Ask probing questions and build on others ideas.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.6
|
||||
},
|
||||
{
|
||||
"agent_name": "Marketing Strategist",
|
||||
"description": "Develops marketing and positioning strategy",
|
||||
"system_prompt": "You are a marketing strategist. Focus on target audience, messaging, channels, and competitive positioning. Contribute marketing insights to the discussion.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.7
|
||||
},
|
||||
{
|
||||
"agent_name": "Sales Director",
|
||||
"description": "Provides sales and customer perspective",
|
||||
"system_prompt": "You are a sales director with small business experience. Focus on pricing, sales process, customer objections, and market adoption. Share practical sales insights.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.5
|
||||
},
|
||||
{
|
||||
"agent_name": "UX Researcher",
|
||||
"description": "Represents user experience and research insights",
|
||||
"system_prompt": "You are a UX researcher specializing in small business tools. Focus on user behavior, usability, adoption barriers, and design considerations.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.4
|
||||
}
|
||||
],
|
||||
"max_loops": 3
|
||||
}'
|
||||
```
|
||||
|
||||
=== "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": "Product Strategy Discussion",
|
||||
"description": "Collaborative chat to develop product strategy",
|
||||
"swarm_type": "GroupChat",
|
||||
"task": "Discuss and develop a go-to-market strategy for a new AI-powered productivity tool targeting small businesses",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Product Manager",
|
||||
"description": "Leads product strategy and development",
|
||||
"system_prompt": "You are a senior product manager. Focus on product positioning, features, user needs, and market fit. Ask probing questions and build on others ideas.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.6
|
||||
},
|
||||
{
|
||||
"agent_name": "Marketing Strategist",
|
||||
"description": "Develops marketing and positioning strategy",
|
||||
"system_prompt": "You are a marketing strategist. Focus on target audience, messaging, channels, and competitive positioning. Contribute marketing insights to the discussion.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.7
|
||||
},
|
||||
{
|
||||
"agent_name": "Sales Director",
|
||||
"description": "Provides sales and customer perspective",
|
||||
"system_prompt": "You are a sales director with small business experience. Focus on pricing, sales process, customer objections, and market adoption. Share practical sales insights.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.5
|
||||
},
|
||||
{
|
||||
"agent_name": "UX Researcher",
|
||||
"description": "Represents user experience and research insights",
|
||||
"system_prompt": "You are a UX researcher specializing in small business tools. Focus on user behavior, usability, adoption barriers, and design considerations.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 3,
|
||||
"temperature": 0.4
|
||||
}
|
||||
],
|
||||
"max_loops": 3
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
f"{API_BASE_URL}/v1/swarm/completions",
|
||||
headers=headers,
|
||||
json=swarm_config
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
print("GroupChat swarm completed successfully!")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Chat discussion: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "product-strategy-discussion",
|
||||
"swarm_type": "GroupChat",
|
||||
"task": "Discuss and develop a go-to-market strategy for a new AI-powered productivity tool targeting small businesses",
|
||||
"output": {
|
||||
"chat_transcript": [
|
||||
{
|
||||
"agent": "Product Manager",
|
||||
"message": "Let's start by defining our target user. What specific pain points do small businesses have with productivity tools?"
|
||||
},
|
||||
{
|
||||
"agent": "UX Researcher",
|
||||
"message": "From our research, small businesses struggle with tool complexity and time to value. They need something that works immediately without extensive setup."
|
||||
},
|
||||
{
|
||||
"agent": "Sales Director",
|
||||
"message": "I agree. SMBs have limited time and resources. They typically abandon tools that require more than a week to see value. Pricing is also critical - they're very cost-conscious."
|
||||
},
|
||||
{
|
||||
"agent": "Marketing Strategist",
|
||||
"message": "This suggests we should focus on 'instant productivity gains' messaging. We could position against complex enterprise tools that overwhelm small teams."
|
||||
}
|
||||
],
|
||||
"key_decisions": [
|
||||
"Target: Small businesses with 5-50 employees",
|
||||
"Positioning: Simple, immediate productivity gains",
|
||||
"Pricing: Freemium model with low-cost paid tiers",
|
||||
"GTM: Self-serve with strong onboarding"
|
||||
],
|
||||
"final_strategy": "Launch with freemium model targeting productivity-focused small businesses through content marketing and self-serve channels..."
|
||||
},
|
||||
"metadata": {
|
||||
"conversation_rounds": 3,
|
||||
"total_messages": 12,
|
||||
"consensus_reached": true,
|
||||
"execution_time_seconds": 38.7,
|
||||
"billing_info": {
|
||||
"total_cost": 0.095
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Set clear discussion goals and objectives
|
||||
- Use diverse agent personalities for richer dialogue
|
||||
- Allow multiple conversation rounds for idea development
|
||||
- Encourage agents to build upon each other's contributions
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [MixtureOfAgents](mixture_of_agents.md) - For complementary expertise
|
||||
- [MajorityVoting](majority_voting.md) - For consensus decision-making
|
||||
- [AutoSwarmBuilder](auto_swarm_builder.md) - For automatic discussion setup
|
@ -0,0 +1,241 @@
|
||||
# HierarchicalSwarm
|
||||
|
||||
*Implements structured, multi-level task management with clear authority*
|
||||
|
||||
**Swarm Type**: `HierarchicalSwarm`
|
||||
|
||||
## 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.
|
||||
|
||||
Key features:
|
||||
- **Structured Hierarchy**: Clear organizational structure with managers and workers
|
||||
- **Delegated Authority**: Manager agents distribute tasks to specialized workers
|
||||
- **Quality Oversight**: Multi-level review and validation processes
|
||||
- **Scalable Organization**: Efficient coordination of large agent teams
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Complex projects requiring management oversight
|
||||
- Large-scale content production workflows
|
||||
- Multi-stage validation and review processes
|
||||
- Enterprise-level task coordination
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic HierarchicalSwarm 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": "Software Development Hierarchy",
|
||||
"description": "Hierarchical software development team with project manager oversight",
|
||||
"swarm_type": "HierarchicalSwarm",
|
||||
"task": "Design and plan a new mobile app for expense tracking targeting freelancers",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Project Manager",
|
||||
"description": "Oversees project planning and coordinates team efforts",
|
||||
"system_prompt": "You are a senior project manager. Coordinate the team, break down tasks, ensure quality, and synthesize outputs. Delegate specific tasks to team members.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "manager",
|
||||
"max_loops": 2,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "UX Designer",
|
||||
"description": "Designs user experience and interface",
|
||||
"system_prompt": "You are a UX designer specializing in mobile apps. Focus on user flows, wireframes, and interface design. Report findings to the project manager.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.6
|
||||
},
|
||||
{
|
||||
"agent_name": "Technical Architect",
|
||||
"description": "Designs technical architecture and system requirements",
|
||||
"system_prompt": "You are a technical architect. Focus on system design, technology stack, database design, and technical requirements. Provide technical guidance.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Business Analyst",
|
||||
"description": "Analyzes business requirements and market fit",
|
||||
"system_prompt": "You are a business analyst. Focus on requirements gathering, market analysis, feature prioritization, and business logic.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "QA Specialist",
|
||||
"description": "Ensures quality and validates deliverables",
|
||||
"system_prompt": "You are a QA specialist. Review all outputs for quality, completeness, and consistency. Identify gaps and suggest improvements.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"max_loops": 2
|
||||
}'
|
||||
```
|
||||
|
||||
=== "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": "Software Development Hierarchy",
|
||||
"description": "Hierarchical software development team with project manager oversight",
|
||||
"swarm_type": "HierarchicalSwarm",
|
||||
"task": "Design and plan a new mobile app for expense tracking targeting freelancers",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Project Manager",
|
||||
"description": "Oversees project planning and coordinates team efforts",
|
||||
"system_prompt": "You are a senior project manager. Coordinate the team, break down tasks, ensure quality, and synthesize outputs. Delegate specific tasks to team members.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "manager",
|
||||
"max_loops": 2,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "UX Designer",
|
||||
"description": "Designs user experience and interface",
|
||||
"system_prompt": "You are a UX designer specializing in mobile apps. Focus on user flows, wireframes, and interface design. Report findings to the project manager.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.6
|
||||
},
|
||||
{
|
||||
"agent_name": "Technical Architect",
|
||||
"description": "Designs technical architecture and system requirements",
|
||||
"system_prompt": "You are a technical architect. Focus on system design, technology stack, database design, and technical requirements. Provide technical guidance.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Business Analyst",
|
||||
"description": "Analyzes business requirements and market fit",
|
||||
"system_prompt": "You are a business analyst. Focus on requirements gathering, market analysis, feature prioritization, and business logic.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "QA Specialist",
|
||||
"description": "Ensures quality and validates deliverables",
|
||||
"system_prompt": "You are a QA specialist. Review all outputs for quality, completeness, and consistency. Identify gaps and suggest improvements.",
|
||||
"model_name": "gpt-4o",
|
||||
"role": "worker",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"max_loops": 2
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
f"{API_BASE_URL}/v1/swarm/completions",
|
||||
headers=headers,
|
||||
json=swarm_config
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
print("HierarchicalSwarm 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
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "software-development-hierarchy",
|
||||
"swarm_type": "HierarchicalSwarm",
|
||||
"task": "Design and plan a new mobile app for expense tracking targeting freelancers",
|
||||
"output": {
|
||||
"project_overview": {
|
||||
"manager_synthesis": "Comprehensive project plan for freelancer expense tracking app...",
|
||||
"timeline": "16-week development cycle",
|
||||
"key_deliverables": ["UX Design", "Technical Architecture", "Business Requirements", "QA Framework"]
|
||||
},
|
||||
"ux_design": {
|
||||
"user_flows": "Streamlined expense entry and categorization flows...",
|
||||
"wireframes": "Mobile-first design with dashboard and reporting views...",
|
||||
"usability_considerations": "One-tap expense entry, photo receipt capture..."
|
||||
},
|
||||
"technical_architecture": {
|
||||
"tech_stack": "React Native, Node.js, PostgreSQL, AWS",
|
||||
"system_design": "Microservices architecture with offline capability...",
|
||||
"security_requirements": "End-to-end encryption, secure authentication..."
|
||||
},
|
||||
"business_requirements": {
|
||||
"target_market": "Freelancers and independent contractors",
|
||||
"core_features": ["Expense tracking", "Receipt scanning", "Tax reporting"],
|
||||
"monetization": "Freemium model with premium reporting features"
|
||||
},
|
||||
"qa_framework": {
|
||||
"testing_strategy": "Automated testing for core functions...",
|
||||
"quality_metrics": "Performance, usability, and security benchmarks...",
|
||||
"validation_checkpoints": "Weekly reviews and milestone validations"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"hierarchy_structure": {
|
||||
"managers": ["Project Manager"],
|
||||
"workers": ["UX Designer", "Technical Architect", "Business Analyst", "QA Specialist"]
|
||||
},
|
||||
"coordination_rounds": 2,
|
||||
"task_delegation": "Manager coordinated 4 specialized work streams",
|
||||
"execution_time_seconds": 52.4,
|
||||
"billing_info": {
|
||||
"total_cost": 0.128
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration Options
|
||||
|
||||
| Parameter | Type | Description | Default |
|
||||
|-----------|------|-------------|---------|
|
||||
| `role` | string | Agent role: "manager" or "worker" | "worker" |
|
||||
| `agents` | Array<AgentSpec> | Mix of manager and worker agents | Required |
|
||||
| `max_loops` | integer | Coordination rounds for managers | 1 |
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Clearly define manager and worker roles using the `role` parameter
|
||||
- Give managers higher `max_loops` for coordination activities
|
||||
- Design worker agents with specialized, focused responsibilities
|
||||
- Use for complex projects requiring oversight and coordination
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [SequentialWorkflow](sequential_workflow.md) - For linear task progression
|
||||
- [MultiAgentRouter](multi_agent_router.md) - For intelligent task routing
|
||||
- [AutoSwarmBuilder](auto_swarm_builder.md) - For automatic hierarchy creation
|
@ -0,0 +1,240 @@
|
||||
# MajorityVoting
|
||||
|
||||
*Implements robust decision-making through consensus and voting*
|
||||
|
||||
**Swarm Type**: `MajorityVoting`
|
||||
|
||||
## Overview
|
||||
|
||||
The MajorityVoting swarm type implements robust decision-making through consensus mechanisms, ideal for tasks requiring collective intelligence or verification. Multiple agents independently analyze the same problem and vote on the best solution, ensuring high-quality, well-validated outcomes through democratic consensus.
|
||||
|
||||
Key features:
|
||||
- **Consensus-Based Decisions**: Multiple agents vote on the best solution
|
||||
- **Quality Assurance**: Reduces individual agent bias through collective input
|
||||
- **Democratic Process**: Fair and transparent decision-making mechanism
|
||||
- **Robust Validation**: Multiple perspectives ensure thorough analysis
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Critical decision-making requiring validation
|
||||
- Quality assurance and verification tasks
|
||||
- Complex problem solving with multiple viable solutions
|
||||
- Risk assessment and evaluation scenarios
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic MajorityVoting 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": "Investment Decision Voting",
|
||||
"description": "Multiple financial experts vote on investment recommendations",
|
||||
"swarm_type": "MajorityVoting",
|
||||
"task": "Evaluate whether to invest $1M in a renewable energy startup. Consider market potential, financial projections, team strength, and competitive landscape.",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Growth Investor",
|
||||
"description": "Focuses on growth potential and market opportunity",
|
||||
"system_prompt": "You are a growth-focused venture capitalist. Evaluate investments based on market size, scalability, and growth potential. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Financial Analyst",
|
||||
"description": "Analyzes financial metrics and projections",
|
||||
"system_prompt": "You are a financial analyst specializing in startups. Evaluate financial projections, revenue models, and unit economics. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Technical Due Diligence",
|
||||
"description": "Evaluates technology and product viability",
|
||||
"system_prompt": "You are a technical due diligence expert. Assess technology viability, intellectual property, product-market fit, and technical risks. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Market Analyst",
|
||||
"description": "Analyzes market conditions and competition",
|
||||
"system_prompt": "You are a market research analyst. Evaluate market dynamics, competitive landscape, regulatory environment, and market timing. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Risk Assessor",
|
||||
"description": "Identifies and evaluates investment risks",
|
||||
"system_prompt": "You are a risk assessment specialist. Identify potential risks, evaluate mitigation strategies, and assess overall risk profile. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"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": "Investment Decision Voting",
|
||||
"description": "Multiple financial experts vote on investment recommendations",
|
||||
"swarm_type": "MajorityVoting",
|
||||
"task": "Evaluate whether to invest $1M in a renewable energy startup. Consider market potential, financial projections, team strength, and competitive landscape.",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Growth Investor",
|
||||
"description": "Focuses on growth potential and market opportunity",
|
||||
"system_prompt": "You are a growth-focused venture capitalist. Evaluate investments based on market size, scalability, and growth potential. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Financial Analyst",
|
||||
"description": "Analyzes financial metrics and projections",
|
||||
"system_prompt": "You are a financial analyst specializing in startups. Evaluate financial projections, revenue models, and unit economics. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Technical Due Diligence",
|
||||
"description": "Evaluates technology and product viability",
|
||||
"system_prompt": "You are a technical due diligence expert. Assess technology viability, intellectual property, product-market fit, and technical risks. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Market Analyst",
|
||||
"description": "Analyzes market conditions and competition",
|
||||
"system_prompt": "You are a market research analyst. Evaluate market dynamics, competitive landscape, regulatory environment, and market timing. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Risk Assessor",
|
||||
"description": "Identifies and evaluates investment risks",
|
||||
"system_prompt": "You are a risk assessment specialist. Identify potential risks, evaluate mitigation strategies, and assess overall risk profile. Provide a recommendation with confidence score.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"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("MajorityVoting completed successfully!")
|
||||
print(f"Final decision: {result['output']['consensus_decision']}")
|
||||
print(f"Vote breakdown: {result['metadata']['vote_breakdown']}")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "investment-decision-voting",
|
||||
"swarm_type": "MajorityVoting",
|
||||
"task": "Evaluate whether to invest $1M in a renewable energy startup. Consider market potential, financial projections, team strength, and competitive landscape.",
|
||||
"output": {
|
||||
"individual_recommendations": [
|
||||
{
|
||||
"agent": "Growth Investor",
|
||||
"recommendation": "INVEST",
|
||||
"confidence": 0.8,
|
||||
"reasoning": "Strong market growth potential in renewable energy sector, scalable technology platform"
|
||||
},
|
||||
{
|
||||
"agent": "Financial Analyst",
|
||||
"recommendation": "INVEST",
|
||||
"confidence": 0.7,
|
||||
"reasoning": "Solid financial projections, reasonable burn rate, clear path to profitability"
|
||||
},
|
||||
{
|
||||
"agent": "Technical Due Diligence",
|
||||
"recommendation": "INVEST",
|
||||
"confidence": 0.75,
|
||||
"reasoning": "Innovative technology with strong IP portfolio, experienced technical team"
|
||||
},
|
||||
{
|
||||
"agent": "Market Analyst",
|
||||
"recommendation": "WAIT",
|
||||
"confidence": 0.6,
|
||||
"reasoning": "Highly competitive market, regulatory uncertainties may impact timeline"
|
||||
},
|
||||
{
|
||||
"agent": "Risk Assessor",
|
||||
"recommendation": "INVEST",
|
||||
"confidence": 0.65,
|
||||
"reasoning": "Manageable risks with strong mitigation strategies, experienced leadership team"
|
||||
}
|
||||
],
|
||||
"consensus_decision": "INVEST",
|
||||
"consensus_confidence": 0.72,
|
||||
"consensus_reasoning": "4 out of 5 experts recommend investment with strong market potential and solid fundamentals, despite some market uncertainties"
|
||||
},
|
||||
"metadata": {
|
||||
"vote_breakdown": {
|
||||
"INVEST": 4,
|
||||
"WAIT": 1,
|
||||
"REJECT": 0
|
||||
},
|
||||
"vote_percentage": {
|
||||
"INVEST": "80%",
|
||||
"WAIT": "20%",
|
||||
"REJECT": "0%"
|
||||
},
|
||||
"average_confidence": 0.70,
|
||||
"consensus_threshold": "Simple majority (50%+)",
|
||||
"execution_time_seconds": 25.8,
|
||||
"billing_info": {
|
||||
"total_cost": 0.063
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Use odd numbers of agents to avoid tie votes
|
||||
- Design agents with different perspectives for robust evaluation
|
||||
- Include confidence scores in agent prompts for weighted decisions
|
||||
- Ideal for high-stakes decisions requiring validation
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [GroupChat](group_chat.md) - For discussion-based consensus
|
||||
- [MixtureOfAgents](mixture_of_agents.md) - For diverse expertise collaboration
|
||||
- [HierarchicalSwarm](hierarchical_swarm.md) - For structured decision-making
|
@ -0,0 +1,248 @@
|
||||
# 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
|
||||
|
||||
### Basic MALT 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": "Legal Document Analysis MALT",
|
||||
"description": "Advanced linguistic analysis of legal documents using MALT framework",
|
||||
"swarm_type": "MALT",
|
||||
"task": "Perform comprehensive linguistic analysis of a complex legal contract including sentiment analysis, risk identification, clause categorization, and language complexity assessment",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Syntactic Analyzer",
|
||||
"description": "Analyzes sentence structure and grammar",
|
||||
"system_prompt": "You are a syntactic analysis expert. Analyze sentence structure, grammatical patterns, and linguistic complexity in legal texts.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Semantic Analyzer",
|
||||
"description": "Analyzes meaning and semantic relationships",
|
||||
"system_prompt": "You are a semantic analysis expert. Extract meaning, identify semantic relationships, and analyze conceptual content in legal documents.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Pragmatic Analyzer",
|
||||
"description": "Analyzes context and implied meanings",
|
||||
"system_prompt": "You are a pragmatic analysis expert. Analyze contextual meaning, implied obligations, and pragmatic implications in legal language.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "Discourse Analyzer",
|
||||
"description": "Analyzes document structure and flow",
|
||||
"system_prompt": "You are a discourse analysis expert. Analyze document structure, logical flow, and coherence in legal texts.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Risk Language Detector",
|
||||
"description": "Identifies risk-related language patterns",
|
||||
"system_prompt": "You are a legal risk language expert. Identify risk indicators, liability language, and potential legal concerns in contract language.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"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": "Legal Document Analysis MALT",
|
||||
"description": "Advanced linguistic analysis of legal documents using MALT framework",
|
||||
"swarm_type": "MALT",
|
||||
"task": "Perform comprehensive linguistic analysis of a complex legal contract including sentiment analysis, risk identification, clause categorization, and language complexity assessment",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Syntactic Analyzer",
|
||||
"description": "Analyzes sentence structure and grammar",
|
||||
"system_prompt": "You are a syntactic analysis expert. Analyze sentence structure, grammatical patterns, and linguistic complexity in legal texts.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Semantic Analyzer",
|
||||
"description": "Analyzes meaning and semantic relationships",
|
||||
"system_prompt": "You are a semantic analysis expert. Extract meaning, identify semantic relationships, and analyze conceptual content in legal documents.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Pragmatic Analyzer",
|
||||
"description": "Analyzes context and implied meanings",
|
||||
"system_prompt": "You are a pragmatic analysis expert. Analyze contextual meaning, implied obligations, and pragmatic implications in legal language.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "Discourse Analyzer",
|
||||
"description": "Analyzes document structure and flow",
|
||||
"system_prompt": "You are a discourse analysis expert. Analyze document structure, logical flow, and coherence in legal texts.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Risk Language Detector",
|
||||
"description": "Identifies risk-related language patterns",
|
||||
"system_prompt": "You are a legal risk language expert. Identify risk indicators, liability language, and potential legal concerns in contract language.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"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("MALT framework completed successfully!")
|
||||
print(f"Linguistic analysis: {result['output']['linguistic_analysis']}")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "legal-document-analysis-malt",
|
||||
"swarm_type": "MALT",
|
||||
"task": "Perform comprehensive linguistic analysis of a complex legal contract including sentiment analysis, risk identification, clause categorization, and language complexity assessment",
|
||||
"output": {
|
||||
"linguistic_analysis": {
|
||||
"syntactic_analysis": {
|
||||
"complexity_score": 8.2,
|
||||
"sentence_structure": "Predominantly complex and compound-complex sentences",
|
||||
"grammatical_patterns": "Heavy use of passive voice, subordinate clauses, and technical terminology",
|
||||
"readability": "Graduate level (16+ years of education required)"
|
||||
},
|
||||
"semantic_analysis": {
|
||||
"key_concepts": ["liability", "indemnification", "force majeure", "intellectual property"],
|
||||
"semantic_relationships": "Strong hierarchical concept relationships with clear definitional structures",
|
||||
"conceptual_density": "High - 3.2 legal concepts per sentence average",
|
||||
"ambiguity_indicators": ["potentially", "reasonable efforts", "material adverse effect"]
|
||||
},
|
||||
"pragmatic_analysis": {
|
||||
"implied_obligations": [
|
||||
"Good faith performance expected",
|
||||
"Timely notice requirements implied",
|
||||
"Mutual cooperation assumed"
|
||||
],
|
||||
"power_dynamics": "Balanced with slight advantage to service provider",
|
||||
"speech_acts": "Predominantly commissives (commitments) and directives (obligations)"
|
||||
},
|
||||
"discourse_analysis": {
|
||||
"document_structure": "Well-organized with clear section hierarchy",
|
||||
"logical_flow": "Sequential with appropriate cross-references",
|
||||
"coherence_score": 8.5,
|
||||
"transition_patterns": "Formal legal transitions with clause numbering"
|
||||
},
|
||||
"risk_language": {
|
||||
"high_risk_terms": ["unlimited liability", "personal guarantee", "joint and several"],
|
||||
"risk_mitigation_language": ["subject to", "limited to", "except as provided"],
|
||||
"liability_indicators": 23,
|
||||
"risk_level": "Medium-High"
|
||||
}
|
||||
},
|
||||
"comprehensive_summary": {
|
||||
"language_complexity": "High complexity legal document requiring specialized knowledge",
|
||||
"risk_assessment": "Medium-high risk with standard legal protections",
|
||||
"readability_concerns": "Requires legal expertise for full comprehension",
|
||||
"recommendations": [
|
||||
"Consider plain language summary for key terms",
|
||||
"Review unlimited liability clauses",
|
||||
"Clarify ambiguous terms identified"
|
||||
]
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"malt_framework": {
|
||||
"linguistic_layers_analyzed": 5,
|
||||
"language_processing_depth": "Advanced multi-layer analysis",
|
||||
"specialized_nlp_operations": [
|
||||
"Syntactic parsing",
|
||||
"Semantic role labeling",
|
||||
"Pragmatic inference",
|
||||
"Discourse segmentation",
|
||||
"Risk pattern recognition"
|
||||
]
|
||||
},
|
||||
"execution_time_seconds": 35.7,
|
||||
"billing_info": {
|
||||
"total_cost": 0.089
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 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
|
@ -0,0 +1,187 @@
|
||||
# MixtureOfAgents
|
||||
|
||||
*Builds diverse teams of specialized agents for complex problem solving*
|
||||
|
||||
**Swarm Type**: `MixtureOfAgents`
|
||||
|
||||
## Overview
|
||||
|
||||
The MixtureOfAgents swarm type combines multiple agent types with different specializations to tackle diverse aspects of complex problems. Each agent contributes unique skills and perspectives, making this architecture ideal for tasks requiring multiple types of expertise working in harmony.
|
||||
|
||||
Key features:
|
||||
- **Diverse Expertise**: Combines agents with different specializations
|
||||
- **Collaborative Problem Solving**: Agents work together leveraging their unique strengths
|
||||
- **Comprehensive Coverage**: Ensures all aspects of complex tasks are addressed
|
||||
- **Balanced Perspectives**: Multiple viewpoints for robust decision-making
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Complex research projects requiring multiple disciplines
|
||||
- Business analysis needing various functional perspectives
|
||||
- Content creation requiring different expertise areas
|
||||
- Strategic planning with multiple considerations
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic MixtureOfAgents 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": "Business Strategy Mixture",
|
||||
"description": "Diverse team analyzing business strategy from multiple perspectives",
|
||||
"swarm_type": "MixtureOfAgents",
|
||||
"task": "Develop a comprehensive market entry strategy for a new AI product in the healthcare sector",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Market Research Analyst",
|
||||
"description": "Analyzes market trends and opportunities",
|
||||
"system_prompt": "You are a market research expert specializing in healthcare technology. Analyze market size, trends, and competitive landscape.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Financial Analyst",
|
||||
"description": "Evaluates financial viability and projections",
|
||||
"system_prompt": "You are a financial analyst expert. Assess financial implications, ROI, and cost structures for business strategies.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Regulatory Expert",
|
||||
"description": "Analyzes compliance and regulatory requirements",
|
||||
"system_prompt": "You are a healthcare regulatory expert. Analyze compliance requirements, regulatory pathways, and potential barriers.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.1
|
||||
},
|
||||
{
|
||||
"agent_name": "Technology Strategist",
|
||||
"description": "Evaluates technical feasibility and strategy",
|
||||
"system_prompt": "You are a technology strategy expert. Assess technical requirements, implementation challenges, and scalability.",
|
||||
"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": "Business Strategy Mixture",
|
||||
"description": "Diverse team analyzing business strategy from multiple perspectives",
|
||||
"swarm_type": "MixtureOfAgents",
|
||||
"task": "Develop a comprehensive market entry strategy for a new AI product in the healthcare sector",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Market Research Analyst",
|
||||
"description": "Analyzes market trends and opportunities",
|
||||
"system_prompt": "You are a market research expert specializing in healthcare technology. Analyze market size, trends, and competitive landscape.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Financial Analyst",
|
||||
"description": "Evaluates financial viability and projections",
|
||||
"system_prompt": "You are a financial analyst expert. Assess financial implications, ROI, and cost structures for business strategies.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Regulatory Expert",
|
||||
"description": "Analyzes compliance and regulatory requirements",
|
||||
"system_prompt": "You are a healthcare regulatory expert. Analyze compliance requirements, regulatory pathways, and potential barriers.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.1
|
||||
},
|
||||
{
|
||||
"agent_name": "Technology Strategist",
|
||||
"description": "Evaluates technical feasibility and strategy",
|
||||
"system_prompt": "You are a technology strategy expert. Assess technical requirements, implementation challenges, and scalability.",
|
||||
"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("MixtureOfAgents swarm completed successfully!")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Output: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "business-strategy-mixture",
|
||||
"swarm_type": "MixtureOfAgents",
|
||||
"task": "Develop a comprehensive market entry strategy for a new AI product in the healthcare sector",
|
||||
"output": {
|
||||
"market_analysis": "Detailed market research findings...",
|
||||
"financial_assessment": "Financial projections and ROI analysis...",
|
||||
"regulatory_compliance": "Regulatory requirements and pathways...",
|
||||
"technology_strategy": "Technical implementation roadmap...",
|
||||
"integrated_strategy": "Comprehensive market entry strategy combining all perspectives..."
|
||||
},
|
||||
"metadata": {
|
||||
"agent_contributions": {
|
||||
"Market Research Analyst": "Market size: $2.3B, Growth rate: 15% CAGR",
|
||||
"Financial Analyst": "Break-even: 18 months, ROI: 35%",
|
||||
"Regulatory Expert": "FDA pathway: 510(k), Timeline: 8-12 months",
|
||||
"Technology Strategist": "MVP timeline: 6 months, Scalability: High"
|
||||
},
|
||||
"execution_time_seconds": 22.1,
|
||||
"billing_info": {
|
||||
"total_cost": 0.067
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Select agents with complementary and diverse expertise
|
||||
- Ensure each agent has a clear, specialized role
|
||||
- Use for complex problems requiring multiple perspectives
|
||||
- Design tasks that benefit from collaborative analysis
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [ConcurrentWorkflow](concurrent_workflow.md) - For parallel task execution
|
||||
- [GroupChat](group_chat.md) - For collaborative discussion
|
||||
- [AutoSwarmBuilder](auto_swarm_builder.md) - For automatic team assembly
|
@ -0,0 +1,224 @@
|
||||
# MultiAgentRouter
|
||||
|
||||
*Intelligent task dispatcher distributing work based on agent capabilities*
|
||||
|
||||
**Swarm Type**: `MultiAgentRouter`
|
||||
|
||||
## Overview
|
||||
|
||||
The MultiAgentRouter acts as an intelligent task dispatcher, distributing work across agents based on their capabilities and current workload. This architecture analyzes incoming tasks and automatically routes them to the most suitable agents, optimizing both efficiency and quality of outcomes.
|
||||
|
||||
Key features:
|
||||
- **Intelligent Routing**: Automatically assigns tasks to best-suited agents
|
||||
- **Capability Matching**: Matches task requirements with agent specializations
|
||||
- **Load Balancing**: Distributes workload efficiently across available agents
|
||||
- **Dynamic Assignment**: Adapts routing based on agent performance and availability
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Customer service request routing
|
||||
- Content categorization and processing
|
||||
- Technical support ticket assignment
|
||||
- Multi-domain question answering
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic MultiAgentRouter 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": "Customer Support Router",
|
||||
"description": "Route customer inquiries to specialized support agents",
|
||||
"swarm_type": "MultiAgentRouter",
|
||||
"task": "Handle multiple customer inquiries: 1) Billing question about overcharge, 2) Technical issue with mobile app login, 3) Product recommendation for enterprise client, 4) Return policy question",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Billing Specialist",
|
||||
"description": "Handles billing, payments, and account issues",
|
||||
"system_prompt": "You are a billing specialist. Handle all billing inquiries, payment issues, refunds, and account-related questions with empathy and accuracy.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Technical Support",
|
||||
"description": "Resolves technical issues and troubleshooting",
|
||||
"system_prompt": "You are a technical support specialist. Diagnose and resolve technical issues, provide step-by-step troubleshooting, and escalate complex problems.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Sales Consultant",
|
||||
"description": "Provides product recommendations and sales support",
|
||||
"system_prompt": "You are a sales consultant. Provide product recommendations, explain features and benefits, and help customers find the right solutions.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "Policy Advisor",
|
||||
"description": "Explains company policies and procedures",
|
||||
"system_prompt": "You are a policy advisor. Explain company policies, terms of service, return procedures, and compliance requirements clearly.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.1
|
||||
}
|
||||
],
|
||||
"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": "Customer Support Router",
|
||||
"description": "Route customer inquiries to specialized support agents",
|
||||
"swarm_type": "MultiAgentRouter",
|
||||
"task": "Handle multiple customer inquiries: 1) Billing question about overcharge, 2) Technical issue with mobile app login, 3) Product recommendation for enterprise client, 4) Return policy question",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Billing Specialist",
|
||||
"description": "Handles billing, payments, and account issues",
|
||||
"system_prompt": "You are a billing specialist. Handle all billing inquiries, payment issues, refunds, and account-related questions with empathy and accuracy.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Technical Support",
|
||||
"description": "Resolves technical issues and troubleshooting",
|
||||
"system_prompt": "You are a technical support specialist. Diagnose and resolve technical issues, provide step-by-step troubleshooting, and escalate complex problems.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Sales Consultant",
|
||||
"description": "Provides product recommendations and sales support",
|
||||
"system_prompt": "You are a sales consultant. Provide product recommendations, explain features and benefits, and help customers find the right solutions.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "Policy Advisor",
|
||||
"description": "Explains company policies and procedures",
|
||||
"system_prompt": "You are a policy advisor. Explain company policies, terms of service, return procedures, and compliance requirements clearly.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.1
|
||||
}
|
||||
],
|
||||
"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("MultiAgentRouter completed successfully!")
|
||||
print(f"Routing decisions: {result['metadata']['routing_decisions']}")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Customer responses: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "customer-support-router",
|
||||
"swarm_type": "MultiAgentRouter",
|
||||
"task": "Handle multiple customer inquiries: 1) Billing question about overcharge, 2) Technical issue with mobile app login, 3) Product recommendation for enterprise client, 4) Return policy question",
|
||||
"output": {
|
||||
"inquiry_1_billing": {
|
||||
"routed_to": "Billing Specialist",
|
||||
"response": "I understand your concern about the overcharge. Let me review your account and identify the issue. I can see the duplicate charge and will process a refund within 3-5 business days...",
|
||||
"resolution_status": "Resolved - Refund processed"
|
||||
},
|
||||
"inquiry_2_technical": {
|
||||
"routed_to": "Technical Support",
|
||||
"response": "Let's troubleshoot the mobile app login issue. Please try these steps: 1) Clear app cache, 2) Update to latest version, 3) Reset password if needed...",
|
||||
"resolution_status": "In Progress - Troubleshooting steps provided"
|
||||
},
|
||||
"inquiry_3_sales": {
|
||||
"routed_to": "Sales Consultant",
|
||||
"response": "For enterprise clients, I recommend our Professional tier with advanced analytics, dedicated support, and custom integrations. This includes...",
|
||||
"resolution_status": "Proposal sent - Follow-up scheduled"
|
||||
},
|
||||
"inquiry_4_policy": {
|
||||
"routed_to": "Policy Advisor",
|
||||
"response": "Our return policy allows returns within 30 days of purchase for full refund. Items must be in original condition. Here's the complete process...",
|
||||
"resolution_status": "Information provided - Customer satisfied"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"routing_decisions": [
|
||||
{
|
||||
"inquiry": "Billing question about overcharge",
|
||||
"routed_to": "Billing Specialist",
|
||||
"confidence": 0.95,
|
||||
"reasoning": "Billing-related inquiry requires specialized financial expertise"
|
||||
},
|
||||
{
|
||||
"inquiry": "Technical issue with mobile app login",
|
||||
"routed_to": "Technical Support",
|
||||
"confidence": 0.98,
|
||||
"reasoning": "Technical troubleshooting requires technical specialist"
|
||||
},
|
||||
{
|
||||
"inquiry": "Product recommendation for enterprise client",
|
||||
"routed_to": "Sales Consultant",
|
||||
"confidence": 0.92,
|
||||
"reasoning": "Enterprise sales requires specialized sales expertise"
|
||||
},
|
||||
{
|
||||
"inquiry": "Return policy question",
|
||||
"routed_to": "Policy Advisor",
|
||||
"confidence": 0.97,
|
||||
"reasoning": "Policy questions require policy specialist knowledge"
|
||||
}
|
||||
],
|
||||
"routing_efficiency": "100% - All inquiries routed to optimal agents",
|
||||
"execution_time_seconds": 16.4,
|
||||
"billing_info": {
|
||||
"total_cost": 0.042
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Define agents with clear, distinct specializations
|
||||
- Use descriptive agent names and descriptions for better routing
|
||||
- Ideal for handling diverse task types that require different expertise
|
||||
- Monitor routing decisions to optimize agent configurations
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [HierarchicalSwarm](hierarchical_swarm.md) - For structured task management
|
||||
- [ConcurrentWorkflow](concurrent_workflow.md) - For parallel task processing
|
||||
- [AutoSwarmBuilder](auto_swarm_builder.md) - For automatic routing setup
|
@ -0,0 +1,192 @@
|
||||
# SequentialWorkflow
|
||||
|
||||
*Executes tasks in a strict, predefined order for step-by-step processing*
|
||||
|
||||
**Swarm Type**: `SequentialWorkflow`
|
||||
|
||||
## Overview
|
||||
|
||||
The SequentialWorkflow swarm type executes tasks in a strict, predefined order where each step depends on the completion of the previous one. This architecture is perfect for workflows that require a linear progression of tasks, ensuring that each agent builds upon the work of the previous agent.
|
||||
|
||||
Key features:
|
||||
- **Ordered Execution**: Agents execute in a specific, predefined sequence
|
||||
- **Step Dependencies**: Each step builds upon previous results
|
||||
- **Predictable Flow**: Clear, linear progression through the workflow
|
||||
- **Quality Control**: Each agent can validate and enhance previous work
|
||||
|
||||
## Use Cases
|
||||
|
||||
- Document processing pipelines
|
||||
- Multi-stage analysis workflows
|
||||
- Content creation and editing processes
|
||||
- Data transformation and validation pipelines
|
||||
|
||||
## API Usage
|
||||
|
||||
### Basic SequentialWorkflow 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": "Content Creation Pipeline",
|
||||
"description": "Sequential content creation from research to final output",
|
||||
"swarm_type": "SequentialWorkflow",
|
||||
"task": "Create a comprehensive blog post about the future of renewable energy",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Research Specialist",
|
||||
"description": "Conducts thorough research on the topic",
|
||||
"system_prompt": "You are a research specialist. Gather comprehensive, accurate information on the given topic from reliable sources.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Content Writer",
|
||||
"description": "Creates engaging written content",
|
||||
"system_prompt": "You are a skilled content writer. Transform research into engaging, well-structured articles that are informative and readable.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.6
|
||||
},
|
||||
{
|
||||
"agent_name": "Editor",
|
||||
"description": "Reviews and polishes the content",
|
||||
"system_prompt": "You are a professional editor. Review content for clarity, grammar, flow, and overall quality. Make improvements while maintaining the author's voice.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "SEO Optimizer",
|
||||
"description": "Optimizes content for search engines",
|
||||
"system_prompt": "You are an SEO expert. Optimize content for search engines while maintaining readability and quality.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"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": "Content Creation Pipeline",
|
||||
"description": "Sequential content creation from research to final output",
|
||||
"swarm_type": "SequentialWorkflow",
|
||||
"task": "Create a comprehensive blog post about the future of renewable energy",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Research Specialist",
|
||||
"description": "Conducts thorough research on the topic",
|
||||
"system_prompt": "You are a research specialist. Gather comprehensive, accurate information on the given topic from reliable sources.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Content Writer",
|
||||
"description": "Creates engaging written content",
|
||||
"system_prompt": "You are a skilled content writer. Transform research into engaging, well-structured articles that are informative and readable.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.6
|
||||
},
|
||||
{
|
||||
"agent_name": "Editor",
|
||||
"description": "Reviews and polishes the content",
|
||||
"system_prompt": "You are a professional editor. Review content for clarity, grammar, flow, and overall quality. Make improvements while maintaining the author's voice.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
},
|
||||
{
|
||||
"agent_name": "SEO Optimizer",
|
||||
"description": "Optimizes content for search engines",
|
||||
"system_prompt": "You are an SEO expert. Optimize content for search engines while maintaining readability and quality.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
}
|
||||
],
|
||||
"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("SequentialWorkflow swarm completed successfully!")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Final output: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "content-creation-pipeline",
|
||||
"swarm_type": "SequentialWorkflow",
|
||||
"task": "Create a comprehensive blog post about the future of renewable energy",
|
||||
"output": {
|
||||
"research_findings": "Comprehensive research on renewable energy trends...",
|
||||
"draft_content": "Initial blog post draft...",
|
||||
"edited_content": "Polished and refined article...",
|
||||
"final_seo_optimized": "SEO-optimized final blog post ready for publication..."
|
||||
},
|
||||
"metadata": {
|
||||
"execution_sequence": [
|
||||
"Research Specialist",
|
||||
"Content Writer",
|
||||
"Editor",
|
||||
"SEO Optimizer"
|
||||
],
|
||||
"step_outputs": {
|
||||
"step_1": "Research findings and data",
|
||||
"step_2": "Draft article content",
|
||||
"step_3": "Edited and refined content",
|
||||
"step_4": "SEO-optimized final version"
|
||||
},
|
||||
"execution_time_seconds": 45.3,
|
||||
"billing_info": {
|
||||
"total_cost": 0.089
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Design agents with clear, sequential dependencies
|
||||
- Ensure each agent builds meaningfully on the previous work
|
||||
- Use for linear workflows where order matters
|
||||
- Validate outputs at each step before proceeding
|
||||
|
||||
## Related Swarm Types
|
||||
|
||||
- [ConcurrentWorkflow](concurrent_workflow.md) - For parallel execution
|
||||
- [AgentRearrange](agent_rearrange.md) - For dynamic sequencing
|
||||
- [HierarchicalSwarm](hierarchical_swarm.md) - For structured workflows
|
@ -0,0 +1,232 @@
|
||||
# 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
|
||||
|
||||
=== "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": "Financial Analysis Spreadsheet",
|
||||
"description": "Systematic financial data analysis using spreadsheet structure",
|
||||
"swarm_type": "SpreadSheetSwarm",
|
||||
"task": "Analyze quarterly financial performance data for a retail company with multiple product lines and create comprehensive insights",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Data Validator",
|
||||
"description": "Validates and cleans financial data",
|
||||
"system_prompt": "You are a data validation specialist. Clean, validate, and structure financial data ensuring accuracy and consistency.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Revenue Analyst",
|
||||
"description": "Analyzes revenue trends and patterns",
|
||||
"system_prompt": "You are a revenue analyst. Focus on revenue trends, growth patterns, and seasonal variations across product lines.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Cost Analyst",
|
||||
"description": "Analyzes cost structures and margins",
|
||||
"system_prompt": "You are a cost analyst. Examine cost structures, margin analysis, and expense categorization.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Performance Calculator",
|
||||
"description": "Calculates KPIs and financial metrics",
|
||||
"system_prompt": "You are a financial metrics specialist. Calculate KPIs, ratios, and performance indicators from the analyzed data.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.1
|
||||
},
|
||||
{
|
||||
"agent_name": "Report Generator",
|
||||
"description": "Creates structured financial reports",
|
||||
"system_prompt": "You are a report generator. Create comprehensive, well-structured financial reports with insights and recommendations.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
}
|
||||
],
|
||||
"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": "Financial Analysis Spreadsheet",
|
||||
"description": "Systematic financial data analysis using spreadsheet structure",
|
||||
"swarm_type": "SpreadSheetSwarm",
|
||||
"task": "Analyze quarterly financial performance data for a retail company with multiple product lines and create comprehensive insights",
|
||||
"agents": [
|
||||
{
|
||||
"agent_name": "Data Validator",
|
||||
"description": "Validates and cleans financial data",
|
||||
"system_prompt": "You are a data validation specialist. Clean, validate, and structure financial data ensuring accuracy and consistency.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.2
|
||||
},
|
||||
{
|
||||
"agent_name": "Revenue Analyst",
|
||||
"description": "Analyzes revenue trends and patterns",
|
||||
"system_prompt": "You are a revenue analyst. Focus on revenue trends, growth patterns, and seasonal variations across product lines.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Cost Analyst",
|
||||
"description": "Analyzes cost structures and margins",
|
||||
"system_prompt": "You are a cost analyst. Examine cost structures, margin analysis, and expense categorization.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.3
|
||||
},
|
||||
{
|
||||
"agent_name": "Performance Calculator",
|
||||
"description": "Calculates KPIs and financial metrics",
|
||||
"system_prompt": "You are a financial metrics specialist. Calculate KPIs, ratios, and performance indicators from the analyzed data.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.1
|
||||
},
|
||||
{
|
||||
"agent_name": "Report Generator",
|
||||
"description": "Creates structured financial reports",
|
||||
"system_prompt": "You are a report generator. Create comprehensive, well-structured financial reports with insights and recommendations.",
|
||||
"model_name": "gpt-4o",
|
||||
"max_loops": 1,
|
||||
"temperature": 0.4
|
||||
}
|
||||
],
|
||||
"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("SpreadSheetSwarm completed successfully!")
|
||||
print(f"Cost: ${result['metadata']['billing_info']['total_cost']}")
|
||||
print(f"Execution time: {result['metadata']['execution_time_seconds']} seconds")
|
||||
print(f"Structured analysis: {result['output']}")
|
||||
else:
|
||||
print(f"Error: {response.status_code} - {response.text}")
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"swarm_name": "financial-analysis-spreadsheet",
|
||||
"swarm_type": "SpreadSheetSwarm",
|
||||
"task": "Analyze quarterly financial performance data for a retail company with multiple product lines and create comprehensive insights",
|
||||
"output": {
|
||||
"data_validation": {
|
||||
"data_quality": "95% accuracy after cleaning",
|
||||
"missing_values": "Identified and filled 3% missing entries",
|
||||
"data_structure": "Standardized format across all product lines"
|
||||
},
|
||||
"revenue_analysis": {
|
||||
"q4_revenue": "$2.4M total revenue",
|
||||
"growth_rate": "12% quarter-over-quarter growth",
|
||||
"top_performers": ["Product Line A: +18%", "Product Line C: +15%"],
|
||||
"seasonal_trends": "Strong holiday season performance"
|
||||
},
|
||||
"cost_analysis": {
|
||||
"total_costs": "$1.8M operational costs",
|
||||
"cost_breakdown": "60% COGS, 25% Marketing, 15% Operations",
|
||||
"margin_analysis": "25% gross margin, 15% net margin",
|
||||
"cost_optimization": "Identified 8% potential savings in supply chain"
|
||||
},
|
||||
"performance_metrics": {
|
||||
"roi": "22% return on investment",
|
||||
"customer_acquisition_cost": "$45 per customer",
|
||||
"lifetime_value": "$320 average CLV",
|
||||
"inventory_turnover": "6.2x annual turnover"
|
||||
},
|
||||
"comprehensive_report": {
|
||||
"executive_summary": "Strong Q4 performance with 12% growth...",
|
||||
"recommendations": ["Expand Product Line A", "Optimize supply chain", "Increase marketing for underperformers"],
|
||||
"forecast": "Projected 15% growth for Q1 based on trends"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"processing_structure": {
|
||||
"rows_processed": 1250,
|
||||
"columns_analyzed": 18,
|
||||
"calculations_performed": 47
|
||||
},
|
||||
"data_pipeline": [
|
||||
"Data Validation",
|
||||
"Revenue Analysis",
|
||||
"Cost Analysis",
|
||||
"Performance Calculation",
|
||||
"Report Generation"
|
||||
],
|
||||
"execution_time_seconds": 34.2,
|
||||
"billing_info": {
|
||||
"total_cost": 0.078
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 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
|
Loading…
Reference in new issue