Krishna Chaitanya Cheedella
Remove all original source attribution and URLs
537891a
---
title: LLM Council
emoji: 🏒
colorFrom: pink
colorTo: green
sdk: gradio
sdk_version: 6.0.0
app_file: app.py
pinned: false
---
# 🏒 LLM Council - Multi-Model AI Deliberation System
A sophisticated system where multiple LLMs collaboratively answer questions through a 3-stage deliberation process.
## 🎯 How It Works
1. **Stage 1 - Individual Responses**: 5 different AI models independently answer your question
2. **Stage 2 - Peer Review**: Each model ranks the anonymized responses from others
3. **Stage 3 - Synthesis**: A chairman model synthesizes the final answer based on all inputs
## πŸ’° Cost: Mostly FREE!
This version uses **FREE HuggingFace Inference API** models:
- βœ… Meta Llama 3.3 70B (FREE)
- βœ… Qwen 2.5 72B (FREE)
- βœ… Mixtral 8x7B (FREE)
- πŸ’΅ OpenAI GPT-4o-mini (low cost)
- πŸ’΅ OpenAI GPT-3.5-turbo (low cost)
**Cost per query**: ~$0.01-0.03 (mostly OpenAI, HF is free!)
## ⚑ Quick Start
### πŸš€ Deploy to Hugging Face (Recommended)
1. **Fork/Duplicate this Space**
2. **Add your API keys** in Settings β†’ Repository secrets:
- `OPENAI_API_KEY` - Get from [OpenAI](https://platform.openai.com/api-keys)
- `HUGGINGFACE_API_KEY` - Get from [HuggingFace](https://huggingface.co/settings/tokens)
3. **Done!** Your space will auto-deploy
### πŸ’» Run Locally
```bash
# Clone repository
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
# Install dependencies
pip install -r requirements.txt
# Create .env file with your API keys
cp .env.example .env
# Edit .env and add:
# OPENAI_API_KEY=your_openai_key
# HUGGINGFACE_API_KEY=your_hf_token
# Run the app
python app.py
```
Visit `http://localhost:7860`
## πŸ”‘ Getting API Keys
### OpenAI API Key (Required)
1. Go to https://platform.openai.com/api-keys
2. Create new secret key
3. Copy and save it (costs ~$0.01-0.03 per query)
### HuggingFace Token (Required for FREE models)
1. Go to https://huggingface.co/settings/tokens
2. Create new token (read access is enough)
3. Copy and save it (100% FREE to use!)
## πŸ€– Council Models
### Current Configuration
- **Meta Llama 3.3 70B** - Excellent reasoning, FREE
- **Qwen 2.5 72B** - Strong performance, FREE
- **Mixtral 8x7B** - Mixture of experts, FREE
- **OpenAI GPT-4o-mini** - Fast & capable, low cost
- **OpenAI GPT-3.5-turbo** - Reliable, low cost
### Chairman
- **OpenAI GPT-4o-mini** - Excellent synthesis capabilities
Want to customize? Edit `backend/config_free.py`!
## πŸ“Š Performance
- **Response Time**: 60-120 seconds (3 stages, parallel processing)
- **Quality**: Better than single-model responses
- **Cost**: ~$0.01-0.03 per query (mostly FREE!)
- **Reliability**: Automatic retries & error handling
## πŸ› οΈ Tech Stack
- **Frontend**: Gradio 6.0+ (with MCP server support)
- **Backend**: Python async/await
- **APIs**:
- HuggingFace Inference API (FREE models)
- OpenAI API (paid models)
- **Storage**: JSON-based conversation persistence
## πŸ“ Project Structure
```
llm_council/
β”œβ”€β”€ app.py # Main Gradio interface
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ .env.example # Environment template
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ config_free.py # FREE model configuration
β”‚ β”œβ”€β”€ api_client.py # HF + OpenAI API client
β”‚ β”œβ”€β”€ council_free.py # 3-stage orchestration
β”‚ β”œβ”€β”€ storage.py # Conversation storage
β”‚ └── main.py # FastAPI backend (optional)
└── docs/
β”œβ”€β”€ QUICKSTART.md
β”œβ”€β”€ DEPLOYMENT_GUIDE.md
└── CODE_ANALYSIS.md
```
## πŸ”§ Configuration
Want different models? Edit `backend/config_free.py`:
```python
# Use ALL FREE models (no OpenAI cost):
COUNCIL_MODELS = [
{"id": "meta-llama/Llama-3.3-70B-Instruct", "provider": "huggingface"},
{"id": "Qwen/Qwen2.5-72B-Instruct", "provider": "huggingface"},
{"id": "mistralai/Mixtral-8x7B-Instruct-v0.1", "provider": "huggingface"},
{"id": "google/gemma-2-27b-it", "provider": "huggingface"},
]
```
## 🀝 Contributing
Improvements welcome! See `CODE_ANALYSIS.md` for refactoring suggestions.
## πŸ“ Credits
- Implementation: Community contributions
- FREE models: Meta, Qwen, Mistral via HuggingFace
## πŸ“„ License
See original repository for license information.
---
**Need Help?** Check the docs folder for detailed guides!