Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ Requirement: `pip install tqdm`

### Thinking - Enable thinking mode for a model
- [thinking.py](thinking.py)

### Thinking (generate) - Enable thinking mode for a model
- [thinking-generate.py](thinking-generate.py)
13 changes: 13 additions & 0 deletions examples/thinking-generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from ollama import generate

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

response = generate('deepseek-r1', 'why is the sky blue', think=True)

print('Thinking:\n========\n\n' + response.thinking)
print('\nResponse:\n========\n\n' + response.response)
4 changes: 4 additions & 0 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def generate(
template: str = '',
context: Optional[Sequence[int]] = None,
stream: Literal[False] = False,
think: Optional[bool] = None,
raw: bool = False,
format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None,
images: Optional[Sequence[Union[str, bytes, Image]]] = None,
Expand All @@ -208,6 +209,7 @@ def generate(
template: str = '',
context: Optional[Sequence[int]] = None,
stream: Literal[True] = True,
think: Optional[bool] = None,
raw: bool = False,
format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None,
images: Optional[Sequence[Union[str, bytes, Image]]] = None,
Expand All @@ -225,6 +227,7 @@ def generate(
template: Optional[str] = None,
context: Optional[Sequence[int]] = None,
stream: bool = False,
think: Optional[bool] = None,
raw: Optional[bool] = None,
format: Optional[Union[Literal['', 'json'], JsonSchemaValue]] = None,
images: Optional[Sequence[Union[str, bytes, Image]]] = None,
Expand Down Expand Up @@ -253,6 +256,7 @@ def generate(
template=template,
context=context,
stream=stream,
think=think,
raw=raw,
format=format,
images=list(_copy_images(images)) if images else None,
Expand Down
Loading