ogegadavis254 commited on
Commit
17ecdc7
1 Parent(s): 81adcc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -18
app.py CHANGED
@@ -128,29 +128,19 @@ st.sidebar.image("https://assets.isu.pub/document-structure/221118065013-a6029cf
128
  st.sidebar.write("A product proudly developed by Kisii University")
129
 
130
  # Accept user input
131
- if prompt := st.chat_input(f"Hi, I'm {selected_model}, let's chat"):
132
  # Display user message in chat message container
133
- with st.chat_message("user"):
134
- st.markdown(prompt)
135
- # Add user message to chat history
136
  st.session_state.messages.append(("user", prompt))
137
-
138
  # Interact with the selected model
139
  assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
140
 
141
  if assistant_response is not None:
142
  # Display assistant response in chat message container
143
- with st.empty():
144
- st.markdown("AI is typing...")
145
- st.empty()
146
- st.markdown(assistant_response)
147
-
148
- # Check if intervention is needed based on bot response
149
- 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"]):
150
- # Intervention logic here
151
- if not st.session_state.ask_intervention:
152
- if st.button("After the analysing our session you may need some extra help, so you can reach out to a certified therapist at +25493609747 Name: Ogega feel free to talk"):
153
- st.write("You can reach out to a certified therapist at +25493609747.")
154
-
155
- # Add assistant response to chat histor
156
  st.session_state.messages.append(("assistant", assistant_response))
 
 
 
 
 
 
 
 
128
  st.sidebar.write("A product proudly developed by Kisii University")
129
 
130
  # Accept user input
131
+ if prompt := st.text_input(f"Hi, I'm {selected_model}, let's chat"):
132
  # Display user message in chat message container
 
 
 
133
  st.session_state.messages.append(("user", prompt))
 
134
  # Interact with the selected model
135
  assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
136
 
137
  if assistant_response is not None:
138
  # Display assistant response in chat message container
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  st.session_state.messages.append(("assistant", assistant_response))
140
+
141
+ # Display chat messages from history
142
+ for role, message in st.session_state.messages:
143
+ if role == "user":
144
+ st.text_input("You:", message, disabled=True)
145
+ elif role == "assistant":
146
+ st.text_area("Assistant:", message, disabled=True)