CoolFace
Apppublic

LuckmanShaik/AP_MSME_Backend

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
App README

AP MSME Chatbot API

FastAPI backend for the AP MSME ONE Portal chatbot. Deployed on Hugging Face Spaces with Docker.

Endpoints

  • —GET /health — pipeline readiness
  • —POST /auth/request-otp — send OTP to a 10-digit mobile (demo OTP: 123456)
  • —POST /auth/verify-otp — verify OTP and receive bearer token
  • —POST /chat — main RAG chat endpoint (requires Authorization: Bearer <token>)
  • —POST /speech/stt — speech-to-text (multipart audio upload)
  • —POST /speech/tts — text-to-speech (returns audio/wav or audio/mpeg)
  • —GET /docs — Swagger UI

Secrets (HF Space Settings → Variables and secrets)

The Docker build only installs dependencies. You must add runtime secrets on the Space (Settings → Variables and secrets). Copy values from your local .env in the main project.

SecretRequiredNotes
MILVUS_URIYesZilliz Cloud public endpoint (not your-cluster.zillizcloud.com)
MILVUS_TOKENYesZilliz API key
COLLECTION_NAMEYese.g. apmsme_chunks_v3
LLM_PROVIDERYese.g. azure
AZURE_OPENAI_* or other LLM keysYesMatch your provider
FRONTEND_URLYesVercel URL for CORS (e.g. https://your-app.vercel.app)
BACKEND_URLOptionalAuto-detected from SPACE_HOST if omitted
HF_TOKENOptionalHugging Face token — faster model downloads

If startup fails with your-cluster.zillizcloud.com, MILVUS_URI / MILVUS_TOKEN were not set on the Space.

Local run

bash
pip install -r requirements.txt
cp .env.example .env   # fill in secrets
python run.py

Docker

requirements.txt is pinned for fast HF builds (CPU PyTorch, no optimum/CUDA wheels). The Dockerfile installs torch from the PyTorch CPU index before other deps.

bash
docker build -t ap-msme-backend .
docker run -p 7860:7860 --env-file .env ap-msme-backend

Windows local dev (Python 3.13 ONNX embeddings only):

bash
pip install -r requirements.txt
pip install optimum[onnxruntime]==1.17.1 onnxruntime==1.23.2

BM25 corpus (optional)

Place output/clean_chunks.json in the repo for keyword search. Vector search works without it.