[PR #7026] server: fix custom template capabiliy checking for generation. (Fixes #7052) #74583

Open
opened 2026-05-05 06:44:36 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7026
Author: @kyRobot
Created: 9/29/2024
Status: 🔄 Open

Base: mainHead: handle-custom-template-capability-check


📝 Commits (9)

  • 1e96996 server: fix custom template capabiliy checking for generation
  • d819fe3 Merge branch 'main' into handle-custom-template-capability-check
  • 035e83c Merge branch 'main' into handle-custom-template-capability-check
  • 5b738bf Merge branch 'main' into handle-custom-template-capability-check
  • e4b85c9 Merge branch 'main' into handle-custom-template-capability-check
  • abd8b7e Merge branch 'main' into handle-custom-template-capability-check
  • a5e518b Merge branch 'main' into handle-custom-template-capability-check
  • 3ba4d50 Merge branch 'main' into handle-custom-template-capability-check
  • ca10dde Merge branch 'main' into handle-custom-template-capability-check

📊 Changes

5 files changed (+79 additions, -10 deletions)

View changed files

📝 server/images.go (+2 -3)
📝 server/routes.go (+20 -7)
📝 server/routes_generate_test.go (+47 -0)
📝 template/template.go (+4 -0)
📝 template/template_test.go (+6 -0)

📄 Description

Closes #7052

Model capability checks for e.g Fill-In-Middle tasks (named insert for Capability) check that the Model Template includes the required template variables for the task

This PR addresses an issue where only the Template from the Modelfile was used to decide on capability rather than the request template when provided which causes failed requests even when the custom template does have the required variables.

Now, when a custom template is provided, the capability check acts on it, not the modelfile template. This allows callers to successfully override model templates in cases where the modelfile does not include an appropriate template or when the caller does not want to use raw request format as an override i.e they wish to take advantage of the templating capability.

Note: This is only for completion generation where template overrides are enabled.

  • tests
  • minor addition to template.go to add a func on Template to ask what it supports vs callers grabbing the Vars directly. This func is used by Images.Model capability check & in routes.go

Broaded Context: This Issue was identified when using Continue.dev pre-release which moves Continue to use ollama Suffix support for tab completion tasks. Using a completion model e.g Qwen2.5 Coder 1.5B base which has the default {{.Prompt}} template, this did not work due to the compatibility check for {{.Suffix}} failing. Sending a custom template also did not work due to the incorrectly targetted compatibility check. With this PR Continue autocompletion with Ollama custom templates now works. This also works via api, and is exercised in the new tests


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/7026 **Author:** [@kyRobot](https://github.com/kyRobot) **Created:** 9/29/2024 **Status:** 🔄 Open **Base:** `main` ← **Head:** `handle-custom-template-capability-check` --- ### 📝 Commits (9) - [`1e96996`](https://github.com/ollama/ollama/commit/1e96996db8ffc306370846dd0bb5d7c2f57e511c) server: fix custom template capabiliy checking for generation - [`d819fe3`](https://github.com/ollama/ollama/commit/d819fe3ec0658f3df328a041056f7a817b1cb149) Merge branch 'main' into handle-custom-template-capability-check - [`035e83c`](https://github.com/ollama/ollama/commit/035e83c1267f0f616936b4919ded38584dcd826f) Merge branch 'main' into handle-custom-template-capability-check - [`5b738bf`](https://github.com/ollama/ollama/commit/5b738bffd0684eb34c57295716a7d1f82d3cedc6) Merge branch 'main' into handle-custom-template-capability-check - [`e4b85c9`](https://github.com/ollama/ollama/commit/e4b85c92e767e53b2a181f44698e78ac2ea1829c) Merge branch 'main' into handle-custom-template-capability-check - [`abd8b7e`](https://github.com/ollama/ollama/commit/abd8b7eba0b88ba84854306030921b03f5dd6a89) Merge branch 'main' into handle-custom-template-capability-check - [`a5e518b`](https://github.com/ollama/ollama/commit/a5e518baafcb88746099e567b272a067ba3a7ce2) Merge branch 'main' into handle-custom-template-capability-check - [`3ba4d50`](https://github.com/ollama/ollama/commit/3ba4d500f5759d42671f8430ba868c33d0f6e4f8) Merge branch 'main' into handle-custom-template-capability-check - [`ca10dde`](https://github.com/ollama/ollama/commit/ca10dde0cba59bbb3d02a8d7600949cc03bfe4c8) Merge branch 'main' into handle-custom-template-capability-check ### 📊 Changes **5 files changed** (+79 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `server/images.go` (+2 -3) 📝 `server/routes.go` (+20 -7) 📝 `server/routes_generate_test.go` (+47 -0) 📝 `template/template.go` (+4 -0) 📝 `template/template_test.go` (+6 -0) </details> ### 📄 Description Closes #7052 Model capability checks for e.g Fill-In-Middle tasks (named insert for Capability) check that the Model Template includes the required template variables for the task This PR addresses an issue where only the Template from the Modelfile was used to decide on capability rather than the request template when provided which causes failed requests even when the custom template does have the required variables. Now, when a custom template is provided, the capability check acts on it, not the modelfile template. This allows callers to successfully override model templates in cases where the modelfile does not include an appropriate template or when the caller does not want to use raw request format as an override i.e they wish to take advantage of the templating capability. Note: This is only for completion generation where template overrides are enabled. - tests - minor addition to `template.go` to add a func on Template to ask what it supports vs callers grabbing the Vars directly. This func is used by `Images.Model` capability check & in `routes.go` Broaded Context: This Issue was identified when using Continue.dev pre-release which moves Continue to use ollama Suffix support for tab completion tasks. Using a completion model e.g Qwen2.5 Coder 1.5B base which has the default `{{.Prompt}}` template, this did not work due to the compatibility check for `{{.Suffix}}` failing. Sending a custom template also did not work due to the incorrectly targetted compatibility check. With this PR Continue autocompletion with Ollama custom templates now works. This also works via api, and is exercised in the new tests --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 06:44:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#74583