File: thinking-levels.py

package info (click to toggle)
ollama-python 0.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 376 kB
  • sloc: python: 3,056; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 546 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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')