[PR #1427] [MERGED] post-response templating #36454

Closed
opened 2026-04-22 21:06:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/1427
Author: @BruceMacD
Created: 12/8/2023
Status: Merged
Merged: 12/22/2023
Merged by: @BruceMacD

Base: mainHead: brucemacd/post-response-template


📝 Commits (2)

  • 2338377 post-response templating
  • f5996c2 use template nodes rather than regex

📊 Changes

3 files changed (+333 additions, -15 deletions)

View changed files

📝 server/images.go (+72 -12)
📝 server/images_test.go (+249 -0)
📝 server/routes.go (+12 -3)

📄 Description

  • add post-response templating to /generate
  • add post-response templating to /chat
  • add templating tests

A common format for LLM templating may include post-response templating. Our current template format kind of supported this by checking {{ if not .First }} but it is confusing to read. This change allows post-response templating to be applied.

Here is an example of a format that is now supported:

<|im_start|>user
{{ .Prompt }}<|im_end|>
<|im_start|>assistant
{{ .Response }}<|im_end|>

Current templates are not effected.

Follow-up: docs

Resolves: #1423


🔄 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/1427 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 12/8/2023 **Status:** ✅ Merged **Merged:** 12/22/2023 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/post-response-template` --- ### 📝 Commits (2) - [`2338377`](https://github.com/ollama/ollama/commit/23383778352a3cddb05000a8af79a5dd88572f9e) post-response templating - [`f5996c2`](https://github.com/ollama/ollama/commit/f5996c23571341a6980da4b05585afda8ab2ef5b) use template nodes rather than regex ### 📊 Changes **3 files changed** (+333 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `server/images.go` (+72 -12) 📝 `server/images_test.go` (+249 -0) 📝 `server/routes.go` (+12 -3) </details> ### 📄 Description - add post-response templating to /generate - add post-response templating to /chat - add templating tests A common format for LLM templating may include post-response templating. Our current template format kind of supported this by checking `{{ if not .First }}` but it is confusing to read. This change allows post-response templating to be applied. Here is an example of a format that is now supported: ``` <|im_start|>user {{ .Prompt }}<|im_end|> <|im_start|>assistant {{ .Response }}<|im_end|> ``` Current templates are not effected. Follow-up: docs Resolves: #1423 --- <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-04-22 21:06:13 -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#36454