Another fix for Kimi-K2 chat template.
This commit is contained in:
parent
f519483d52
commit
e0eda17d42
|
|
@ -36,12 +36,8 @@
|
||||||
{%- if message['role'] == 'assistant' and message.get('tool_calls') -%}
|
{%- if message['role'] == 'assistant' and message.get('tool_calls') -%}
|
||||||
{{render_content(message)}}<|tool_calls_section_begin|>
|
{{render_content(message)}}<|tool_calls_section_begin|>
|
||||||
{%- for tool_call in message['tool_calls'] -%}
|
{%- for tool_call in message['tool_calls'] -%}
|
||||||
{%- if tool_call['id'] is defined -%}
|
{%- set formatted_id = 'functions.' + tool_call['function']['name'] + ':' + (tool_call_counter.value | string) -%}
|
||||||
{%- set formatted_id = tool_call['id'] -%}
|
{%- set tool_call_counter.value = tool_call_counter.value + 1 -%}
|
||||||
{%- else -%}
|
|
||||||
{%- set formatted_id = 'functions.' + tool_call['function']['name'] + ':' + (tool_call_counter.value | string) -%}
|
|
||||||
{%- set tool_call_counter.value = tool_call_counter.value + 1 -%}
|
|
||||||
{%- endif -%}
|
|
||||||
{%- set _ = tool_response_queue.ids.append(formatted_id) -%}
|
{%- set _ = tool_response_queue.ids.append(formatted_id) -%}
|
||||||
<|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
|
<|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,8 @@
|
||||||
{%- macro render_toolcalls(message) -%}
|
{%- macro render_toolcalls(message) -%}
|
||||||
<|tool_calls_section_begin|>
|
<|tool_calls_section_begin|>
|
||||||
{%- for tool_call in message['tool_calls'] -%}
|
{%- for tool_call in message['tool_calls'] -%}
|
||||||
{%- if tool_call['id'] is defined -%}
|
{%- set formatted_id = 'functions.' + tool_call['function']['name'] + ':' + (tool_call_counter.value | string) -%}
|
||||||
{%- set formatted_id = tool_call['id'] -%}
|
{%- set tool_call_counter.value = tool_call_counter.value + 1 -%}
|
||||||
{%- else -%}
|
|
||||||
{%- set formatted_id = 'functions.' + tool_call['function']['name'] + ':' + (tool_call_counter.value | string) -%}
|
|
||||||
{%- set tool_call_counter.value = tool_call_counter.value + 1 -%}
|
|
||||||
{%- endif -%}
|
|
||||||
{%- set _ = tool_response_queue.ids.append(formatted_id) -%}
|
{%- set _ = tool_response_queue.ids.append(formatted_id) -%}
|
||||||
<|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
|
<|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue