hashirehtisham commited on
Commit
c4a61f8
·
verified ·
1 Parent(s): 34f8c80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -22,10 +22,23 @@ def respond(user_input):
22
  else:
23
  st.session_state['chat_history_ids'] = torch.cat([st.session_state['chat_history_ids'], new_user_input_ids], dim=-1)
24
 
25
- # Check for specific requests and provide specific answers
26
- if "facts about blue" in user_input.lower():
27
- response = "Here are some happy facts about blue:\n1. Blue is often associated with calmness and tranquility.\n2. Studies show that blue can help reduce stress and promote relaxation.\n3. The sky and ocean are blue, reminding us of nature's beauty.\n4. Blue is the color of many happy brands, symbolizing trust and dependability."
 
 
 
 
 
 
 
 
 
 
 
 
28
  else:
 
29
  chat_history_ids = model.generate(
30
  st.session_state['chat_history_ids'],
31
  max_length=1000,
@@ -45,8 +58,8 @@ def respond(user_input):
45
  return response
46
 
47
  # Streamlit app layout
48
- st.title("Emotional Health Chatbot")
49
- st.write("Hello! I am here to support you emotionally. How are you feeling today?")
50
 
51
  # Display chat history
52
  if st.session_state['chat_history']:
 
22
  else:
23
  st.session_state['chat_history_ids'] = torch.cat([st.session_state['chat_history_ids'], new_user_input_ids], dim=-1)
24
 
25
+ # Check for specific emotional support requests
26
+ if "happy" in user_input.lower():
27
+ response = "Wow, that's great to hear! What made you feel happy today?"
28
+ elif "sad" in user_input.lower():
29
+ response = "I'm really sorry to hear that. Would you like to share what’s making you feel sad? I'm here to listen."
30
+ elif "angry" in user_input.lower():
31
+ response = "It's okay to feel angry sometimes. Would you like to talk about what's bothering you?"
32
+ elif "facts about blue" in user_input.lower():
33
+ response = (
34
+ "Here are some happy facts about blue:\n"
35
+ "1. Blue is often associated with calmness and tranquility.\n"
36
+ "2. Studies show that blue can help reduce stress and promote relaxation.\n"
37
+ "3. The sky and ocean are blue, reminding us of nature's beauty.\n"
38
+ "4. Blue is the color of many happy brands, symbolizing trust and dependability."
39
+ )
40
  else:
41
+ # Generate a response from the model for general queries
42
  chat_history_ids = model.generate(
43
  st.session_state['chat_history_ids'],
44
  max_length=1000,
 
58
  return response
59
 
60
  # Streamlit app layout
61
+ st.title("Emotional Health & General Knowledge Chatbot")
62
+ st.write("Hello! I'm here to support you emotionally and answer any questions. How are you feeling today?")
63
 
64
  # Display chat history
65
  if st.session_state['chat_history']: