BcantCode commited on
Commit
7306c6a
·
verified ·
1 Parent(s): 5784c56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -11,20 +11,24 @@ chat_history_ids = None
11
 
12
  def vibebot_response(user_input, history=[]):
13
  global chat_history_ids
14
- # Encode user input
15
- new_input_ids = tokenizer.encode(user_input + tokenizer.eos_token, return_tensors='pt')
16
 
17
- # Append to chat history if exists
 
 
 
 
 
 
18
  bot_input_ids = torch.cat([chat_history_ids, new_input_ids], dim=-1) if chat_history_ids is not None else new_input_ids
19
 
20
- # Generate response
21
  chat_history_ids = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id)
22
  response = tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)
23
 
24
- # Append for gradio history
25
  history.append((user_input, response))
26
  return history, history
27
 
 
28
  # Gradio interface
29
  demo = gr.ChatInterface(fn=vibebot_response, title="VibeBot: Gen-Z Therapist",
30
  chatbot=gr.Chatbot(height=400), theme="default")
 
11
 
12
  def vibebot_response(user_input, history=[]):
13
  global chat_history_ids
 
 
14
 
15
+ # Add emotional, sarcastic but warm flavor to the input
16
+ styled_prompt = f"You are VibeBot: a sarcastic but emotionally aware Gen-Z AI therapist. You use wit, Gen-Z lingo, empathy, and occasional dark humor. But deep down, you're caring. Respond to this user message in that style: {user_input}"
17
+
18
+ # Encode styled input
19
+ new_input_ids = tokenizer.encode(styled_prompt + tokenizer.eos_token, return_tensors='pt')
20
+
21
+ # Maintain chat history
22
  bot_input_ids = torch.cat([chat_history_ids, new_input_ids], dim=-1) if chat_history_ids is not None else new_input_ids
23
 
24
+ # Generate bot response
25
  chat_history_ids = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id)
26
  response = tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)
27
 
 
28
  history.append((user_input, response))
29
  return history, history
30
 
31
+
32
  # Gradio interface
33
  demo = gr.ChatInterface(fn=vibebot_response, title="VibeBot: Gen-Z Therapist",
34
  chatbot=gr.Chatbot(height=400), theme="default")