Spaces:
No application file
No application file
File size: 1,528 Bytes
0fc9402 |
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 |
---
title: Text Prediction API
emoji: π
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
license: mit
app_port: 7860
---
# Text Prediction API
AI-powered text prediction service built with FastAPI.
## Features
- π **Secure Authentication** - JWT Bearer token verification
- π **Fast Performance** - Built on FastAPI with async support
- π **Health Monitoring** - Built-in health check endpoint
- π³ **Docker Ready** - Optimized for Hugging Face Spaces deployment
## API Endpoints
### Health Check
```
GET /health
```
Returns the service health status.
### Prediction
```
POST /predict
Authorization: Bearer <token>
Content-Type: application/json
{
"text": "Your input text here"
}
```
**Response:**
```json
{
"prediction": "Processed: Your input text here",
"confidence": 0.95,
"input_text": "Your input text here"
}
```
## Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| `JWT_SECRET` | Secret key for JWT token verification | Yes |
| `ALLOWED_ORIGINS` | Comma-separated list of allowed CORS origins | No |
## Local Development
```bash
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export JWT_SECRET=your_secret_key
# Run the server
uvicorn main:app --reload --port 8001
```
## Deployment
This service is designed to run on Hugging Face Spaces with Docker SDK.
1. Create a new Space with Docker SDK
2. Set the `JWT_SECRET` secret in Space settings
3. Push this code to the Space repository
|