weirek commited on
Commit
7fc9dfd
·
verified ·
1 Parent(s): 57e808e

Upload folder using huggingface_hub

Browse files
chat_template.jinja CHANGED
@@ -14,16 +14,37 @@
14
  {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
  {%- endif %}
16
  {%- endif %}
17
- {%- for message in messages %}
18
- {%- if message.content is string %}
19
- {%- set content = message.content %}
20
- {%- else %}
21
- {%- set content = '' %}
 
22
  {%- endif %}
 
 
23
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
24
- {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
25
  {%- elif message.role == "assistant" %}
26
- {{- '<|im_start|>' + message.role + '\n' + content }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  {%- if message.tool_calls %}
28
  {%- for tool_call in message.tool_calls %}
29
  {%- if (loop.first and content) or (not loop.first) %}
@@ -49,7 +70,7 @@
49
  {{- '<|im_start|>user' }}
50
  {%- endif %}
51
  {{- '\n<tool_response>\n' }}
52
- {{- content }}
53
  {{- '\n</tool_response>' }}
54
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
55
  {{- '<|im_end|>\n' }}
@@ -58,4 +79,9 @@
58
  {%- endfor %}
59
  {%- if add_generation_prompt %}
60
  {{- '<|im_start|>assistant\n' }}
61
- {%- endif %}
 
 
 
 
 
 
14
  {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
  {%- endif %}
16
  {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
  {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
27
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
28
  {%- elif message.role == "assistant" %}
29
+ {%- set content = message.content %}
30
+ {%- set reasoning_content = '' %}
31
+ {%- if message.reasoning_content is defined and message.reasoning_content is not none %}
32
+ {%- set reasoning_content = message.reasoning_content %}
33
+ {%- else %}
34
+ {%- if '</think>' in message.content %}
35
+ {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
36
+ {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
37
+ {%- endif %}
38
+ {%- endif %}
39
+ {%- if loop.index0 > ns.last_query_index %}
40
+ {%- if loop.last or (not loop.last and reasoning_content) %}
41
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
42
+ {%- else %}
43
+ {{- '<|im_start|>' + message.role + '\n' + content }}
44
+ {%- endif %}
45
+ {%- else %}
46
+ {{- '<|im_start|>' + message.role + '\n' + content }}
47
+ {%- endif %}
48
  {%- if message.tool_calls %}
49
  {%- for tool_call in message.tool_calls %}
50
  {%- if (loop.first and content) or (not loop.first) %}
 
70
  {{- '<|im_start|>user' }}
71
  {%- endif %}
72
  {{- '\n<tool_response>\n' }}
73
+ {{- message.content }}
74
  {{- '\n</tool_response>' }}
75
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
76
  {{- '<|im_end|>\n' }}
 
79
  {%- endfor %}
80
  {%- if add_generation_prompt %}
81
  {{- '<|im_start|>assistant\n' }}
82
+ {%- if enable_thinking is defined and enable_thinking is false %}
83
+ {{- '<think>\n\n</think>\n\n' }}
84
+ {%- else %}
85
+ {{- '<think>\n\n' }}
86
+ {%- endif %}
87
+ {%- endif %}
debug.log CHANGED
The diff for this file is too large to render. See raw diff
 
model-00001-of-00002.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9fb0ab06ad9fe842daf543c83b76993491c9eab43b3e375ce28b323d62733239
3
  size 4967215360
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d338ec7ebf4f5868b9515584104a412e114e045c109937b097cc61558f13e2ce
3
  size 4967215360
model-00002-of-00002.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:02c8bb17295b3d1db77c916ca27b73adc1c1efedab13c210ee6401394dc87d13
3
  size 3077766632
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10bc4224f79c658f59adce95bc4c534a9ac18755a252aebcb94d251de5e3a447
3
  size 3077766632