21 lines
396 B
Python
21 lines
396 B
Python
import requests
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
url = "http://localhost:11434/api/chat"
|
|
payload = {
|
|
"model": "gpt-oss",
|
|
"messages": [
|
|
{"role": "user", "content": "why is the sky blue?"}
|
|
]
|
|
}
|
|
|
|
resp = requests.post(url, json=payload, timeout=120)
|
|
resp.raise_for_status()
|
|
data = resp.json()
|
|
|
|
# Ollama returns the assistant reply under data["message"]["content"]
|
|
print(data["message"]["content"]) |