File: async-generate.py

package info (click to toggle)
ollama-python 0.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 376 kB
  • sloc: python: 3,056; makefile: 5
file content (16 lines) | stat: -rw-r--r-- 293 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import asyncio

import ollama


async def main():
  client = ollama.AsyncClient()
  response = await client.generate('gemma3', 'Why is the sky blue?')
  print(response['response'])


if __name__ == '__main__':
  try:
    asyncio.run(main())
  except KeyboardInterrupt:
    print('\nGoodbye!')