|
1 | 1 | // This file is auto generated, please do not modify manually |
2 | 2 | // To update it, run "pnpm run build:automap" |
3 | 3 |
|
4 | | -import type { OllamaChatTemplateMapEntry } from "./types"; |
| 4 | +import { OllamaChatTemplateMapEntry } from "./types"; |
5 | 5 |
|
6 | 6 | /** |
7 | 7 | * Skipped these models due to error: |
8 | | - * - library/llama3-groq-tool-use:70b |
9 | | - * - library/athene-v2:72b |
| 8 | + * - library/qwen2-math:72b |
| 9 | + * - library/falcon:180b |
| 10 | + * - library/stable-beluga:13b |
10 | 11 | */ |
11 | 12 |
|
12 | 13 | export const OLLAMA_CHAT_TEMPLATE_MAPPING: OllamaChatTemplateMapEntry[] = [ |
@@ -831,6 +832,19 @@ export const OLLAMA_CHAT_TEMPLATE_MAPPING: OllamaChatTemplateMapEntry[] = [ |
831 | 832 | }, |
832 | 833 | }, |
833 | 834 | }, |
| 835 | + { |
| 836 | + model: "library/qwq:32b", |
| 837 | + gguf: "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- '' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" and not message.tool_calls %}\n {%- set content = message.content.split('</think>')[-1].lstrip('\\n') %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content.split('</think>')[-1].lstrip('\\n') %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n<think>\\n' }}\n{%- endif %}\n", |
| 838 | + ollama: { |
| 839 | + template: |
| 840 | + '{{- if or .System .Tools }}<|im_start|>system\n{{- if .System }}\n{{ .System }}\n{{- end }}\n{{- if .Tools }}\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>\n{{- range .Tools }}\n{"type": "function", "function": {{ .Function }}}\n{{- end }}\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{"name": <function-name>, "arguments": <args-json-object>}\n</tool_call>\n{{- end }}<|im_end|>\n{{ end }}\n{{- range $i, $_ := .Messages }}\n{{- $last := eq (len (slice $.Messages $i)) 1 -}}\n{{- if eq .Role "user" }}<|im_start|>user\n{{ .Content }}<|im_end|>\n{{ else if eq .Role "assistant" }}<|im_start|>assistant\n{{ if .Content }}{{ .Content }}\n{{- else if .ToolCalls }}<tool_call>\n{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}\n{{ end }}</tool_call>\n{{- end }}{{ if not $last }}<|im_end|>\n{{ end }}\n{{- else if eq .Role "tool" }}<|im_start|>user\n<tool_response>\n{{ .Content }}\n</tool_response><|im_end|>\n{{ end }}\n{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant\n{{ end }}\n{{- end }}', |
| 841 | + tokens: ["<|im_start|>", "<tools>", "<tool_call>", "<|im_end|>", "<tool_response>", "<think>"], |
| 842 | + params: { |
| 843 | + stop: ["<|im_start|>", "<|im_end|>"], |
| 844 | + temperature: 0.6, |
| 845 | + }, |
| 846 | + }, |
| 847 | + }, |
834 | 848 | { |
835 | 849 | model: "library/r1-1776:671b", |
836 | 850 | gguf: "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{% set ns.system_prompt = ns.system_prompt + message['content'] %}{% set ns.is_first_sp = false %}{%- else %}{% set ns.system_prompt = ns.system_prompt + '\\n\\n' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{{ bos_token }}{{ ns.system_prompt }}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<ď˝Userď˝>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' in message %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls'] %}{%- if not ns.is_first %}{%- if message['content'] is none %}{{'<ď˝Assistantď˝><ď˝toolâcallsâbeginď˝><ď˝toolâcallâbeginď˝>' + tool['type'] + '<ď˝toolâsepď˝>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<ď˝toolâcallâendď˝>'}}{%- else %}{{'<ď˝Assistantď˝>' + message['content'] + '<ď˝toolâcallsâbeginď˝><ď˝toolâcallâbeginď˝>' + tool['type'] + '<ď˝toolâsepď˝>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<ď˝toolâcallâendď˝>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{'\\n' + '<ď˝toolâcallâbeginď˝>' + tool['type'] + '<ď˝toolâsepď˝>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<ď˝toolâcallâendď˝>'}}{%- endif %}{%- endfor %}{{'<ď˝toolâcallsâendď˝><ď˝endâofâsentenceď˝>'}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' not in message %}{%- if ns.is_tool %}{{'<ď˝toolâoutputsâendď˝>' + message['content'] + '<ď˝endâofâsentenceď˝>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{{'<ď˝Assistantď˝>' + content + '<ď˝endâofâsentenceď˝>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<ď˝toolâoutputsâbeginď˝><ď˝toolâoutputâbeginď˝>' + message['content'] + '<ď˝toolâoutputâendď˝>'}}{%- set ns.is_output_first = false %}{%- else %}{{'<ď˝toolâoutputâbeginď˝>' + message['content'] + '<ď˝toolâoutputâendď˝>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<ď˝toolâoutputsâendď˝>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<ď˝Assistantď˝>'}}{% endif %}", |
|
0 commit comments