Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -39,8 +39,8 @@ if user_input:
|
|
39 |
# Run sentiment analysis to check for distress
|
40 |
sentiment = sentiment_analysis(user_input)[0]
|
41 |
|
42 |
-
# Generate empathetic response
|
43 |
-
response = conversational_bot(user_input, max_length=
|
44 |
|
45 |
# Ensure response does not repeat what the user said, and is supportive
|
46 |
if user_input.lower() in response.lower():
|
@@ -48,13 +48,13 @@ if user_input:
|
|
48 |
|
49 |
# Check if the response is too similar to the previous one, if so, generate a new one
|
50 |
if response == st.session_state.previous_response:
|
51 |
-
response = conversational_bot(user_input, max_length=
|
52 |
|
53 |
# Store the response for future comparison
|
54 |
st.session_state.previous_response = response
|
55 |
|
56 |
# Display response
|
57 |
-
st.text_area("Bot's Response:", response, height=
|
58 |
|
59 |
# Text-to-speech output
|
60 |
tts = gTTS(response, lang='en')
|
|
|
39 |
# Run sentiment analysis to check for distress
|
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=1, temperature=0.9, top_k=50)[0]['generated_text']
|
44 |
|
45 |
# Ensure response does not repeat what the user said, and is supportive
|
46 |
if user_input.lower() in response.lower():
|
|
|
48 |
|
49 |
# Check if the response is too similar to the previous one, if so, generate a new one
|
50 |
if response == st.session_state.previous_response:
|
51 |
+
response = conversational_bot(user_input, max_length=300, num_return_sequences=1, temperature=0.9, top_k=50)[0]['generated_text']
|
52 |
|
53 |
# Store the response for future comparison
|
54 |
st.session_state.previous_response = response
|
55 |
|
56 |
# Display response
|
57 |
+
st.text_area("Bot's Response:", response, height=250)
|
58 |
|
59 |
# Text-to-speech output
|
60 |
tts = gTTS(response, lang='en')
|