litmudoc commited on
Commit
c26dbca
ยท
verified ยท
1 Parent(s): 13ffadb

Upload chat_template.jinja

Browse files

fixed. jinja chat template.

Files changed (1) hide show
  1. chat_template.jinja +54 -68
chat_template.jinja CHANGED
@@ -1,72 +1,58 @@
1
  {%- if tools is iterable and tools | length > 0 %}
2
- {{- '<|im_start|><|system|>'}}
3
- {{- '๋‹น์‹ ์€ ๋„๊ตฌ ํ˜ธ์ถœ ๊ธฐ๋Šฅ์„ ๊ฐ–์ถ˜ ์œ ์šฉํ•œ ๋„์šฐ๋ฏธ์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ ํ•„์š”ํ•œ ๋„๊ตฌ๊ฐ€ ์ฃผ์–ด์ง„ ๋ชฉ๋ก์— ์žˆ๋Š” ๊ฒฝ์šฐ ๋„๊ตฌ ํ˜ธ์ถœ๋กœ ์‘๋‹ตํ•˜์„ธ์š”.
4
- ํ•„์š”ํ•œ ๋„๊ตฌ๊ฐ€ ๋ชฉ๋ก์— ์—†๋Š” ๊ฒฝ์šฐ์—๋Š” ๋„๊ตฌ ํ˜ธ์ถœ ์—†์ด ์‚ฌ์šฉ์ž๊ฐ€ ์š”๊ตฌํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜์„ธ์š”.
5
- ํ•„์š”ํ•œ ๋„๊ตฌ๊ฐ€ ๋ชฉ๋ก์— ์žˆ์ง€๋งŒ ํ•ด๋‹น ๋„๊ตฌ๋ฅผ ํ˜ธ์ถœํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ argument ์ •๋ณด๊ฐ€ ๋ถ€์กฑํ•œ ๊ฒฝ์šฐ ํ•ด๋‹น ์ •๋ณด๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ์š”์ฒญํ•˜์„ธ์š”.
6
- ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์—ฌ๋Ÿฌ๋ฒˆ ๋„๊ตฌ๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
7
- ๋„๊ตฌ ํ˜ธ์ถœ ์ดํ›„ ๋„๊ตฌ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์œผ๋ฉด ํ•ด๋‹น ๊ฒฐ๊ณผ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋‹ต๋ณ€์„ ์ƒ์„ฑํ•˜์„ธ์š”.
 
 
 
 
8
 
9
- ๋‹ค์Œ์€ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ๋“ค์˜ ๋ชฉ๋ก ์ž…๋‹ˆ๋‹ค:
10
- <tools>
11
- '}}
12
- {%- for t in tools %}
13
- {{- t | tojson }}
14
- {{- '
15
- ' }}
16
- {%- endfor %}
17
- {{- '</tools>' }}
18
- {{- '
19
-
20
- ๋„๊ตฌ๋ฅผ ํ˜ธ์ถœํ•˜๋ ค๋ฉด ์•„๋ž˜์˜ JSON์œผ๋กœ ์‘๋‹ตํ•˜์„ธ์š”.
21
- ๋„๊ตฌ ํ˜ธ์ถœ ํ˜•์‹: <tool_call>{"name": ๋„๊ตฌ ์ด๋ฆ„, "arguments": dictionary ํ˜•ํƒœ์˜ ๋„๊ตฌ ์ธ์ž๊ฐ’}</tool_call>' }}
22
- {{- '<|im_end|>' }}
23
- {%- endif %}
24
 
25
- {%- for message in messages %}
26
- {%- if message.role == 'system' %}
27
- {{- '<|im_start|><|system|>' + message.content + '<|im_end|>'}}
28
- {%- elif message.role == 'user' %}
29
- {{- '<|im_start|><|user|>' + message.content + '<|im_end|>'}}
30
- {%- elif message.role == 'assistant' %}
31
- {{- '<|im_start|><|assistant|>'}}
32
- {%- set content = '' %}
33
- {%- if message.content is defined %}
34
- {%- set content = message.content %}
35
- {%- endif %}
36
-
37
- {%- if add_generation_prompt and not (message.reasoning_content is defined and message.reasoning_content is not none) %}
38
- {%- if '</think>' in message.content %}
39
- {%- set content = message.content.split('</think>'.strip())[-1].lstrip('\n') %}
40
- {%- endif %}
41
  {%- endif %}
42
-
43
- {{- content}}
44
- {%- if message.tool_calls is defined %}
45
- {%- for tool_call in message.tool_calls %}
46
- {%- if tool_call.function is defined %}
47
- {%- set tool_call = tool_call.function %}
48
- {%- endif %}
49
- {{- '<tool_call>' }}
50
- {{- '{' }}
51
- {{- '"name": "' }}
52
- {{- tool_call.name }}
53
- {{- '"' }}
54
- {%- if tool_call.arguments is defined %}
55
- {{- ', ' }}
56
- {{- '"arguments": ' }}
57
- {{- tool_call.arguments|tojson }}
58
- {%- endif %}
59
- {{- '}' }}
60
- {{- '</tool_call>' }}
61
- {%- endfor %}
62
- {%- endif %}
63
- {{- '<|im_end|>'}}
64
-
65
- {%- elif message.role == 'tool' %}
66
- {{- '<|im_start|><|extra_id_13|><tool_output>' + message.content + '</tool_output><|im_end|>'}}
67
- {%- endif %}
68
- {%- endfor %}
69
-
70
- {%- if add_generation_prompt %}
71
- {{- '<|im_start|><|assistant|>' }}
72
- {%- endif %}
 
1
  {%- if tools is iterable and tools | length > 0 %}
2
+ {{- '<|im_start|><|system|>'}}
3
+ {{- '๋‹น์‹ ์€ ๋„๊ตฌ ํ˜ธ์ถœ ๊ธฐ๋Šฅ์„ ๊ฐ–์ถ˜ ์œ ์šฉํ•œ ๋„์šฐ๋ฏธ์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ ํ•„์š”ํ•œ ๋„๊ตฌ๊ฐ€ ์ฃผ์–ด์ง„ ๋ชฉ๋ก์— ์žˆ๋Š” ๊ฒฝ์šฐ ๋„๊ตฌ ํ˜ธ์ถœ๋กœ ์‘๋‹ตํ•˜์„ธ์š”. ํ•„์š”ํ•œ ๋„๊ตฌ๊ฐ€ ๋ชฉ๋ก์— ์—†๋Š” ๊ฒฝ์šฐ์—๋Š” ๋„๊ตฌ ํ˜ธ์ถœ ์—†์ด ์‚ฌ์šฉ์ž๊ฐ€ ์š”๊ตฌํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜์„ธ์š”. ํ•„์š”ํ•œ ๋„๊ตฌ๊ฐ€ ๋ชฉ๋ก์— ์žˆ์ง€๋งŒ ํ•ด๋‹น ๋„๊ตฌ๋ฅผ ํ˜ธ์ถœํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ argument ์ •๋ณด๊ฐ€ ๋ถ€์กฑํ•œ ๊ฒฝ์šฐ ํ•ด๋‹น ์ •๋ณด๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ์š”์ฒญํ•˜์„ธ์š”. ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์—ฌ๋Ÿฌ๋ฒˆ ๋„๊ตฌ๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋„๊ตฌ ํ˜ธ์ถœ ์ดํ›„ ๋„๊ตฌ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์œผ๋ฉด ํ•ด๋‹น ๊ฒฐ๊ณผ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋‹ต๋ณ€์„ ์ƒ์„ฑํ•˜์„ธ์š”. ๋‹ค์Œ์€ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ๋“ค์˜ ๋ชฉ๋ก ์ž…๋‹ˆ๋‹ค: <tools>'}}
4
+ {%- for t in tools %}
5
+ {{- t | tojson }}
6
+ {{- '' }}
7
+ {%- endfor %}
8
+ {{- '</tools>' }}
9
+ {{- '๋„๊ตฌ๋ฅผ ํ˜ธ์ถœํ•˜๋ ค๋ฉด ์•„๋ž˜์˜ JSON์œผ๋กœ ์‘๋‹ตํ•˜์„ธ์š”. ๋„๊ตฌ ํ˜ธ์ถœ ํ˜•์‹: <tool_call>{"name": ๋„๊ตฌ ์ด๋ฆ„, "arguments": dictionary ํ˜•ํƒœ์˜ ๋„๊ตฌ ์ธ์ž๊ฐ’}</tool_call>' }}
10
+ {{- '<|im_end|>' }}
11
+ {%- endif %}
12
 
13
+ {%- for message in messages %}
14
+ {%- if message.role == 'system' %}
15
+ {{- '<|im_start|><|system|>' + message.content + '<|im_end|>'}}
16
+ {%- elif message.role == 'user' %}
17
+ {{- '<|im_start|><|user|>' + message.content + '<|im_end|>'}}
18
+ {%- elif message.role == 'assistant' %}
19
+ {{- '<|im_start|><|assistant|>'}}
20
+ {%- set content = '' %}
21
+ {%- if message.content is defined %}
22
+ {%- set content = message.content %}
23
+ {%- endif %}
 
 
 
 
24
 
25
+ {%- if add_generation_prompt and not (message.reasoning_content is defined and message.reasoning_content is not none) %}
26
+ {%- if '</think>' in message.content %}
27
+ {%- set content = (message.content.split('</think>'.strip()) | last).lstrip('\n') %}
28
+ {%- endif %}
29
+ {%- endif %}
30
+ {{- content}}
31
+ {%- if message.tool_calls is defined %}
32
+ {%- for tool_call in message.tool_calls %}
33
+ {%- if tool_call.function is defined %}
34
+ {%- set tool_call = tool_call.function %}
 
 
 
 
 
 
35
  {%- endif %}
36
+ {{- '<tool_call>' }}
37
+ {{- '{' }}
38
+ {{- '"name": "' }}
39
+ {{- tool_call.name }}
40
+ {{- '"' }}
41
+ {%- if tool_call.arguments is defined %}
42
+ {{- ', ' }}
43
+ {{- '"arguments": ' }}
44
+ {{- tool_call.arguments|tojson }}
45
+ {%- endif %}
46
+ {{- '}' }}
47
+ {{- '</tool_call>' }}
48
+ {%- endfor %}
49
+ {%- endif %}
50
+ {{- '<|im_end|>'}}
51
+ {%- elif message.role == 'tool' %}
52
+ {{- '<|im_start|><|extra_id_13|><tool_output>' + message.content + '</tool_output><|im_end|>'}}
53
+ {%- endif %}
54
+ {%- endfor %}
55
+
56
+ {%- if add_generation_prompt %}
57
+ {{- '<|im_start|><|assistant|>' }}
58
+ {%- endif %}