metadata
title: PsyPredict [Backend]
emoji: π§
colorFrom: indigo
colorTo: purple
sdk: docker
pinned: false
PsyPredict - Backend
FastAPI backend for PsyPredict β production-grade multimodal clinical AI system.
What Runs Here
| Service | Technology |
|---|---|
| API Framework | FastAPI + Uvicorn |
| LLM Inference | Ollama / Llama3 (local) |
| Text Emotion | DistilBERT (bhadresh-savani/distilbert-base-uncased-emotion) |
| Crisis Detection | Zero-shot NLI (MiniLM) |
| Face Emotion | Keras CNN (custom trained, emotion_model_trained.h5) |
| Remedies | CSV lookup (MEDICATION.csv) |
Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/api/chat |
Main therapist β returns PsychReport |
POST |
/api/predict/emotion |
Facial emotion detection |
GET |
/api/get_advice |
Remedy/condition lookup |
POST |
/api/analyze/text |
Text emotion + crisis score |
GET |
/api/health |
System health check |
Running Locally
# 1. Install Ollama + LLaMA 3 (one-time)
winget install Ollama.Ollama
ollama pull llama3
# 2. Install dependencies
pip install -r requirements.txt
# 3. Start server
uvicorn app.main:app --host 0.0.0.0 --port 7860 --reload
Swagger docs: http://localhost:7860/docs
Key Files
app/
βββ main.py # FastAPI app factory
βββ config.py # Pydantic Settings
βββ schemas.py # All request/response models (PsychReport etc.)
βββ services/
β βββ ollama_engine.py # LLaMA 3 async client
β βββ text_emotion_engine.py# DistilBERT classifier
β βββ crisis_engine.py # Zero-shot NLI crisis detection
β βββ fusion_engine.py # Multimodal weighted fusion
β βββ emotion_engine.py # Keras CNN face emotion (preserved)
β βββ remedy_engine.py # CSV remedy lookup (preserved)
βββ api/endpoints/
βββ therapist.py # POST /api/chat
βββ facial.py # POST /api/predict/emotion
βββ remedies.py # GET /api/get_advice
βββ analysis.py # POST /api/analyze/text + GET /api/health