ProfessorCEO's picture
Cool Shot Systems
0fc9402 verified
metadata
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:

{
  "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

# 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