Spaces:
Sleeping
Sleeping
ogegadavis254
commited on
Commit
•
af2ab77
1
Parent(s):
72954c0
Update app.py
Browse files
app.py
CHANGED
@@ -100,21 +100,21 @@ if prompt := st.chat_input(f"Hi, I'm {selected_model}, ask me a question"):
|
|
100 |
st.session_state.messages.append(("user", prompt))
|
101 |
st.session_state.message_count += 1
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
100 |
st.session_state.messages.append(("user", prompt))
|
101 |
st.session_state.message_count += 1
|
102 |
|
103 |
+
# Check if intervention is needed based on user input or bot response
|
104 |
+
if any(keyword in prompt.lower() for keyword in ["human", "therapist", "someone", "died", "death", "help", "suicide", "suffering", "crisis", "emergency", "support", "depressed", "anxiety", "lonely", "desperate", "struggling", "counseling", "distressed", "hurt", "pain", "grief", "trauma", "abuse", "danger", "risk", "urgent", "need assistance"] for prompt in st.session_state.messages):
|
105 |
+
# Intervention logic here
|
106 |
+
if not st.session_state.ask_intervention:
|
107 |
+
st.session_state.ask_intervention = True
|
108 |
+
st.markdown("<span style='color:red;'>It seems like you might need to talk to someone. Click [here](https://www.google.com) for immediate assistance.</span>", unsafe_allow_html=True)
|
109 |
+
|
110 |
+
# Interact with the selected model
|
111 |
+
assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
|
112 |
+
|
113 |
+
# Display assistant response in chat message container
|
114 |
+
with st.empty():
|
115 |
+
st.markdown("AI is typing...")
|
116 |
+
st.empty()
|
117 |
+
st.markdown(assistant_response)
|
118 |
+
|
119 |
+
# Add assistant response to chat history
|
120 |
+
st.session_state.messages.append(("assistant", assistant_response))
|