Features β’ Quick Start β’ Installation β’ Usage β’ API β’ What's New β’ Contributing
- Overview
- Features
- Architecture
- Quick Start
- Installation
- Configuration
- Usage
- AI Agents
- API Reference
- Development
- Troubleshooting
- Contributing
- Recent Improvements
- Roadmap
- License
SwarAI is an advanced multi-agent AI task automation assistant that combines natural language processing, voice recognition, file management, and cross-platform communication into a unified, intelligent system.
- π€ 13 Specialized AI Agents for different tasks
- π€ Voice Recognition with multiple engines (Google Speech, Whisper AI)
- π£οΈ Text-to-Speech with multiple TTS engines (Edge TTS, gTTS, Coqui)
- π± WhatsApp Integration for automated messaging
- π Intelligent File Search with fuzzy matching
- π Multi-Agent Orchestration using CrewAI
- π Modern Web Interface built with Next.js
- π FastAPI Backend with WebSocket support
- πΎ Conversation Memory with MongoDB (optional)
- Natural language understanding with context awareness
- Personality-driven responses
- Multi-turn conversation support
- Intent classification and routing
- Emotional intelligence
- Speech-to-Text: Google Speech Recognition, Whisper AI
- Text-to-Speech: Microsoft Edge TTS, Google TTS, Coqui TTS, pyttsx3
- Multi-language support (English variants)
- Noise reduction and ambient adjustment
- Real-time voice processing
- Send messages via voice or text commands
- Contact management with fuzzy search
- WhatsApp URL generation (wa.me format)
- Natural language command parsing
- Multiple command pattern support
- Cross-platform file search (Windows, macOS, Linux)
- Fuzzy matching algorithm
- Recursive directory searching
- File operations: search, open, share
- Performance-optimized scanning
- Volume control (Windows with pycaw)
- Brightness adjustment
- Battery status monitoring
- System information retrieval
- Application launching
- CrewAI-powered agent coordination
- Complex workflow execution
- Task delegation and routing
- Error recovery and fallbacks
- Parallel task processing
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Next.js) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Voice UI β β Agent Cards β β Results β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β HTTP/WebSocket
ββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββ
β Backend (FastAPI) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Agent Manager (MCP) β β
β β - Intent Detection - Agent Routing - Workflows β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ β
β β Specialized Agents β β
β β WhatsApp β FileSearch β Conversation β System β β
β β Email β Calendar β Payment β WebSearch β ... β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ β
β β CrewAI Orchestration Layer β β
β β - Multi-Agent Coordination β β
β β - Task Delegation β β
β β - Workflow Management β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ β
β β LLM Integration (Groq) β β
β β LangChain β LangGraph β Groq LLM β Context Memory β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Framework: FastAPI 0.115+
- AI/ML:
- CrewAI 0.86+ (Multi-agent orchestration)
- LangChain 1.2+ (AI framework)
- LangGraph 1.0+ (Stateful workflows)
- Groq LLM (Language model)
- Speech:
- SpeechRecognition 3.10+
- gTTS 2.5+
- pydub 0.25+
- pygame 2.5+
- Database:
- MongoDB (via pymongo/motor)
- Server: Uvicorn (ASGI)
- Framework: Next.js 15.5
- UI: React 19, TailwindCSS 4
- State: Zustand
- Queries: TanStack Query
- Components: Radix UI, Framer Motion
- Icons: Lucide React
- Python 3.10 or higher
- Node.js 18+ and npm
- Groq API Key (Get one free)
- MongoDB (optional, for conversation memory)
git clone https://github.com/shashankpc7746/SwarAI.git
cd SwarAI# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# Install dependencies
cd backend
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and add your GROQ_API_KEYcd frontend
npm install --legacy-peer-depsTerminal 1 - Backend:
cd backend
python main.pyTerminal 2 - Frontend:
cd frontend
npm run dev- Frontend UI: http://localhost:3000
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
-
Create and activate virtual environment:
python -m venv venv venv\Scripts\activate # Windows source venv/bin/activate # Linux/Mac
-
Install Python dependencies:
cd backend pip install -r requirements.txt -
Set up environment variables:
cp .env.example .env
-
Edit
.envfile:# Required GROQ_API_KEY=your_groq_api_key_here GROQ_MODEL=llama-3.1-70b-versatile # Optional MONGODB_URL=mongodb://localhost:27017 MONGODB_DATABASE=swarai_assistant TTS_ENGINE=edge # edge, gtts, coqui, pyttsx3 ENABLE_VOICE_FEEDBACK=true
-
Install Node.js dependencies:
cd frontend npm install --legacy-peer-deps -
Configure environment (optional):
# Create .env.local if needed echo "NEXT_PUBLIC_API_URL=http://localhost:8000" > .env.local
For full system control features:
# Windows volume control
pip install pycaw comtypes
# System monitoring
pip install psutil
# Brightness control
pip install screen-brightness-control| Variable | Description | Default | Required |
|---|---|---|---|
GROQ_API_KEY |
Groq API key for LLM | - | β Yes |
GROQ_MODEL |
Groq model to use | llama-3.1-70b-versatile |
No |
FASTAPI_HOST |
Backend host | 0.0.0.0 |
No |
FASTAPI_PORT |
Backend port | 8000 |
No |
| Variable | Description | Default |
|---|---|---|
TTS_ENGINE |
TTS engine (edge/gtts/coqui/pyttsx3) | edge |
SWARAI_VOICE |
Voice for TTS | en-US-AriaNeural |
ENABLE_VOICE_FEEDBACK |
Enable voice responses | true |
SPEECH_TIMEOUT |
Speech recognition timeout (seconds) | 7 |
SPEECH_PHRASE_TIME_LIMIT |
Max phrase duration (seconds) | 15 |
| Variable | Description | Default |
|---|---|---|
MONGODB_URL |
MongoDB connection string | mongodb://localhost:27017 |
MONGODB_DATABASE |
Database name | swarai_assistant |
CONVERSATION_MEMORY_LIMIT |
Max conversation history | 50 |
| Variable | Description | Default |
|---|---|---|
AGENT_TEMPERATURE |
LLM temperature | 0.1 |
MAX_RESPONSE_TOKENS |
Max tokens in response | 1000 |
"Send WhatsApp to Jay: Hello, how are you?"
"Message Mom: I'll be late for dinner"
"WhatsApp Vijay: Can we reschedule the meeting?"
"Find my presentation"
"Search for report.pdf"
"Open the latest invoice"
"Find photos from last week"
"Set volume to 50%"
"Increase brightness"
"Check battery status"
"What's my system info?"
"Hello SwarAI!"
"What can you do?"
"Help me with my tasks"
"Tell me a joke"
curl -X POST http://localhost:8000/process-command \
-H "Content-Type: application/json" \
-d '{"command": "Send WhatsApp to Jay: Hello!"}'curl -X POST http://localhost:8000/tts \
-H "Content-Type: application/json" \
-d '{"text": "Hello from SwarAI!"}'const ws = new WebSocket('ws://localhost:8000/ws');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};
ws.send(JSON.stringify({
type: 'command',
data: { command: 'Hello SwarAI!' }
}));| Agent | Description | Capabilities |
|---|---|---|
| Message automation | Send messages, contact search, URL generation | |
| FileSearch | File management | Search files, open files, fuzzy matching |
| Conversation | Natural dialogue | Context-aware chat, personality, memory |
| System Control | System operations | Volume, brightness, battery, system info |
| Email automation | Compose, send emails (Gmail integration) | |
| Calendar | Calendar management | Create events, reminders (Google Calendar) |
| Payment | Payment processing | PayPal, Google Pay, UPI integration |
| WebSearch | Web searching | Google, Bing, DuckDuckGo, YouTube |
| Phone | Phone operations | Make calls, SMS (platform-dependent) |
| App Launcher | Application control | Launch apps, manage windows |
| Screenshot | Screen capture | Take screenshots, save images |
| Task | Task management | Create, manage tasks and reminders |
| Multi-Task | Workflow orchestration | Complex multi-step operations |
Each agent follows a consistent pattern:
class Agent:
def __init__(self):
self.llm = ChatGroq(...) # Groq LLM
self.tools = [...] # Agent-specific tools
def process_command(self, user_input: str) -> Dict:
# 1. Parse command
# 2. Execute action
# 3. Return result
passProcess a text or voice command.
Request:
{
"command": "Send WhatsApp to Jay: Hello!",
"use_voice": false
}Response:
{
"success": true,
"message": "WhatsApp message ready for Jay!",
"agent": "whatsapp",
"data": {
"whatsapp_url": "https://wa.me/911234567890?text=Hello!"
}
}Convert text to speech.
Request:
{
"text": "Hello from SwarAI!",
"engine": "edge"
}Response:
{
"success": true,
"audio_file": "path/to/audio.mp3"
}Check API health status.
Response:
{
"status": "healthy",
"version": "2.0.0",
"agents_loaded": 13,
"llm_available": true
}List all available agents.
Response:
{
"agents": [
{
"name": "WhatsApp Agent",
"status": "active",
"capabilities": ["send_message", "contact_search"]
},
...
]
}{
"type": "command",
"data": {
"command": "Hello SwarAI!"
}
}{
"type": "response",
"data": {
"message": "Hello! How can I help you?",
"agent": "conversation"
}
}SwarAI/
βββ backend/
β βββ agents/ # AI Agents
β β βββ __init__.py
β β βββ agent_manager.py # Main coordinator
β β βββ whatsapp_agent.py
β β βββ filesearch_agent.py
β β βββ conversation_agent.py
β β βββ ...
β βββ utils/ # Utilities
β β βββ enhanced_speech_processor.py
β β βββ conversational_tts.py
β β βββ conversation_memory.py
β β βββ ...
β βββ config.py # Configuration
β βββ main.py # FastAPI server
β βββ crew_main.py # CrewAI server
β βββ crew_config.py # CrewAI configuration
β βββ requirements.txt # Python dependencies
β βββ .env.example # Environment template
βββ frontend/
β βββ src/
β β βββ app/ # Next.js app
β β βββ components/ # React components
β β βββ hooks/ # Custom hooks
β βββ package.json
β βββ next.config.ts
βββ .gitignore
βββ README.md
# Backend tests
cd backend
pytest
# Frontend tests
cd frontend
npm test# Python (Black, isort)
cd backend
black .
isort .
# TypeScript (ESLint, Prettier)
cd frontend
npm run lint
npm run format- Create agent file in
backend/agents/:
from langchain.tools import BaseTool
from langchain_groq import ChatGroq
class MyAgent:
def __init__(self):
self.llm = ChatGroq(...)
def process_command(self, user_input: str):
# Implementation
pass- Register in
agent_manager.py:
from agents.my_agent import MyAgent
self.my_agent = MyAgent()- Add routing logic in
process_command().
Solution:
pip install streamlit pycaw comtypes psutil screen-brightness-controlSolution: The app works without MongoDB (uses in-memory storage). To fix:
# Install MongoDB locally or use MongoDB Atlas
# Update MONGODB_URL in .envSolution:
# Install audio dependencies
pip install pyaudio # May need system libraries
# Windows: Download PyAudio wheel
# Linux: sudo apt-get install portaudio19-dev python3-pyaudio
# Mac: brew install portaudioSolution:
cd frontend
rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
npm run devSolution:
- Get API key from https://console.groq.com/
- Add to
backend/.env:GROQ_API_KEY=your_actual_key_here
Enable debug logging:
# .env
LOG_LEVEL=DEBUG
DEBUG_MODE=trueWe welcome contributions! Here's how you can help:
- Report Bugs: Open an issue with details
- Suggest Features: Share your ideas
- Submit Pull Requests: Fix bugs or add features
- Improve Documentation: Help others understand
- Share Feedback: Tell us what works and what doesn't
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Test thoroughly
- Commit with clear messages:
git commit -m "Add amazing feature" - Push to your fork:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow PEP 8 for Python
- Use TypeScript for frontend
- Write clear commit messages
- Add tests for new features
- Update documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- CrewAI - Multi-agent orchestration framework
- LangChain - AI application framework
- Groq - Fast LLM inference
- FastAPI - Modern Python web framework
- Next.js - React framework
- All contributors - Thank you!
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [Your Email]
- Mobile app (React Native)
- Voice cloning
- Custom agent creation UI
- Plugin system
- Cloud deployment guides
- Docker support
- Kubernetes manifests
- Advanced analytics
- Multi-language support
- Integration marketplace
Problem: Speech would continue playing in background after page refresh.
Solution: Added cleanup handlers to stop speech immediately on:
- Page refresh
- Navigation away
- Tab close
- Component unmount
Result: Clean, professional user experience with controllable audio.
Problem: Introduction responses were too long (45+ seconds).
Solution: Shortened to 2-3 sentences maximum with key capabilities only.
Result: Quick, clear introductions (~10 seconds) without overwhelming users.
Automatically improves grammar in all WhatsApp messages:
Features:
- Capitalizes first letter of sentences
- Adds proper punctuation (. ? !)
- Fixes grammar mistakes naturally
- Preserves conversational tone
- Smart context-aware punctuation
Examples:
"how are you" β "How are you?"
"i am coming home" β "I am coming home."
"meeting at 5" β "Meeting at 5."
"gonna be late" β "Gonna be late."
Workflow Integration:
Parse Command β AI Grammar Correction β Search Contact β Generate URL β Send
When you specify only a file type (without filename), SwarAI opens the most recent file of that type from Downloads.
Examples:
"open pdf" β Opens newest PDF from Downloads
"open word" β Opens latest .docx from Downloads
"open excel" β Opens latest .xlsx from Downloads
"open powerpoint" β Opens latest .pptx from DownloadsSpecific file search still works:
"open NPTEL certificates" β Finds and opens specific fileProblem: SwarAI was reading file paths in speech.
Solution: Intelligent removal of:
- Windows paths:
C:\Users\... - Unix paths:
/home/user/... - Path patterns:
Path: ... - Special symbols with paths
Result:
Before: "Successfully opened: NPTEL.pdf Path: C:\Users\Shashank Gupta\Downloads\NPTEL.pdf"
After: "Opened NPTEL.pdf"
Problem: Redundant "Got it!" before greeting responses.
Solution: Skip acknowledgment for greetings (hi, hello, hey, good morning, etc.)
Result:
Before: "Got it!" β pause β "Hello, I'm SwarAI..."
After: "Hello, I'm SwarAI, nice to meet you..."
Problem: Required exact contact names, failing for variations.
Solution: Intelligent fuzzy matching that handles:
- Partial names: "Shivam" β Finds "Shivam Patel"
- Common suffixes: "clg", "college", "mam", "sir", "bro", "sis"
- First name only: "Jay" β Finds "Jay Sharma"
- Substring matching
Examples:
β
"Shivam clg" β Finds "Shivam Patel"
β
"Gitanjali mam" β Finds "Gitanjali"
β
"Jay" β Finds "Jay Sharma"
Problem: SwarAI was reading URLs and technical content.
Solution: Smart filtering that removes:
- URLs:
https://wa.me/... - Phone numbers:
+919876543219 - Technical instructions: "Click the link to send"
- Keeps full text in chat for visual reference
Result:
Before: "WhatsApp message ready for Gitanjali! Click the link to send: https://wa.me/+919876543219?text=..."
After: "WhatsApp message ready for Gitanjali. Opening WhatsApp now."
Problem: Speech cut off at 200 characters regardless of content.
Solution: Smart length limits based on content type:
| Agent Type | Max Length | Purpose |
|---|---|---|
| Conversation | 1000 chars | Full responses |
| WebSearch | 1000 chars | Complete information |
| 100 chars | Brief confirmations | |
| FileSearch | 100 chars | Quick feedback |
| 100 chars | Action confirmations | |
| Payment | 100 chars | Transaction confirmations |
| Default | 500 chars | Balanced |
Result: Full educational content and conversations, brief action confirmations.
The speech system now applies intelligent filtering:
- Remove Emojis - Clean visual symbols
- Remove URLs - No "https colon slash slash"
- Remove File Paths - No directory structures
- Remove Technical Patterns - No wa.me links, phone numbers
- Remove Instructions - No "Click here" messages
- Agent-Specific Simplification - Context-aware brevity
- Context-Aware Length Limiting - Appropriate for content type
"send WhatsApp to Shivam clg that AI is working"
"message Gitanjali mam hello"
"WhatsApp Jay that meeting at 5"
"open pdf" β Opens latest PDF
"open NPTEL certificates" β Opens specific file
"hello" β Direct greeting (no "Got it!")
"give me details about Harappan civilization" β Full response