ollama/template
Devon Rifkin c87b910232 WIP: stable ordering for tool args
Right now we deserialize tool call definitions' arguments into golang
maps. These purposefully don't have a predictable iteration order,
whereas we want to maintain the order the user originally provided.

Unstable rendering of arguments means that we break the kv cache, which
this change fixes.

There's no way to build this in a fully backwards compatible way when
executing existing templates exactly as they are. We get around this by
rewriting templates dynamically just before they're rendered. This is
fragile, but perhaps the least bad option?
2025-10-07 15:38:58 -07:00
..
testdata templates: add autotemplate for gemma3 (#9880) 2025-03-20 00:15:30 -07:00
alfred.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
alfred.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
alpaca.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
alpaca.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
chatml.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
chatml.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
chatqa.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
chatqa.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
codellama-70b-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
codellama-70b-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
command-r.gotmpl convert: import support for command-r models from safetensors (#6063) 2025-01-15 16:31:22 -08:00
command-r.json convert: import support for command-r models from safetensors (#6063) 2025-01-15 16:31:22 -08:00
falcon-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
falcon-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
gemma-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
gemma-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
gemma3-instruct.gotmpl templates: add autotemplate for gemma3 (#9880) 2025-03-20 00:15:30 -07:00
gemma3-instruct.json templates: add autotemplate for gemma3 (#9880) 2025-03-20 00:15:30 -07:00
granite-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
granite-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
index.json templates: add autotemplate for gemma3 (#9880) 2025-03-20 00:15:30 -07:00
llama2-chat.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
llama2-chat.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
llama3-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
llama3-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
magicoder.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
magicoder.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
mistral-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
mistral-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
openchat.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
openchat.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
phi-3.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
phi-3.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
rewrite.go WIP: stable ordering for tool args 2025-10-07 15:38:58 -07:00
rewrite_test.go WIP: stable ordering for tool args 2025-10-07 15:38:58 -07:00
solar-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
solar-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
starcoder2-instruct.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
starcoder2-instruct.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
template.go WIP: stable ordering for tool args 2025-10-07 15:38:58 -07:00
template_test.go test: add template error test (#12489) 2025-10-03 12:05:34 -07:00
vicuna.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
vicuna.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00
zephyr.gotmpl update templates to use messages 2024-08-27 15:44:04 -07:00
zephyr.json autodetect stop parameters from template 2024-07-12 16:01:23 -07:00