[PR #14248] fix: reduce vertical spacing in collated assistant messages #14589

Open
opened 2026-04-13 00:58:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14248
Author: @BurakBebek1
Created: 2/14/2026
Status: 🔄 Open

Base: mainHead: fix-only-spacing


📝 Commits (1)

  • e924b27 fix: reduce vertical spacing in collated messages

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 template/template.go (+1 -1)

📄 Description

Description:

This PR fixes an issue where numbered lists (and other consecutive assistant messages) appear with excessive vertical whitespace in GUIs.

The Problem:

In template/template.go, the collate function merges consecutive messages of the same role using \n\n as a separator. When an LLM generates a numbered list across multiple turns or when messages are merged, this double newline forces Markdown renderers to treat each list item as a separate paragraph block, creating large gaps.

The Fix:

Changed the message separator in the collate function from \n\n to \n. This ensures that consecutive messages maintain a "tight" list structure in Markdown while still providing a clear line break.

Verification:

Before: Two assistant messages "1. Item" and "2. Item" merged as "1. Item\n\n2. Item", causing UI padding issues.

After: They merge as "1. Item\n2. Item", resulting in a clean, compact numbered list.

Before the Development

curl http://localhost:11434/api/chat -d '{l http://localhost:11434/api/chat -d '{
"model": "gemma3:4b",
"messages": [
{ "role": "user", "content": "Test isteği" },
{ "role": "assistant", "content": "1. Birinci madde" },
{ "role": "assistant", "content": "2. İkinci madde" }
],
"stream": false
}'
{"model":"gemma3:4b","created_at":"2026-02-14T07:49:16.912032932Z","message":{"role":"assistant","content":"\n\n3. Üçüncü madde\n\nTest tamamlandı. Başka bir test yapmak ister misiniz?\n"},"done":true,"done_reason":"stop","total_duration":15553528734,"load_duration":14343479814,"prompt_eval_count":24,"prompt_eval_duration":207596227,"eval_count":24,"eval_duration":854874092}

After the Development

curl http://localhost:11434/api/chat -d '{
"model": "gemma3:4b",
"messages": [
{ "role": "user", "content": "Test isteği" },
{ "role": "assistant", "content": "1. Birinci madde" },
{ "role": "assistant", "content": "2. İkinci madde" }
],
"stream": false
}'
{"model":"gemma3:4b","created_at":"2026-02-14T07:52:30.050331549Z","message":{"role":"assistant","content":"\n3. Üçüncü madde\n\nBu, basit bir test isteğiydi. Başka bir şey test etmek mi istersiniz? Örneğin, belirli bir konuda bilgi test edebilirim, bir problem çözebilirim veya bir konuyu açıklayabilirim.\n"},"done":true,"done_reason":"stop","total_duration":15661340756,"load_duration":12678836526,"prompt_eval_count":24,"prompt_eval_duration":230992784,"eval_count":56,"eval_duration":2005354518}

Fixes: #14239


🔄 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/14248 **Author:** [@BurakBebek1](https://github.com/BurakBebek1) **Created:** 2/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-only-spacing` --- ### 📝 Commits (1) - [`e924b27`](https://github.com/ollama/ollama/commit/e924b2773a7a21084e03bcd1ae4dbdf3d9dbc836) fix: reduce vertical spacing in collated messages ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `template/template.go` (+1 -1) </details> ### 📄 Description ### Description: This PR fixes an issue where numbered lists (and other consecutive assistant messages) appear with excessive vertical whitespace in GUIs. --- ### The Problem: In template/template.go, the collate function merges consecutive messages of the same role using \n\n as a separator. When an LLM generates a numbered list across multiple turns or when messages are merged, this double newline forces Markdown renderers to treat each list item as a separate paragraph block, creating large gaps. --- ### The Fix: Changed the message separator in the collate function from \n\n to \n. This ensures that consecutive messages maintain a "tight" list structure in Markdown while still providing a clear line break. --- ### Verification: Before: Two assistant messages "1. Item" and "2. Item" merged as "1. Item\n\n2. Item", causing UI padding issues. After: They merge as "1. Item\n2. Item", resulting in a clean, compact numbered list. --- ### Before the Development curl http://localhost:11434/api/chat -d '{l http://localhost:11434/api/chat -d '{ "model": "gemma3:4b", "messages": [ { "role": "user", "content": "Test isteği" }, { "role": "assistant", "content": "1. Birinci madde" }, { "role": "assistant", "content": "2. İkinci madde" } ], "stream": false }' {"model":"gemma3:4b","created_at":"2026-02-14T07:49:16.912032932Z","message":{"role":"assistant","content":"\n\n3. Üçüncü madde\n\nTest tamamlandı. Başka bir test yapmak ister misiniz?\n"},"done":true,"done_reason":"stop","total_duration":15553528734,"load_duration":14343479814,"prompt_eval_count":24,"prompt_eval_duration":207596227,"eval_count":24,"eval_duration":854874092} --- ### After the Development curl http://localhost:11434/api/chat -d '{ "model": "gemma3:4b", "messages": [ { "role": "user", "content": "Test isteği" }, { "role": "assistant", "content": "1. Birinci madde" }, { "role": "assistant", "content": "2. İkinci madde" } ], "stream": false }' {"model":"gemma3:4b","created_at":"2026-02-14T07:52:30.050331549Z","message":{"role":"assistant","content":"\n3. Üçüncü madde\n\nBu, basit bir test isteğiydi. Başka bir şey test etmek mi istersiniz? Örneğin, belirli bir konuda bilgi test edebilirim, bir problem çözebilirim veya bir konuyu açıklayabilirim.\n"},"done":true,"done_reason":"stop","total_duration":15661340756,"load_duration":12678836526,"prompt_eval_count":24,"prompt_eval_duration":230992784,"eval_count":56,"eval_duration":2005354518} Fixes: #14239 --- <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-13 00:58:42 -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#14589