mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-14 06:07:17 +08:00
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
27 lines
546 B
Python
27 lines
546 B
Python
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')
|