Unverified Commit 41e95c52 authored by Kyle Mistele's avatar Kyle Mistele Committed by GitHub
Browse files

[Bugfix] Fix Hermes tool call chat template bug (#8256)


Co-authored-by: default avatarKyle Mistele <kyle@constellate.ai>
parent 12dd7158
...@@ -89,22 +89,23 @@ ...@@ -89,22 +89,23 @@
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" and message.tool_calls is defined %} {%- elif message.role == "assistant" and message.tool_calls is defined %}
{{- '<|im_start|>' + message.role }} {{- '<|im_start|>' + message.role }}
{%- for tool_call in message.tool_calls %} {%- for tool_call in message.tool_calls %}
{{- '\n<tool_call>\n' }} {{- '\n<tool_call>\n' }}
{%- if tool_call.function is defined %} {%- if tool_call.function is defined %}
{%- set tool_call = tool_call.function %} {%- set tool_call = tool_call.function %}
{%- endif %} {%- endif %}
{{- '{' }} {{- '{' }}
{{- '"name": "' }} {{- '"name": "' }}
{{- tool_call.name }} {{- tool_call.name }}
{{- '"}' }} {{- '"' }}
{%- if tool_call.arguments is defined %}
{{- ', ' }} {{- ', ' }}
{%- if tool_call.arguments is defined %} {{- '"arguments": ' }}
{{- '"arguments": ' }} {{- tool_call.arguments|tojson }}
{{- tool_call.arguments|tojson }} {%- endif %}
{%- endif %} {{- '}' }}
{{- '\n</tool_call>' }} {{- '\n</tool_call>' }}
{%- endfor %} {%- endfor %}
{{- '<|im_end|>\n' }} {{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %} {%- elif message.role == "tool" %}
{%- if loop.previtem and loop.previtem.role != "tool" %} {%- if loop.previtem and loop.previtem.role != "tool" %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment