mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 02:25:01 +08:00
[Misc] Update llama 3.2 template to support system prompt with images (#10901)
Signed-off-by: Travis Johnson <tsjohnso@us.ibm.com>
This commit is contained in:
parent
1f958a7d52
commit
39c89e71a8
@ -26,13 +26,11 @@
|
|||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
|
||||||
{#- This block extracts the system message, so we can slot it into the right place. #}
|
{#- This block extracts the system message, so we can slot it into the right place. #}
|
||||||
{%- if messages[0]['role'] == 'system' %}
|
{%- if messages[0]['role'] == 'system' %}
|
||||||
{%- if messages[0]['content'] is string %}
|
{%- if messages[0]['content'] is string %}
|
||||||
{%- set system_message = messages[0]['content']|trim %}
|
{%- set system_message = messages[0]['content']|trim %}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
{#- Support vLLM's transforming of a content string to JSON. #}
|
|
||||||
{%- set system_message = messages[0]['content'][0]['text']|trim %}
|
{%- set system_message = messages[0]['content'][0]['text']|trim %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- set messages = messages[1:] %}
|
{%- set messages = messages[1:] %}
|
||||||
@ -44,14 +42,8 @@
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{#- Including an image is not compatible with a system message #}
|
{#- System message if there are no images, if the user supplied one, or if tools are used (default tool system message) #}
|
||||||
{%- if image_ns.has_images and not system_message == "" %}
|
{%- if system_message or not image_ns.has_images %}
|
||||||
{{- raise_exception("Prompting with images is incompatible with system messages and tool use.") }}
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
|
|
||||||
{#- System message, if there are no images #}
|
|
||||||
{%- if not image_ns.has_images %}
|
|
||||||
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
|
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
|
||||||
{%- if tools is not none %}
|
{%- if tools is not none %}
|
||||||
{{- "Environment: ipython\n" }}
|
{{- "Environment: ipython\n" }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user