mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-14 06:07:17 +08:00
* Examples and README updates --------- Co-authored-by: fujitatomoya <tomoya.fujita825@gmail.com> Co-authored-by: Michael Yang <mxyng@pm.me>
20 lines
340 B
Python
20 lines
340 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('llama3.2', messages=messages)
|
|
print(response['message']['content'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|