kaoruhotarubi commited on
Commit
0b1fa3b
·
1 Parent(s): 36e292a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -63,16 +63,17 @@ def chat(input_text):
63
  conversation_history.append(f"User: {input_text}")
64
 
65
  # Limit the size of the conversation history
66
- if len(conversation_history) > 30:
67
- conversation_history = conversation_history[-30:]
68
 
69
  # Combine base prompt and conversation history
70
  history = "\n".join(conversation_history)
71
- final_prompt = base_prompt + "\n" + history + "\nRena:"
72
-
 
73
  # Tokenize and generate a response
74
  inputs = tokenizer(final_prompt, return_tensors="pt").to('cuda')
75
- outputs = model.generate(**inputs, max_new_tokens=300, do_sample=True)
76
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
77
 
78
  # Remove the base prompt from the response
 
63
  conversation_history.append(f"User: {input_text}")
64
 
65
  # Limit the size of the conversation history
66
+ if len(conversation_history) > 20:
67
+ conversation_history = conversation_history[-20:]
68
 
69
  # Combine base prompt and conversation history
70
  history = "\n".join(conversation_history)
71
+ personality_reminder = "Remember, Rena is bubbly, sassy, flirty, and fun!"
72
+ final_prompt = f"{base_prompt}\n### Conversation History ###\n{history}\n{personality_reminder}\nRena:"
73
+
74
  # Tokenize and generate a response
75
  inputs = tokenizer(final_prompt, return_tensors="pt").to('cuda')
76
+ outputs = model.generate(**inputs, max_new_tokens=350, do_sample=True)
77
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
78
 
79
  # Remove the base prompt from the response