Add proper jinja2 error (#35533)

* Cleanup jinja2 imports

* Raise a proper error if Jinja is missing

* make fixup
This commit is contained in:
Matt 2025-01-16 15:31:11 +00:00 committed by GitHub
parent 3292e96a4f
commit 1302c32a84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -362,6 +362,11 @@ def _render_with_assistant_indices(
@lru_cache
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):
# This extension is used to track the indices of assistant-generated tokens in the rendered chat
tags = {"generation"}