[PR #10472] [CLOSED] Add ability to not send think tokens #75545

Closed
opened 2026-05-05 07:57:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/10472
Author: @woutermans
Created: 4/29/2025
Status: Closed

Base: mainHead: main


📝 Commits (2)

  • a772430 Add ability to not send think tokens
  • 7ac3a16 Add preiodic keep-alive messages while in disabled tag block

📊 Changes

2 files changed (+48 additions, -4 deletions)

View changed files

📝 envconfig/config.go (+3 -0)
📝 llm/server.go (+45 -4)

📄 Description

Implement OLLAMA_DISABLE_TOKEN_TAG for filtering streamed tokens

This PR introduces a new environment variable OLLAMA_DISABLE_TOKEN_TAG that allows users to specify a tag whose content should not be streamed in the model's response. This is particularly useful for filtering out internal thought processes or other tagged sections from the final output. (Potentially saving context size for clients that don't support this themselves)

This PR adds a new environment variable OLLAMA_DISABLE_TOKEN_TAG. When this variable is set to a tag name (e.g., think), the server will detect content within <tag> </tag> blocks and prevent those tokens from being sent to the client.

How to Use:

Set the OLLAMA_DISABLE_TOKEN_TAG environment variable to the name of the tag you want to disable. For example, to disable content within <think> </think> tags, run Ollama with:

OLLAMA_DISABLE_TOKEN_TAG=think go run . serve

If the OLLAMA_DISABLE_TOKEN_TAG environment variable is not set or is empty, all tokens will be streamed as before.


🔄 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/10472 **Author:** [@woutermans](https://github.com/woutermans) **Created:** 4/29/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`a772430`](https://github.com/ollama/ollama/commit/a7724309efcb994d0dc4a56ef32f737d42beb680) Add ability to not send think tokens - [`7ac3a16`](https://github.com/ollama/ollama/commit/7ac3a16ba3ff0c886bd78e89485351fbfbd5c544) Add preiodic keep-alive messages while in disabled tag block ### 📊 Changes **2 files changed** (+48 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `envconfig/config.go` (+3 -0) 📝 `llm/server.go` (+45 -4) </details> ### 📄 Description ## Implement OLLAMA_DISABLE_TOKEN_TAG for filtering streamed tokens This PR introduces a new environment variable `OLLAMA_DISABLE_TOKEN_TAG` that allows users to specify a tag whose content should not be streamed in the model's response. This is particularly useful for filtering out internal thought processes or other tagged sections from the final output. (Potentially saving context size for clients that don't support this themselves) This PR adds a new environment variable `OLLAMA_DISABLE_TOKEN_TAG`. When this variable is set to a tag name (e.g., `think`), the server will detect content within `<tag> </tag>` blocks and prevent those tokens from being sent to the client. **How to Use:** Set the `OLLAMA_DISABLE_TOKEN_TAG` environment variable to the name of the tag you want to disable. For example, to disable content within `<think> </think>` tags, run Ollama with: ```bash OLLAMA_DISABLE_TOKEN_TAG=think go run . serve ``` If the `OLLAMA_DISABLE_TOKEN_TAG` environment variable is not set or is empty, all tokens will be streamed as before. --- <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:57:50 -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#75545