Spaces:
Runtime error
Runtime error
Commit Β·
4d14417
1
Parent(s): 3fcb89e
Use tokenizer chat template for tiny prompts
Browse files
app.py
CHANGED
|
@@ -318,8 +318,9 @@ def build_prompt(processor_obj, user_text: str) -> str:
|
|
| 318 |
],
|
| 319 |
}
|
| 320 |
]
|
| 321 |
-
|
| 322 |
-
|
|
|
|
| 323 |
return f"<image>\n{user_text}"
|
| 324 |
|
| 325 |
|
|
|
|
| 318 |
],
|
| 319 |
}
|
| 320 |
]
|
| 321 |
+
tokenizer = getattr(processor_obj, "tokenizer", None)
|
| 322 |
+
if tokenizer is not None and hasattr(tokenizer, "apply_chat_template"):
|
| 323 |
+
return tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 324 |
return f"<image>\n{user_text}"
|
| 325 |
|
| 326 |
|