Skip to content

Commit

Permalink
fixes to templates to get unit tests passing
Browse files Browse the repository at this point in the history
Signed-off-by: Travis Johnson <tsjohnso@us.ibm.com>
  • Loading branch information
tjohnson31415 committed Nov 22, 2024
1 parent ecbb268 commit 7c6c0ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions examples/tool_chat_template_llama3.1_json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
{%- if messages[0]['content'] is string %}
{%- set first_user_message = messages[0]['content']|trim %}
{%- else %}
{%- set first_user_message = messages[0]['content']['text']|trim %}
{%- set first_user_message = messages[0]['content'] | selectattr('type', 'equalto', 'text') | map(attribute='text') | map('trim') | join('\n') %}
{%- endif %}
{%- set messages = messages[1:] %}
{%- else %}
Expand Down Expand Up @@ -106,7 +106,11 @@
{%- if message.content is string %}
{{- { "output": message.content } | tojson }}
{%- else %}
{{- message.content | tojson }}
{%- for content in message['content'] %}
{%- if content['type'] == 'text' %}
{{- { "output": content['text'] } | tojson }}
{%- endif %}
{%- endfor %}
{%- endif %}
{{- "<|eot_id|>" }}
{%- endif %}
Expand Down
8 changes: 6 additions & 2 deletions examples/tool_chat_template_llama3.2_json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
{%- if messages[0]['content'] is string %}
{%- set first_user_message = messages[0]['content']|trim %}
{%- else %}
{%- set first_user_message = messages[0]['content']['text']|trim %}
{%- set first_user_message = messages[0]['content'] | selectattr('type', 'equalto', 'text') | map(attribute='text') | map('trim') | join('\n') %}
{%- endif %}
{%- set messages = messages[1:] %}
{%- else %}
Expand Down Expand Up @@ -127,7 +127,11 @@
{%- if message.content is string %}
{{- { "output": message.content } | tojson }}
{%- else %}
{{- message.content | tojson }}
{%- for content in message['content'] %}
{%- if content['type'] == 'text' %}
{{- { "output": content['text'] } | tojson }}
{%- endif %}
{%- endfor %}
{%- endif %}
{{- "<|eot_id|>" }}
{%- endif %}
Expand Down

0 comments on commit 7c6c0ba

Please sign in to comment.