ollama - 💡(How to fix) Fix Set thinking level to Off using Python package [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#14726Fetched 2026-04-08 00:32:29
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
closed ×1commented ×1labeled ×1
RAW_BUFFERClick to expand / collapse

as through ollama cli , we can easily configure /set nothink for the thinking models. there should also be a feature to disable when calling ollama through python or api to set the thinking level to none

from ollama import chat

def heading(text): print(text) print('=' * len(text))

messages = [ {'role': 'user', 'content': 'What is 10 + 23?'}, ]

gpt-oss supports 'low', 'medium', 'high'

levels = ['low', 'medium', 'high'] for i, level in enumerate(levels): response = chat('gpt-oss:20b', messages=messages, think=level)

heading(f'Thinking ({level})') print(response.message.thinking) print('\n') heading('Response') print(response.message.content) print('\n') if i < len(levels) - 1: print('-' * 20) print('\n')

it should be

levels = ['none , 'low', 'medium', 'high']

extent analysis

Fix Plan

To add a feature to disable thinking when calling Ollama through Python or API, we need to modify the levels list and update the chat function call.

Code Changes

from ollama import chat

def heading(text):
  print(text)
  print('=' * len(text))

messages = [
  {'role': 'user', 'content': 'What is 10 + 23?'},
]

# Add 'none' to the levels list
levels = ['none', 'low', 'medium', 'high']
for i, level in enumerate(levels):
  # Update the chat function call to handle 'none' level
  if level == 'none':
    response = chat('gpt-oss:20b', messages=messages, think=None)
  else:
    response = chat('gpt-oss:20b', messages=messages, think=level)

  heading(f'Thinking ({level})')
  print(response.message.thinking)
  print('\n')
  heading('Response')
  print(response.message.content)
  print('\n')
  if i < len(levels) - 1:
    print('-' * 20)
    print('\n')

Verification

Run the updated code and verify that the thinking level is set to none when the level is 'none'. Check the output to ensure that the response is generated correctly.

Extra Tips

  • Make sure to update the ollama library to the latest version to ensure compatibility with the updated code.
  • If you encounter any issues, check the ollama documentation for any specific requirements or restrictions on using the think parameter.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix Set thinking level to Off using Python package [1 comments, 2 participants]