Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,12 +18,17 @@ You can create a requirements.txt with:
|
|
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:
|
@@ -34,15 +39,10 @@ try:
|
|
34 |
except ImportError:
|
35 |
raise ImportError("Missing dependency: torch. Install it with 'pip install torch'.")
|
36 |
|
37 |
-
|
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")
|
45 |
-
|
46 |
# Load the Hugging Face summarization model (cached to avoid reloading)
|
47 |
@st.cache(allow_output_mutation=True)
|
48 |
def load_summarizer():
|
@@ -64,7 +64,7 @@ st.write(
|
|
64 |
# Text area for user input
|
65 |
user_input = st.text_area("Your message", height=150)
|
66 |
|
67 |
-
#
|
68 |
if st.button("Send"):
|
69 |
if user_input.strip():
|
70 |
# Append the message to conversation history
|
|
|
18 |
Deploy this file (app.py) along with requirements.txt to Hugging Face Spaces.
|
19 |
"""
|
20 |
|
21 |
+
# Dependency checks and initial imports
|
22 |
try:
|
23 |
import streamlit as st
|
24 |
except ImportError:
|
25 |
raise ImportError("Missing dependency: streamlit. Install it with 'pip install streamlit'.")
|
26 |
|
27 |
+
# Immediately set the page configuration
|
28 |
+
st.set_page_config(page_title="AI Friend Therapist Assistant", layout="centered")
|
29 |
+
|
30 |
+
import os
|
31 |
+
|
32 |
try:
|
33 |
from transformers import pipeline
|
34 |
except ImportError:
|
|
|
39 |
except ImportError:
|
40 |
raise ImportError("Missing dependency: torch. Install it with 'pip install torch'.")
|
41 |
|
42 |
+
# Optional: display a note if running on Hugging Face Spaces
|
|
|
|
|
43 |
if os.environ.get("SPACE_ID"):
|
44 |
st.info("Running on Hugging Face Spaces.")
|
45 |
|
|
|
|
|
|
|
46 |
# Load the Hugging Face summarization model (cached to avoid reloading)
|
47 |
@st.cache(allow_output_mutation=True)
|
48 |
def load_summarizer():
|
|
|
64 |
# Text area for user input
|
65 |
user_input = st.text_area("Your message", height=150)
|
66 |
|
67 |
+
# Process user input when "Send" is clicked
|
68 |
if st.button("Send"):
|
69 |
if user_input.strip():
|
70 |
# Append the message to conversation history
|