Skip to content

Commit 37c932d

Browse files
committed
Update templates to support prefix_column
Signed-off-by: Samuel Monson <[email protected]>
1 parent 7f3960b commit 37c932d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/guidellm/data/formatters/templates.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ class JinjaTemplatesRegistry(RegistryMixin[Union[Template, str]]):
2222
textwrap.dedent("""
2323
{% set obj = {
2424
"json_body": {
25-
"prompt": (
26-
text_column[0]
27-
if text_column and text_column|length == 1
28-
else text_column
29-
)
25+
"prompt": prefix_column[0]|default("") + text_column[0]
3026
}
3127
} %}
3228
@@ -52,6 +48,10 @@ class JinjaTemplatesRegistry(RegistryMixin[Union[Template, str]]):
5248
{% set obj = {
5349
"json_body": {
5450
"messages": [
51+
{
52+
"role": "system",
53+
"content": prefix_column[0]|default("")
54+
},
5555
{
5656
"role": "user",
5757
"content": []
@@ -61,11 +61,11 @@ class JinjaTemplatesRegistry(RegistryMixin[Union[Template, str]]):
6161
} %}
6262
6363
{%- for item in text_column or [] %}
64-
{% do obj["json_body"].messages[0].content.append({"type": "text", "text": item}) %}
64+
{% do obj["json_body"].messages[1].content.append({"type": "text", "text": item}) %}
6565
{%- endfor %}
6666
6767
{%- for item in image_column or [] %}
68-
{% do obj["json_body"].messages[0].content.append({
68+
{% do obj["json_body"].messages[1].content.append({
6969
"type": "image_url",
7070
"image_url": encode_image(
7171
item,
@@ -78,7 +78,7 @@ class JinjaTemplatesRegistry(RegistryMixin[Union[Template, str]]):
7878
{%- endfor %}
7979
8080
{%- for item in video_column or [] %}
81-
{% do obj["json_body"].messages[0].content.append({
81+
{% do obj["json_body"].messages[1].content.append({
8282
"type": "video_url",
8383
"video_url": encode_video(
8484
item,

0 commit comments

Comments
 (0)