Created
March 31, 2025 13:25
-
-
Save psahni/a3f8715945a44a135df4826010545d80 to your computer and use it in GitHub Desktop.
ollama_test.py
This file contains 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 openai import OpenAI | |
client = OpenAI( | |
base_url = 'http://localhost:11434/v1', | |
api_key='ollama', # required, but unused | |
) | |
response = client.chat.completions.create( | |
model="llama2", | |
messages=[ | |
{"role": "system", "content": "You are a helpful assistant."}, | |
{"role": "user", "content": "Who won the world series in 2020?"}, | |
{"role": "assistant", "content": "The LA Dodgers won in 2020."}, | |
{"role": "user", "content": "Where was it played?"} | |
] | |
) | |
print(response.choices[0].message.conte |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment