psyche commited on
Commit
8a9f83e
·
verified ·
1 Parent(s): dac4432

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -74,7 +74,7 @@ def generate(
74
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
75
  conversation.append({"role": "user", "content": message})
76
 
77
- input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
78
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
79
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
80
  gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
 
74
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
75
  conversation.append({"role": "user", "content": message})
76
 
77
+ input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True)
78
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
79
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
80
  gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")