go / chat_template.json
jva96160's picture
Upload 32 files
4c1ba5a verified
{"chat_template": "{{ bos_token }}\n{%- if tools %}\n {% set tools_json = tools %}\n You have access to the following tools:\n {% for tool in tools_json %}\n > Tool Name: {{ tool.name }}\n Tool Description: {{ tool.description }}\n Tool Args:\n {% if tool.parameters.properties %}\n {% for prop_name, prop_data in tool.parameters.properties.items() %}\n - {{ prop_name }} ({{ prop_data.type }}, {% if prop_name in tool.parameters.required %}required{% else %}optional{% endif %}): {{ prop_data.description }}\n {% endfor %}\n {% else %}\n {% endif %}\n\n {% endfor %}, where each item should be object\n Use the following format if using a tool:\n ```\n Action: tool name (one of [{{ tools_json | map(attribute='name') | join(', ') }}])\n Action Input: the input to the tool, in a JSON format representing the kwargs (e.g. ```{\"input\": \"hello world\", \"num_beams\": 5}```)\n ```\n {{'\n'}}\n{%- endif -%}\n\n\n{%- for message in messages -%}\n {%- if message['from'] == \"human\" -%}\n {%- if message['value'] is string -%}\n {{'<start_of_turn>user\n' + message['value'] + '<end_of_turn>\n'}}\n {%- elif message['value'] is iterable -%}\n {{'<start_of_turn>user\n'}}\n {%- for item in message['value'] -%}\n {%- if item['type'] == 'image' -%}\n {{ '<start_of_image>' }}\n {%- elif item['type'] == 'audio' -%}\n {{ '<start_of_audio>' }}\n {%- elif item['type'] == 'text' -%}\n {{ item['text'] | trim }}\n {%- endif -%}\n {{'<end_of_turn>\n'}}\n {%- endfor -%}\n {%- endif -%}\n {%- elif message['from'] == \"gpt\" -%}\n {{'<start_of_turn>model\n' + message['value'] + '<end_of_turn>\n'}} \n {%- elif message['from'] == \"function_call\" -%}\n {%- set func_call = message['value'] -%}\n {{'<start_of_turn>model\n' + 'Action:' + func_call.name + '\n' + 'Action Input:' + func_call.arguments + '<end_of_turn>\n'}} \n {%- elif message['from'] == \"observation\" -%}\n {{'<start_of_turn>tool\n' + message['value'] + '<end_of_turn>\n'}} \n {%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {{'<start_of_turn>model\n'}}\n{%- endif -%}\n"}