Merge branch 'kyegomez:master' into OpenAIFunctionCaller-Removal

pull/1101/head
CI-DEV 1 week ago committed by GitHub
commit 21b8be8ace
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -290,7 +290,6 @@ nav:
- Overview: "swarms/structs/multi_swarm_orchestration.md" - Overview: "swarms/structs/multi_swarm_orchestration.md"
- HierarchicalSwarm: "swarms/structs/hierarchical_swarm.md" - HierarchicalSwarm: "swarms/structs/hierarchical_swarm.md"
- Hierarchical Structured Communication Framework: "swarms/structs/hierarchical_structured_communication_framework.md" - Hierarchical Structured Communication Framework: "swarms/structs/hierarchical_structured_communication_framework.md"
- Auto Agent Builder: "swarms/structs/auto_agent_builder.md"
- Hybrid Hierarchical-Cluster Swarm: "swarms/structs/hhcs.md" - Hybrid Hierarchical-Cluster Swarm: "swarms/structs/hhcs.md"
- Auto Swarm Builder: "swarms/structs/auto_swarm_builder.md" - Auto Swarm Builder: "swarms/structs/auto_swarm_builder.md"
- Swarm Matcher: "swarms/structs/swarm_matcher.md" - Swarm Matcher: "swarms/structs/swarm_matcher.md"

@ -1,200 +0,0 @@
# Agent Builder
The Agent Builder is a powerful class that automatically builds and manages swarms of AI agents. It provides a flexible and extensible framework for creating, coordinating, and executing multiple AI agents working together to accomplish complex tasks.
## Overview
The Agent Builder uses a boss agent to delegate work and create new specialized agents as needed. It's designed to be production-ready with robust error handling, logging, and configuration options.
## Architecture
```mermaid
graph TD
A[Agent Builder] --> B[Configuration]
A --> C[Agent Creation]
A --> D[Task Execution]
B --> B1[Name]
B --> B2[Description]
B --> B3[Model Settings]
C --> C1[Agent Pool]
C --> C2[Agent Registry]
C --> C3[Agent Configuration]
D --> D1[Task Distribution]
D --> D2[Result Collection]
D --> D3[Error Handling]
C1 --> E[Specialized Agents]
C2 --> E
C3 --> E
E --> F[Task Execution]
F --> G[Results]
```
## Class Structure
### AgentsBuilder Class
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| name | str | "swarm-creator-01" | The name of the swarm |
| description | str | "This is a swarm that creates swarms" | A description of the swarm's purpose |
| verbose | bool | True | Whether to output detailed logs |
| max_loops | int | 1 | Maximum number of execution loops |
| model_name | str | "gpt-4o" | The model to use for agent creation |
| return_dictionary | bool | True | Whether to return results as a dictionary |
| system_prompt | str | BOSS_SYSTEM_PROMPT | The system prompt for the boss agent |
### Methods
| Method | Description | Parameters | Returns |
|--------|-------------|------------|---------|
| run | Run the swarm on a given task | task: str, image_url: str = None, *args, **kwargs | Tuple[List[Agent], int] |
| _create_agents | Create necessary agents for a task | task: str, *args, **kwargs | List[Agent] |
| build_agent | Build a single agent with specifications | agent_name: str, agent_description: str, agent_system_prompt: str, max_loops: int = 1, model_name: str = "gpt-4o", dynamic_temperature_enabled: bool = True, auto_generate_prompt: bool = False, role: str = "worker", max_tokens: int = 8192, temperature: float = 0.5 | Agent |
## Enterprise Use Cases
### 1. Customer Service Automation
- Create specialized agents for different aspects of customer service
- Handle ticket routing, response generation, and escalation
- Maintain consistent service quality across channels
### 2. Data Analysis Pipeline
- Build agents for data collection, cleaning, analysis, and visualization
- Automate complex data processing workflows
- Generate insights and reports automatically
### 3. Content Creation and Management
- Deploy agents for content research, writing, editing, and publishing
- Maintain brand consistency across content
- Automate content scheduling and distribution
### 4. Process Automation
- Create agents for workflow automation
- Handle document processing and routing
- Manage approval chains and notifications
### 5. Research and Development
- Build agents for literature review, experiment design, and data collection
- Automate research documentation and reporting
- Facilitate collaboration between research teams
## Example Usage
```python
from swarms import AgentsBuilder
# Initialize the agent builder
agents_builder = AgentsBuilder(
name="enterprise-automation",
description="Enterprise workflow automation swarm",
verbose=True
)
# Define a use-case for building agents
task = "Develop a swarm of agents to automate the generation of personalized marketing strategies based on customer data and market trends"
# Run the swarm
agents = agents_builder.run(task)
# Access results
print(agents)
```
## Best Practices
1. **Error Handling**
- Always implement proper error handling for agent failures
- Use retry mechanisms for transient failures
- Log all errors for debugging and monitoring
2. **Resource Management**
- Monitor agent resource usage
- Implement rate limiting for API calls
- Use connection pooling for database operations
3. **Security**
- Implement proper authentication and authorization
- Secure sensitive data and API keys
- Follow least privilege principle for agent permissions
4. **Monitoring and Logging**
- Implement comprehensive logging
- Monitor agent performance metrics
- Set up alerts for critical failures
5. **Scalability**
- Design for horizontal scaling
- Implement load balancing
- Use distributed systems when needed
## Integration Patterns
```mermaid
graph LR
A[External System] --> B[API Gateway]
B --> C[Agent Builder]
C --> D[Agent Pool]
D --> E[Specialized Agents]
E --> F[External Services]
subgraph "Monitoring"
G[Logs]
H[Metrics]
I[Alerts]
end
C --> G
C --> H
C --> I
```
## Performance Considerations
1. **Agent Pool Management**
- Implement connection pooling
- Use caching for frequently accessed data
- Optimize agent creation and destruction
2. **Task Distribution**
- Implement load balancing
- Use priority queues for task scheduling
- Handle task timeouts and retries
3. **Resource Optimization**
- Monitor memory usage
- Implement garbage collection
- Use efficient data structures
## Troubleshooting
Common issues and solutions:
1. **Agent Creation Failures**
- Check API credentials
- Verify model availability
- Review system prompts
2. **Performance Issues**
- Monitor resource usage
- Check network latency
- Review agent configurations
3. **Integration Problems**
- Verify API endpoints
- Check authentication
- Review data formats

@ -154,11 +154,6 @@ flowchart TD
- Covers detailed implementation, constructor arguments, and full examples - Covers detailed implementation, constructor arguments, and full examples
### Auto Agent Builder Documentation:
- [Agent Builder Documentation](https://docs.swarms.world/en/latest/swarms/structs/auto_agent_builder/)
- Includes enterprise use cases, best practices, and integration patterns
3. SwarmRouter Documentation: 3. SwarmRouter Documentation:

@ -36,7 +36,6 @@ This page provides a comprehensive overview of all available multi-agent archite
| Architecture | Use Case | Key Functionality | Documentation | | Architecture | Use Case | Key Functionality | Documentation |
|-------------|----------|-------------------|---------------| |-------------|----------|-------------------|---------------|
| HierarchicalSwarm | Hierarchical task orchestration | Director agent coordinates specialized worker agents | [Docs](hierarchical_swarm.md) | | HierarchicalSwarm | Hierarchical task orchestration | Director agent coordinates specialized worker agents | [Docs](hierarchical_swarm.md) |
| Auto Agent Builder | Automated agent creation | Automatically creates and configures agents | [Docs](auto_agent_builder.md) |
| Hybrid Hierarchical-Cluster Swarm | Complex organization | Combines hierarchical and cluster-based organization | [Docs](hhcs.md) | | Hybrid Hierarchical-Cluster Swarm | Complex organization | Combines hierarchical and cluster-based organization | [Docs](hhcs.md) |
| Auto Swarm Builder | Automated swarm creation | Automatically creates and configures swarms | [Docs](auto_swarm_builder.md) | | Auto Swarm Builder | Automated swarm creation | Automatically creates and configures swarms | [Docs](auto_swarm_builder.md) |

@ -0,0 +1,76 @@
BOSS_SYSTEM_PROMPT = """
# Swarm Intelligence Orchestrator
You are the Chief Orchestrator of a sophisticated agent swarm. Your primary responsibility is to analyze tasks and create the optimal team of specialized agents to accomplish complex objectives efficiently.
## Agent Creation Protocol
1. **Task Analysis**:
- Thoroughly analyze the user's task to identify all required skills, knowledge domains, and subtasks
- Break down complex problems into discrete components that can be assigned to specialized agents
- Identify potential challenges and edge cases that might require specialized handling
2. **Agent Design Principles**:
- Create highly specialized agents with clearly defined roles and responsibilities
- Design each agent with deep expertise in their specific domain
- Provide agents with comprehensive and extremely extensive system prompts that include:
* Precise definition of their role and scope of responsibility
* Detailed methodology for approaching problems in their domain
* Specific techniques, frameworks, and mental models to apply
* Guidelines for output format and quality standards
* Instructions for collaboration with other agents
* In-depth examples and scenarios to illustrate expected behavior and decision-making processes
* Extensive background information relevant to the tasks they will undertake
3. **Cognitive Enhancement**:
- Equip agents with advanced reasoning frameworks:
* First principles thinking to break down complex problems
* Systems thinking to understand interconnections
* Lateral thinking for creative solutions
* Critical thinking to evaluate information quality
- Implement specialized thought patterns:
* Step-by-step reasoning for complex problems
* Hypothesis generation and testing
* Counterfactual reasoning to explore alternatives
* Analogical reasoning to apply solutions from similar domains
4. **Swarm Architecture**:
- Design optimal agent interaction patterns based on task requirements
- Consider hierarchical, networked, or hybrid structures
- Establish clear communication protocols between agents
- Define escalation paths for handling edge cases
5. **Agent Specialization Examples**:
- Research Agents: Literature review, data gathering, information synthesis
- Analysis Agents: Data processing, pattern recognition, insight generation
- Creative Agents: Idea generation, content creation, design thinking
- Planning Agents: Strategy development, resource allocation, timeline creation
- Implementation Agents: Code writing, document drafting, execution planning
- Quality Assurance Agents: Testing, validation, error detection
- Integration Agents: Combining outputs, ensuring consistency, resolving conflicts
## Output Format
For each agent, provide:
1. **Agent Name**: Clear, descriptive title reflecting specialization
2. **Description**: Concise overview of the agent's purpose and capabilities
3. **System Prompt**: Comprehensive and extremely extensive instructions including:
- Role definition and responsibilities
- Specialized knowledge and methodologies
- Thinking frameworks and problem-solving approaches
- Output requirements and quality standards
- Collaboration guidelines with other agents
- Detailed examples and context to ensure clarity and effectiveness
## Optimization Guidelines
- Create only the agents necessary for the task - no more, no less
- Ensure each agent has a distinct, non-overlapping area of responsibility
- Design system prompts that maximize agent performance through clear guidance and specialized knowledge
- Balance specialization with the need for effective collaboration
- Prioritize agents that address the most critical aspects of the task
Remember: Your goal is to create a swarm of agents that collectively possesses the intelligence, knowledge, and capabilities to deliver exceptional results for the user's task.
"""

@ -1,5 +1,4 @@
from swarms.structs.agent import Agent from swarms.structs.agent import Agent
from swarms.structs.agent_builder import AgentsBuilder
from swarms.structs.agent_loader import AgentLoader from swarms.structs.agent_loader import AgentLoader
from swarms.structs.agent_rearrange import AgentRearrange, rearrange from swarms.structs.agent_rearrange import AgentRearrange, rearrange
from swarms.structs.auto_swarm_builder import AutoSwarmBuilder from swarms.structs.auto_swarm_builder import AutoSwarmBuilder
@ -155,7 +154,6 @@ __all__ = [
"MultiAgentRouter", "MultiAgentRouter",
"MemeAgentGenerator", "MemeAgentGenerator",
"ModelRouter", "ModelRouter",
"AgentsBuilder",
"MALT", "MALT",
"HybridHierarchicalClusterSwarm", "HybridHierarchicalClusterSwarm",
"get_agents_info", "get_agents_info",

@ -496,6 +496,7 @@ class LiteLLM:
if isinstance(out, BaseModel): if isinstance(out, BaseModel):
out = out.model_dump() out = out.model_dump()
return out return out
def output_for_reasoning(self, response: any): def output_for_reasoning(self, response: any):

Loading…
Cancel
Save