ogegadavis254 commited on
Commit
4f4ef99
1 Parent(s): 8ccf576

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -76,14 +76,15 @@ st.sidebar.button('Reset Chat', on_click=reset_conversation)
76
  # Add cautionary message about testing phase at the bottom of the sidebar
77
  st.sidebar.markdown("**Note**: This model is still in the testing phase. Responses may be inaccurate or undesired. Use it cautiously, especially for critical issues.")
78
 
79
- # Add logo to the sidebar
80
  st.sidebar.image("https://assets.isu.pub/document-structure/221118065013-a6029cf3d563afaf9b946bb9497d45d4/v1/2841525b232adaef7bd0efe1da81a4c5.jpeg", width=200)
 
81
 
82
  # Initialize chat history
83
  if "messages" not in st.session_state:
84
  st.session_state.messages = []
85
  st.session_state.message_count = 0
86
- st.session_state.ask_recommendation = False
87
 
88
  # Display chat messages from history on app rerun
89
  for message in st.session_state.messages:
@@ -99,12 +100,12 @@ if prompt := st.chat_input(f"Hi, I'm {selected_model}, ask me a question"):
99
  st.session_state.messages.append(("user", prompt))
100
  st.session_state.message_count += 1
101
 
102
- # Check if it's time to ask for recommendation
103
- if st.session_state.message_count >= 10 and not st.session_state.ask_recommendation:
104
- if st.button("Would you recommend this model to others?"):
105
- st.session_state.ask_recommendation = True
106
- # Add your logic here for handling the recommendation
107
- # You may want to store the response in session state or a database
108
 
109
  # Interact with the selected model
110
  assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
 
76
  # Add cautionary message about testing phase at the bottom of the sidebar
77
  st.sidebar.markdown("**Note**: This model is still in the testing phase. Responses may be inaccurate or undesired. Use it cautiously, especially for critical issues.")
78
 
79
+ # Add logo and text to the sidebar
80
  st.sidebar.image("https://assets.isu.pub/document-structure/221118065013-a6029cf3d563afaf9b946bb9497d45d4/v1/2841525b232adaef7bd0efe1da81a4c5.jpeg", width=200)
81
+ st.sidebar.write("A product of Kisii University")
82
 
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
+ st.session_state.ask_intervention = False
88
 
89
  # Display chat messages from history on app rerun
90
  for message in st.session_state.messages:
 
100
  st.session_state.messages.append(("user", prompt))
101
  st.session_state.message_count += 1
102
 
103
+ # Check if intervention is needed
104
+ if "suicide" in prompt.lower() or "help" in prompt.lower():
105
+ if not st.session_state.ask_intervention:
106
+ if st.button("Do you need to talk to a therapist?"):
107
+ st.session_state.ask_intervention = True
108
+ st.write("You can reach out to a certified therapist at +25493609747.")
109
 
110
  # Interact with the selected model
111
  assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])