ssdataanalysis commited on
Commit
0bdc187
·
verified ·
1 Parent(s): 1ad74df

Upload chat_template.jinja with huggingface_hub

Browse files
Files changed (1) hide show
  1. chat_template.jinja +92 -0
chat_template.jinja ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {# ───── header (system message) ───── #}
2
+ {{- "<|im_start|>system\n" -}}
3
+ {# ───── get the custom instructions + optional thinking override ───── #}
4
+ {%- if messages[0].role == "system" -%}
5
+ {%- set custom_instructions = messages[0].content.rstrip() -%}
6
+ {%- endif -%}
7
+ {# ───── set the system prompt ───── #}
8
+ {%- if custom_instructions -%}
9
+ {{- custom_instructions -}}
10
+ {%- else -%}
11
+ {{- "You are a helpful AI assistant named Dicta-LM 3.0, Trained by Dicta, the Israel Center for Text Analysis. Your role is to provide accurate, helpful, and well-structured responses to user questions and requests.\nProvide clear, logical, and precise answers that thoroughly address what the user is asking for. Structure your responses in a way that is easy to understand and follow." -}}
12
+ {%- endif -%}
13
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages | length - 1) -%}
14
+ {%- for message in messages[::-1] -%}
15
+ {%- set index = messages | length - 1 - loop.index0 -%}
16
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not (message.content.startswith("<tool_response>") and message.content.endswith("</tool_response>")) -%}
17
+ {%- set ns.multi_step_tool = false -%}
18
+ {%- set ns.last_query_index = index -%}
19
+ {%- endif -%}
20
+ {%- endfor -%}
21
+ {%- if tools -%}
22
+ {{- "\n\n## 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>" -}}
23
+ {%- for tool in tools -%}
24
+ {{- "\n" -}}
25
+ {{- tool | tojson -}}
26
+ {%- endfor -%}
27
+ {{- "\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>" -}}
28
+ {%- endif -%}
29
+ {{- "<|im_end|>" -}}
30
+ {%- for message in messages -%}
31
+ {%- if message.content is string -%}
32
+ {%- set content = message.content -%}
33
+ {%- else -%}
34
+ {%- set content = "" -%}
35
+ {%- endif -%}
36
+ {%- if message.role == "user" or message.role == "system" and not loop.first -%}
37
+ {{- "\n<|im_start|>" + message.role + "\n" + content + "<|im_end|>" -}}
38
+ {%- elif message.role == "assistant" -%}
39
+ {% generation %}
40
+ {%- set reasoning_content = "" -%}
41
+ {%- if message.reasoning_content is string -%}
42
+ {%- set reasoning_content = message.reasoning_content -%}
43
+ {%- elif "</think>" in content -%}
44
+ {%- set reasoning_content = content.split("</think>")[0].rstrip("\n").split("<think>")[-1].lstrip("\n") -%}
45
+ {%- set content = content.split("</think>")[-1].lstrip("\n") -%}
46
+ {%- endif -%}
47
+ {%- if loop.index0 > ns.last_query_index -%}
48
+ {%- if loop.last or not loop.last and reasoning_content -%}
49
+ {{- "\n<|im_start|>" + message.role + "\n<think>" + reasoning_content.strip("\n") + "</think>" + content.lstrip("\n") -}}
50
+ {%- else -%}
51
+ {{- "\n<|im_start|>" + message.role + "\n" + content -}}
52
+ {%- endif -%}
53
+ {%- else -%}
54
+ {{- "\n<|im_start|>" + message.role + "\n" + content -}}
55
+ {%- endif -%}
56
+ {%- if message.tool_calls -%}
57
+ {%- for tool_call in message.tool_calls -%}
58
+ {%- if loop.first and content or not loop.first -%}
59
+ {{- "\n" -}}
60
+ {%- endif -%}
61
+ {%- if tool_call.function -%}
62
+ {%- set tool_call = tool_call.function -%}
63
+ {%- endif -%}
64
+ {{- "<tool_call>\n{\"name\": \"" -}}
65
+ {{- tool_call.name -}}
66
+ {{- "\", \"arguments\": " -}}
67
+ {%- if tool_call.arguments is string -%}
68
+ {{- tool_call.arguments -}}
69
+ {%- else -%}
70
+ {{- tool_call.arguments | tojson -}}
71
+ {%- endif -%}
72
+ {{- "}\n</tool_call>" -}}
73
+ {%- endfor -%}
74
+ {%- endif -%}
75
+ {{- "<|im_end|>" -}}
76
+ {% endgeneration %}
77
+ {%- elif message.role == "tool" -%}
78
+ {%- if loop.first or messages[loop.index0 - 1].role != "tool" -%}
79
+ {{- "\n<|im_start|>user" -}}
80
+ {%- endif -%}
81
+ {{- "\n<tool_response>\n" -}}
82
+ {{- content -}}
83
+ {{- "\n</tool_response>" -}}
84
+ {%- if loop.last or messages[loop.index0 + 1].role != "tool" -%}
85
+ {{- "<|im_end|>" -}}
86
+ {%- endif -%}
87
+ {%- endif -%}
88
+ {%- endfor -%}
89
+ {{- "\n" -}}
90
+ {%- if add_generation_prompt -%}
91
+ {{- "<|im_start|>assistant\n<think>" -}}
92
+ {%- endif -%}