Skip to content
Open
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
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Requirement: `pip install tqdm`
### Thinking (generate) - Enable thinking mode for a model

- [thinking-generate.py](thinking-generate.py)
- [async-thinking.py](async-thinking.py)

### Thinking (levels) - Choose the thinking level

Expand Down
22 changes: 22 additions & 0 deletions examples/async-thinking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import asyncio

from ollama import AsyncClient


async def main():
messages = [
{
'role': 'user',
'content': 'How many r letters are in the word strawberry?',
},
]
Comment thread
red1-for-hek marked this conversation as resolved.

client = AsyncClient()
response = await client.chat('deepseek-r1', messages=messages, think=True)
Comment thread
red1-for-hek marked this conversation as resolved.

print('Thinking:\n========\n\n' + response.message.thinking)
Comment thread
red1-for-hek marked this conversation as resolved.
print('\nResponse:\n========\n\n' + response.message.content)


if __name__ == '__main__':
asyncio.run(main())