Krishna Chaitanya Cheedella
Refactor to use FREE HuggingFace models + OpenAI instead of OpenRouter
aa61236
๐ Quick Start Guide - LLM Council
๐ฆ What You Have
A sophisticated multi-LLM system where multiple AI models:
- Individually answer your question
- Rank each other's responses anonymously
- Synthesize a final best answer
โก Quick Setup (5 minutes)
1๏ธโฃ Get OpenRouter API Key
- Go to openrouter.ai
- Sign up / Login
- Go to Keys โ Create new key
- Copy your API key
2๏ธโฃ Set Up Locally
# Install dependencies
pip install -r requirements.txt
# Create environment file
cp .env.example .env
# Edit .env and add your API key
# OPENROUTER_API_KEY=your_key_here
3๏ธโฃ Run It!
python app.py
Visit http://localhost:7860 ๐
๐ Deploy to Hugging Face Spaces (FREE)
Option A: Fork Existing Space
- Visit: https://huggingface.co/spaces/burtenshaw/karpathy-llm-council
- Click "โฎ" โ "Duplicate this Space"
- Settings โ Repository secrets โ Add
OPENROUTER_API_KEY - Done! Your space will auto-deploy
Option B: Create New Space
- Go to huggingface.co/new-space
- Choose Gradio SDK 6.0.0
- Clone and push your code:
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE
cd YOUR_SPACE
cp -r ../llm_council/* .
git add .
git commit -m "Initial commit"
git push
- Settings โ Repository secrets โ Add
OPENROUTER_API_KEY
๐ฏ Usage Examples
Simple Question
Question: What is the capital of France?
โฑ๏ธ Response time: ~30 seconds
๐ฐ Cost: ~$0.01
Complex Analysis
Question: Compare pros and cons of renewable energy
โฑ๏ธ Response time: ~90 seconds
๐ฐ Cost: ~$0.07
๐ง Use Improved Models
Replace these files to use latest stable models:
# Backup originals
mv backend/config.py backend/config_old.py
mv backend/openrouter.py backend/openrouter_old.py
# Use improved versions
mv backend/config_improved.py backend/config.py
mv backend/openrouter_improved.py backend/openrouter.py
Improved models:
- DeepSeek V3 (Chat & Reasoner)
- Claude 3.7 Sonnet
- GPT-4o
- Gemini 2.0 Flash Thinking
- QwQ 32B
๐ Monitor Usage
Check your costs at: openrouter.ai/activity
Typical costs:
- Budget Council: $0.01-0.03 per query
- Balanced Council: $0.05-0.15 per query
- Premium Council: $0.20-0.50 per query
โ Troubleshooting
"All models failed to respond"
- โ Check API key in .env
- โ Verify OpenRouter credit balance
- โ Test API key: https://openrouter.ai/playground
Space won't start on HF
- โ Check logs in Space โ Logs tab
- โ
Verify secret name is exact:
OPENROUTER_API_KEY - โ Ensure requirements.txt is present
Slow responses
- โ Normal! 3 stages take 45-135 seconds
- โ Use Budget Council for faster results
- โ Reduce number of council members
๐ Full Documentation
- Complete Guide: See
DEPLOYMENT_GUIDE.md - Code Analysis: See
CODE_ANALYSIS.md - Original Project: https://github.com/machine-theory/lm-council
๐ก Tips
- Start with Budget Council to test without spending much
- Use Premium Council for important questions
- Monitor costs in OpenRouter dashboard
- Set spending limits to avoid surprises
๐จ Customization
Edit backend/config.py to:
- Change council models
- Adjust chairman model
- Modify timeouts
- Configure retries
See DEPLOYMENT_GUIDE.md for preset configurations!
Need Help? Check DEPLOYMENT_GUIDE.md for comprehensive documentation.