ssdataanalysis commited on
Commit
ed862b3
·
verified ·
1 Parent(s): 7c6ea11

Upload chat_template.jinja with huggingface_hub

Browse files
Files changed (1) hide show
  1. chat_template.jinja +77 -0
chat_template.jinja ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {{- "\n<|im_start|>" + message.role + "\n" + content -}}
41
+ {%- if message.tool_calls -%}
42
+ {%- for tool_call in message.tool_calls -%}
43
+ {%- if loop.first and content or not loop.first -%}
44
+ {{- "\n" -}}
45
+ {%- endif -%}
46
+ {%- if tool_call.function -%}
47
+ {%- set tool_call = tool_call.function -%}
48
+ {%- endif -%}
49
+ {{- "<tool_call>\n{\"name\": \"" -}}
50
+ {{- tool_call.name -}}
51
+ {{- "\", \"arguments\": " -}}
52
+ {%- if tool_call.arguments is string -%}
53
+ {{- tool_call.arguments -}}
54
+ {%- else -%}
55
+ {{- tool_call.arguments | tojson -}}
56
+ {%- endif -%}
57
+ {{- "}\n</tool_call>" -}}
58
+ {%- endfor -%}
59
+ {%- endif -%}
60
+ {{- "<|im_end|>" -}}
61
+ {% endgeneration %}
62
+ {%- elif message.role == "tool" -%}
63
+ {%- if loop.first or messages[loop.index0 - 1].role != "tool" -%}
64
+ {{- "\n<|im_start|>user" -}}
65
+ {%- endif -%}
66
+ {{- "\n<tool_response>\n" -}}
67
+ {{- content -}}
68
+ {{- "\n</tool_response>" -}}
69
+ {%- if loop.last or messages[loop.index0 + 1].role != "tool" -%}
70
+ {{- "<|im_end|>" -}}
71
+ {%- endif -%}
72
+ {%- endif -%}
73
+ {%- endfor -%}
74
+ {{- "\n" -}}
75
+ {%- if add_generation_prompt -%}
76
+ {{- "<|im_start|>assistant\n" -}}
77
+ {%- endif -%}