kaoruhotarubi commited on
Commit
f7d0973
·
1 Parent(s): f861ab7

fixed emotions issues

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -125,6 +125,8 @@ def truncate_history(history, max_tokens=1024):
125
  token_count = 0
126
  truncated_history = []
127
  for message in reversed(history):
 
 
128
  token_count += len(tokenizer(message).input_ids)
129
  if token_count <= max_tokens:
130
  truncated_history.insert(0, message)
@@ -150,12 +152,14 @@ def chat(input_text):
150
  # Combine base prompt and conversation history
151
  history = "\n".join(conversation_history)
152
  final_prompt = f"""{base_prompt}
 
 
 
153
 
154
  ### Conversation History ###
155
  {history}
156
 
157
- ### Instructions ###
158
- Respond concisely and directly to the user's input. Avoid repeating the user's input unless clarification is needed.
159
 
160
  Rena:"""
161
 
@@ -228,8 +232,8 @@ def chat(input_text):
228
  # Custom CSS for avatar styling
229
  css = """
230
  #rena_avatar img {
231
- width: 450px !important;
232
- height: 450px !important;
233
  object-fit: contain;
234
  margin: auto;
235
  display: block;
 
125
  token_count = 0
126
  truncated_history = []
127
  for message in reversed(history):
128
+ if "### Instructions ###" in message:
129
+ continue # Skip instructions in history
130
  token_count += len(tokenizer(message).input_ids)
131
  if token_count <= max_tokens:
132
  truncated_history.insert(0, message)
 
152
  # Combine base prompt and conversation history
153
  history = "\n".join(conversation_history)
154
  final_prompt = f"""{base_prompt}
155
+
156
+ ### Instructions ###
157
+ Respond concisely and directly to the user's input. Avoid repeating the user's input unless clarification is needed.
158
 
159
  ### Conversation History ###
160
  {history}
161
 
162
+
 
163
 
164
  Rena:"""
165
 
 
232
  # Custom CSS for avatar styling
233
  css = """
234
  #rena_avatar img {
235
+ width: 400px !important;
236
+ height: 400px !important;
237
  object-fit: contain;
238
  margin: auto;
239
  display: block;