This project integrates the BYOAI (Bring Your Own AI) framework with OpenAI's Swarm, creating a powerful, decentralized, and context-driven agent system. The integration provides a flexible and scalable solution for distributed task execution and AI-driven workflows.
- Decentralized agent architecture
- Context-driven task distribution
- Specialization-based task assignment
- Priority queue for efficient task management
- RESTful API for task submission and status monitoring
- Dynamic agent scaling based on workload
- Detailed logging and monitoring
- Task redistribution for load balancing
-
Clone the repository:
git clone https://github.com/your-repo/byoai-swarm.git cd byoai-swarm
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
export CONTEXT_WORKFLOW_DIR=workflows export CONTEXT_AGENT_PORT=8099 export CONTEXT_AGENT_HOST=0.0.0.0
-
Start the BYOAI-Swarm system:
python byoai-script.py
-
Access the API endpoints:
- Home:
http://localhost:8099/
- Status:
http://localhost:8099/status
- Swarm State:
http://localhost:8099/swarm/state
- Add Task:
POST http://localhost:8099/swarm/add_task
- Task Status:
GET http://localhost:8099/swarm/task_status/<task_id>
- Agent Load:
GET http://localhost:8099/swarm/agent_load
- Redistribute Tasks:
POST http://localhost:8099/swarm/redistribute_tasks
- Swarm Statistics:
GET http://localhost:8099/swarm/statistics
- Scale Agents:
POST http://localhost:8099/agents/scale
- Home:
-
Create and place workflow YAML files in the
workflows
directory. The system will automatically load and execute these workflows.
curl -X POST http://localhost:8099/swarm/add_task \
-H "Content-Type: application/json" \
-d '{"description": "Complex math calculation", "priority": 8, "specialization": "math"}'
curl http://localhost:8099/swarm/state
curl http://localhost:8099/swarm/task_status/1
curl -X POST http://localhost:8099/swarm/redistribute_tasks \
-H "Content-Type: application/json" \
-d '{"threshold": 5}'
curl http://localhost:8099/swarm/statistics
curl -X POST http://localhost:8099/agents/scale \
-H "Content-Type: application/json" \
-d '{"num_agents": 2}'
The integrated BYOAI-Swarm system consists of the following main components:
-
BYOAI Script (
byoai-script.py
): The main entry point that initializes the system, loads workflows, and starts the Flask server. -
Swarm Integration (
swarm_integration.py
): Implements the core Swarm functionality, including task management, agent specializations, and decentralized task execution. -
Workflows: YAML files defining task sequences, priorities, and specializations.
-
Flask API: Provides endpoints for system interaction and monitoring.
-
Dynamic Agent Scaling: Automatically scales the number of agents based on the current workload.
Workflows are defined in YAML files with the following structure:
name: Sample Workflow
steps:
- name: Task Name
action: action_to_perform
priority: 5
specialization: math
The API provides clear error messages for various scenarios:
- Invalid JSON payload
- Missing required fields
- Task not found
- Internal server errors
Error responses include a JSON object with an "error" key containing a descriptive message.
The system provides detailed logging for all operations, including:
- Task addition and execution
- Agent registration and task assignment
- Workflow loading and execution
- API requests and responses
- Dynamic agent scaling
Logs can be found in the console output when running the application.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.