From 73ed19f0816c7c17244e90927316a283541b9157 Mon Sep 17 00:00:00 2001 From: Redoyanul Haque Date: Fri, 5 Jun 2026 17:24:52 +0600 Subject: [PATCH 1/2] Add async thinking example with AsyncClient --- examples/async-thinking.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/async-thinking.py diff --git a/examples/async-thinking.py b/examples/async-thinking.py new file mode 100644 index 00000000..603c4e6e --- /dev/null +++ b/examples/async-thinking.py @@ -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?', + }, + ] + + client = AsyncClient() + response = await client.chat('deepseek-r1', messages=messages, think=True) + + print('Thinking:\n========\n\n' + response.message.thinking) + print('\nResponse:\n========\n\n' + response.message.content) + + +if __name__ == '__main__': + asyncio.run(main()) From 2ac0ca0a797ba1ba1d992d8d5e016b1e1114ba86 Mon Sep 17 00:00:00 2001 From: Redoyanul Haque Date: Fri, 5 Jun 2026 17:26:36 +0600 Subject: [PATCH 2/2] Add async-thinking.py to README examples --- examples/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/README.md b/examples/README.md index 1df713ea..27bbd72f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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