Created
September 3, 2024 01:00
-
-
Save stevegt/50f5e20777c15bdeae20a9e160a94f47 to your computer and use it in GitHub Desktop.
example ollama client in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ollama import Client | |
import os | |
# derived from https://github.com/ollama/ollama-python | |
host = os.getenv('OLLAMA_HOST', 'http://localhost:11434') | |
client = Client(host=host) | |
response = client.chat(model='llama3.1:8b', messages=[ | |
{ | |
'role': 'user', | |
'content': 'Why is the sky blue?', | |
}, | |
]) | |
print(response['message']['content']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment