Spaces:
Sleeping
Sleeping
File size: 7,461 Bytes
ea81a05 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | ---
title: Heavy Multi-Model 2.0
emoji: π€
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: "4.44.1"
app_file: app.py
pinned: false
---
# π€ Heavy Multi-Model 2.0 - AI Analysis System
**Version 2.0** - Now with Web Search Integration!
A powerful multi-agent AI analysis system that leverages multiple AI models working in parallel to provide comprehensive, well-researched responses to complex queries.
## π What's New in v2.0
### Web Search Integration with Tavily
- **Real-time Information**: Agents can now search the web for current data and facts
- **Enhanced Analysis**: Each agent performs web searches for their specialized questions
- **Source Citation**: Responses include references to web sources when using search
- **Optional Feature**: Enable/disable web search with a simple checkbox
- **User-provided API Key**: Bring your own Tavily API key for complete control
### Features from v1.0
- **Multi-Model Support**: GPT-5, **GPT-5.1**, Gemini 3 Pro Preview, Gemini 2.5 Pro, Claude 4.5 Sonnet, **Claude 4.5 Opus**, GPT-4.1 Mini, Gemini 2.0 Flash, Llama 3.1 70B
- **Flexible Configuration**:
- Single Model Mode: Use one model for all roles
- Multi-Model Mode: Assign different models to each role
- make-it-heavy Mode: Use the original implementation
- **Parallel Execution**: Multiple agents analyze different aspects simultaneously
- **Web Interface**: Beautiful Gradio-based UI with real-time updates
## ποΈ Architecture
### Multi-Agent Workflow
1. **Orchestrator**: Breaks down your query into specialized research questions
2. **Agents** (2-8): Each agent:
- Receives a specialized question
- **(NEW)** Optionally searches the web for relevant information
- Analyzes their question from a unique perspective
- Runs in parallel with other agents
3. **Synthesizer**: Combines all agent insights into a comprehensive response
### Role-Based Model Assignment
Different AI models excel at different tasks:
- **Orchestrator**: Requires strong reasoning to generate meaningful questions
- **Agents**: Need analytical depth and diverse perspectives
- **Synthesizer**: Must excel at combining and organizing information
You can assign the best model to each role, or keep it simple with a single model for everything.
## π Getting Started
### Prerequisites
- Python 3.8 or higher
- OpenRouter API key (get it from [openrouter.ai/keys](https://openrouter.ai/keys))
- **(Optional)** Tavily API key for web search (get it from [tavily.com](https://tavily.com))
### Installation
1. Navigate to this directory:
```bash
cd "Heavy 2.0"
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run the application:
```bash
python app.py
```
4. Open your browser to `http://localhost:7860`
## π Usage
### Basic Workflow
1. **Enter API Keys**:
- OpenRouter API key (required)
- Tavily API key (optional, for web search)
2. **Enable Web Search** (Optional):
- Check the "Enable Web Search" box
- Enter your Tavily API key
- Agents will now search the web for each specialized question
3. **Choose Configuration Mode**:
- **Single Model**: Use one model for all roles (simplest)
- **Multi-Model**: Assign different models to each role (most flexible)
- **make-it-heavy**: Use the original implementation (cost-effective)
4. **Configure Analysis**:
- Number of agents (2-8): More agents = more perspectives
- Show agent thoughts: Display individual agent analyses
5. **Submit Your Query** and watch the magic happen!
### Example Queries
Perfect for web search:
- "What are the latest developments in quantum computing?"
- "What are the current best practices for React 18?"
- "What happened in the tech industry this week?"
Great for analysis:
- "What are the trade-offs between microservices and monolithic architecture?"
- "How should I design a scalable authentication system?"
- "What factors should I consider when choosing a database?"
## π§ Configuration
### Model Options
All models are accessed through OpenRouter:
| Model | Best For | Speed | Cost |
|-------|----------|-------|------|
| GPT-5.1 | Frontier reasoning + creativity | Medium | $$$$ |
| GPT-5 | Creative solutions | Fast | $$$ |
| Gemini 3 Pro Preview | Multimodal depth & planning | Medium | $$$ |
| Gemini 2.5 Pro | Synthesis & organization | Medium | $$ |
| Claude 4.5 Opus | Frontier reasoning & software engineering | Medium | $$$$ |
| Claude 4.5 Sonnet | Deep reasoning | Medium | $$$ |
| GPT-4.1 Mini | Cost-effective analysis | Fast | $ |
| Gemini 2.0 Flash | Quick responses | Very Fast | $ |
| Llama 3.1 70B | Open source option | Medium | $ |
### Web Search (Tavily)
When enabled, each agent:
1. Receives their specialized question
2. Searches the web using Tavily's advanced search
3. Gets an AI-generated summary + top 5 search results
4. Uses this context to enhance their analysis
5. Cites sources in their response
**Search Depth**: Advanced (configurable in `tavily_search.py`)
**Results per query**: 5 (configurable)
## π Project Structure
```
Heavy 2.0/
βββ app.py # Entry point for Gradio app
βββ config.yaml # Configuration file
βββ requirements.txt # Python dependencies
βββ src/
β βββ __init__.py
β βββ multi_web.py # Gradio web interface
β βββ multi_client.py # Multi-model API client
β βββ multi_orchestrator.py # Workflow orchestrator
β βββ multi_agent.py # Individual agent logic
β βββ tavily_search.py # NEW: Tavily web search integration
βββ README.md
```
## π Security & Privacy
- **API Keys**: Never stored, only used during your session
- **Web Search**: Tavily searches are performed on-demand and not cached
- **No Data Collection**: Your queries and responses are not logged or saved
## π οΈ Development
### Extending the System
**Add a new model**:
```python
# In src/multi_client.py
MODELS = {
"your-model": {
"provider": "openrouter",
"model_id": "provider/model-name",
"display_name": "Your Model Name"
}
}
```
**Customize web search**:
```python
# In src/tavily_search.py
def search(self, query: str, max_results: int = 5):
# Adjust max_results, search_depth, etc.
pass
```
**Modify agent behavior**:
```python
# In src/multi_agent.py
def _build_system_prompt(self):
# Customize agent instructions
pass
```
## π Performance Tips
1. **Use web search selectively**: Great for current events, not needed for general analysis
2. **Adjust agent count**: More agents = more perspectives but slower/costlier
3. **Choose models wisely**:
- Quick answers: Gemini 2.0 Flash + GPT-4.1 Mini
- Deep analysis: Claude 4.5 Sonnet + GPT-5
- Cost-effective: GPT-4.1 Mini for all roles
## π€ Contributing
This is based on the original Heavy/make-it-heavy project. v2.0 adds:
- Tavily web search integration
- Enhanced UI with search controls
- Dynamic context enrichment for agents
- Source citation capabilities
## π License
[Same as original project]
## π Acknowledgments
- Original Heavy project from Justin-Choo
- Tavily for web search API
- OpenRouter for multi-model access
- Gradio for the amazing UI framework
---
**Built with β€οΈ using Python, Gradio, and multiple AI models**
For questions or issues, please refer to the original project or check the Tavily/OpenRouter documentation.
|