mirror of
https://github.com/ollama/ollama-python.git
synced 2026-08-23 13:09:52 +00:00
add support for 'high'/'medium'/'low' think values
currently only supported on gpt-oss, but as more models come out with support like this we'll likely relax the particular values that can be provided
This commit is contained in:
@@ -73,3 +73,6 @@ Requirement: `pip install tqdm`
|
||||
|
||||
### Thinking (generate) - Enable thinking mode for a model
|
||||
- [thinking-generate.py](thinking-generate.py)
|
||||
|
||||
### Thinking (levels) - Choose the thinking level
|
||||
- [thinking-levels.py](thinking-generate.py)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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')
|
||||
Reference in New Issue
Block a user