Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
update named templates
Michael Yangfb6cbc02fbe0
diff --git a/go.mod b/go.modindex 6807b9b48..2e0c6614c 100644--- a/go.mod+++ b/go.mod@@ -18,6 +18,7 @@ require (require (github.com/agnivade/levenshtein v1.1.1github.com/d4l3k/go-bfloat16 v0.0.0-20211005043715-690c3bdd05f1+ github.com/google/go-cmp v0.6.0github.com/mattn/go-runewidth v0.0.14github.com/nlpodyssey/gopickle v0.3.0github.com/pdevine/tensor v0.0.0-20240510204454-f88f4562727c@@ -71,7 +72,7 @@ require (golang.org/x/net v0.25.0 // indirectgolang.org/x/sys v0.20.0golang.org/x/term v0.20.0- golang.org/x/text v0.15.0 // indirect+ golang.org/x/text v0.15.0google.golang.org/protobuf v1.34.1gopkg.in/yaml.v3 v3.0.1 // indirect)diff --git a/server/routes_create_test.go b/server/routes_create_test.goindex 340612822..269a0ba12 100644--- a/server/routes_create_test.go+++ b/server/routes_create_test.go@@ -545,9 +545,9 @@ func TestCreateDetectTemplate(t *testing.T) {}checkFileExists(t, filepath.Join(p, "blobs", "*"), []string{- filepath.Join(p, "blobs", "sha256-2f8e594e6f34b1b4d36a246628eeb3365ce442303d656f1fcc69e821722acea0"),- filepath.Join(p, "blobs", "sha256-542b217f179c7825eeb5bca3c77d2b75ed05bafbd3451d9188891a60a85337c6"),filepath.Join(p, "blobs", "sha256-553c4a3f747b3d22a4946875f1cc8ed011c2930d83f864a0c7265f9ec0a20413"),+ filepath.Join(p, "blobs", "sha256-9512c372dfc7d84d6065b8dd2b601aeed8cc1a78e7a7aa784a42fff37f5524b7"),+ filepath.Join(p, "blobs", "sha256-b8b78cb8c6eefd14c06f1af042e6161255bf87bbf2dd14fce57cdac893db8139"),})})diff --git a/template/alfred.gotmpl b/template/alfred.gotmplindex cecb9d2c8..44284f04c 100644--- a/template/alfred.gotmpl+++ b/template/alfred.gotmpl@@ -1 +1,8 @@-{{ if .System }}<start_system>{{ .System }}<end_message>{{ end }}{{ if .Prompt }}<start_user>{{ .Prompt }}<end_message>{{ end }}<start_assistant>{{ .Response }}<end_message>\ No newline at end of file+{{- if .Messages }}+{{- if .System }}<start_system>{{ .System }}<end_message>+{{- end }}+{{- range .Messages }}<start_{{ .Role }}>{{ .Content }}<end_message>+{{- end }}<start_assistant>+{{- else }}+{{ if .System }}<start_system>{{ .System }}<end_message>{{ end }}{{ if .Prompt }}<start_user>{{ .Prompt }}<end_message>{{ end }}<start_assistant>{{ .Response }}<end_message>+{{- end }}\ No newline at end of filediff --git a/template/alpaca.gotmpl b/template/alpaca.gotmplindex 440d06627..c1f69dc92 100644--- a/template/alpaca.gotmpl+++ b/template/alpaca.gotmpl@@ -1,7 +1,19 @@+{{- if .Messages }}+{{- if .System }}{{ .System }}+{{- end }}+{{- range .Messages }}+{{- if eq .Role "user" }}### Instruction:+{{- else if eq .Role "assistant" }}### Response:+{{- end }}+{{ .Content }}++{{ end }}### Response:+{{ else }}{{ if .System }}{{ .System }}{{ end }}{{ if .Prompt }}### Instruction:{{ .Prompt }}{{ end }}### Response:-{{ .Response }}\ No newline at end of file+{{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/chatml.gotmpl b/template/chatml.gotmplindex dcf172853..d945547c7 100644--- a/template/chatml.gotmpl+++ b/template/chatml.gotmpl@@ -1,6 +1,15 @@+{{- if .Messages }}+{{- if .System }}<|im_start|>system+{{ .System }}<|im_end|>+{{ end }}+{{- range .Messages }}<|im_start|>{{ .Role }}+{{ .Content }}<|im_end|>+{{ end }}<|im_start|>assistant+{{ else }}{{ if .System }}<|im_start|>system{{ .System }}<|im_end|>{{ end }}{{ if .Prompt }}<|im_start|>user{{ .Prompt }}<|im_end|>{{ end }}<|im_start|>assistant-{{ .Response }}<|im_end|>\ No newline at end of file+{{ .Response }}<|im_end|>+{{- end }}\ No newline at end of filediff --git a/template/chatqa.gotmpl b/template/chatqa.gotmplindex 1ede6227f..7022c4790 100644--- a/template/chatqa.gotmpl+++ b/template/chatqa.gotmpl@@ -1,5 +1,17 @@+{{- if .Messages }}+{{- if .System }}System: {{ .System }}++{{ end }}+{{- range .Messages }}+{{- if eq .Role "user" }}User:+{{- else if eq .Role "assistant" }}Assistant:+{{- end }} {{ .Content }}++{{ end }}Assistant:+{{- else }}{{ if .System }}System: {{ .System }}{{ end }}{{ if .Prompt }}User: {{ .Prompt }}-{{ end }}Assistant: <|begin_of_text|>{{ .Response }}\ No newline at end of file+{{ end }}Assistant: <|begin_of_text|>{{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/codellama-70b-instruct.gotmpl b/template/codellama-70b-instruct.gotmplindex 3196bd6fd..392d839eb 100644--- a/template/codellama-70b-instruct.gotmpl+++ b/template/codellama-70b-instruct.gotmpl@@ -1,3 +1,13 @@+{{- if .Messages }}+{{- if .System }}Source: system++ {{ .System }} <step> {{ end }}+{{- range .Messages }}Source: {{ .Role }}++ {{ .Content }} <step> {{ end }}Source: assistant+Destination: user++{{ else }}{{ if .System }} Source: system{{ .System }} <step>{{ end }} Source: user@@ -5,4 +15,5 @@{{ .Prompt }} <step> Source: assistantDestination: user- {{ .Response }}<step>\ No newline at end of file+ {{ .Response }}<step>+{{- end }}\ No newline at end of filediff --git a/template/falcon-instruct.gotmpl b/template/falcon-instruct.gotmplindex 2309a1c5d..99d67f93c 100644--- a/template/falcon-instruct.gotmpl+++ b/template/falcon-instruct.gotmpl@@ -1,3 +1,13 @@+{{- if .Messages }}+{{- if .System }}System: {{ .System }}+{{ end }}+{{- range .Messages }}+{{- if eq .Role "user" }}User:+{{ else if eq .Role "assistant" }}Falcon:+{{ end }}{{ .Content }}+{{ end }}Falcon:+{{ else }}{{ if .System }}{{ .System }}{{ end }}{{ if .Prompt }}User: {{ .Prompt }}-{{ end }}Assistant: {{ .Response }}\ No newline at end of file+{{ end }}Assistant: {{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/gemma-instruct.gotmpl b/template/gemma-instruct.gotmplindex 91b9883a1..870a8f2e2 100644--- a/template/gemma-instruct.gotmpl+++ b/template/gemma-instruct.gotmpl@@ -1,4 +1,16 @@+{{- if .Messages }}+{{- range $index, $_ := .Messages }}<start_of_turn>+{{- if eq .Role "user" }}user+{{- if and $.System (eq $index 0) }}+{{ $.System }}+{{- end }}+{{- else if eq .Role "assistant" }}model+{{- end }}+{{ .Content }}<end_of_turn>+{{ end }}<start_of_turn>model+{{ else }}<start_of_turn>user{{ if .System }}{{ .System }} {{ end }}{{ .Prompt }}<end_of_turn><start_of_turn>model-{{ .Response }}<end_of_turn>\ No newline at end of file+{{ .Response }}<end_of_turn>+{{- end }}\ No newline at end of filediff --git a/template/granite-instruct.gotmpl b/template/granite-instruct.gotmplindex 2ede647f5..327ff3eef 100644--- a/template/granite-instruct.gotmpl+++ b/template/granite-instruct.gotmpl@@ -1,3 +1,16 @@+{{- if .Messages }}+{{- if .System }}System:+{{ .System }}++{{ end }}+{{- range .Messages }}+{{- if eq .Role "user" }}Question:+{{- else if eq .Role "assistant" }}Answer:+{{- end }}+{{ .Content }}++{{ end }}Answer:+{{ else }}{{ if .System }}System:{{ .System }}@@ -6,4 +19,5 @@ System:{{ .Prompt }}{{ end }}Answer:-{{ .Response }}\ No newline at end of file+{{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/llama2-chat.gotmpl b/template/llama2-chat.gotmplindex a739f6908..6327d5812 100644--- a/template/llama2-chat.gotmpl+++ b/template/llama2-chat.gotmpl@@ -1,3 +1,16 @@+{{- if .Messages }}+{{- range $index, $_ := .Messages }}+{{- if eq .Role "user" }}[INST] {{ if eq $index 0 }}<<SYS>>+{{- if $.System }}+{{ $.System }}+{{ end }}<</SYS>>++{{ end }}{{ .Content }}+{{- else }} [/INST] {{ .Content }}</s><s>+{{- end }}+{{- end }} [/INST]+{{- else }}[INST] <<SYS>>{{ .System }}<</SYS>>-{{ .Prompt }} [/INST] {{ .Response }}\ No newline at end of file+{{ .Prompt }} [/INST] {{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/llama3-instruct.gotmpl b/template/llama3-instruct.gotmplindex 36d0218b6..9c81a9535 100644--- a/template/llama3-instruct.gotmpl+++ b/template/llama3-instruct.gotmpl@@ -1,7 +1,19 @@+{{- if .Messages }}+{{- if .System }}<|start_header_id|>system<|end_header_id|>++{{ .System }}<|eot_id|>+{{- end }}+{{- range .Messages }}<|start_header_id|>{{ .Role }}<|end_header_id|>++{{ .Content }}<|eot_id|>+{{- end }}<|start_header_id|>assistant<|end_header_id|>++{{ else }}{{ if .System }}<|start_header_id|>system<|end_header_id|>{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>-{{ .Response }}<|eot_id|>\ No newline at end of file+{{ .Response }}<|eot_id|>+{{- end }}\ No newline at end of filediff --git a/template/magicoder.gotmpl b/template/magicoder.gotmplindex 306972ecc..73a58127c 100644--- a/template/magicoder.gotmpl+++ b/template/magicoder.gotmpl@@ -1,7 +1,20 @@+{{- if .Messages }}+{{- if .System }}{{ .System }}++{{ end }}+{{- range .Messages }}+{{- if eq .Role "user" }}@@ Instruction+{{- else if eq .Role "assistant" }}@@ Response+{{- end }}+{{ .Content }}++{{ end }}@@ Response+{{ else }}{{ if .System }}{{ .System }}{{ end }}{{ if .Prompt }}@@ Instruction{{ .Prompt }}{{ end }}@@ Response-{{ .Response }}\ No newline at end of file+{{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/mistral-instruct.gotmpl b/template/mistral-instruct.gotmplindex dcf172853..eb3d5ced2 100644--- a/template/mistral-instruct.gotmpl+++ b/template/mistral-instruct.gotmpl@@ -1,6 +1,9 @@-{{ if .System }}<|im_start|>system-{{ .System }}<|im_end|>-{{ end }}{{ if .Prompt }}<|im_start|>user-{{ .Prompt }}<|im_end|>-{{ end }}<|im_start|>assistant-{{ .Response }}<|im_end|>\ No newline at end of file+{{- if .Messages }}+{{- range $index, $_ := .Messages }}+{{- if eq .Role "user" }}[INST] {{ if and $.System (eq (len (slice $.Messages $index)) 1) }}{{ $.System }}+{{ end }}{{ .Content }}+{{- else if eq .Role "assistant" }}[/INST] {{ .Content }}</s>+{{- end }}+{{- end }}[/INST]+{{- else }}[INST] {{ if .System }}{{ .System }} {{ end }}{{ .Prompt }} [/INST] {{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/openchat.gotmpl b/template/openchat.gotmplindex d2ca38685..d5e1cbb0d 100644--- a/template/openchat.gotmpl+++ b/template/openchat.gotmpl@@ -1 +1,11 @@-{{ .System }}<|end_of_turn|>GPT4 Correct User: {{ .Prompt }}<|end_of_turn|>GPT4 Correct Assistant: {{ .Response }}<|end_of_turn|>\ No newline at end of file+{{- if .Messages }}+{{- if .System }}GPT Correct System: {{ .System }}<|end_of_turn|>+{{- end }}+{{- range .Messages }}GPT Correct+{{- if eq .Role "user" }} User:+{{- else if eq .Role "assistant" }} Assistant:+{{- end }} {{ .Content }}<|end_of_turn|>+{{- end }}GPT Correct Assistant:+{{- else }}+{{ .System }}<|end_of_turn|>GPT4 Correct User: {{ .Prompt }}<|end_of_turn|>GPT4 Correct Assistant: {{ .Response }}<|end_of_turn|>+{{- end }}\ No newline at end of filediff --git a/template/phi-3.gotmpl b/template/phi-3.gotmplindex bf26dcee2..a3558d2b7 100644--- a/template/phi-3.gotmpl+++ b/template/phi-3.gotmpl@@ -1,6 +1,15 @@+{{- if .Messages }}+{{- if .System }}<|system|>+{{ .System }}<|end|>+{{ end }}+{{- range .Messages }}<|{{ .Role }}|>+{{ .Content }}<|end|>+{{ end }}<|assistant|>+{{ else }}{{ if .System }}<|system|>{{ .System }}<|end|>{{ end }}{{ if .Prompt }}<|user|>{{ .Prompt }}<|end|>{{ end }}<|assistant|>-{{ .Response }}<|end|>\ No newline at end of file+{{ .Response }}<|end|>+{{- end }}\ No newline at end of filediff --git a/template/solar-instruct.gotmpl b/template/solar-instruct.gotmplindex c275a26a3..caa6e8e77 100644--- a/template/solar-instruct.gotmpl+++ b/template/solar-instruct.gotmpl@@ -1,3 +1,16 @@+{{- if .Messages }}+{{- if .System }}### System:+{{ .System }}++{{ end }}+{{- range .Messages }}+{{- if eq .Role "user" }}### User:+{{ .Content }}+{{ else if eq .Role "assistant" }}### Assistant:+{{ .Content }}</s>+{{ end }}+{{ end }}### Assistant:+{{ else }}{{ if .System }}### System:{{ .System }}@@ -5,4 +18,5 @@{{ .Prompt }}{{ end }}### Assistant:-{{ .Response }}\ No newline at end of file+{{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/starcoder2-instruct.gotmpl b/template/starcoder2-instruct.gotmplindex 33357e54e..7d7ff9326 100644--- a/template/starcoder2-instruct.gotmpl+++ b/template/starcoder2-instruct.gotmpl@@ -1,3 +1,17 @@+{{- if .Messages }}+{{- if .System }}{{ .System }}++{{ end }}+{{- range .Messages }}+{{- if eq .Role "user" }}### Instruction+{{ .Content }}++{{ else if eq .Role "assistant" }}### Response+{{ .Content }}<|endoftext|>++{{ end }}+{{- end }}### Response+{{ else }}{{ if .System }}{{ .System }}{{ end }}{{ if .Prompt }}### Instruction@@ -7,3 +21,4 @@{{ end }}### Response{{ .Response }}<|endoftext|>+{{- end }}\ No newline at end of filediff --git a/template/template_test.go b/template/template_test.goindex ac16bd606..428cdc77c 100644--- a/template/template_test.go+++ b/template/template_test.go@@ -8,9 +8,10 @@ import ("os""path/filepath""slices"+ "strings""testing"- "text/template"+ "github.com/google/go-cmp/cmp""github.com/ollama/ollama/api""github.com/ollama/ollama/llm")@@ -47,7 +48,7 @@ func TestNamed(t *testing.T) {t.Fatal(err)}- tmpl, err := template.New(s).Parse(b.String())+ tmpl, err := Parse(b.String())if err != nil {t.Fatal(err)}@@ -60,6 +61,70 @@ func TestNamed(t *testing.T) {}}+func TestTemplate(t *testing.T) {+ cases := make(map[string][]api.Message)+ for _, mm := range [][]api.Message{+ {+ {Role: "user", Content: "Hello, how are you?"},+ },+ {+ {Role: "user", Content: "Hello, how are you?"},+ {Role: "assistant", Content: "I'm doing great. How can I help you today?"},+ {Role: "user", Content: "I'd like to show off how chat templating works!"},+ },+ {+ {Role: "system", Content: "You are a helpful assistant."},+ {Role: "user", Content: "Hello, how are you?"},+ {Role: "assistant", Content: "I'm doing great. How can I help you today?"},+ {Role: "user", Content: "I'd like to show off how chat templating works!"},+ },+ } {+ var roles []string+ for _, m := range mm {+ roles = append(roles, m.Role)+ }++ cases[strings.Join(roles, "-")] = mm+ }++ matches, err := filepath.Glob("*.gotmpl")+ if err != nil {+ t.Fatal(err)+ }++ for _, match := range matches {+ t.Run(match, func(t *testing.T) {+ bts, err := os.ReadFile(match)+ if err != nil {+ t.Fatal(err)+ }++ tmpl, err := Parse(string(bts))+ if err != nil {+ t.Fatal(err)+ }++ for n, tt := range cases {+ t.Run(n, func(t *testing.T) {+ var actual bytes.Buffer+ if err := tmpl.Execute(&actual, Values{Messages: tt}); err != nil {+ t.Fatal(err)+ }++ expect, err := os.ReadFile(filepath.Join("testdata", match, n))+ if err != nil {+ t.Fatal(err)+ }++ if diff := cmp.Diff(actual.Bytes(), expect); diff != "" {+ t.Errorf("mismatch (-got +want):\n%s", diff)+ }+ })+ }+ })+ }+}+func TestParse(t *testing.T) {cases := []struct {template stringdiff --git a/template/testdata/alfred.gotmpl/system-user-assistant-user b/template/testdata/alfred.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..03e23ea9c--- /dev/null+++ b/template/testdata/alfred.gotmpl/system-user-assistant-user@@ -0,0 +1 @@+<start_system>You are a helpful assistant.<end_message><start_user>Hello, how are you?<end_message><start_assistant>I'm doing great. How can I help you today?<end_message><start_user>I'd like to show off how chat templating works!<end_message><start_assistant>\ No newline at end of filediff --git a/template/testdata/alfred.gotmpl/user b/template/testdata/alfred.gotmpl/usernew file mode 100644index 000000000..7c884a6f0--- /dev/null+++ b/template/testdata/alfred.gotmpl/user@@ -0,0 +1 @@+<start_user>Hello, how are you?<end_message><start_assistant>\ No newline at end of filediff --git a/template/testdata/alfred.gotmpl/user-assistant-user b/template/testdata/alfred.gotmpl/user-assistant-usernew file mode 100644index 000000000..a60701ed7--- /dev/null+++ b/template/testdata/alfred.gotmpl/user-assistant-user@@ -0,0 +1 @@+<start_user>Hello, how are you?<end_message><start_assistant>I'm doing great. How can I help you today?<end_message><start_user>I'd like to show off how chat templating works!<end_message><start_assistant>\ No newline at end of filediff --git a/template/testdata/alpaca.gotmpl/system-user-assistant-user b/template/testdata/alpaca.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..20182d829--- /dev/null+++ b/template/testdata/alpaca.gotmpl/system-user-assistant-user@@ -0,0 +1,10 @@+You are a helpful assistant.### Instruction:+Hello, how are you?++### Response:+I'm doing great. How can I help you today?++### Instruction:+I'd like to show off how chat templating works!++### Response:diff --git a/template/testdata/alpaca.gotmpl/user b/template/testdata/alpaca.gotmpl/usernew file mode 100644index 000000000..a0ce5dec7--- /dev/null+++ b/template/testdata/alpaca.gotmpl/user@@ -0,0 +1,4 @@+### Instruction:+Hello, how are you?++### Response:diff --git a/template/testdata/alpaca.gotmpl/user-assistant-user b/template/testdata/alpaca.gotmpl/user-assistant-usernew file mode 100644index 000000000..6c5e23ff5--- /dev/null+++ b/template/testdata/alpaca.gotmpl/user-assistant-user@@ -0,0 +1,10 @@+### Instruction:+Hello, how are you?++### Response:+I'm doing great. How can I help you today?++### Instruction:+I'd like to show off how chat templating works!++### Response:diff --git a/template/testdata/chatml.gotmpl/system-user-assistant-user b/template/testdata/chatml.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..8b013fcfb--- /dev/null+++ b/template/testdata/chatml.gotmpl/system-user-assistant-user@@ -0,0 +1,9 @@+<|im_start|>system+You are a helpful assistant.<|im_end|>+<|im_start|>user+Hello, how are you?<|im_end|>+<|im_start|>assistant+I'm doing great. How can I help you today?<|im_end|>+<|im_start|>user+I'd like to show off how chat templating works!<|im_end|>+<|im_start|>assistantdiff --git a/template/testdata/chatml.gotmpl/user b/template/testdata/chatml.gotmpl/usernew file mode 100644index 000000000..aa9e597a4--- /dev/null+++ b/template/testdata/chatml.gotmpl/user@@ -0,0 +1,3 @@+<|im_start|>user+Hello, how are you?<|im_end|>+<|im_start|>assistantdiff --git a/template/testdata/chatml.gotmpl/user-assistant-user b/template/testdata/chatml.gotmpl/user-assistant-usernew file mode 100644index 000000000..a7cba4de0--- /dev/null+++ b/template/testdata/chatml.gotmpl/user-assistant-user@@ -0,0 +1,7 @@+<|im_start|>user+Hello, how are you?<|im_end|>+<|im_start|>assistant+I'm doing great. How can I help you today?<|im_end|>+<|im_start|>user+I'd like to show off how chat templating works!<|im_end|>+<|im_start|>assistantdiff --git a/template/testdata/chatqa.gotmpl/system-user-assistant-user b/template/testdata/chatqa.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..98fd59bfa--- /dev/null+++ b/template/testdata/chatqa.gotmpl/system-user-assistant-user@@ -0,0 +1,9 @@+System: You are a helpful assistant.++User: Hello, how are you?++Assistant: I'm doing great. How can I help you today?++User: I'd like to show off how chat templating works!++Assistant:\ No newline at end of filediff --git a/template/testdata/chatqa.gotmpl/user b/template/testdata/chatqa.gotmpl/usernew file mode 100644index 000000000..9e7cf702d--- /dev/null+++ b/template/testdata/chatqa.gotmpl/user@@ -0,0 +1,3 @@+User: Hello, how are you?++Assistant:\ No newline at end of filediff --git a/template/testdata/chatqa.gotmpl/user-assistant-user b/template/testdata/chatqa.gotmpl/user-assistant-usernew file mode 100644index 000000000..405bbe12c--- /dev/null+++ b/template/testdata/chatqa.gotmpl/user-assistant-user@@ -0,0 +1,7 @@+User: Hello, how are you?++Assistant: I'm doing great. How can I help you today?++User: I'd like to show off how chat templating works!++Assistant:\ No newline at end of filediff --git a/template/testdata/codellama-70b-instruct.gotmpl/system-user-assistant-user b/template/testdata/codellama-70b-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..fdd0fc8b4--- /dev/null+++ b/template/testdata/codellama-70b-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,11 @@+Source: system++ You are a helpful assistant. <step> Source: user++ Hello, how are you? <step> Source: assistant++ I'm doing great. How can I help you today? <step> Source: user++ I'd like to show off how chat templating works! <step> Source: assistant+Destination: user+diff --git a/template/testdata/codellama-70b-instruct.gotmpl/user b/template/testdata/codellama-70b-instruct.gotmpl/usernew file mode 100644index 000000000..9e7174a84--- /dev/null+++ b/template/testdata/codellama-70b-instruct.gotmpl/user@@ -0,0 +1,5 @@+Source: user++ Hello, how are you? <step> Source: assistant+Destination: user+diff --git a/template/testdata/codellama-70b-instruct.gotmpl/user-assistant-user b/template/testdata/codellama-70b-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..b4ba1736b--- /dev/null+++ b/template/testdata/codellama-70b-instruct.gotmpl/user-assistant-user@@ -0,0 +1,9 @@+Source: user++ Hello, how are you? <step> Source: assistant++ I'm doing great. How can I help you today? <step> Source: user++ I'd like to show off how chat templating works! <step> Source: assistant+Destination: user+diff --git a/template/testdata/falcon-instruct.gotmpl/system-user-assistant-user b/template/testdata/falcon-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..16e45e5b6--- /dev/null+++ b/template/testdata/falcon-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,8 @@+System: You are a helpful assistant.+User:+Hello, how are you?+Falcon:+I'm doing great. How can I help you today?+User:+I'd like to show off how chat templating works!+Falcon:diff --git a/template/testdata/falcon-instruct.gotmpl/user b/template/testdata/falcon-instruct.gotmpl/usernew file mode 100644index 000000000..110831a2c--- /dev/null+++ b/template/testdata/falcon-instruct.gotmpl/user@@ -0,0 +1,3 @@+User:+Hello, how are you?+Falcon:diff --git a/template/testdata/falcon-instruct.gotmpl/user-assistant-user b/template/testdata/falcon-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..b49639ea5--- /dev/null+++ b/template/testdata/falcon-instruct.gotmpl/user-assistant-user@@ -0,0 +1,7 @@+User:+Hello, how are you?+Falcon:+I'm doing great. How can I help you today?+User:+I'd like to show off how chat templating works!+Falcon:diff --git a/template/testdata/gemma-instruct.gotmpl/system-user-assistant-user b/template/testdata/gemma-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..5f6c37324--- /dev/null+++ b/template/testdata/gemma-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,8 @@+<start_of_turn>user+You are a helpful assistant.+Hello, how are you?<end_of_turn>+<start_of_turn>model+I'm doing great. How can I help you today?<end_of_turn>+<start_of_turn>user+I'd like to show off how chat templating works!<end_of_turn>+<start_of_turn>modeldiff --git a/template/testdata/gemma-instruct.gotmpl/user b/template/testdata/gemma-instruct.gotmpl/usernew file mode 100644index 000000000..dc8b30b68--- /dev/null+++ b/template/testdata/gemma-instruct.gotmpl/user@@ -0,0 +1,3 @@+<start_of_turn>user+Hello, how are you?<end_of_turn>+<start_of_turn>modeldiff --git a/template/testdata/gemma-instruct.gotmpl/user-assistant-user b/template/testdata/gemma-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..1185924b0--- /dev/null+++ b/template/testdata/gemma-instruct.gotmpl/user-assistant-user@@ -0,0 +1,7 @@+<start_of_turn>user+Hello, how are you?<end_of_turn>+<start_of_turn>model+I'm doing great. How can I help you today?<end_of_turn>+<start_of_turn>user+I'd like to show off how chat templating works!<end_of_turn>+<start_of_turn>modeldiff --git a/template/testdata/granite-instruct.gotmpl/system-user-assistant-user b/template/testdata/granite-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..a732a77fb--- /dev/null+++ b/template/testdata/granite-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,13 @@+System:+You are a helpful assistant.++Question:+Hello, how are you?++Answer:+I'm doing great. How can I help you today?++Question:+I'd like to show off how chat templating works!++Answer:diff --git a/template/testdata/granite-instruct.gotmpl/user b/template/testdata/granite-instruct.gotmpl/usernew file mode 100644index 000000000..7abd2ea35--- /dev/null+++ b/template/testdata/granite-instruct.gotmpl/user@@ -0,0 +1,4 @@+Question:+Hello, how are you?++Answer:diff --git a/template/testdata/granite-instruct.gotmpl/user-assistant-user b/template/testdata/granite-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..da5e43eae--- /dev/null+++ b/template/testdata/granite-instruct.gotmpl/user-assistant-user@@ -0,0 +1,10 @@+Question:+Hello, how are you?++Answer:+I'm doing great. How can I help you today?++Question:+I'd like to show off how chat templating works!++Answer:diff --git a/template/testdata/llama2-chat.gotmpl/system-user-assistant-user b/template/testdata/llama2-chat.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..fc2679bf0--- /dev/null+++ b/template/testdata/llama2-chat.gotmpl/system-user-assistant-user@@ -0,0 +1,5 @@+[INST] <<SYS>>+You are a helpful assistant.+<</SYS>>++Hello, how are you? [/INST] I'm doing great. How can I help you today?</s><s>[INST] I'd like to show off how chat templating works! [/INST]\ No newline at end of filediff --git a/template/testdata/llama2-chat.gotmpl/user b/template/testdata/llama2-chat.gotmpl/usernew file mode 100644index 000000000..ceef9bdbb--- /dev/null+++ b/template/testdata/llama2-chat.gotmpl/user@@ -0,0 +1,3 @@+[INST] <<SYS>><</SYS>>++Hello, how are you? [/INST]\ No newline at end of filediff --git a/template/testdata/llama2-chat.gotmpl/user-assistant-user b/template/testdata/llama2-chat.gotmpl/user-assistant-usernew file mode 100644index 000000000..42b4c5294--- /dev/null+++ b/template/testdata/llama2-chat.gotmpl/user-assistant-user@@ -0,0 +1,3 @@+[INST] <<SYS>><</SYS>>++Hello, how are you? [/INST] I'm doing great. How can I help you today?</s><s>[INST] I'd like to show off how chat templating works! [/INST]\ No newline at end of filediff --git a/template/testdata/llama3-instruct.gotmpl/system-user-assistant-user b/template/testdata/llama3-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..6740bcb4d--- /dev/null+++ b/template/testdata/llama3-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,10 @@+<|start_header_id|>system<|end_header_id|>++You are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>++Hello, how are you?<|eot_id|><|start_header_id|>assistant<|end_header_id|>++I'm doing great. How can I help you today?<|eot_id|><|start_header_id|>user<|end_header_id|>++I'd like to show off how chat templating works!<|eot_id|><|start_header_id|>assistant<|end_header_id|>+diff --git a/template/testdata/llama3-instruct.gotmpl/user b/template/testdata/llama3-instruct.gotmpl/usernew file mode 100644index 000000000..470aa028f--- /dev/null+++ b/template/testdata/llama3-instruct.gotmpl/user@@ -0,0 +1,4 @@+<|start_header_id|>user<|end_header_id|>++Hello, how are you?<|eot_id|><|start_header_id|>assistant<|end_header_id|>+diff --git a/template/testdata/llama3-instruct.gotmpl/user-assistant-user b/template/testdata/llama3-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..6dd768af5--- /dev/null+++ b/template/testdata/llama3-instruct.gotmpl/user-assistant-user@@ -0,0 +1,8 @@+<|start_header_id|>user<|end_header_id|>++Hello, how are you?<|eot_id|><|start_header_id|>assistant<|end_header_id|>++I'm doing great. How can I help you today?<|eot_id|><|start_header_id|>user<|end_header_id|>++I'd like to show off how chat templating works!<|eot_id|><|start_header_id|>assistant<|end_header_id|>+diff --git a/template/testdata/magicoder.gotmpl/system-user-assistant-user b/template/testdata/magicoder.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..c966a861d--- /dev/null+++ b/template/testdata/magicoder.gotmpl/system-user-assistant-user@@ -0,0 +1,12 @@+You are a helpful assistant.++@@ Instruction+Hello, how are you?++@@ Response+I'm doing great. How can I help you today?++@@ Instruction+I'd like to show off how chat templating works!++@@ Responsediff --git a/template/testdata/magicoder.gotmpl/user b/template/testdata/magicoder.gotmpl/usernew file mode 100644index 000000000..ccfb02bd2--- /dev/null+++ b/template/testdata/magicoder.gotmpl/user@@ -0,0 +1,4 @@+@@ Instruction+Hello, how are you?++@@ Responsediff --git a/template/testdata/magicoder.gotmpl/user-assistant-user b/template/testdata/magicoder.gotmpl/user-assistant-usernew file mode 100644index 000000000..3aea6dab9--- /dev/null+++ b/template/testdata/magicoder.gotmpl/user-assistant-user@@ -0,0 +1,10 @@+@@ Instruction+Hello, how are you?++@@ Response+I'm doing great. How can I help you today?++@@ Instruction+I'd like to show off how chat templating works!++@@ Responsediff --git a/template/testdata/mistral-instruct.gotmpl/system-user-assistant-user b/template/testdata/mistral-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..b6b4bf93e--- /dev/null+++ b/template/testdata/mistral-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,2 @@+[INST] Hello, how are you?[/INST] I'm doing great. How can I help you today?</s>[INST] You are a helpful assistant.+I'd like to show off how chat templating works![/INST]\ No newline at end of filediff --git a/template/testdata/mistral-instruct.gotmpl/user b/template/testdata/mistral-instruct.gotmpl/usernew file mode 100644index 000000000..b04871e5d--- /dev/null+++ b/template/testdata/mistral-instruct.gotmpl/user@@ -0,0 +1 @@+[INST] Hello, how are you?[/INST]\ No newline at end of filediff --git a/template/testdata/mistral-instruct.gotmpl/user-assistant-user b/template/testdata/mistral-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..b473e0df0--- /dev/null+++ b/template/testdata/mistral-instruct.gotmpl/user-assistant-user@@ -0,0 +1 @@+[INST] Hello, how are you?[/INST] I'm doing great. How can I help you today?</s>[INST] I'd like to show off how chat templating works![/INST]\ No newline at end of filediff --git a/template/testdata/openchat.gotmpl/system-user-assistant-user b/template/testdata/openchat.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..1214c1264--- /dev/null+++ b/template/testdata/openchat.gotmpl/system-user-assistant-user@@ -0,0 +1 @@+GPT Correct System: You are a helpful assistant.<|end_of_turn|>GPT Correct User: Hello, how are you?<|end_of_turn|>GPT Correct Assistant: I'm doing great. How can I help you today?<|end_of_turn|>GPT Correct User: I'd like to show off how chat templating works!<|end_of_turn|>GPT Correct Assistant:\ No newline at end of filediff --git a/template/testdata/openchat.gotmpl/user b/template/testdata/openchat.gotmpl/usernew file mode 100644index 000000000..611daa83e--- /dev/null+++ b/template/testdata/openchat.gotmpl/user@@ -0,0 +1 @@+GPT Correct User: Hello, how are you?<|end_of_turn|>GPT Correct Assistant:\ No newline at end of filediff --git a/template/testdata/openchat.gotmpl/user-assistant-user b/template/testdata/openchat.gotmpl/user-assistant-usernew file mode 100644index 000000000..f97b02b9c--- /dev/null+++ b/template/testdata/openchat.gotmpl/user-assistant-user@@ -0,0 +1 @@+GPT Correct User: Hello, how are you?<|end_of_turn|>GPT Correct Assistant: I'm doing great. How can I help you today?<|end_of_turn|>GPT Correct User: I'd like to show off how chat templating works!<|end_of_turn|>GPT Correct Assistant:\ No newline at end of filediff --git a/template/testdata/phi-3.gotmpl/system-user-assistant-user b/template/testdata/phi-3.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..6109a9a24--- /dev/null+++ b/template/testdata/phi-3.gotmpl/system-user-assistant-user@@ -0,0 +1,9 @@+<|system|>+You are a helpful assistant.<|end|>+<|user|>+Hello, how are you?<|end|>+<|assistant|>+I'm doing great. How can I help you today?<|end|>+<|user|>+I'd like to show off how chat templating works!<|end|>+<|assistant|>diff --git a/template/testdata/phi-3.gotmpl/user b/template/testdata/phi-3.gotmpl/usernew file mode 100644index 000000000..feb96e7c9--- /dev/null+++ b/template/testdata/phi-3.gotmpl/user@@ -0,0 +1,3 @@+<|user|>+Hello, how are you?<|end|>+<|assistant|>diff --git a/template/testdata/phi-3.gotmpl/user-assistant-user b/template/testdata/phi-3.gotmpl/user-assistant-usernew file mode 100644index 000000000..db79d01c1--- /dev/null+++ b/template/testdata/phi-3.gotmpl/user-assistant-user@@ -0,0 +1,7 @@+<|user|>+Hello, how are you?<|end|>+<|assistant|>+I'm doing great. How can I help you today?<|end|>+<|user|>+I'd like to show off how chat templating works!<|end|>+<|assistant|>diff --git a/template/testdata/solar-instruct.gotmpl/system-user-assistant-user b/template/testdata/solar-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..28c1730ab--- /dev/null+++ b/template/testdata/solar-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,13 @@+### System:+You are a helpful assistant.++### User:+Hello, how are you?++### Assistant:+I'm doing great. How can I help you today?</s>++### User:+I'd like to show off how chat templating works!++### Assistant:diff --git a/template/testdata/solar-instruct.gotmpl/user b/template/testdata/solar-instruct.gotmpl/usernew file mode 100644index 000000000..3a43382af--- /dev/null+++ b/template/testdata/solar-instruct.gotmpl/user@@ -0,0 +1,4 @@+### User:+Hello, how are you?++### Assistant:diff --git a/template/testdata/solar-instruct.gotmpl/user-assistant-user b/template/testdata/solar-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..8553e73ba--- /dev/null+++ b/template/testdata/solar-instruct.gotmpl/user-assistant-user@@ -0,0 +1,10 @@+### User:+Hello, how are you?++### Assistant:+I'm doing great. How can I help you today?</s>++### User:+I'd like to show off how chat templating works!++### Assistant:diff --git a/template/testdata/starcoder2-instruct.gotmpl/system-user-assistant-user b/template/testdata/starcoder2-instruct.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..5b718b3ec--- /dev/null+++ b/template/testdata/starcoder2-instruct.gotmpl/system-user-assistant-user@@ -0,0 +1,12 @@+You are a helpful assistant.++### Instruction+Hello, how are you?++### Response+I'm doing great. How can I help you today?<|endoftext|>++### Instruction+I'd like to show off how chat templating works!++### Responsediff --git a/template/testdata/starcoder2-instruct.gotmpl/user b/template/testdata/starcoder2-instruct.gotmpl/usernew file mode 100644index 000000000..11b0be1fe--- /dev/null+++ b/template/testdata/starcoder2-instruct.gotmpl/user@@ -0,0 +1,4 @@+### Instruction+Hello, how are you?++### Responsediff --git a/template/testdata/starcoder2-instruct.gotmpl/user-assistant-user b/template/testdata/starcoder2-instruct.gotmpl/user-assistant-usernew file mode 100644index 000000000..d99feabb0--- /dev/null+++ b/template/testdata/starcoder2-instruct.gotmpl/user-assistant-user@@ -0,0 +1,10 @@+### Instruction+Hello, how are you?++### Response+I'm doing great. How can I help you today?<|endoftext|>++### Instruction+I'd like to show off how chat templating works!++### Responsediff --git a/template/testdata/vicuna.gotmpl/system-user-assistant-user b/template/testdata/vicuna.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..50d2f92c1--- /dev/null+++ b/template/testdata/vicuna.gotmpl/system-user-assistant-user@@ -0,0 +1,6 @@+You are a helpful assistant.++USER: Hello, how are you?+ASSISTANT: I'm doing great. How can I help you today?</s>+USER: I'd like to show off how chat templating works!+ASSISTANT:\ No newline at end of filediff --git a/template/testdata/vicuna.gotmpl/user b/template/testdata/vicuna.gotmpl/usernew file mode 100644index 000000000..cbe5ef709--- /dev/null+++ b/template/testdata/vicuna.gotmpl/user@@ -0,0 +1,2 @@+USER: Hello, how are you?+ASSISTANT:\ No newline at end of filediff --git a/template/testdata/vicuna.gotmpl/user-assistant-user b/template/testdata/vicuna.gotmpl/user-assistant-usernew file mode 100644index 000000000..9172547e3--- /dev/null+++ b/template/testdata/vicuna.gotmpl/user-assistant-user@@ -0,0 +1,4 @@+USER: Hello, how are you?+ASSISTANT: I'm doing great. How can I help you today?</s>+USER: I'd like to show off how chat templating works!+ASSISTANT:\ No newline at end of filediff --git a/template/testdata/zephyr.gotmpl/system-user-assistant-user b/template/testdata/zephyr.gotmpl/system-user-assistant-usernew file mode 100644index 000000000..03d43fc34--- /dev/null+++ b/template/testdata/zephyr.gotmpl/system-user-assistant-user@@ -0,0 +1,9 @@+<|system|>+You are a helpful assistant.</s>+<|user|>+Hello, how are you?</s>+<|assistant|>+I'm doing great. How can I help you today?</s>+<|user|>+I'd like to show off how chat templating works!</s>+<|assistant|>diff --git a/template/testdata/zephyr.gotmpl/user b/template/testdata/zephyr.gotmpl/usernew file mode 100644index 000000000..6cefdaa0f--- /dev/null+++ b/template/testdata/zephyr.gotmpl/user@@ -0,0 +1,3 @@+<|user|>+Hello, how are you?</s>+<|assistant|>diff --git a/template/testdata/zephyr.gotmpl/user-assistant-user b/template/testdata/zephyr.gotmpl/user-assistant-usernew file mode 100644index 000000000..3937b006a--- /dev/null+++ b/template/testdata/zephyr.gotmpl/user-assistant-user@@ -0,0 +1,7 @@+<|user|>+Hello, how are you?</s>+<|assistant|>+I'm doing great. How can I help you today?</s>+<|user|>+I'd like to show off how chat templating works!</s>+<|assistant|>diff --git a/template/vicuna.gotmpl b/template/vicuna.gotmplindex 174c1a353..2e13e990d 100644--- a/template/vicuna.gotmpl+++ b/template/vicuna.gotmpl@@ -1,3 +1,14 @@+{{- if .Messages }}+{{- if .System }}{{ .System }}++{{ end }}+{{- range .Messages }}+{{- if eq .Role "user" }}USER: {{ .Content }}+{{ else if eq .Role "assistant" }}ASSISTANT: {{ .Content }}</s>+{{ end }}+{{- end }}ASSISTANT:+{{- else }}{{ if .System }}{{ .System }}{{ end }}{{ if .Prompt }}USER: {{ .Prompt }}-{{ end }}ASSISTANT: {{ .Response }}\ No newline at end of file+{{ end }}ASSISTANT: {{ .Response }}+{{- end }}\ No newline at end of filediff --git a/template/zephyr.gotmpl b/template/zephyr.gotmplindex aac0c7a1f..e66688480 100644--- a/template/zephyr.gotmpl+++ b/template/zephyr.gotmpl@@ -1,6 +1,15 @@+{{- if .Messages }}+{{- if .System }}<|system|>+{{ .System }}</s>+{{ end }}+{{- range .Messages }}<|{{ .Role }}|>+{{ .Content }}</s>+{{ end }}<|assistant|>+{{ else }}{{ if .System }}<|system|>{{ .System }}</s>{{ end }}{{ if .Prompt }}<|user|>{{ .Prompt }}</s>{{ end }}<|assistant|>-{{ .Response }}</s>\ No newline at end of file+{{ .Response }}</s>+{{- end }}\ No newline at end of file