prithivMLmods commited on
Commit
0db4c3f
·
verified ·
1 Parent(s): 07b9650
Files changed (1) hide show
  1. chat_template.jinja +20 -6
chat_template.jinja CHANGED
@@ -1,5 +1,10 @@
1
  {%- set image_count = namespace(value=0) %}
2
  {%- set video_count = namespace(value=0) %}
 
 
 
 
 
3
  {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
  {%- if content is string %}
5
  {{- content }}
@@ -39,12 +44,15 @@
39
  {{- raise_exception('Unexpected content type.') }}
40
  {%- endif %}
41
  {%- endmacro %}
 
42
  {%- if not messages %}
43
  {{- raise_exception('No messages provided.') }}
44
  {%- endif %}
 
45
  {%- if tools and tools is iterable and tools is not mapping %}
46
  {{- '<|im_start|>system\n' }}
47
- {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
 
48
  {%- for tool in tools %}
49
  {{- "\n" }}
50
  {{- tool | tojson }}
@@ -60,10 +68,13 @@
60
  {{- '<|im_end|>\n' }}
61
  {%- else %}
62
  {%- if messages[0].role == 'system' %}
63
- {%- set content = render_content(messages[0].content, false, true)|trim %}
64
- {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
 
 
65
  {%- endif %}
66
  {%- endif %}
 
67
  {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
  {%- for message in messages[::-1] %}
69
  {%- set index = (messages|length - 1) - loop.index0 %}
@@ -75,9 +86,11 @@
75
  {%- endif %}
76
  {%- endif %}
77
  {%- endfor %}
 
78
  {%- if ns.multi_step_tool %}
79
  {{- raise_exception('No user query found in messages.') }}
80
  {%- endif %}
 
81
  {%- for message in messages %}
82
  {%- set content = render_content(message.content, true)|trim %}
83
  {%- if message.role == "system" %}
@@ -144,11 +157,12 @@
144
  {{- raise_exception('Unexpected message role.') }}
145
  {%- endif %}
146
  {%- endfor %}
 
147
  {%- if add_generation_prompt %}
148
  {{- '<|im_start|>assistant\n' }}
149
- {%- if enable_thinking is defined and enable_thinking is false %}
150
- {{- '<think>\n\n</think>\n\n' }}
151
- {%- else %}
152
  {{- '<think>\n' }}
 
 
153
  {%- endif %}
154
  {%- endif %}
 
1
  {%- set image_count = namespace(value=0) %}
2
  {%- set video_count = namespace(value=0) %}
3
+
4
+ {%- set detection_system_prompt %}
5
+ You are a helpful assistant to detect objects in images. When asked to detect elements based on a description you return bounding boxes for all elements in the form of [xmin, ymin, xmax, ymax] with the values being scaled between 0 and 1000. When there are more than one result, answer with a list of bounding boxes in the form of [[xmin, ymin, xmax, ymax], [xmin, ymin, xmax, ymax], ...].
6
+ {%- endset %}
7
+
8
  {%- macro render_content(content, do_vision_count, is_system_content=false) %}
9
  {%- if content is string %}
10
  {{- content }}
 
44
  {{- raise_exception('Unexpected content type.') }}
45
  {%- endif %}
46
  {%- endmacro %}
47
+
48
  {%- if not messages %}
49
  {{- raise_exception('No messages provided.') }}
50
  {%- endif %}
51
+
52
  {%- if tools and tools is iterable and tools is not mapping %}
53
  {{- '<|im_start|>system\n' }}
54
+ {{- detection_system_prompt }}
55
+ {{- "\n\n# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
56
  {%- for tool in tools %}
57
  {{- "\n" }}
58
  {{- tool | tojson }}
 
68
  {{- '<|im_end|>\n' }}
69
  {%- else %}
70
  {%- if messages[0].role == 'system' %}
71
+ {%- set user_system = render_content(messages[0].content, false, true)|trim %}
72
+ {{- '<|im_start|>system\n' + detection_system_prompt + '\n\n' + user_system + '<|im_end|>\n' }}
73
+ {%- else %}
74
+ {{- '<|im_start|>system\n' + detection_system_prompt + '<|im_end|>\n' }}
75
  {%- endif %}
76
  {%- endif %}
77
+
78
  {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
79
  {%- for message in messages[::-1] %}
80
  {%- set index = (messages|length - 1) - loop.index0 %}
 
86
  {%- endif %}
87
  {%- endif %}
88
  {%- endfor %}
89
+
90
  {%- if ns.multi_step_tool %}
91
  {{- raise_exception('No user query found in messages.') }}
92
  {%- endif %}
93
+
94
  {%- for message in messages %}
95
  {%- set content = render_content(message.content, true)|trim %}
96
  {%- if message.role == "system" %}
 
157
  {{- raise_exception('Unexpected message role.') }}
158
  {%- endif %}
159
  {%- endfor %}
160
+
161
  {%- if add_generation_prompt %}
162
  {{- '<|im_start|>assistant\n' }}
163
+ {%- if enable_thinking is defined and enable_thinking is true %}
 
 
164
  {{- '<think>\n' }}
165
+ {%- else %}
166
+ {{- '<think>\n\n</think>\n\n' }}
167
  {%- endif %}
168
  {%- endif %}