Update chat_template.jinja

#2
by latent-variable - opened
Files changed (1) hide show
  1. chat_template.jinja +8 -5
chat_template.jinja CHANGED
@@ -1,10 +1,10 @@
1
  {% macro render_extra_keys(json_dict, handled_keys) %}
2
  {%- if json_dict is mapping %}
3
  {%- for json_key in json_dict if json_key not in handled_keys %}
4
- {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}
5
- {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}
6
- {%- else %}
7
  {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
 
 
8
  {%- endif %}
9
  {%- endfor %}
10
  {%- endif %}
@@ -93,8 +93,11 @@
93
  {%- if tool_call.arguments is defined %}
94
  {%- for args_name, args_value in tool_call.arguments|items %}
95
  {{- '<parameter=' + args_name + '>\n' }}
96
- {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
97
- {{- args_value }}
 
 
 
98
  {{- '\n</parameter>\n' }}
99
  {%- endfor %}
100
  {%- endif %}
 
1
  {% macro render_extra_keys(json_dict, handled_keys) %}
2
  {%- if json_dict is mapping %}
3
  {%- for json_key in json_dict if json_key not in handled_keys %}
4
+ {%- if json_dict[json_key] is string %}
 
 
5
  {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
6
+ {%- else %}
7
+ {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson) ~ '</' ~ json_key ~ '>' }}
8
  {%- endif %}
9
  {%- endfor %}
10
  {%- endif %}
 
93
  {%- if tool_call.arguments is defined %}
94
  {%- for args_name, args_value in tool_call.arguments|items %}
95
  {{- '<parameter=' + args_name + '>\n' }}
96
+ {%- if args_value is string %}
97
+ {{- args_value | string }}
98
+ {%- else %}
99
+ {{- args_value | tojson }}
100
+ {%- endif %}
101
  {{- '\n</parameter>\n' }}
102
  {%- endfor %}
103
  {%- endif %}