Skip to content

Commit 4de63f3

Browse files
author
ochafik
committed
Create llama-cpp-microsoft-Phi-4-mini-instruct.jinja
1 parent 769cd71 commit 4de63f3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{%- if messages[0]["role"] == "system" %}
2+
{%- set system_message = messages[0]["content"] %}
3+
{% elif tools is defined -%}
4+
{%- set system_message = "You are a helpful assistant with access to tools." -%}
5+
{% else %}
6+
{%- set system_message = "" -%}
7+
{%- endif %}
8+
{%- if tools is defined -%}
9+
{%- set system_message = system_message + '<|tool|>' + (tools | tojson) + '<|/tool|>' -%}
10+
{%- if '<|tool_call|>' not in system_message -%}
11+
{%- set system_message = system_message + "\nTo use a tool, respond in this format: <|tool_call|>{\"name\": \"foo\", \"arguments\": {\"a\": 1}}<|/tool_call|>" %}
12+
{%- endif %}
13+
{%- endif %}
14+
{%- if system_message is defined -%}
15+
{{- '<|system|>' + system_message + '<|end|>' -}}
16+
{%- endif -%}
17+
{%- for message in messages -%}
18+
{%- if message['role'] == 'tool' -%}
19+
{{- '<|tool_response|>' + (message['content'] | tojson) + '<|/tool_response|>' -}}
20+
{%- elif message['role'] != 'system' -%}
21+
{{- '<|' + message['role'] + '|>' -}}
22+
{%- if message.content -%}
23+
{{- message['content'] -}}
24+
{%- endif -%}
25+
{%- for tool_call in message.tool_calls -%}
26+
{{- '<|tool_call|>' + (tool_call | tojson) + '<|/tool_call|>' -}}
27+
{%- endfor -%}
28+
{{- '<|end|>' -}}
29+
{%- endif -%}
30+
{%- endfor -%}
31+
{%- if add_generation_prompt -%}
32+
{{- '<|assistant|>' -}}
33+
{%- else -%}
34+
{{- eos_token -}}
35+
{%- endif -%}

0 commit comments

Comments
 (0)