Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,44 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Configure the Streamlit page
|
5 |
st.set_page_config(page_title="AI Friend Therapist Assistant", layout="centered")
|
|
|
1 |
+
"""
|
2 |
+
Hugging Face Spaces: AI Friend Therapist Assistant
|
3 |
+
|
4 |
+
This app listens to your messages, flags language that might indicate distress,
|
5 |
+
and provides emergency contacts for Canada if needed. It also uses a Hugging Face
|
6 |
+
summarization pipeline to generate a brief "therapist summary" of your conversation.
|
7 |
+
|
8 |
+
Dependencies:
|
9 |
+
- streamlit
|
10 |
+
- transformers
|
11 |
+
- torch
|
12 |
+
|
13 |
+
You can create a requirements.txt with:
|
14 |
+
streamlit
|
15 |
+
transformers
|
16 |
+
torch
|
17 |
+
|
18 |
+
Deploy this file (app.py) along with requirements.txt to Hugging Face Spaces.
|
19 |
+
"""
|
20 |
+
|
21 |
+
# Dependency checks
|
22 |
+
try:
|
23 |
+
import streamlit as st
|
24 |
+
except ImportError:
|
25 |
+
raise ImportError("Missing dependency: streamlit. Install it with 'pip install streamlit'.")
|
26 |
+
|
27 |
+
try:
|
28 |
+
from transformers import pipeline
|
29 |
+
except ImportError:
|
30 |
+
raise ImportError("Missing dependency: transformers. Install it with 'pip install transformers'.")
|
31 |
+
|
32 |
+
try:
|
33 |
+
import torch
|
34 |
+
except ImportError:
|
35 |
+
raise ImportError("Missing dependency: torch. Install it with 'pip install torch'.")
|
36 |
+
|
37 |
+
import os
|
38 |
+
|
39 |
+
# Optional: display a note if running on Hugging Face Spaces (the SPACE_ID env var is set in Spaces)
|
40 |
+
if os.environ.get("SPACE_ID"):
|
41 |
+
st.info("Running on Hugging Face Spaces.")
|
42 |
|
43 |
# Configure the Streamlit page
|
44 |
st.set_page_config(page_title="AI Friend Therapist Assistant", layout="centered")
|