From 9e8a4b5f34cfefa2fa0c6def27c10d7a5e51dc9b Mon Sep 17 00:00:00 2001 From: tom-mi Date: Fri, 14 Aug 2026 15:04:12 +0200 Subject: [PATCH] fix (gallery): Parse harmony output of gpt-oss-* models correctly (#8037) (#11518) fix: Parse harmony output of gpt-oss-* models correctly (#8037) * Delegate templating to llama.cpp's jinja runtime Assisted-by: opencode:GLM-5.2 Signed-off-by: Thomas Reifenberger --- gallery/harmony.yaml | 64 +++++++------------------------------------- 1 file changed, 9 insertions(+), 55 deletions(-) diff --git a/gallery/harmony.yaml b/gallery/harmony.yaml index 2fca5d821..4e975d3ad 100644 --- a/gallery/harmony.yaml +++ b/gallery/harmony.yaml @@ -5,65 +5,19 @@ config_file: | known_usecases: - chat mmap: true + # Delegate templating to llama.cpp's jinja runtime so the C++ autoparser + # can classify the harmony <|channel|> sections into reasoning_content / + # content / tool_calls natively. Without use_jinja the autoparser falls + # back to a "pure content" PEG parser that leaks the channel tags into + # content. + options: + - use_jinja:true + template: + use_tokenizer_template: true stopwords: - <|im_end|> - - - <|endoftext|> - <|return|> - template: - chat: |- - <|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI. - Knowledge cutoff: 2024-06 - Current date: {{ now | date "Mon Jan 2 15:04:05 MST 2006" }} - - Reasoning: {{if eq .ReasoningEffort ""}}medium{{else}}{{.ReasoningEffort}}{{end}} - - # {{with .Metadata}}{{ if ne .system_prompt "" }}{{ .system_prompt }}{{ end }}{{else}}You are a friendly and helpful assistant.{{ end }}<|end|>{{- .Input -}}<|start|>assistant - chat_message: |- - <|start|>{{ if .FunctionCall -}}functions.{{ .FunctionCall.Name }} to=assistant{{ else if eq .RoleName "assistant"}}assistant<|channel|>final<|message|>{{else}}{{ .RoleName }}{{end}}<|message|> - {{- if .Content -}} - {{- .Content -}} - {{- end -}} - {{- if .FunctionCall -}} - {{- toJson .FunctionCall -}} - {{- end -}}<|end|> - completion: | - {{.Input}} - function: |- - <|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI. - Knowledge cutoff: 2024-06 - Current date: {{ now | date "Mon Jan 2 15:04:05 MST 2006" }} - - Reasoning: {{if eq .ReasoningEffort ""}}medium{{else}}{{.ReasoningEffort}}{{end}} - - # {{with .Metadata}}{{ if ne .system_prompt "" }}{{ .system_prompt }}{{ end }}{{else}}You are a friendly and helpful assistant.{{ end }}<|end|>{{- .Input -}}<|start|>assistant - - # Tools - - ## functions - - namespace functions { - {{-range .Functions}} - {{if .Description }} - // {{ .Description }} - {{- end }} - {{- if and .Parameters.Properties (gt (len .Parameters.Properties) 0) }} - type {{ .Name }} = (_: { - {{- range $name, $prop := .Parameters.Properties }} - {{- if $prop.Description }} - // {{ $prop.Description }} - {{- end }} - {{ $name }}: {{ if gt (len $prop.Type) 1 }}{{ range $i, $t := $prop.Type }}{{ if $i }} | {{ end }}{{ $t }}{{ end }}{{ else }}{{ index $prop.Type 0 }}{{ end }}, - {{- end }} - }) => any; - {{- else }} - type {{ .Function.Name }} = () => any; - {{- end }} - {{- end }}{{/* end of range .Functions */}} - } // namespace functions - - # Instructions - - <|end|>{{.Input -}}<|start|>assistant name: harmony