Upload yandex.jinja
Browse files- yandex.jinja +64 -0
yandex.jinja
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{%- set names = {'assistant': ' Ассистент:', 'user': ' Пользователь:', 'system': 'Система:'} %}
|
2 |
+
{%- set tools_prefix = 'Тебе доступны следующие функции:' %}
|
3 |
+
|
4 |
+
{%- macro __render_tool(tool) %}
|
5 |
+
{%- set name = tool.function.name %}
|
6 |
+
{%- set description = tool.function.description|default('') %}
|
7 |
+
{%- set parameters = tool.function.parameters|tojson %}
|
8 |
+
{{- '\n' }}function {{ '{' }}'name':'{{ name }}',
|
9 |
+
{%- if tool.description %}'description':'{{ description }}',{% endif %}
|
10 |
+
'parameters':{{ parameters }}
|
11 |
+
{{- '}' }}
|
12 |
+
{%- endmacro %}
|
13 |
+
|
14 |
+
{%- macro __render_tools(tools) %}
|
15 |
+
{{- tools_prefix }}
|
16 |
+
{%- for tool in tools %}
|
17 |
+
{{- __render_tool(tool) }}
|
18 |
+
{%- endfor %}
|
19 |
+
{{- '\n\n' }}
|
20 |
+
{%- endmacro %}
|
21 |
+
|
22 |
+
{%- macro __render_tool_message(message) %}
|
23 |
+
{{- '\n\nРезультат вызова' }} {{ message.name }}: {{ message.content }} {{ '\n\n' }}
|
24 |
+
{%- endmacro %}
|
25 |
+
|
26 |
+
{%- macro __render_user_message(message) %}
|
27 |
+
{{ names.user }} {{ message.content + '\n\n' }}
|
28 |
+
{%- endmacro %}
|
29 |
+
|
30 |
+
{%- macro __render_assistant_message(message) %}
|
31 |
+
{{- names.assistant }}
|
32 |
+
{%- set call = message['function_call'] %}
|
33 |
+
{%- if call %}
|
34 |
+
{{- '\n[TOOL_CALL_START]' }}{{ call.name }}{{ '\n' }}{{ call.arguments|tojson }}
|
35 |
+
{%- else %}
|
36 |
+
{{- ' ' + message.content + '\n\n' }}
|
37 |
+
{%- endif %}
|
38 |
+
{%- endmacro %}
|
39 |
+
|
40 |
+
{%- macro __render_system_message(message) %}
|
41 |
+
Система: {{ message.content + '\n\n' }}
|
42 |
+
{%- endmacro %}
|
43 |
+
|
44 |
+
{%- if not add_generation_prompt is defined %}
|
45 |
+
{%- set add_generation_prompt = false %}
|
46 |
+
{%- endif %}
|
47 |
+
|
48 |
+
{%- for message in messages %}
|
49 |
+
{%- if message['role'] == 'system' %}
|
50 |
+
{{- __render_system_message(message) }}
|
51 |
+
{%- endif %}
|
52 |
+
{%- if message['role'] == 'user' %}
|
53 |
+
{{- __render_user_message(message) }}
|
54 |
+
{%- endif %}
|
55 |
+
{%- if message.role == 'assistant' and not loop.last %}
|
56 |
+
{{- __render_assistant_message(message) }}
|
57 |
+
{%- endif %}
|
58 |
+
{%- if message.role == 'tool' %}
|
59 |
+
{{- __render_tool_message(message) }}
|
60 |
+
{%- endif %}
|
61 |
+
{%- if loop.last %}
|
62 |
+
{{- ' Ассистент:[SEP]' }}
|
63 |
+
{%- endif %}
|
64 |
+
{%- endfor %}
|