Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,8 +36,8 @@ def generate_story(theme):
|
|
36 |
return story
|
37 |
|
38 |
def generate_response(user_input):
|
39 |
-
#
|
40 |
-
response_prompt = f"
|
41 |
|
42 |
# Generate the response using the GPT-2 model
|
43 |
input_ids = gpt2_tokenizer.encode(response_prompt, return_tensors='pt')
|
@@ -54,12 +54,11 @@ def generate_response(user_input):
|
|
54 |
response = gpt2_tokenizer.decode(response_ids[0], skip_special_tokens=True)
|
55 |
|
56 |
# Strip out the prompt portion to get a clean, empathetic message
|
57 |
-
cleaned_response = response.replace(f"
|
58 |
|
59 |
return cleaned_response
|
60 |
|
61 |
|
62 |
-
|
63 |
# Analyze user input for emotional tone
|
64 |
def get_emotion(user_input):
|
65 |
emotions = emotion_classifier(user_input)
|
|
|
36 |
return story
|
37 |
|
38 |
def generate_response(user_input):
|
39 |
+
# Refined prompt focusing only on empathetic and supportive language
|
40 |
+
response_prompt = f"You are a compassionate and empathetic support bot. A user has shared their feelings: '{user_input}'. Please respond with empathy, validation of their emotions, and offer support without providing unsolicited advice. Be reassuring and comforting, showing understanding of their emotional pain."
|
41 |
|
42 |
# Generate the response using the GPT-2 model
|
43 |
input_ids = gpt2_tokenizer.encode(response_prompt, return_tensors='pt')
|
|
|
54 |
response = gpt2_tokenizer.decode(response_ids[0], skip_special_tokens=True)
|
55 |
|
56 |
# Strip out the prompt portion to get a clean, empathetic message
|
57 |
+
cleaned_response = response.replace(f"You are a compassionate and empathetic support bot. A user has shared their feelings: '{user_input}'. Please respond with empathy, validation of their emotions, and offer support without providing unsolicited advice. Be reassuring and comforting, showing understanding of their emotional pain.", "").strip()
|
58 |
|
59 |
return cleaned_response
|
60 |
|
61 |
|
|
|
62 |
# Analyze user input for emotional tone
|
63 |
def get_emotion(user_input):
|
64 |
emotions = emotion_classifier(user_input)
|