Spaces:
Sleeping
Sleeping
ogegadavis254
commited on
Commit
•
668f790
1
Parent(s):
5f43718
Update app.py
Browse files
app.py
CHANGED
@@ -83,6 +83,7 @@ st.sidebar.write("A product proudly developed by Kisii University")
|
|
83 |
# Initialize chat history
|
84 |
if "messages" not in st.session_state:
|
85 |
st.session_state.messages = []
|
|
|
86 |
|
87 |
# Keywords for intervention
|
88 |
intervention_keywords = [
|
@@ -99,15 +100,23 @@ if prompt := st.chat_input(f"Hi, I'm {selected_model}, ask me a question"):
|
|
99 |
st.markdown(prompt)
|
100 |
# Add user message to chat history
|
101 |
st.session_state.messages.append(("user", prompt))
|
|
|
102 |
|
103 |
# Check if intervention is needed based on bot response
|
104 |
if any(keyword in prompt.lower() for keyword in intervention_keywords):
|
105 |
# Intervention logic here
|
106 |
-
st.
|
|
|
107 |
|
108 |
# Interact with the selected model
|
109 |
assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
|
110 |
|
111 |
# Display assistant response in chat message container
|
112 |
-
with st.
|
113 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
# Initialize chat history
|
84 |
if "messages" not in st.session_state:
|
85 |
st.session_state.messages = []
|
86 |
+
st.session_state.message_count = 0
|
87 |
|
88 |
# Keywords for intervention
|
89 |
intervention_keywords = [
|
|
|
100 |
st.markdown(prompt)
|
101 |
# Add user message to chat history
|
102 |
st.session_state.messages.append(("user", prompt))
|
103 |
+
st.session_state.message_count += 1
|
104 |
|
105 |
# Check if intervention is needed based on bot response
|
106 |
if any(keyword in prompt.lower() for keyword in intervention_keywords):
|
107 |
# Intervention logic here
|
108 |
+
with st.chat_message("assistant"):
|
109 |
+
st.markdown("<span style='color:red;'>I have a feeling you may need to talk to a therapist. If you agree with me please contact +254793609747; Name: Davis. If you dont then keep talking to me as we figure this out.</span>", unsafe_allow_html=True)
|
110 |
|
111 |
# Interact with the selected model
|
112 |
assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
|
113 |
|
114 |
# Display assistant response in chat message container
|
115 |
+
with st.empty():
|
116 |
+
st.markdown("AI is typing...")
|
117 |
+
st.empty()
|
118 |
+
with st.chat_message("assistant"):
|
119 |
+
st.markdown(assistant_response)
|
120 |
+
|
121 |
+
# Add assistant response to chat history
|
122 |
+
st.session_state.messages.append(("assistant", assistant_response))
|