metadata
title: Chatbot Sports Academies System
emoji: π
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
Chatbot Sports Academies System
Django-based chatbot for sports academy services, knowledge-base Q&A, service-intent detection, and backend workflow execution.
This Space runs as a Docker Space and exposes Django/Gunicorn on port 7860.
Runtime Flow
User message
β
Input validation / rate limiting
β
Prompt routing policy: live platform request, knowledge question, or follow-up
β
Conservative service candidate ranking with conversation context
β
If high confidence: return SERVICE_REQUEST to the authenticated backend
If ambiguous: return CLARIFICATION_REQUIRED
If knowledge-only: search the CSV knowledge base
The deterministic router is authoritative for service selection. The optional service-intent model enriches already-selected services with flexible parameters; it does not independently choose or execute a service. Explicit live-data requests never fall through to an unrelated knowledge-base answer.
Required CSV datasets
Copy these files into apps/chat/training_models/data/ before production/training:
data.csvservice_intents.csvservice_intents_model_training.csv
Model skip/training logic
Startup runs:
python manage.py ensure_model --remote --wait --download-artifact
Logic:
- Check
SERVICE_INTENT_MODEL_DIR. - If Hugging Face model files already exist, skip training.
- If missing, train remotely using
service_intents_model_training.csv. - If training fails, app still starts with deterministic service detection.
Environment variables
Set these in Hugging Face Space settings:
DJANGO_SECRET_KEY=change-me
DJANGO_DEBUG=0
DJANGO_ALLOWED_HOSTS=.hf.space,localhost,127.0.0.1
DJANGO_SECURE_SSL_REDIRECT=1
SEMANTIC_SEARCH_ENABLED=False
SERVICE_INTENT_MODEL_DIR=/app/artifacts/service_intent_model
SERVICE_INTENT_TRAINING_SPACE_URL=https://mortadhabbb-train-model-chatbot.hf.space
N8N_BASE_URL=https://mortadhabbb-n8n-service-orchestration.hf.space
Optional secrets:
CHATBOT_API_KEY=
HF_TOKEN=
SERVICE_INTENT_TRAINING_SPACE_API_KEY=
Local run
python -m venv .venv
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
Docker run
docker build -t chatbot-sports-academies .
docker run --rm -p 7860:7860 -e DJANGO_SECRET_KEY=dev -e DJANGO_DEBUG=0 chatbot-sports-academies
Push to Hugging Face
git add .
git commit -m "Regenerate Django chatbot project"
git push space main
If replacing the whole Space repository:
git push --force space main