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