Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -94,7 +94,7 @@ def generate(
|
|
| 94 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
| 95 |
conversation.append({"role": "user", "content": message})
|
| 96 |
|
| 97 |
-
|
| 98 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
| 99 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
| 100 |
gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
|
|
|
|
| 94 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
| 95 |
conversation.append({"role": "user", "content": message})
|
| 96 |
|
| 97 |
+
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
| 98 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
| 99 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
| 100 |
gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
|