Skip to content

Commit 57ba38e

Browse files
committed
ollama: fix gemma2 template
1 parent 86ec6ef commit 57ba38e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/ollama-utils/src/chat-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const CUSTOM_TEMPLATE_MAPPING: ((ggufTmpl: string) => OllamaCustomMappedTemplate
3131
? {
3232
// for some reason, gemma2 has weird variants
3333
ollamaTmpl:
34-
"<start_of_turn>user\n{{ if .System }}{{ .System }} {{ end }}{{ .Prompt }}<end_of_turn>\n<start_of_turn>model\n{{ .Response }}<end_of_turn>\n",
34+
'{{- range $i, $_ := .Messages }}\n{{- $last := eq (len (slice $.Messages $i)) 1 }}\n{{- if or (eq .Role "user") (eq .Role "system") }}<start_of_turn>user\n{{ .Content }}<end_of_turn>\n{{ if $last }}<start_of_turn>model\n{{ end }}\n{{- else if eq .Role "assistant" }}<start_of_turn>model\n{{ .Content }}{{ if not $last }}<end_of_turn>\n{{ end }}\n{{- end }}\n{{- end }}',
3535
stop: "<end_of_turn>",
3636
}
3737
: undefined,

0 commit comments

Comments
 (0)