Update chat_template.jinja
Browse files- chat_template.jinja +20 -50
    	
        chat_template.jinja
    CHANGED
    
    | @@ -1,36 +1,26 @@ | |
| 1 | 
            -
            {# ============================================================
         | 
| 2 | 
            -
            # chat_template_uic_captcha_v1.jinja
         | 
| 3 | 
            -
            # for Qwen3-VL / Unsloth / vLLM 多模態 + UIC + CAPTCHA 任務支援
         | 
| 4 | 
            -
            # 作者: gary109
         | 
| 5 | 
            -
            # 修改日期: 2025-10-24
         | 
| 6 | 
            -
            # ============================================================ #}
         | 
| 7 | 
            -
             | 
| 8 | 
             
            {%- if tools %}
         | 
| 9 | 
            -
            {{- '<|im_start|>system\n' }}
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            {%- if messages[0]. | 
| 12 | 
            -
             | 
| 13 | 
            -
                    { | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
                            { | 
| 18 | 
            -
                        {%-  | 
| 19 | 
            -
                    {%-  | 
|  | |
| 20 | 
             
                {%- endif %}
         | 
| 21 | 
            -
                {{-  | 
| 22 | 
            -
            {%-  | 
| 23 | 
            -
            {{- " | 
| 24 | 
            -
            { | 
| 25 | 
            -
                { | 
| 26 | 
            -
                {{-  | 
| 27 | 
            -
            {%- endfor %}
         | 
| 28 | 
            -
            {{- "\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><|im_end|>\n" }}
         | 
| 29 | 
            -
            <|uic_end|>
         | 
| 30 | 
             
            {%- else %}
         | 
| 31 | 
             
                {%- if messages[0].role == 'system' %}
         | 
| 32 | 
             
                    {{- '<|im_start|>system\n' }}
         | 
| 33 | 
            -
                    <|uic_start|>
         | 
| 34 | 
             
                    {%- if messages[0].content is string %}
         | 
| 35 | 
             
                        {{- messages[0].content }}
         | 
| 36 | 
             
                    {%- else %}
         | 
| @@ -40,26 +30,14 @@ | |
| 40 | 
             
                            {%- endif %}
         | 
| 41 | 
             
                        {%- endfor %}
         | 
| 42 | 
             
                    {%- endif %}
         | 
| 43 | 
            -
                    <|uic_end|>
         | 
| 44 | 
             
                    {{- '<|im_end|>\n' }}
         | 
| 45 | 
             
                {%- endif %}
         | 
| 46 | 
             
            {%- endif %}
         | 
| 47 | 
            -
             | 
| 48 | 
             
            {%- set image_count = namespace(value=0) %}
         | 
| 49 | 
             
            {%- set video_count = namespace(value=0) %}
         | 
| 50 | 
            -
             | 
| 51 | 
             
            {%- for message in messages %}
         | 
| 52 | 
             
                {%- if message.role == "user" %}
         | 
| 53 | 
             
                    {{- '<|im_start|>' + message.role + '\n' }}
         | 
| 54 | 
            -
             | 
| 55 | 
            -
                    {# === 🔹 CAPTCHA 任務自動提示區 === #}
         | 
| 56 | 
            -
                    {%- if message.task_type is defined and message.task_type == "captcha" %}
         | 
| 57 | 
            -
            <|captcha_start|>
         | 
| 58 | 
            -
            請辨識下列圖片中的驗證碼,輸出純文字結果。
         | 
| 59 | 
            -
            請只輸出 JSON:{"captcha_text": "<答案>"}
         | 
| 60 | 
            -
            <|captcha_end|>
         | 
| 61 | 
            -
                    {%- endif %}
         | 
| 62 | 
            -
             | 
| 63 | 
             
                    {%- if message.content is string %}
         | 
| 64 | 
             
                        {{- message.content }}
         | 
| 65 | 
             
                    {%- else %}
         | 
| @@ -78,23 +56,17 @@ | |
| 78 | 
             
                        {%- endfor %}
         | 
| 79 | 
             
                    {%- endif %}
         | 
| 80 | 
             
                    {{- '<|im_end|>\n' }}
         | 
| 81 | 
            -
             | 
| 82 | 
             
                {%- elif message.role == "assistant" %}
         | 
| 83 | 
             
                    {{- '<|im_start|>' + message.role + '\n' }}
         | 
| 84 | 
             
                    {%- if message.content is string %}
         | 
| 85 | 
            -
                        <|solution_start|>
         | 
| 86 | 
             
                        {{- message.content }}
         | 
| 87 | 
            -
                        <|solution_end|>
         | 
| 88 | 
             
                    {%- else %}
         | 
| 89 | 
             
                        {%- for content_item in message.content %}
         | 
| 90 | 
             
                            {%- if 'text' in content_item %}
         | 
| 91 | 
            -
                                <|solution_start|>
         | 
| 92 | 
             
                                {{- content_item.text }}
         | 
| 93 | 
            -
                                <|solution_end|>
         | 
| 94 | 
             
                            {%- endif %}
         | 
| 95 | 
             
                        {%- endfor %}
         | 
| 96 | 
             
                    {%- endif %}
         | 
| 97 | 
            -
             | 
| 98 | 
             
                    {%- if message.tool_calls %}
         | 
| 99 | 
             
                        {%- for tool_call in message.tool_calls %}
         | 
| 100 | 
             
                            {%- if (loop.first and message.content) or (not loop.first) %}
         | 
| @@ -115,7 +87,6 @@ | |
| 115 | 
             
                        {%- endfor %}
         | 
| 116 | 
             
                    {%- endif %}
         | 
| 117 | 
             
                    {{- '<|im_end|>\n' }}
         | 
| 118 | 
            -
             | 
| 119 | 
             
                {%- elif message.role == "tool" %}
         | 
| 120 | 
             
                    {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
         | 
| 121 | 
             
                        {{- '<|im_start|>user' }}
         | 
| @@ -144,7 +115,6 @@ | |
| 144 | 
             
                    {%- endif %}
         | 
| 145 | 
             
                {%- endif %}
         | 
| 146 | 
             
            {%- endfor %}
         | 
| 147 | 
            -
             | 
| 148 | 
             
            {%- if add_generation_prompt %}
         | 
| 149 | 
            -
            {{- '<|im_start|>assistant\n | 
| 150 | 
            -
            {%- endif %}
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 1 | 
             
            {%- if tools %}
         | 
| 2 | 
            +
                {{- '<|im_start|>system\n' }}
         | 
| 3 | 
            +
                {%- if messages[0].role == 'system' %}
         | 
| 4 | 
            +
                    {%- if messages[0].content is string %}
         | 
| 5 | 
            +
                        {{- messages[0].content }}
         | 
| 6 | 
            +
                    {%- else %}
         | 
| 7 | 
            +
                        {%- for content in messages[0].content %}
         | 
| 8 | 
            +
                            {%- if 'text' in content %}
         | 
| 9 | 
            +
                                {{- content.text }}
         | 
| 10 | 
            +
                            {%- endif %}
         | 
| 11 | 
            +
                        {%- endfor %}
         | 
| 12 | 
            +
                    {%- endif %}
         | 
| 13 | 
            +
                    {{- '\n\n' }}
         | 
| 14 | 
             
                {%- endif %}
         | 
| 15 | 
            +
                {{- "# 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>" }}
         | 
| 16 | 
            +
                {%- for tool in tools %}
         | 
| 17 | 
            +
                    {{- "\n" }}
         | 
| 18 | 
            +
                    {{- tool | tojson }}
         | 
| 19 | 
            +
                {%- endfor %}
         | 
| 20 | 
            +
                {{- "\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><|im_end|>\n" }}
         | 
|  | |
|  | |
|  | |
| 21 | 
             
            {%- else %}
         | 
| 22 | 
             
                {%- if messages[0].role == 'system' %}
         | 
| 23 | 
             
                    {{- '<|im_start|>system\n' }}
         | 
|  | |
| 24 | 
             
                    {%- if messages[0].content is string %}
         | 
| 25 | 
             
                        {{- messages[0].content }}
         | 
| 26 | 
             
                    {%- else %}
         | 
|  | |
| 30 | 
             
                            {%- endif %}
         | 
| 31 | 
             
                        {%- endfor %}
         | 
| 32 | 
             
                    {%- endif %}
         | 
|  | |
| 33 | 
             
                    {{- '<|im_end|>\n' }}
         | 
| 34 | 
             
                {%- endif %}
         | 
| 35 | 
             
            {%- endif %}
         | 
|  | |
| 36 | 
             
            {%- set image_count = namespace(value=0) %}
         | 
| 37 | 
             
            {%- set video_count = namespace(value=0) %}
         | 
|  | |
| 38 | 
             
            {%- for message in messages %}
         | 
| 39 | 
             
                {%- if message.role == "user" %}
         | 
| 40 | 
             
                    {{- '<|im_start|>' + message.role + '\n' }}
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 41 | 
             
                    {%- if message.content is string %}
         | 
| 42 | 
             
                        {{- message.content }}
         | 
| 43 | 
             
                    {%- else %}
         | 
|  | |
| 56 | 
             
                        {%- endfor %}
         | 
| 57 | 
             
                    {%- endif %}
         | 
| 58 | 
             
                    {{- '<|im_end|>\n' }}
         | 
|  | |
| 59 | 
             
                {%- elif message.role == "assistant" %}
         | 
| 60 | 
             
                    {{- '<|im_start|>' + message.role + '\n' }}
         | 
| 61 | 
             
                    {%- if message.content is string %}
         | 
|  | |
| 62 | 
             
                        {{- message.content }}
         | 
|  | |
| 63 | 
             
                    {%- else %}
         | 
| 64 | 
             
                        {%- for content_item in message.content %}
         | 
| 65 | 
             
                            {%- if 'text' in content_item %}
         | 
|  | |
| 66 | 
             
                                {{- content_item.text }}
         | 
|  | |
| 67 | 
             
                            {%- endif %}
         | 
| 68 | 
             
                        {%- endfor %}
         | 
| 69 | 
             
                    {%- endif %}
         | 
|  | |
| 70 | 
             
                    {%- if message.tool_calls %}
         | 
| 71 | 
             
                        {%- for tool_call in message.tool_calls %}
         | 
| 72 | 
             
                            {%- if (loop.first and message.content) or (not loop.first) %}
         | 
|  | |
| 87 | 
             
                        {%- endfor %}
         | 
| 88 | 
             
                    {%- endif %}
         | 
| 89 | 
             
                    {{- '<|im_end|>\n' }}
         | 
|  | |
| 90 | 
             
                {%- elif message.role == "tool" %}
         | 
| 91 | 
             
                    {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
         | 
| 92 | 
             
                        {{- '<|im_start|>user' }}
         | 
|  | |
| 115 | 
             
                    {%- endif %}
         | 
| 116 | 
             
                {%- endif %}
         | 
| 117 | 
             
            {%- endfor %}
         | 
|  | |
| 118 | 
             
            {%- if add_generation_prompt %}
         | 
| 119 | 
            +
                {{- '<|im_start|>assistant\n' }}
         | 
| 120 | 
            +
            {%- endif %}
         | 
