Spaces:
Sleeping
Sleeping
File size: 3,415 Bytes
a8772c4 964103b a8772c4 964103b a8772c4 964103b a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 964103b a8772c4 964103b a8772c4 964103b a8772c4 964103b a8772c4 964103b a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 a8772c4 b33a861 | 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 | ---
title: Smart Escalation API
emoji: π€
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
license: mit
---
# Smart Escalation API
AI-powered L1 customer support system that intelligently answers customer questions or escalates to human agents when uncertain.
## π Features
- **RAG-Based Retrieval**: Uses sentence-transformers and FAISS for semantic search over help articles
- **Intelligent Escalation**: Automatically escalates to human agents when confidence is low
- **FastAPI Backend**: Fast, async API with automatic OpenAPI documentation
- **Google Gemini LLM**: Powered by gemini-1.5-flash for fast, accurate responses
## π‘ API Endpoints
- `GET /` - API information
- `GET /health` - Health check
- `POST /ask` - Submit customer questions and get answers
## π§ Environment Variables
Configure these in your Space settings under "Repository secrets":
| Variable | Description | Default |
|----------|-------------|---------|
| `GOOGLE_API_KEY` | Google Gemini API key (required) | - |
| `ARTICLES_DIR` | Path to help articles | `data/articles` |
| `EMBEDDING_MODEL` | Sentence transformer model | `all-MiniLM-L6-v2` |
| `RELEVANCE_THRESHOLD` | Minimum similarity score (0-1) | `0.5` |
| `TOP_K_CHUNKS` | Number of chunks to retrieve | `3` |
| `CHUNK_SIZE` | Characters per chunk | `500` |
| `CHUNK_OVERLAP` | Overlap between chunks | `50` |
| `LLM_MODEL` | Gemini model name | `gemini-1.5-flash` |
| `LLM_TEMPERATURE` | LLM temperature (0-1) | `0.3` |
| `CORS_ORIGINS` | Allowed CORS origins | `*` |
## π Usage
### Example Request
```bash
curl -X POST https://webflow97-deployment-taskflow.hf.space/ask \
-H "Content-Type: application/json" \
-d '{"question": "How do I reset my password?"}'
```
### Example Response (Answer)
```json
{
"response_type": "answer",
"message": "To reset your password, go to the login page and click 'Forgot Password'. Enter your email address and you'll receive a reset link.",
"confidence_explanation": "High confidence - retrieved relevant content with similarity score 0.82",
"sources": ["getting-started.md"]
}
```
### Example Response (Escalation)
```json
{
"response_type": "escalation",
"message": "I'm not certain I can answer this accurately. Let me connect you with a human support agent who can help.",
"confidence_explanation": "Low confidence - best retrieval score was 0.42",
"sources": null
}
```
## π Interactive Documentation
Visit `/docs` for interactive API documentation powered by Swagger UI.
## ποΈ Architecture
- **Backend**: Python FastAPI
- **Vector Store**: FAISS (in-memory) with sentence-transformers embeddings
- **LLM**: Google Gemini API (gemini-1.5-flash)
- **Deployment**: Hugging Face Spaces (Docker)
## π Help Articles
The system includes help articles about TaskFlow (a fictional project management SaaS):
1. **Getting Started** - TaskFlow basics, account setup, first project
2. **Billing and Subscriptions** - Plans, payment methods, billing cycles
3. **Integrations** - Slack, GitHub, Jira integrations
4. **Team Permissions** - Roles, access control, admin settings
5. **Troubleshooting** - Common errors, login issues, performance tips
## π Links
- **Frontend**: https://escalation-api-frontend.vercel.app/
- **GitHub**: https://github.com/webflow-ai/Escalation-api
- **API Docs**: https://webflow97-deployment-taskflow.hf.space/docs
## π License
MIT
|