diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index 26b86a085e3..f137c90f65d 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -221,7 +221,7 @@ def phind_codellama_pt(messages): def hf_chat_template(model: str, messages: list, chat_template: Optional[Any] = None): # Define Jinja2 environment with autoescaping disabled - env = ImmutableSandboxedEnvironment(trim_blocks=True, lstrip_blocks=True) + env = ImmutableSandboxedEnvironment() def raise_exception(message): raise Exception(f"Error message - {message}") @@ -259,13 +259,6 @@ def hf_chat_template(model: str, messages: list, chat_template: Optional[Any] = eos_token = tokenizer_config["eos_token"] chat_template = tokenizer_config["chat_template"] - # Render the chat_template safely - rendered_template = env.from_string(chat_template).render(messages=messages) - - # Now you can use the rendered_template in your application - # For example, return it or process further - return rendered_template - try: template = env.from_string(chat_template) except Exception as e: