Merge pull request from GHSA-56xg-wfcc-g829

Co-authored-by: Andrei <abetlen@gmail.com>
This commit is contained in:
Patrick Peng 2024-05-10 12:47:56 +08:00 committed by GitHub
parent 5ab40e6167
commit b454f40a9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,6 +11,7 @@ from contextlib import ExitStack
from typing import Any, Dict, Iterator, List, Literal, Optional, Tuple, Union, Protocol, cast from typing import Any, Dict, Iterator, List, Literal, Optional, Tuple, Union, Protocol, cast
import jinja2 import jinja2
from jinja2.sandbox import ImmutableSandboxedEnvironment
import numpy as np import numpy as np
import numpy.typing as npt import numpy.typing as npt
@ -191,7 +192,7 @@ class Jinja2ChatFormatter(ChatFormatter):
self.add_generation_prompt = add_generation_prompt self.add_generation_prompt = add_generation_prompt
self.stop_token_ids = set(stop_token_ids) if stop_token_ids is not None else None self.stop_token_ids = set(stop_token_ids) if stop_token_ids is not None else None
self._environment = jinja2.Environment( self._environment = ImmutableSandboxedEnvironment(
loader=jinja2.BaseLoader(), loader=jinja2.BaseLoader(),
trim_blocks=True, trim_blocks=True,
lstrip_blocks=True, lstrip_blocks=True,