mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-01 02:31:11 +06:00
Add proper jinja2 error (#35533)
* Cleanup jinja2 imports * Raise a proper error if Jinja is missing * make fixup
This commit is contained in:
parent
3292e96a4f
commit
1302c32a84
@ -362,6 +362,11 @@ def _render_with_assistant_indices(
|
|||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def _compile_jinja_template(chat_template):
|
def _compile_jinja_template(chat_template):
|
||||||
|
if not is_jinja_available():
|
||||||
|
raise ImportError(
|
||||||
|
"apply_chat_template requires jinja2 to be installed. Please install it using `pip install jinja2`."
|
||||||
|
)
|
||||||
|
|
||||||
class AssistantTracker(Extension):
|
class AssistantTracker(Extension):
|
||||||
# This extension is used to track the indices of assistant-generated tokens in the rendered chat
|
# This extension is used to track the indices of assistant-generated tokens in the rendered chat
|
||||||
tags = {"generation"}
|
tags = {"generation"}
|
||||||
|
Loading…
Reference in New Issue
Block a user