| {%- if tools is iterable and tools | length > 0 %} |
| {{- '<|im_start|>system |
| '}} |
| {{- '๋น์ ์ ๋๊ตฌ ํธ์ถ ๊ธฐ๋ฅ์ ๊ฐ์ถ ์ ์ฉํ ๋์ฐ๋ฏธ์
๋๋ค. ์ฌ์ฉ์์ ์์ฒญ์ ์ฒ๋ฆฌํ๊ธฐ ์ํด์ ํ์ํ ๋๊ตฌ๊ฐ ์ฃผ์ด์ง ๋ชฉ๋ก์ ์๋ ๊ฒฝ์ฐ ๋๊ตฌ ํธ์ถ๋ก ์๋ตํ์ธ์. |
| ํ์ํ ๋๊ตฌ๊ฐ ๋ชฉ๋ก์ ์๋ ๊ฒฝ์ฐ์๋ ๋๊ตฌ ํธ์ถ ์์ด ์ฌ์ฉ์๊ฐ ์๊ตฌํ ์ ๋ณด๋ฅผ ์ ๊ณตํ์ธ์. |
| ํ์ํ ๋๊ตฌ๊ฐ ๋ชฉ๋ก์ ์์ง๋ง ํด๋น ๋๊ตฌ๋ฅผ ํธ์ถํ๋๋ฐ ํ์ํ argument ์ ๋ณด๊ฐ ๋ถ์กฑํ ๊ฒฝ์ฐ ํด๋น ์ ๋ณด๋ฅผ ์ฌ์ฉ์์๊ฒ ์์ฒญํ์ธ์. |
| ์ฌ์ฉ์์ ์์ฒญ์ ์ฒ๋ฆฌํ๊ธฐ ์ํด ์ฌ๋ฌ๋ฒ ๋๊ตฌ๋ฅผ ํธ์ถํ ์ ์์ด์ผ ํฉ๋๋ค. |
| ๋๊ตฌ ํธ์ถ ์ดํ ๋๊ตฌ ์คํ ๊ฒฐ๊ณผ๋ฅผ ์
๋ ฅ์ผ๋ก ๋ฐ์ผ๋ฉด ํด๋น ๊ฒฐ๊ณผ๋ฅผ ํ์ฉํ์ฌ ๋ต๋ณ์ ์์ฑํ์ธ์. |
| |
| ๋ค์์ ์ ๊ทผํ ์ ์๋ ๋๊ตฌ๋ค์ ๋ชฉ๋ก ์
๋๋ค: |
| <tools> |
| '}} |
| {%- for t in tools %} |
| {{- t | tojson }} |
| {{- ' |
| ' }} |
| {%- endfor %} |
| {{- '</tools>' }} |
| {{- ' |
| |
| ๋๊ตฌ๋ฅผ ํธ์ถํ๋ ค๋ฉด ์๋์ JSON์ผ๋ก ์๋ตํ์ธ์. |
| ๋๊ตฌ ํธ์ถ ํ์: <tool_call>{"name": ๋๊ตฌ ์ด๋ฆ, "arguments": dictionary ํํ์ ๋๊ตฌ ์ธ์๊ฐ}</tool_call>' }} |
| {{- '<|im_end|> |
| ' }} |
| {%- endif %} |
| |
| {%- for message in messages %} |
| {%- if message.role == 'system' %} |
| {{- '<|im_start|>system |
| ' + message.content + '<|im_end|> |
| '}} |
| {%- elif message.role == 'user' %} |
| {{- '<|im_start|>user |
| ' + message.content + '<|im_end|> |
| '}} |
| {%- elif message.role == 'assistant' %} |
| {{- '<|im_start|>assistant |
| '}} |
| {%- set content = '' %} |
| {%- if message.content is defined %} |
| {%- set content = message.content %} |
| {%- endif %} |
| |
| {%- if add_generation_prompt and not (message.reasoning_content is defined and message.reasoning_content is not none) %} |
| {%- if message.content is defined and '</think>' in message.content %} |
| {%- set content = message.content.split('</think>'.strip())[-1].lstrip('\n') %} |
| {%- endif %} |
| {%- endif %} |
| |
| {{- content}} |
| {%- if message.tool_calls is defined %} |
| {%- for tool_call in message.tool_calls %} |
| {%- if tool_call.function is defined %} |
| {%- set tool_call = tool_call.function %} |
| {%- endif %} |
| {{- '<tool_call>' }} |
| {{- '{' }} |
| {{- '"name": "' }} |
| {{- tool_call.name }} |
| {{- '"' }} |
| {%- if tool_call.arguments is defined %} |
| {{- ', ' }} |
| {{- '"arguments": ' }} |
| {{- tool_call.arguments|tojson }} |
| {%- endif %} |
| {{- '}' }} |
| {{- '</tool_call>' }} |
| {%- endfor %} |
| {%- endif %} |
| {{- '<|im_end|> |
| '}} |
| |
| {%- elif message.role == 'tool' %} |
| {{- '<|im_start|>user |
| <tool_response>' + message.content + '</tool_response><|im_end|> |
| '}} |
| {%- endif %} |
| {%- endfor %} |
| |
| {%- if add_generation_prompt %} |
| {{- '<|im_start|>assistant |
| ' }} |
| {%- if enable_thinking is defined and enable_thinking is true %} |
| {{- '<think>' }} |
| {%- else %} |
| {{- '</think>' }} |
| {%- endif %} |
| {%- endif %} |