Spaces:
Sleeping
Sleeping
File size: 6,553 Bytes
d4abd8e |
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 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# Quick Setup with OpenAI (Recommended)
Due to HuggingFace API migration issues, **we recommend using OpenAI for reliable production use**.
---
## β‘ 5-Minute OpenAI Setup
### Step 1: Get OpenAI API Key (2 minutes)
1. Go to https://platform.openai.com/api-keys
2. Sign up or log in
3. Click "Create new secret key"
4. **Copy the key** (starts with `sk-`)
5. **Save it somewhere safe** (you won't see it again)
### Step 2: Add Credits (1 minute)
1. Go to https://platform.openai.com/account/billing
2. Click "Add payment method"
3. Add $5-10 to start (lasts for 200-1000 surveys)
4. Set up usage limits to control costs
### Step 3: Configure ConversAI (2 minutes)
**On HuggingFace Spaces:**
1. Go to your Space Settings
2. Click "Variables" or "Secrets"
3. Add these two variables:
```
Name: LLM_PROVIDER
Value: openai
Name: OPENAI_API_KEY
Value: sk-your-actual-key-here
```
4. Restart your Space
**Running Locally:**
```bash
export LLM_PROVIDER=openai
export OPENAI_API_KEY=sk-your-actual-key-here
python app.py
```
### Step 4: Test It! (30 seconds)
1. Open your ConversAI app
2. Look for green banner: "β
Active LLM Provider: OPENAI"
3. Try generating a survey
4. Should work in ~5 seconds!
---
## π° Cost Breakdown
OpenAI is **very affordable** for survey work:
### Typical Costs with GPT-4o-mini (Recommended):
| Task | Approximate Cost |
|------|------------------|
| Generate 10-question survey | $0.01 - $0.02 |
| Translate to 5 languages | $0.03 - $0.05 |
| Analyze 50 responses | $0.05 - $0.10 |
| **Complete workflow** | **$0.09 - $0.17** |
### With $10 credit, you can:
- Generate ~500 surveys
- Translate ~200 surveys to 5 languages each
- Analyze ~100 datasets with 50 responses each
- Run ~60-100 complete workflows (generate + translate + analyze)
### Cost Control Tips:
1. **Use GPT-4o-mini** (default) - Much cheaper than GPT-4
```bash
LLM_MODEL=gpt-4o-mini # Already the default
```
2. **Set usage limits:**
- Go to https://platform.openai.com/account/limits
- Set monthly limit (e.g., $10/month)
- Get email alerts at 50%, 75%, 90%
3. **Monitor usage:**
- Check https://platform.openai.com/usage daily
- Review costs per request
- Adjust if needed
---
## π― Why OpenAI Over HuggingFace?
| Feature | OpenAI | HuggingFace Free |
|---------|--------|------------------|
| **Speed** | 3-10 seconds | 30-120 seconds |
| **Reliability** | 99.9% uptime | Variable |
| **Quality** | Excellent | Good |
| **Rate Limits** | Generous | Restrictive |
| **API Issues** | Stable | Migrating |
| **Support** | Commercial | Community |
| **Cost** | ~$0.02/survey | Free |
**Bottom line:** For $10, you get 500+ surveys with:
- β‘ 10x faster generation
- β
Reliable service
- β Better quality
- π Production-ready
---
## π Switching from HuggingFace
Already using HuggingFace? Here's how to switch:
### On HuggingFace Spaces:
1. **Add OpenAI credentials** (see Step 3 above)
2. **Restart Space**
3. **That's it!** No code changes needed
The app automatically detects OpenAI credentials and uses them.
### What happens to HuggingFace?
- HuggingFace still works as fallback
- OpenAI takes priority if both are configured
- You can remove HF token if you want
---
## π§ͺ Test Your Setup
Run this to verify OpenAI is working:
```bash
python check_env.py
```
Should show:
```
β
OPENAI_API_KEY SET (sk-proj-...)
β
LLM_PROVIDER SET (openai)
```
And at the bottom:
```
β
Will use: OpenAI (explicit)
```
Or test directly in the app - look for:
```
β
Active LLM Provider: OPENAI | Model: gpt-4o-mini
```
---
## π Troubleshooting
### "Invalid API key"
- Check key starts with `sk-`
- Make sure you copied the full key
- Regenerate if needed: https://platform.openai.com/api-keys
### "Insufficient quota"
- Add credits: https://platform.openai.com/account/billing
- Minimum: $5 recommended
### "Rate limit exceeded"
- You're on free tier - upgrade to pay-as-you-go
- Or wait a few minutes
### Still using HuggingFace?
- Check LLM_PROVIDER is set to "openai"
- Check OPENAI_API_KEY is set correctly
- Run `python check_env.py`
---
## π‘ Pro Tips
### 1. Use Different Models for Different Tasks
```bash
# For survey generation (fast, cheap)
LLM_MODEL=gpt-4o-mini
# For complex analysis (better quality, more expensive)
LLM_MODEL=gpt-4o
```
### 2. Monitor Costs
Set up email alerts:
- 50% of limit: Review usage
- 75% of limit: Check if expected
- 90% of limit: Urgent review
### 3. Batch Operations
- Generate multiple survey versions at once
- Translate to all languages together
- More efficient than one at a time
### 4. Cache Results
- Save generated surveys
- Reuse translations when possible
- Don't regenerate unnecessarily
---
## π Monthly Cost Estimates
Based on typical usage:
**Light Use (10 surveys/month):**
- Generate: 10 surveys Γ $0.02 = $0.20
- Translate: 5 translations Γ $0.04 = $0.20
- Analyze: 5 analyses Γ $0.08 = $0.40
- **Total: ~$1/month**
**Medium Use (50 surveys/month):**
- Generate: 50 Γ $0.02 = $1.00
- Translate: 25 Γ $0.04 = $1.00
- Analyze: 25 Γ $0.08 = $2.00
- **Total: ~$4/month**
**Heavy Use (200 surveys/month):**
- Generate: 200 Γ $0.02 = $4.00
- Translate: 100 Γ $0.04 = $4.00
- Analyze: 100 Γ $0.08 = $8.00
- **Total: ~$16/month**
**Enterprise (1000+ surveys/month):**
- Contact OpenAI for volume pricing
- Consider fine-tuned models
- Estimated: $50-100/month
---
## β
Recommendation
**For ConversAI production use:**
1. β
**Use OpenAI** (not HuggingFace)
2. β
**Start with GPT-4o-mini** (cheapest, fast)
3. β
**Add $10 credit** (lasts months for typical use)
4. β
**Set $10/month limit** (safety)
5. β
**Monitor usage weekly**
**Cost:** ~$1-5/month for typical use
**Benefit:** Reliable, fast, production-ready
**ROI:** Saves hours vs manual survey design
---
## π Ready to Start?
1. Get API key: https://platform.openai.com/api-keys
2. Add $5-10 credit
3. Configure ConversAI (see Step 3 above)
4. Start creating surveys!
**Questions?** See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) or [USER_GUIDE.md](USER_GUIDE.md)
---
**Updated:** November 2025
**Recommended for:** All production deployments
**Alternative:** Anthropic Claude (similar cost, great quality)
|