Bey007 commited on
Commit
7f1a28e
1 Parent(s): a311870

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -36,11 +36,10 @@ def generate_story(theme):
36
  return story
37
 
38
 
39
- # Function to generate an empathetic response
40
  def generate_response(user_input):
41
- response_prompt = f"You are a compassionate support bot. A user has shared: '{user_input}'. Respond with empathy and encouragement."
42
- input_ids = tokenizer.encode(response_prompt, return_tensors='pt')
43
- chat_history_ids = model.generate(
44
  input_ids,
45
  max_length=300,
46
  temperature=0.85,
@@ -48,10 +47,11 @@ def generate_response(user_input):
48
  repetition_penalty=1.2,
49
  num_return_sequences=1
50
  )
51
- response = tokenizer.decode(chat_history_ids[:, input_ids.shape[-1]:][0], skip_special_tokens=True)
52
  return response
53
 
54
 
 
55
  # Analyze user input for emotional tone
56
  def get_emotion(user_input):
57
  emotions = emotion_classifier(user_input)
 
36
  return story
37
 
38
 
 
39
  def generate_response(user_input):
40
+ response_prompt = f"You are a compassionate, kind ,and empathetic support bot. A user has shared their feelings: '{user_input}'. Respond with empathy, encouragement, and motivation."
41
+ input_ids = gpt2_tokenizer.encode(response_prompt, return_tensors='pt')
42
+ response_ids = gpt2_model.generate(
43
  input_ids,
44
  max_length=300,
45
  temperature=0.85,
 
47
  repetition_penalty=1.2,
48
  num_return_sequences=1
49
  )
50
+ response = gpt2_tokenizer.decode(response_ids[0], skip_special_tokens=True)
51
  return response
52
 
53
 
54
+
55
  # Analyze user input for emotional tone
56
  def get_emotion(user_input):
57
  emotions = emotion_classifier(user_input)