mirror of
https://github.com/kharonsec/ollama-python
synced 2026-04-25 23:24:55 +02:00
18 lines
347 B
Python
18 lines
347 B
Python
from ollama import chat
|
|
|
|
|
|
messages = [
|
|
{
|
|
'role': 'user',
|
|
'content': 'Why is the sky blue?',
|
|
},
|
|
]
|
|
|
|
for message in chat('mistral', messages=messages, stream=True):
|
|
if message := message.get('message'):
|
|
if message.get('role') == 'assistant':
|
|
print(message.get('content', ''), end='', flush=True)
|
|
|
|
# end with a newline
|
|
print()
|