Skip to content

Commit 3cef09c

Browse files
committed
Revert chat format test
1 parent d7b28f7 commit 3cef09c

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

tests/test_llama_chat_format.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -86,46 +86,3 @@ def test_hf_tokenizer_config_str_to_chat_formatter():
8686
)
8787

8888
assert chat_formatter_respoonse.prompt == ("<s>[INST] Hello, world! [/INST]</s>" "")
89-
90-
import uuid
91-
from jinja2 import Template
92-
from typing import List, Tuple, Any
93-
94-
def render_and_strip_images(template_string: str, **template_args: Any) -> Tuple[str, List[int]]:
95-
# Placeholder for images
96-
image_placeholder = uuid.uuid4().hex
97-
98-
# Render the template
99-
template = Template(template_string)
100-
rendered = template.render(image=image_placeholder, **template_args)
101-
102-
# Find positions of image placeholders and remove them
103-
positions: List[int] = []
104-
current_pos = 0
105-
106-
while True:
107-
pos = rendered.find(image_placeholder, current_pos)
108-
if pos == -1:
109-
break
110-
# Adjust position for previously removed placeholders
111-
adjusted_pos = pos - len(image_placeholder) * len(positions)
112-
positions.append(adjusted_pos)
113-
current_pos = pos + len(image_placeholder)
114-
115-
# Clean the rendered string
116-
clean_rendered = rendered.replace(image_placeholder, '')
117-
118-
return clean_rendered, positions
119-
120-
121-
def test_render_and_strip_images():
122-
template_string = "Hello, {{name}}! {{image}} How are you? {{image}}"
123-
template_args = {"name": "world"}
124-
125-
# Sanity test
126-
assert Template(template_string).render({ "name": "world", "image": ""}) == "Hello, world! How are you? "
127-
128-
rendered, positions = render_and_strip_images(template_string, **template_args)
129-
130-
assert rendered == "Hello, world! How are you? "
131-
assert positions == [14, 28]

0 commit comments

Comments
 (0)