Skip to content

Instantly share code, notes, and snippets.

@psahni
Created March 31, 2025 13:25
Show Gist options
  • Save psahni/a3f8715945a44a135df4826010545d80 to your computer and use it in GitHub Desktop.
Save psahni/a3f8715945a44a135df4826010545d80 to your computer and use it in GitHub Desktop.
ollama_test.py
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