Ollama Python Library
The Ollama Python library provides the easiest way to integrate Python 3.8+ projects with Ollama.
Prerequisites
Ollama should be installed and running
Pull a model to use with the library: ollama pull e.g. ollama pull llama3.2
See Ollama.com for more information on the models available.
Usage
from ollama import chat
from ollama import ChatResponse
response: ChatResponse = chat(model=llama3.2 , messages=[
{
'role': user ,
'content': Why is the sky blue? ,
},
])
print(response['message']['content'])
print(response.message.content)
|