IlyasMoutawwakil's picture
Upload folder using huggingface_hub
baa0dbb verified
Raw
History Blame Contribute Delete
4.27 kB
{%- 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 %}