Skip to content

Commit 6667247

Browse files
authored
add break, continue and strftime
1 parent 09385dc commit 6667247

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llama_cpp/llama_chat_format.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import string
99

1010
from contextlib import ExitStack
11+
from datetime import datetime
1112
from typing import Any, Dict, Iterator, List, Literal, Optional, Tuple, Union, Protocol, cast
1213

1314
import jinja2
@@ -195,8 +196,10 @@ def __init__(
195196
environment = ImmutableSandboxedEnvironment(
196197
trim_blocks=True,
197198
lstrip_blocks=True,
199+
extensions=[jinja2.ext.loopcontrols],
198200
)
199201
environment.filters["tojson"] = lambda x, indent=None: json.dumps(x, indent=indent, ensure_ascii=False)
202+
environment.globals["strftime"] = lambda format: datetime.now().strftime(format)
200203
self._environment = environment.from_string(self.template)
201204

202205
def __call__(

0 commit comments

Comments
 (0)