ogegadavis254 commited on
Commit
12ab455
1 Parent(s): ebd3bc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -43,10 +43,13 @@ def interact_with_together_api(messages, model_link, diagnostic=False):
43
 
44
  if diagnostic:
45
  diagnostic_prompt = "Analyze the following conversation and predict the mental issue the user might be suffering from:"
46
- all_messages.append({"role": "user", "content": diagnostic_prompt})
 
47
  for message in messages:
48
  if message[0] == "user":
49
- all_messages.append({"role": "user", "content": message[1]})
 
 
50
 
51
  url = "https://api.together.xyz/v1/chat/completions"
52
  payload = {
@@ -124,12 +127,6 @@ st.sidebar.markdown("**Note**: This model is still in the beta phase. Responses
124
  st.sidebar.image("https://assets.isu.pub/document-structure/221118065013-a6029cf3d563afaf9b946bb9497d45d4/v1/2841525b232adaef7bd0efe1da81a4c5.jpeg", width=200)
125
  st.sidebar.write("A product proudly developed by Kisii University")
126
 
127
- # Display diagnosis in the sidebar
128
- if st.session_state.message_count >= 4:
129
- if "diagnosis" not in st.session_state or st.session_state.diagnosis is None:
130
- st.session_state.diagnosis = diagnose_mental_health(st.session_state.messages)
131
- st.sidebar.markdown(f"### Diagnosis:\n**{st.session_state.diagnosis}**")
132
-
133
  # Initialize chat history
134
  if "messages" not in st.session_state:
135
  st.session_state.messages = []
@@ -137,6 +134,12 @@ if "messages" not in st.session_state:
137
  st.session_state.ask_intervention = False
138
  st.session_state.diagnosis = None
139
 
 
 
 
 
 
 
140
  # Display chat messages from history on app rerun
141
  for message in st.session_state.messages:
142
  with st.chat_message(message[0]):
 
43
 
44
  if diagnostic:
45
  diagnostic_prompt = "Analyze the following conversation and predict the mental issue the user might be suffering from:"
46
+ diagnostic_messages = [{"role": "system", "content": "You are an AI model specialized in mental health diagnosis."},
47
+ {"role": "user", "content": diagnostic_prompt}]
48
  for message in messages:
49
  if message[0] == "user":
50
+ diagnostic_messages.append({"role": "user", "content": message[1]})
51
+
52
+ all_messages = diagnostic_messages
53
 
54
  url = "https://api.together.xyz/v1/chat/completions"
55
  payload = {
 
127
  st.sidebar.image("https://assets.isu.pub/document-structure/221118065013-a6029cf3d563afaf9b946bb9497d45d4/v1/2841525b232adaef7bd0efe1da81a4c5.jpeg", width=200)
128
  st.sidebar.write("A product proudly developed by Kisii University")
129
 
 
 
 
 
 
 
130
  # Initialize chat history
131
  if "messages" not in st.session_state:
132
  st.session_state.messages = []
 
134
  st.session_state.ask_intervention = False
135
  st.session_state.diagnosis = None
136
 
137
+ # Display diagnosis in the sidebar
138
+ if st.session_state.message_count >= 4:
139
+ if "diagnosis" not in st.session_state or st.session_state.diagnosis is None:
140
+ st.session_state.diagnosis = diagnose_mental_health(st.session_state.messages)
141
+ st.sidebar.markdown(f"### Diagnosis:\n**{st.session_state.diagnosis}**")
142
+
143
  # Display chat messages from history on app rerun
144
  for message in st.session_state.messages:
145
  with st.chat_message(message[0]):