{ | |
"chat_template": "{{ bos_token }}\n{%- for msg in messages %}\n {%- if (msg['role'] == 'assistant') %}\n {%- set role = 'model' %}\n {%- elif (msg['role'] == 'ipython') %}\n {%- set role = 'tool' %}\n {%- else %}\n {%- set role = msg['role'] %}\n {%- endif %}\n\n {{- '<start_of_turn>' + role + '\n' }}\n {%- if msg.tool_calls %}\n {%- for call in msg.tool_calls -%}\n\t\t {\"name\": \"{{ call.function.name }}\", \"parameters\": {{ call.function.arguments }}}{{- '\n' }}\n {%- endfor %}\n {%- elif msg['content'] is string %}\n {{- msg['content'] | trim }}\n {%- elif msg['content'] is iterable %}\n {%- for item in msg['content'] %}\n {%- if item['type'] == 'image' or item['type'] == 'image_url' %}\n {{- '<start_of_image>' }}\n {%- elif item['type'] == 'text' %}\n {{- item['text'] }}\n {%- endif %}\n {%- endfor %}\n {%- else %}\n {{ raise_exception(\"Invalid content type\") }}\n {%- endif %}\n {%- if loop.first and tools is defined and tools %}\n\nEnvironment: ipython\n# If one of these functions helps answer the user prompt, call it.\n# Note: To call a function, include a JSON object in the response with the format: {\"name\": \"function_name\", \"parameters\": {\"argument_name\": value}}.\n# Tools:{{- '\n' }}\n {%- for tool in tools %}\n {{- tool | tojson(indent=4) + '\n\n' }}\n {%- endfor -%}\n# When you receive a tool call response, use the output to format an answer to the orginal user question.\n {%- endif %}\n<end_of_turn>\n\n{% endfor %}\n{%- if add_generation_prompt -%}\n {{'<start_of_turn>model\n'}}\n{%- endif -%}\n" | |
} | |