Bey007 commited on
Commit
a452a78
·
verified ·
1 Parent(s): 62d4ef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
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, num_return_sequences=3, temperature=0.9, top_k=50)
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
- # If no diverse response was found, generate a default supportive message
53
- if not best_response:
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