prithivMLmods commited on
Commit
5b60a7b
·
1 Parent(s): 6bd813c

Delete chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +0 -159
chat_template.jinja DELETED
@@ -1,159 +0,0 @@
1
- {%- set image_count = namespace(value=0) %}
2
- {%- set video_count = namespace(value=0) %}
3
- {%- set default_system_prompt = "You are a strict, zero-tolerance parental control content-safety guardrail classifier for visual media.\nYour role is minor protection: any media containing suggestive, revealing, sexually provocative, or explicit visual elements must be flagged as NSFW.\n\nSTRICT ZERO-TOLERANCE CLASSIFICATION RULES:\n1. Nudity & Exposure: Any full or partial nudity, exposed breasts, cleavage, buttocks, groin, or visible pubic area MUST be classified as NSFW.\n2. Underwear & Swimwear: Thongs, G-strings, micro-bikinis, skimpy/revealing swimwear, bras, panties, lingerie, see-through clothing, or unbuttoned tops revealing undergarments/bare torsos MUST be classified as NSFW.\n3. Poses & Suggestiveness: Sexually suggestive poses, seductive modeling, cleavage-emphasizing framing, fetish content, or explicit erotic themes MUST be classified as NSFW.\n4. Artwork & Animation: Anime nudes, ecchi, hentai, suggestive illustrations, or 2D/3D stylized erotica MUST be classified as NSFW.\n5. Classification Threshold: When in doubt, err on the side of caution and classify the content as NSFW (nsfw = 1, safe = 0).\n\nOutput strictly valid JSON with no extra conversational text, commentary, or markdown formatting outside the JSON object:\n{\n \"caption\": \"<Detailed, objective visual description of the subject, clothing, exposure, and pose>\",\n \"is_nsfw\": true | false,\n \"reason\": \"<Precise reason for classification based on clothing, exposure, or pose>\",\n \"nsfw\": 1 | 0,\n \"safe\": 1 | 0\n}" %}
4
- {%- macro render_content(content, do_vision_count, is_system_content=false) %}
5
- {%- if content is string %}
6
- {{- content }}
7
- {%- elif content is iterable and content is not mapping %}
8
- {%- for item in content %}
9
- {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
10
- {%- if is_system_content %}
11
- {{- raise_exception('System message cannot contain images.') }}
12
- {%- endif %}
13
- {%- if do_vision_count %}
14
- {%- set image_count.value = image_count.value + 1 %}
15
- {%- endif %}
16
- {%- if add_vision_id %}
17
- {{- 'Picture ' ~ image_count.value ~ ': ' }}
18
- {%- endif %}
19
- {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
20
- {%- elif 'video' in item or item.type == 'video' %}
21
- {%- if is_system_content %}
22
- {{- raise_exception('System message cannot contain videos.') }}
23
- {%- endif %}
24
- {%- if do_vision_count %}
25
- {%- set video_count.value = video_count.value + 1 %}
26
- {%- endif %}
27
- {%- if add_vision_id %}
28
- {{- 'Video ' ~ video_count.value ~ ': ' }}
29
- {%- endif %}
30
- {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
31
- {%- elif 'text' in item %}
32
- {{- item.text }}
33
- {%- else %}
34
- {{- raise_exception('Unexpected item type in content.') }}
35
- {%- endif %}
36
- {%- endfor %}
37
- {%- elif content is none or content is undefined %}
38
- {{- '' }}
39
- {%- else %}
40
- {{- raise_exception('Unexpected content type.') }}
41
- {%- endif %}
42
- {%- endmacro %}
43
- {%- if not messages %}
44
- {{- raise_exception('No messages provided.') }}
45
- {%- endif %}
46
- {%- if tools and tools is iterable and tools is not mapping %}
47
- {{- '<|im_start|>system\n' }}
48
- {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
49
- {%- for tool in tools %}
50
- {{- "\n" }}
51
- {{- tool | tojson }}
52
- {%- endfor %}
53
- {{- "\n</tools>" }}
54
- {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
55
- {%- if messages[0].role == 'system' %}
56
- {%- set content = render_content(messages[0].content, false, true)|trim %}
57
- {%- if content %}
58
- {{- '\n\n' + content }}
59
- {%- endif %}
60
- {%- else %}
61
- {{- '\n\n' + default_system_prompt }}
62
- {%- endif %}
63
- {{- '<|im_end|>\n' }}
64
- {%- else %}
65
- {%- if messages[0].role == 'system' %}
66
- {%- set content = render_content(messages[0].content, false, true)|trim %}
67
- {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
68
- {%- else %}
69
- {{- '<|im_start|>system\n' + default_system_prompt + '<|im_end|>\n' }}
70
- {%- endif %}
71
- {%- endif %}
72
- {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
73
- {%- for message in messages[::-1] %}
74
- {%- set index = (messages|length - 1) - loop.index0 %}
75
- {%- if ns.multi_step_tool and message.role == "user" %}
76
- {%- set content = render_content(message.content, false)|trim %}
77
- {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
78
- {%- set ns.multi_step_tool = false %}
79
- {%- set ns.last_query_index = index %}
80
- {%- endif %}
81
- {%- endif %}
82
- {%- endfor %}
83
- {%- if ns.multi_step_tool %}
84
- {{- raise_exception('No user query found in messages.') }}
85
- {%- endif %}
86
- {%- for message in messages %}
87
- {%- set content = render_content(message.content, true)|trim %}
88
- {%- if message.role == "system" %}
89
- {%- if not loop.first %}
90
- {{- raise_exception('System message must be at the beginning.') }}
91
- {%- endif %}
92
- {%- elif message.role == "user" %}
93
- {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
94
- {%- elif message.role == "assistant" %}
95
- {%- set reasoning_content = '' %}
96
- {%- if message.reasoning_content is string %}
97
- {%- set reasoning_content = message.reasoning_content %}
98
- {%- else %}
99
- {%- if '</think>' in content %}
100
- {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
101
- {%- set content = content.split('</think>')[-1].lstrip('\n') %}
102
- {%- endif %}
103
- {%- endif %}
104
- {%- set reasoning_content = reasoning_content|trim %}
105
- {%- if loop.index0 > ns.last_query_index %}
106
- {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
107
- {%- else %}
108
- {{- '<|im_start|>' + message.role + '\n' + content }}
109
- {%- endif %}
110
- {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
111
- {%- for tool_call in message.tool_calls %}
112
- {%- if tool_call.function is defined %}
113
- {%- set tool_call = tool_call.function %}
114
- {%- endif %}
115
- {%- if loop.first %}
116
- {%- if content|trim %}
117
- {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
- {%- else %}
119
- {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
120
- {%- endif %}
121
- {%- else %}
122
- {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
123
- {%- endif %}
124
- {%- if tool_call.arguments is defined %}
125
- {%- for args_name, args_value in tool_call.arguments|items %}
126
- {{- '<parameter=' + args_name + '>\n' }}
127
- {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
128
- {{- args_value }}
129
- {{- '\n</parameter>\n' }}
130
- {%- endfor %}
131
- {%- endif %}
132
- {{- '</function>\n</tool_call>' }}
133
- {%- endfor %}
134
- {%- endif %}
135
- {{- '<|im_end|>\n' }}
136
- {%- elif message.role == "tool" %}
137
- {%- if loop.previtem and loop.previtem.role != "tool" %}
138
- {{- '<|im_start|>user' }}
139
- {%- endif %}
140
- {{- '\n<tool_response>\n' }}
141
- {{- content }}
142
- {{- '\n</tool_response>' }}
143
- {%- if not loop.last and loop.nextitem.role != "tool" %}
144
- {{- '<|im_end|>\n' }}
145
- {%- elif loop.last %}
146
- {{- '<|im_end|>\n' }}
147
- {%- endif %}
148
- {%- else %}
149
- {{- raise_exception('Unexpected message role.') }}
150
- {%- endif %}
151
- {%- endfor %}
152
- {%- if add_generation_prompt %}
153
- {{- '<|im_start|>assistant\n' }}
154
- {%- if enable_thinking is defined and enable_thinking is true %}
155
- {{- '<think>\n' }}
156
- {%- else %}
157
- {{- '<think>\n\n</think>\n\n' }}
158
- {%- endif %}
159
- {%- endif %}