mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-14 06:07:17 +08:00
21 lines
339 B
Python
21 lines
339 B
Python
import asyncio
|
|
|
|
from ollama import AsyncClient
|
|
|
|
|
|
async def main():
|
|
messages = [
|
|
{
|
|
'role': 'user',
|
|
'content': 'Why is the sky blue?',
|
|
},
|
|
]
|
|
|
|
client = AsyncClient()
|
|
response = await client.chat('gemma3', messages=messages)
|
|
print(response['message']['content'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|