Commit ·
1b9f53e
1
Parent(s): fe9ce92
Fix tool calling: support array-formatted tool content (vLLM/SGLang) (#8)
Browse files- Fix tool calling: support array-formatted tool content (vLLM/SGLang) (f35a54e09d9aa6e358cf458de0f594c9da2c3274)
Co-authored-by: Tej <cudaoom@users.noreply.huggingface.co>
- chat_template.jinja +3 -1
chat_template.jinja
CHANGED
|
@@ -94,7 +94,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 94 |
{%- endif %}
|
| 95 |
{%- if m.content is string -%}
|
| 96 |
{{- '<tool_response>' + m.content + '</tool_response>' -}}
|
| 97 |
-
{%-
|
| 98 |
{{- '<tool_response><tools>\n' -}}
|
| 99 |
{% for tr in m.content %}
|
| 100 |
{%- for tool in tools -%}
|
|
@@ -107,6 +107,8 @@ For each function call, output the function name and arguments within the follow
|
|
| 107 |
{%- endfor -%}
|
| 108 |
{%- endfor -%}
|
| 109 |
{{- '</tools></tool_response>' -}}
|
|
|
|
|
|
|
| 110 |
{% endif -%}
|
| 111 |
{%- elif m.role == 'system' -%}
|
| 112 |
<|system|>{{ visible_text(m.content) }}
|
|
|
|
| 94 |
{%- endif %}
|
| 95 |
{%- if m.content is string -%}
|
| 96 |
{{- '<tool_response>' + m.content + '</tool_response>' -}}
|
| 97 |
+
{%- elif m.content is iterable and m.content is not mapping and m.content and m.content.0.type == "tool_reference" -%}
|
| 98 |
{{- '<tool_response><tools>\n' -}}
|
| 99 |
{% for tr in m.content %}
|
| 100 |
{%- for tool in tools -%}
|
|
|
|
| 107 |
{%- endfor -%}
|
| 108 |
{%- endfor -%}
|
| 109 |
{{- '</tools></tool_response>' -}}
|
| 110 |
+
{%- else -%}
|
| 111 |
+
{{- '<tool_response>' + visible_text(m.content) + '</tool_response>' -}}
|
| 112 |
{% endif -%}
|
| 113 |
{%- elif m.role == 'system' -%}
|
| 114 |
<|system|>{{ visible_text(m.content) }}
|