Spaces:
Sleeping
Sleeping
Commit ·
286428e
1
Parent(s): 34632d5
update backend for AWS
Browse files- README.md +2 -2
- app/api/endpoints/therapist.py +1 -1
- app/config.py +1 -1
- app/main.py +1 -1
- app/services/ollama_engine.py +2 -2
- main.py +1 -1
README.md
CHANGED
|
@@ -16,7 +16,7 @@ pinned: false
|
|
| 16 |
| Service | Technology |
|
| 17 |
|---------|-----------|
|
| 18 |
| API Framework | FastAPI + Uvicorn |
|
| 19 |
-
| LLM Inference | Ollama /
|
| 20 |
| Text Emotion | DistilBERT (`bhadresh-savani/distilbert-base-uncased-emotion`) |
|
| 21 |
| Crisis Detection | Zero-shot NLI (MiniLM) |
|
| 22 |
| Face Emotion | Keras CNN (custom trained, `emotion_model_trained.h5`) |
|
|
@@ -37,7 +37,7 @@ pinned: false
|
|
| 37 |
```bash
|
| 38 |
# 1. Install Ollama + LLaMA 3 (one-time)
|
| 39 |
winget install Ollama.Ollama
|
| 40 |
-
ollama pull
|
| 41 |
|
| 42 |
# 2. Install dependencies
|
| 43 |
pip install -r requirements.txt
|
|
|
|
| 16 |
| Service | Technology |
|
| 17 |
|---------|-----------|
|
| 18 |
| API Framework | FastAPI + Uvicorn |
|
| 19 |
+
| LLM Inference | Ollama / Llama3 (local) |
|
| 20 |
| Text Emotion | DistilBERT (`bhadresh-savani/distilbert-base-uncased-emotion`) |
|
| 21 |
| Crisis Detection | Zero-shot NLI (MiniLM) |
|
| 22 |
| Face Emotion | Keras CNN (custom trained, `emotion_model_trained.h5`) |
|
|
|
|
| 37 |
```bash
|
| 38 |
# 1. Install Ollama + LLaMA 3 (one-time)
|
| 39 |
winget install Ollama.Ollama
|
| 40 |
+
ollama pull llama3
|
| 41 |
|
| 42 |
# 2. Install dependencies
|
| 43 |
pip install -r requirements.txt
|
app/api/endpoints/therapist.py
CHANGED
|
@@ -5,7 +5,7 @@ Full inference pipeline:
|
|
| 5 |
2. Text emotion classification (DistilBERT)
|
| 6 |
3. Crisis evaluation (zero-shot NLI) — override if triggered
|
| 7 |
4. Multimodal fusion (text + face)
|
| 8 |
-
5. Ollama/
|
| 9 |
6. PsychReport JSON schema validation
|
| 10 |
7. Streaming response option
|
| 11 |
"""
|
|
|
|
| 5 |
2. Text emotion classification (DistilBERT)
|
| 6 |
3. Crisis evaluation (zero-shot NLI) — override if triggered
|
| 7 |
4. Multimodal fusion (text + face)
|
| 8 |
+
5. Ollama/Llama3 structured report generation
|
| 9 |
6. PsychReport JSON schema validation
|
| 10 |
7. Streaming response option
|
| 11 |
"""
|
app/config.py
CHANGED
|
@@ -12,7 +12,7 @@ class Settings(BaseSettings):
|
|
| 12 |
# Default is localhost (e.g. for development), but in production it should be like:
|
| 13 |
# OLLAMA_BASE_URL: str = "http://123.45.67.89:11434"
|
| 14 |
OLLAMA_BASE_URL: str = "http://127.0.0.1:11434"
|
| 15 |
-
OLLAMA_MODEL: str = "
|
| 16 |
OLLAMA_TIMEOUT_S: int = 90
|
| 17 |
|
| 18 |
# Retry logic for external LLM API
|
|
|
|
| 12 |
# Default is localhost (e.g. for development), but in production it should be like:
|
| 13 |
# OLLAMA_BASE_URL: str = "http://123.45.67.89:11434"
|
| 14 |
OLLAMA_BASE_URL: str = "http://127.0.0.1:11434"
|
| 15 |
+
OLLAMA_MODEL: str = "llama3"
|
| 16 |
OLLAMA_TIMEOUT_S: int = 90
|
| 17 |
|
| 18 |
# Retry logic for external LLM API
|
app/main.py
CHANGED
|
@@ -108,7 +108,7 @@ def create_app() -> FastAPI:
|
|
| 108 |
title="PsyPredict API",
|
| 109 |
description=(
|
| 110 |
"Production-grade multimodal mental health AI system. "
|
| 111 |
-
"Powered by
|
| 112 |
),
|
| 113 |
version="2.0.0",
|
| 114 |
lifespan=lifespan,
|
|
|
|
| 108 |
title="PsyPredict API",
|
| 109 |
description=(
|
| 110 |
"Production-grade multimodal mental health AI system. "
|
| 111 |
+
"Powered by Llama3 (Ollama) + DistilBERT + Keras CNN facial emotion model."
|
| 112 |
),
|
| 113 |
version="2.0.0",
|
| 114 |
lifespan=lifespan,
|
app/services/ollama_engine.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
ollama_engine.py — PsyPredict Local LLM Engine (
|
| 3 |
Async Ollama client with:
|
| 4 |
- Structured JSON output enforced via schema-in-prompt + Ollama format param
|
| 5 |
- Context window trimming
|
|
@@ -97,7 +97,7 @@ FACE_DISTRESS_MAP: dict[str, float] = {
|
|
| 97 |
|
| 98 |
class OllamaEngine:
|
| 99 |
"""
|
| 100 |
-
Production async LLM engine backed by local Ollama/
|
| 101 |
"""
|
| 102 |
|
| 103 |
def __init__(self) -> None:
|
|
|
|
| 1 |
"""
|
| 2 |
+
ollama_engine.py — PsyPredict Local LLM Engine (Llama3)
|
| 3 |
Async Ollama client with:
|
| 4 |
- Structured JSON output enforced via schema-in-prompt + Ollama format param
|
| 5 |
- Context window trimming
|
|
|
|
| 97 |
|
| 98 |
class OllamaEngine:
|
| 99 |
"""
|
| 100 |
+
Production async LLM engine backed by local Ollama/Llama3.
|
| 101 |
"""
|
| 102 |
|
| 103 |
def __init__(self) -> None:
|
main.py
CHANGED
|
@@ -118,7 +118,7 @@ def create_app() -> FastAPI:
|
|
| 118 |
title="PsyPredict API",
|
| 119 |
description=(
|
| 120 |
"Production-grade multimodal mental health AI system. "
|
| 121 |
-
"Powered by
|
| 122 |
),
|
| 123 |
version="2.0.0",
|
| 124 |
lifespan=lifespan,
|
|
|
|
| 118 |
title="PsyPredict API",
|
| 119 |
description=(
|
| 120 |
"Production-grade multimodal mental health AI system. "
|
| 121 |
+
"Powered by Llama3 (Ollama) + DistilBERT + Keras CNN facial emotion model."
|
| 122 |
),
|
| 123 |
version="2.0.0",
|
| 124 |
lifespan=lifespan,
|