-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Labels
Feature requestRequest for a new featureRequest for a new feature
Description
Feature request
GLM45 requires fromjson
in jinja2 to deserialize str typed tool_calls.function.arguments
to dict within chat template so it can iterate over arguments
's k-v within jinja2 chat template.
{% for tc in m.tool_calls %}
{%- if tc.function %}
{%- set tc = tc.function %}
{%- endif %}
{{ '\n<tool_call>' + tc.name }}
{% set _args = tc.arguments | fromjson %}
{% for k, v in _args.items() %}
<arg_key>{{ k }}</arg_key>
<arg_value>{{ v \| tojson(ensure_ascii=False) if v is not string else v }}</arg_value>
{% endfor %}
</tool_call>{% endfor %}
{% endif %}
https://huggingface.co/zai-org/GLM-4.5/blob/main/chat_template.jinja#L75
Motivation
GLM45 requires fromjson
in jinja2 to deserialize str typed tool_calls.function.arguments
to dict within chat template so it can iterate over arguments
's k-v within jinja2 chat template.
{% for tc in m.tool_calls %}
{%- if tc.function %}
{%- set tc = tc.function %}
{%- endif %}
{{ '\n<tool_call>' + tc.name }}
{% set _args = tc.arguments | fromjson %}
{% for k, v in _args.items() %}
<arg_key>{{ k }}</arg_key>
<arg_value>{{ v \| tojson(ensure_ascii=False) if v is not string else v }}</arg_value>
{% endfor %}
</tool_call>{% endfor %}
{% endif %}
https://huggingface.co/zai-org/GLM-4.5/blob/main/chat_template.jinja#L75
Your contribution
I will submit a PR
Metadata
Metadata
Assignees
Labels
Feature requestRequest for a new featureRequest for a new feature