Spaces:
Sleeping
Sleeping
ogegadavis254
commited on
Commit
•
7800e67
1
Parent(s):
af2ab77
Update app.py
Browse files
app.py
CHANGED
@@ -39,8 +39,9 @@ def interact_with_together_api(messages, model_link):
|
|
39 |
all_messages.append({"role": "user", "content": human})
|
40 |
all_messages.append({"role": "assistant", "content": assistant})
|
41 |
|
42 |
-
# Add the latest user message
|
43 |
-
|
|
|
44 |
|
45 |
url = "https://api.together.xyz/v1/chat/completions"
|
46 |
payload = {
|
@@ -101,7 +102,7 @@ if prompt := st.chat_input(f"Hi, I'm {selected_model}, ask me a question"):
|
|
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
|
105 |
# Intervention logic here
|
106 |
if not st.session_state.ask_intervention:
|
107 |
st.session_state.ask_intervention = True
|
|
|
39 |
all_messages.append({"role": "user", "content": human})
|
40 |
all_messages.append({"role": "assistant", "content": assistant})
|
41 |
|
42 |
+
# Add the latest user message if messages list is not empty
|
43 |
+
if messages:
|
44 |
+
all_messages.append({"role": "user", "content": messages[-1][1]})
|
45 |
|
46 |
url = "https://api.together.xyz/v1/chat/completions"
|
47 |
payload = {
|
|
|
102 |
st.session_state.message_count += 1
|
103 |
|
104 |
# Check if intervention is needed based on user input or bot response
|
105 |
+
if any(keyword in message[1].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 message in st.session_state.messages):
|
106 |
# Intervention logic here
|
107 |
if not st.session_state.ask_intervention:
|
108 |
st.session_state.ask_intervention = True
|