Created
August 2, 2025 05:44
-
-
Save ynniv/bdfc5258b152ee1a4b17498a9b6c1954 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Fixed Modelfile for Qwen3-Coder using Llama 3.1-style tool calling | |
| FROM qwen3-coder:30b | |
| TEMPLATE """{{- $lastUserIdx := -1 -}} | |
| {{- range $idx, $msg := .Messages -}} | |
| {{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}} | |
| {{- end }} | |
| {{- if or .System .Tools }}<|im_start|>system | |
| {{ if .System }} | |
| {{ .System }} | |
| {{- end }} | |
| {{- if .Tools }} | |
| You are a helpful assistant with tool calling capabilities. | |
| {{- end -}} | |
| <|im_end|> | |
| {{ end }} | |
| {{- range $i, $_ := .Messages }} | |
| {{- $last := eq (len (slice $.Messages $i)) 1 -}} | |
| {{- if eq .Role "user" }}<|im_start|>user | |
| {{- if and $.Tools $last }} | |
| Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt. | |
| Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. Do not use variables. | |
| {{- range $.Tools }} | |
| {{ .Function }} | |
| {{- end }} | |
| Question: {{ .Content }}<|im_end|> | |
| {{- else }} | |
| {{ .Content }}<|im_end|> | |
| {{- end }}{{ if $last }}<|im_start|>assistant | |
| {{ end }} | |
| {{- else if eq .Role "assistant" }}<|im_start|>assistant | |
| {{ if (and $.IsThinkSet (and .Thinking (or $last (gt $i $lastUserIdx)))) -}} | |
| <think>{{ .Thinking }}</think> | |
| {{ end -}} | |
| {{- if .ToolCalls }} | |
| {{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}}{{ end }} | |
| {{- else }} | |
| {{ .Content }} | |
| {{- end }}{{ if not $last }}<|im_end|> | |
| {{ end }} | |
| {{- else if eq .Role "tool" }}<|im_start|>user | |
| <tool_response> | |
| {{ .Content }} | |
| </tool_response><|im_end|> | |
| {{ if $last }}<|im_start|>assistant | |
| {{ end }} | |
| {{- end }} | |
| {{- end }}""" | |
| PARAMETER top_k 20 | |
| PARAMETER top_p 0.8 | |
| PARAMETER repeat_penalty 1.05 | |
| PARAMETER stop <|im_start|> | |
| PARAMETER stop <|im_end|> | |
| PARAMETER stop <|endoftext|> | |
| PARAMETER temperature 0.7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment