Delete chat_template.jinja
Browse files- chat_template.jinja +0 -109
chat_template.jinja
DELETED
@@ -1,109 +0,0 @@
|
|
1 |
-
{%- set today = strftime_now("%Y-%m-%d") %}
|
2 |
-
{%- set default_system_message = "detailed thinking on" %}
|
3 |
-
{{- bos_token }}
|
4 |
-
{%- if messages[0]['role'] == 'system' %}
|
5 |
-
{%- if messages[0]['content'] is string %}
|
6 |
-
{%- set system_message = messages[0]['content'] %}
|
7 |
-
{%- set loop_messages = messages[1:] %}
|
8 |
-
{%- else %}
|
9 |
-
{%- set system_message = messages[0]['content'][0]['text'] %}
|
10 |
-
{%- set loop_messages = messages[1:] %}
|
11 |
-
{%- endif %}
|
12 |
-
{%- else %}
|
13 |
-
{%- set system_message = default_system_message %}
|
14 |
-
{%- set loop_messages = messages %}
|
15 |
-
{%- endif %}
|
16 |
-
{%- if not tools is defined %}
|
17 |
-
{%- set tools = none %}
|
18 |
-
{%- elif tools is not none %}
|
19 |
-
{%- set parallel_tool_prompt = "You are a helpful assistant that can call tools. If you call one or more tools, format them in a single JSON array or objects, where each object is a tool call, not as separate objects outside of an array or multiple arrays. Use the format [{\"name\": tool call name, \"arguments\": tool call arguments}, additional tool calls] if you call more than one tool. If you call tools, do not attempt to interpret them or otherwise provide a response until you receive a tool call result that you can interpret for the user." %}
|
20 |
-
{%- if system_message is defined %}
|
21 |
-
{%- set system_message = system_message + "\n\n" + parallel_tool_prompt %}
|
22 |
-
{%- else %}
|
23 |
-
{%- set system_message = parallel_tool_prompt %}
|
24 |
-
{%- endif %}
|
25 |
-
{%- endif %}
|
26 |
-
{{- '[SYSTEM_PROMPT]' + system_message + '[/SYSTEM_PROMPT]' }}
|
27 |
-
{%- set user_messages = loop_messages | selectattr("role", "equalto", "user") | list %}
|
28 |
-
{%- for message in loop_messages %}
|
29 |
-
{%- if message["role"] == "user" %}
|
30 |
-
{%- if tools is not none and (message == user_messages[-1]) %}
|
31 |
-
{{- "[AVAILABLE_TOOLS] [" }}
|
32 |
-
{%- for tool in tools %}
|
33 |
-
{%- set tool = tool.function %}
|
34 |
-
{{- '{"type": "function", "function": {' }}
|
35 |
-
{%- for key, val in tool.items() if key != "return" %}
|
36 |
-
{%- if val is string %}
|
37 |
-
{{- '"' + key + '": "' + val + '"' }}
|
38 |
-
{%- else %}
|
39 |
-
{{- '"' + key + '": ' + val|tojson }}
|
40 |
-
{%- endif %}
|
41 |
-
{%- if not loop.last %}
|
42 |
-
{{- ", " }}
|
43 |
-
{%- endif %}
|
44 |
-
{%- endfor %}
|
45 |
-
{{- "}}" }}
|
46 |
-
{%- if not loop.last %}
|
47 |
-
{{- ", " }}
|
48 |
-
{%- else %}
|
49 |
-
{{- "]" }}
|
50 |
-
{%- endif %}
|
51 |
-
{%- endfor %}
|
52 |
-
{{- "[/AVAILABLE_TOOLS]" }}
|
53 |
-
{%- endif %}
|
54 |
-
{%- if message['content'] is string %}
|
55 |
-
{{- '[INST]' + message['content'] + '[/INST]' }}
|
56 |
-
{%- else %}
|
57 |
-
{{- '[INST]' }}
|
58 |
-
{%- for block in message['content'] %}
|
59 |
-
{%- if block['type'] == 'text' %}
|
60 |
-
{{- block['text'] }}
|
61 |
-
{%- elif block['type'] == 'image' or block['type'] == 'image_url' %}
|
62 |
-
{{- '[IMG]' }}
|
63 |
-
{%- else %}
|
64 |
-
{{- raise_exception('Only text and image blocks are supported in message content!') }}
|
65 |
-
{%- endif %}
|
66 |
-
{%- endfor %}
|
67 |
-
{{- '[/INST]' }}
|
68 |
-
{%- endif %}
|
69 |
-
{%- elif message["role"] == "tool_calls" or message.tool_calls is defined %}
|
70 |
-
{%- if message.tool_calls is defined %}
|
71 |
-
{%- set tool_calls = message.tool_calls %}
|
72 |
-
{%- else %}
|
73 |
-
{%- set tool_calls = message.content %}
|
74 |
-
{%- endif %}
|
75 |
-
{{- "[TOOL_CALLS] [" }}
|
76 |
-
{%- for tool_call in tool_calls %}
|
77 |
-
{%- set out = tool_call.function|tojson %}
|
78 |
-
{{- out[:-1] }}
|
79 |
-
{%- if not tool_call.id is defined or tool_call.id|length < 9 %}
|
80 |
-
{{- raise_exception("Tool call IDs should be alphanumeric strings with length >= 9! (1)" + tool_call.id) }}
|
81 |
-
{%- endif %}
|
82 |
-
{{- ', "id": "' + tool_call.id[-9:] + '"}' }}
|
83 |
-
{%- if not loop.last %}
|
84 |
-
{{- ", " }}
|
85 |
-
{%- else %}
|
86 |
-
{{- "]" + eos_token }}
|
87 |
-
{%- endif %}
|
88 |
-
{%- endfor %}
|
89 |
-
{%- elif message['role'] == 'assistant' %}
|
90 |
-
{%- if message['content'] is string %}
|
91 |
-
{{- message['content'] + eos_token }}
|
92 |
-
{%- else %}
|
93 |
-
{{- message['content'][0]['text'] + eos_token }}
|
94 |
-
{%- endif %}
|
95 |
-
{%- elif message["role"] == "tool_results" or message["role"] == "tool" %}
|
96 |
-
{%- if message.content is defined and message.content.content is defined %}
|
97 |
-
{%- set content = message.content.content %}
|
98 |
-
{%- else %}
|
99 |
-
{%- set content = message.content %}
|
100 |
-
{%- endif %}
|
101 |
-
{{- '[TOOL_RESULTS] {"content": ' + content|string + ", " }}
|
102 |
-
{%- if not message.tool_call_id is defined or message.tool_call_id|length < 9 %}
|
103 |
-
{{- raise_exception("Tool call IDs should be alphanumeric strings with length >= 9! (2)" + message.tool_call_id) }}
|
104 |
-
{%- endif %}
|
105 |
-
{{- '"call_id": "' + message.tool_call_id[-9:] + '"}[/TOOL_RESULTS]' }}
|
106 |
-
{%- else %}
|
107 |
-
{{- raise_exception("Only user and assistant roles are supported, with the exception of an initial optional system message!") }}
|
108 |
-
{%- endif %}
|
109 |
-
{%- endfor %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|