[PR #7980] [MERGED] prompt: Don't trim whitespace from prompts #74875

Closed
opened 2026-05-05 07:11:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7980
Author: @jessegross
Created: 12/6/2024
Status: Merged
Merged: 12/9/2024
Merged by: @jessegross

Base: mainHead: jessegross/prompt


📝 Commits (1)

  • 342c582 prompt: Don't trim whitespace from prompts

📊 Changes

2 files changed (+6 additions, -7 deletions)

View changed files

📝 server/prompt.go (+1 -2)
📝 server/prompt_test.go (+5 -5)

📄 Description

New lines can be an important part of a user's prompt and trimming it can alter the results. We previously only trimmed prompts with images but refactoring brought this behavior to all prompts, where it became more noticeable.

The /generate endpoint adds less whitespace and therefore doesn't need to trim it out - this brings the same behavior to /chat.

Thanks to @gabe-l-hart for spotting the issue!

Fixes #7795


🔄 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/7980 **Author:** [@jessegross](https://github.com/jessegross) **Created:** 12/6/2024 **Status:** ✅ Merged **Merged:** 12/9/2024 **Merged by:** [@jessegross](https://github.com/jessegross) **Base:** `main` ← **Head:** `jessegross/prompt` --- ### 📝 Commits (1) - [`342c582`](https://github.com/ollama/ollama/commit/342c582a3f056f3556f5c4aa074564c4cb84bfa0) prompt: Don't trim whitespace from prompts ### 📊 Changes **2 files changed** (+6 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `server/prompt.go` (+1 -2) 📝 `server/prompt_test.go` (+5 -5) </details> ### 📄 Description New lines can be an important part of a user's prompt and trimming it can alter the results. We previously only trimmed prompts with images but refactoring brought this behavior to all prompts, where it became more noticeable. The /generate endpoint adds less whitespace and therefore doesn't need to trim it out - this brings the same behavior to /chat. Thanks to @gabe-l-hart for spotting the issue! Fixes #7795 --- <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 07:11:51 -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#74875