@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / ca04b97c93
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 11:00 UTC

[Bugfix] Fix tool call template validation for Mistral models (#17644)

Signed-off-by: Rick Yuan <yuan821120@gmail.com> Signed-off-by: RIck Yuan <yuan821120@gmail.com> Co-authored-by: Aaron Pham <Aaronpham0103@gmail.com>

Rick Yuan committed May 8, 2025 at 17:47 UTC ca04b97c93614ae51d2b79e2323aa731fbaed697
1 file changed +9 -2
examples/tool_chat_template_mistral3.jinja
+9 -2
@@ -29,7 +29,14 @@
29
30 {%- set user_messages = loop_messages | selectattr("role", "equalto", "user") | list %}
31
32 -{%- for message in loop_messages | rejectattr("role", "equalto", "tool") | rejectattr("role", "equalto", "tool_results") | selectattr("tool_calls", "undefined") %}
32 +{%- set filtered_messages = [] %}
33 +{%- for message in loop_messages %}
34 + {%- if message["role"] not in ["tool", "tool_results"] and not message.get("tool_calls") %}
35 + {%- set filtered_messages = filtered_messages + [message] %}
36 + {%- endif %}
37 +{%- endfor %}
38 +
39 +{%- for message in filtered_messages %}
40 {%- if (message["role"] == "user") != (loop.index0 % 2 == 0) %}
41 {{- raise_exception("After the optional system message, conversation roles must alternate user/assistant/user/assistant/...") }}
42 {%- endif %}
@@ -116,4 +123,4 @@
123 {%- else %}
124 {{- raise_exception("Only user and assistant roles are supported, with the exception of an initial optional system message!") }}
125 {%- endif %}
119 -{%- endfor %}
\ No newline at end of file
126 +{%- endfor %}