char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Piotr Wilkin (ilintar)Autoparser - complete refactoring of parser architecture (#18675)566059a26

char/aliceai-t5-moe
4.0 KiB77 linesraw
1{{ bos_token }}
2{%- if messages[0]['role'] == 'system' %}
3    {%- set system_message = messages[0]['content'] %}
4    {%- set loop_start_index = 1 %}
5{%- else %}
6    {%- set system_message = "" %}
7    {%- set loop_start_index = 0 %}
8{%- endif %}
9
10{%- if system_message or tools %}
11    {{- '<|im_start|>system\n' }}
12    {%- if system_message %}
13        {{- system_message }}
14    {%- endif %}
15    {%- if tools %}
16        {{- '\n\nMasz dostęp do następujących narzędzi. Definicje narzędzi znajdują się poniżej wewnątrz znaczników <|function_list|>:\n<|function_list|>\n' }}
17        {{- '[' }}
18        {%- for tool in tools %}
19            {{- tool | tojson }}
20            {%- if not loop.last %}
21                {{- ',\n' }}
22            {%- endif %}
23        {%- endfor %}
24        {{- ']\n<|function_list|>\n\nAby wywołać narzędzie, użyj formatu <tool_call>{"name": "nazwa_narzędzia", "arguments": {"argument": "wartość"}}</tool_call>. Wyniki działania narzędzi zostaną przekazane z markerem <|function_output|>.\n' }}
25    {%- endif %}
26    {%- if enable_thinking %}
27        {{- '\n\nZanim odpowiesz na pytanie, najpierw przemyśl swoje kroki i umieść swoje myśli wewnątrz tagów <think>...</think>. Musisz najpierw pomyśleć, zanim udzielisz odpowiedzi. ' -}}
28        {{- 'WAŻNE: Powinieneś myśleć w tym samym języku, co pytanie użytkownika. Jeśli pytanie jest zadane po polsku, powinieneś również myśleć po polsku. Jeśli pytanie jest po angielsku, myślisz również po angielsku itd. ' }}
29        {{- '** PAMIĘTAJ! ** Pytanie po polsku -> myślenie po polsku -> odpowiedź po polsku!' -}}
30        {{- '*** BARDZO WAŻNE!!! *** Jesteś Bielikiem, polskim modelem językowym. Twoją główną cechą jest umiejętność pisania po polsku. Jeśli użytkownik zadaje Ci pytania po polsku, ZAWSZE odpowiadaj po polsku. ' -}}
31        {{- 'Nawet, jeśli korzystasz z narzędzia, którego większość instrukcji jest po angielsku, powinieneś przede wszystkim odpowiadać po polsku, jeśli użytkownik zadaje pytanie w tym języku. ' -}}
32    {%- endif %}
33    {{- '<|im_end|>\n' }}
34{%- endif %}
35
36{%- for message in messages[loop_start_index:] %}
37    {%- if message['role'] == 'user' %}
38        {{- '<|im_start|>user\n' + message['content'] + '<|im_end|>\n' }}
39    {%- elif message['role'] == 'assistant' %}
40        {{- '<|im_start|>assistant\n' }}
41        {%- set content = message.content | default('') %}
42        {%- set reasoning_content = message.reasoning_content | default('') %}
43        {%- if not reasoning_content and '<think>' in content and '</think>' in content %}
44            {%- set reasoning_parts = content.split('</think>') %}
45            {%- set reasoning_content = reasoning_parts[0].split('<think>')[-1] %}
46            {%- set content = reasoning_parts[1:] | join('</think>') %}
47        {%- endif %}
48        {%- if reasoning_content %}
49            {{- '<think>\n' + reasoning_content.strip() + '\n</think>\n' }}
50        {%- endif %}
51        {{- content.lstrip() }}
52        {%- if message.tool_calls %}
53            {%- for tool_call in message.tool_calls %}
54                {%- if tool_call.function %}
55                    {%- set tool_call = tool_call.function %}
56                {%- endif %}
57                {{- '\n<tool_call>\n{"name": "' + tool_call.name + '", "arguments": ' + (tool_call.arguments if tool_call.arguments is string else tool_call.arguments | tojson) + '}\n</tool_call>' }}
58            {%- endfor %}
59        {%- endif %}
60        {{- '<|im_end|>\n' }}
61    {%- elif message['role'] == 'tool' %}
62        {%- if loop.index0 == 0 or messages[loop.index0 - 1]['role'] != 'tool' %}
63            {{- '<|im_start|>user\n' }}
64        {%- endif %}
65        {{- '<|function_output|>' + message['content'] }}
66        {%- if loop.last or messages[loop.index0 + 1]['role'] != 'tool' %}
67            {{- '<|im_end|>\n' }}
68        {%- endif %}
69    {%- endif %}
70{%- endfor %}
71
72{%- if add_generation_prompt %}
73    {{- '<|im_start|>assistant\n' }}
74    {%- if enable_thinking %}
75        {{- '<think>\n' }}
76    {%- endif %}
77{%- endif %}