Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,17 +40,13 @@ if user_input:
|
|
40 |
sentiment = sentiment_analysis(user_input)[0]
|
41 |
|
42 |
# Generate empathetic response with increased length and more context
|
43 |
-
response = conversational_bot(user_input, max_length=300,
|
44 |
|
45 |
# Choose the response that does not repeat what the user said
|
46 |
-
best_response =
|
47 |
-
for generated in response:
|
48 |
-
if user_input.lower() not in generated['generated_text'].lower():
|
49 |
-
best_response = generated['generated_text']
|
50 |
-
break
|
51 |
|
52 |
-
#
|
53 |
-
if
|
54 |
best_response = "I understand how you're feeling. You're not alone in this. I'm here to listen and help."
|
55 |
|
56 |
# Store the response for future comparison
|
|
|
40 |
sentiment = sentiment_analysis(user_input)[0]
|
41 |
|
42 |
# Generate empathetic response with increased length and more context
|
43 |
+
response = conversational_bot(user_input, max_length=300, temperature=0.9, top_k=50, num_return_sequences=1)
|
44 |
|
45 |
# Choose the response that does not repeat what the user said
|
46 |
+
best_response = response[0]['generated_text']
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
# Ensure the response is supportive and does not repeat the user's input
|
49 |
+
if user_input.lower() in best_response.lower():
|
50 |
best_response = "I understand how you're feeling. You're not alone in this. I'm here to listen and help."
|
51 |
|
52 |
# Store the response for future comparison
|