hashirehtisham
commited on
Commit
•
8317b0d
1
Parent(s):
c4a61f8
Update app.py
Browse files
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 |
-
#
|
26 |
if "happy" in user_input.lower():
|
27 |
-
response = "
|
28 |
elif "sad" in user_input.lower():
|
29 |
-
response = "I'm
|
30 |
elif "angry" in user_input.lower():
|
31 |
-
response = "It's okay to feel angry
|
32 |
-
elif "
|
33 |
-
response =
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
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
|
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
|
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
|