Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -153,17 +153,18 @@ def chat(user_text, model_label, blocks_json):
|
|
| 153 |
|
| 154 |
messages = build_messages(user_text, data["user_profile"], blocks)
|
| 155 |
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
| 161 |
).to("cpu")
|
| 162 |
-
|
| 163 |
start = time.time()
|
| 164 |
with torch.no_grad():
|
| 165 |
outputs = model.generate(
|
| 166 |
-
**inputs,
|
| 167 |
max_new_tokens=200,
|
| 168 |
do_sample=False,
|
| 169 |
use_cache=False
|
|
|
|
| 153 |
|
| 154 |
messages = build_messages(user_text, data["user_profile"], blocks)
|
| 155 |
|
| 156 |
+
inputs = tokenizer.apply_chat_template(
|
| 157 |
+
messages,
|
| 158 |
+
add_generation_prompt=True,
|
| 159 |
+
tokenize=True,
|
| 160 |
+
return_tensors="pt",
|
| 161 |
+
return_dict=True # <-- this makes inputs a dict
|
| 162 |
).to("cpu")
|
| 163 |
+
|
| 164 |
start = time.time()
|
| 165 |
with torch.no_grad():
|
| 166 |
outputs = model.generate(
|
| 167 |
+
**inputs, # now safe, inputs is a dict
|
| 168 |
max_new_tokens=200,
|
| 169 |
do_sample=False,
|
| 170 |
use_cache=False
|