Spaces:
Sleeping
Sleeping
Initial clean commit with hosted model
Browse files- .DS_Store +0 -0
- Dockerfile +6 -10
- README.md +46 -75
.DS_Store
CHANGED
|
Binary files a/.DS_Store and b/.DS_Store differ
|
|
|
Dockerfile
CHANGED
|
@@ -1,21 +1,17 @@
|
|
| 1 |
-
# Base image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Install system dependencies
|
| 8 |
-
RUN apt-get update && apt-get install -y git
|
| 9 |
-
|
| 10 |
# Copy files
|
| 11 |
COPY . .
|
| 12 |
|
| 13 |
-
# Install
|
| 14 |
-
RUN pip install --upgrade pip
|
| 15 |
-
|
| 16 |
|
| 17 |
-
# Expose Streamlit
|
| 18 |
-
EXPOSE
|
| 19 |
|
| 20 |
# Run the app
|
| 21 |
-
CMD ["streamlit", "run", "app.py", "--server.port=
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
# Copy files
|
| 7 |
COPY . .
|
| 8 |
|
| 9 |
+
# Install dependencies
|
| 10 |
+
RUN pip install --upgrade pip && \
|
| 11 |
+
pip install -r requirements.txt
|
| 12 |
|
| 13 |
+
# Expose Streamlit port
|
| 14 |
+
EXPOSE 7860
|
| 15 |
|
| 16 |
# Run the app
|
| 17 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
README.md
CHANGED
|
@@ -1,122 +1,93 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Counselor Assistant
|
| 3 |
-
emoji: π
|
| 4 |
-
colorFrom: red
|
| 5 |
-
colorTo: blue
|
| 6 |
-
sdk: streamlit
|
| 7 |
-
sdk_version: 1.44.1
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
license: mit
|
| 11 |
-
---
|
| 12 |
# π§ Mental Health Counselor Assistant
|
| 13 |
|
| 14 |
-
This
|
| 15 |
|
| 16 |
---
|
| 17 |
|
| 18 |
-
##
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
---
|
| 26 |
|
| 27 |
-
##
|
| 28 |
-
|
| 29 |
-
- β
Fine-tuned classifier (DistilBERT) for predicting intent (advice, question, validation, information)
|
| 30 |
-
- π Streaming text generation using Flan-T5-XL
|
| 31 |
-
- π Safety detection for crisis, violence, and toxicity
|
| 32 |
-
- π‘ Suggestion prompts tailored to each response type
|
| 33 |
-
- πΎ Option to save conversation logs
|
| 34 |
-
- πΈ Screenshots for walkthrough
|
| 35 |
-
|
| 36 |
-
---
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
| 41 |
-
- **Text Generator**: `google/flan-t5-xl` used to generate helpful, human-like counselor suggestions.
|
| 42 |
-
- **Safety Filter**: Includes custom regex patterns and `Detoxify` toxicity detector.
|
| 43 |
|
| 44 |
---
|
| 45 |
|
| 46 |
-
##
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
-
|
| 51 |
-
|
| 52 |
-
- `cleaned_combined_mental_health_dataset.csv`
|
| 53 |
|
| 54 |
---
|
| 55 |
|
| 56 |
-
##
|
| 57 |
|
| 58 |
```bash
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
βββ datasets/ # Training + testing datasets
|
| 65 |
-
βββ models/ # Fine-tuned model + tokenizer
|
| 66 |
-
βββ notebooks/ # Data prep + training notebooks
|
| 67 |
-
βββ logs/ # Saved chat logs
|
| 68 |
-
βββ screenshots/ # App walkthrough examples
|
| 69 |
-
βββ cache/ # Prompt-response cache
|
| 70 |
-
βββ alert/ # Alert logs (for flagged inputs)
|
| 71 |
```
|
| 72 |
|
| 73 |
---
|
| 74 |
|
| 75 |
-
## π³ Docker
|
| 76 |
-
|
| 77 |
-
To build and run the app locally:
|
| 78 |
|
| 79 |
```bash
|
|
|
|
| 80 |
docker build -t counselor-assistant .
|
|
|
|
|
|
|
| 81 |
docker run -p 7860:7860 counselor-assistant
|
| 82 |
```
|
| 83 |
|
| 84 |
-
Then
|
| 85 |
|
| 86 |
---
|
| 87 |
|
| 88 |
-
##
|
| 89 |
-
|
| 90 |
-
You can deploy to [Hugging Face Spaces](https://huggingface.co/spaces/) by:
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
|
| 96 |
---
|
| 97 |
|
| 98 |
-
##
|
| 99 |
-
|
| 100 |
-
### π¬ Classifier Prediction + Suggestions
|
| 101 |
-

|
| 102 |
-
|
| 103 |
-
### π¨ Safe Response for Crisis Input
|
| 104 |
-

|
| 105 |
|
| 106 |
-
|
| 107 |
-

|
| 108 |
|
| 109 |
-
|
| 110 |
-

|
| 111 |
|
| 112 |
---
|
| 113 |
|
| 114 |
-
##
|
| 115 |
-
|
| 116 |
-
Install dependencies:
|
| 117 |
|
| 118 |
```bash
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
```
|
| 121 |
|
|
|
|
|
|
|
|
|
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# π§ Mental Health Counselor Assistant
|
| 2 |
|
| 3 |
+
This app helps mental health counselors generate helpful, informed, and compassionate suggestions based on patient messages. It classifies the message intent and offers guidance for how a counselor might respond, with built-in safety checks for crisis or violent content.
|
| 4 |
|
| 5 |
---
|
| 6 |
|
| 7 |
+
## π‘ Features
|
| 8 |
|
| 9 |
+
- β
Response type classification (advice, validation, information, question)
|
| 10 |
+
- π¬ LLM-generated counselor suggestions using `google/flan-t5-xl`
|
| 11 |
+
- π‘οΈ Built-in safety detection for crisis and toxic content
|
| 12 |
+
- πΎ Conversation history logging and export
|
| 13 |
+
- π Web-based Streamlit interface
|
| 14 |
|
| 15 |
---
|
| 16 |
|
| 17 |
+
## π¦ Hosted Model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
This app uses a fine-tuned classification model hosted at:
|
| 20 |
|
| 21 |
+
β‘οΈ [`scdong/distilbert-response-type`](https://huggingface.co/scdong/distilbert-response-type)
|
|
|
|
|
|
|
| 22 |
|
| 23 |
---
|
| 24 |
|
| 25 |
+
## π How to Use
|
| 26 |
|
| 27 |
+
1. Enter a patient's message in the chat box.
|
| 28 |
+
2. The app detects safety concerns (e.g. suicidal, violent, or toxic content).
|
| 29 |
+
3. If safe, it classifies the message and generates counselor-style suggestions.
|
| 30 |
+
4. You can export the session log as a CSV file.
|
|
|
|
| 31 |
|
| 32 |
---
|
| 33 |
|
| 34 |
+
## π₯οΈ Running Locally
|
| 35 |
|
| 36 |
```bash
|
| 37 |
+
# Install dependencies
|
| 38 |
+
pip install -r requirements.txt
|
| 39 |
+
|
| 40 |
+
# Run the app
|
| 41 |
+
streamlit run app.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
---
|
| 45 |
|
| 46 |
+
## π³ Docker (optional)
|
|
|
|
|
|
|
| 47 |
|
| 48 |
```bash
|
| 49 |
+
# Build Docker image
|
| 50 |
docker build -t counselor-assistant .
|
| 51 |
+
|
| 52 |
+
# Run it
|
| 53 |
docker run -p 7860:7860 counselor-assistant
|
| 54 |
```
|
| 55 |
|
| 56 |
+
Then go to `http://localhost:7860` in your browser.
|
| 57 |
|
| 58 |
---
|
| 59 |
|
| 60 |
+
## π§ Example Use Case
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
> **Patient:** I feel like Iβm not good enough, no matter how hard I try.
|
| 63 |
+
> **Suggestions:**
|
| 64 |
+
> - You're doing more than enough β even if it doesn't feel like it right now.
|
| 65 |
+
> - Try to be as kind to yourself as you would to a close friend.
|
| 66 |
+
> - Even small steps forward count. You're showing up, and that matters.
|
| 67 |
|
| 68 |
---
|
| 69 |
|
| 70 |
+
## π Crisis Handling
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
If the input includes high-risk language (e.g., "I want to kill myself"), the app immediately responds with:
|
|
|
|
| 73 |
|
| 74 |
+
> _"I'm really sorry you're feeling this way. You're not alone. Please consider calling 988 or speaking with a mental health professional right away."_
|
|
|
|
| 75 |
|
| 76 |
---
|
| 77 |
|
| 78 |
+
## π File Structure
|
|
|
|
|
|
|
| 79 |
|
| 80 |
```bash
|
| 81 |
+
.
|
| 82 |
+
βββ app.py # Main Streamlit app
|
| 83 |
+
βββ requirements.txt # Python dependencies
|
| 84 |
+
βββ Dockerfile # (Optional) Docker setup
|
| 85 |
+
βββ cache.json # Prompt/response cache
|
| 86 |
+
βββ README.md # This file
|
| 87 |
```
|
| 88 |
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## π€ License
|
| 92 |
|
| 93 |
+
MIT License.
|