WebScraper991923 commited on
Commit
1c25baf
·
verified ·
1 Parent(s): 09da152

Cleaning repository before upload

Browse files
Files changed (1) hide show
  1. chat_template.jinja +0 -113
chat_template.jinja DELETED
@@ -1,113 +0,0 @@
1
- {%- set ns = namespace(last_query_index=-1) %}
2
- {%- for message in messages %}
3
- {%- if message.role == "user" %}
4
- {%- set ns.last_query_index = loop.index0 %}
5
- {%- endif %}
6
- {%- endfor %}
7
- {%- if tools %}
8
- {{- '<|im_start|>system\n' }}
9
- {%- if messages[0].role == 'system' %}
10
- {{- messages[0].content + '\n\n' }}
11
- {%- endif %}
12
- {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
13
- {%- for tool in tools %}
14
- {{- "\n" }}
15
- {{- tool | tojson }}
16
- {%- endfor %}
17
- {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
18
- {%- else %}
19
- {%- if messages[0].role == 'system' %}
20
- {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
21
- {%- endif %}
22
- {%- endif %}
23
- {%- for message in messages %}
24
- {%- if message.content is string %}
25
- {%- set content = message.content %}
26
- {%- else %}
27
- {%- set content = '' %}
28
- {%- endif %}
29
- {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
30
- {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
31
- {%- elif message.role == "assistant" %}
32
- {%- set has_loss = (message.loss is defined and message.loss) %}
33
- {%- set reasoning_content = '' %}
34
- {%- if message.reasoning_content is string %}
35
- {%- set reasoning_content = message.reasoning_content %}
36
- {%- else %}
37
- {%- if '</think>' in content %}
38
- {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
39
- {%- set content = content.split('</think>')[-1].lstrip('\n') %}
40
- {%- endif %}
41
- {%- endif %}
42
- {{- '<|im_start|>' + message.role + '\n' }}
43
- {%- if has_loss -%}
44
- {%- generation -%}
45
- {%- if loop.index0 > ns.last_query_index and reasoning_content %}
46
- {{- '<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
47
- {%- else %}
48
- {{- content }}
49
- {%- endif %}
50
- {%- if message.tool_calls %}
51
- {%- for tool_call in message.tool_calls %}
52
- {%- if (loop.first and content) or (not loop.first) %}
53
- {{- '\n' }}
54
- {%- endif %}
55
- {%- if tool_call.function %}
56
- {%- set tool_call = tool_call.function %}
57
- {%- endif %}
58
- {{- '<tool_call>\n{"name": "' }}
59
- {{- tool_call.name }}
60
- {{- '", "arguments": ' }}
61
- {%- if tool_call.arguments is string %}
62
- {{- tool_call.arguments }}
63
- {%- else %}
64
- {{- tool_call.arguments | tojson }}
65
- {%- endif %}
66
- {{- '}\n</tool_call>' }}
67
- {%- endfor %}
68
- {%- endif %}
69
- {{- '<|im_end|>' }}
70
- {%- endgeneration -%}
71
- {{- '\n' }}
72
- {%- else -%}
73
- {%- if loop.index0 > ns.last_query_index and reasoning_content %}
74
- {{- '<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
75
- {%- else %}
76
- {{- content }}
77
- {%- endif %}
78
- {%- if message.tool_calls %}
79
- {%- for tool_call in message.tool_calls %}
80
- {%- if (loop.first and content) or (not loop.first) %}
81
- {{- '\n' }}
82
- {%- endif %}
83
- {%- if tool_call.function %}
84
- {%- set tool_call = tool_call.function %}
85
- {%- endif %}
86
- {{- '<tool_call>\n{"name": "' }}
87
- {{- tool_call.name }}
88
- {{- '", "arguments": ' }}
89
- {%- if tool_call.arguments is string %}
90
- {{- tool_call.arguments }}
91
- {%- else %}
92
- {{- tool_call.arguments | tojson }}
93
- {%- endif %}
94
- {{- '}\n</tool_call>' }}
95
- {%- endfor %}
96
- {%- endif %}
97
- {{- '<|im_end|>\n' }}
98
- {%- endif %}
99
- {%- elif message.role == "tool" %}
100
- {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
101
- {{- '<|im_start|>user' }}
102
- {%- endif %}
103
- {{- '\n<tool_response>\n' }}
104
- {{- content }}
105
- {{- '\n</tool_response>' }}
106
- {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
107
- {{- '<|im_end|>\n' }}
108
- {%- endif %}
109
- {%- endif %}
110
- {%- endfor %}
111
- {%- if add_generation_prompt %}
112
- {{- '<|im_start|>assistant\n' }}
113
- {%- endif %}