Skip to content

Commit 39c89e7

Browse files
authoredDec 5, 2024
[Misc] Update llama 3.2 template to support system prompt with images (vllm-project#10901)
Signed-off-by: Travis Johnson <[email protected]>
1 parent 1f958a7 commit 39c89e7

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed
 

‎examples/tool_chat_template_llama3.2_json.jinja

+2-10
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
{%- endfor %}
2727
{%- endfor %}
2828

29-
3029
{#- This block extracts the system message, so we can slot it into the right place. #}
3130
{%- if messages[0]['role'] == 'system' %}
3231
{%- if messages[0]['content'] is string %}
3332
{%- set system_message = messages[0]['content']|trim %}
3433
{%- else %}
35-
{#- Support vLLM's transforming of a content string to JSON. #}
3634
{%- set system_message = messages[0]['content'][0]['text']|trim %}
3735
{%- endif %}
3836
{%- set messages = messages[1:] %}
@@ -44,14 +42,8 @@
4442
{%- endif %}
4543
{%- endif %}
4644

47-
{#- Including an image is not compatible with a system message #}
48-
{%- if image_ns.has_images and not system_message == "" %}
49-
{{- raise_exception("Prompting with images is incompatible with system messages and tool use.") }}
50-
{%- endif %}
51-
52-
53-
{#- System message, if there are no images #}
54-
{%- if not image_ns.has_images %}
45+
{#- System message if there are no images, if the user supplied one, or if tools are used (default tool system message) #}
46+
{%- if system_message or not image_ns.has_images %}
5547
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
5648
{%- if tools is not none %}
5749
{{- "Environment: ipython\n" }}

0 commit comments

Comments
 (0)
Please sign in to comment.