hashirehtisham commited on
Commit
8317b0d
1 Parent(s): c4a61f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -22,23 +22,21 @@ 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 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 whats 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,7 +56,7 @@ def respond(user_input):
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
 
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
+ # Emotional detection and response
26
  if "happy" in user_input.lower():
27
+ response = "That's wonderful to hear! What made you feel happy today?"
28
  elif "sad" in user_input.lower():
29
+ response = "I'm sorry to hear that. Would you like to share what's making you feel sad?"
30
  elif "angry" in user_input.lower():
31
+ response = "It's okay to feel angry. What’s bothering you?"
32
+ elif "excited" in user_input.lower():
33
+ response = "That's great! What are you excited about?"
34
+ elif "depressed" in user_input.lower():
35
+ response = "I'm really sorry to hear that. It's important to talk about it. Would you like to share more?"
36
+ elif "stressed" in user_input.lower():
37
+ response = "Stress can be tough. What's been stressing you out?"
 
 
38
  else:
39
+ # Generate a response from the model for general inquiries
40
  chat_history_ids = model.generate(
41
  st.session_state['chat_history_ids'],
42
  max_length=1000,
 
56
  return response
57
 
58
  # Streamlit app layout
59
+ st.title("Emotional Support & General Knowledge Chatbot")
60
  st.write("Hello! I'm here to support you emotionally and answer any questions. How are you feeling today?")
61
 
62
  # Display chat history