Kora-API / test_kora.py
ProfessorCEO's picture
Deploy API
e251d62
import requests
import json
import time
url = "http://127.0.0.1:8000/v1/chat/completions"
# Let's ask a question that proves it knows it's KORA
payload = {
"model": "ProfessorCEO/KORA-v1",
"messages": [
{"role": "user", "content": "Who are you and what company created you?"}
],
"stream": False,
"temperature": 0.3
}
headers = {
"Content-Type": "application/json"
}
print("Waiting for KORA server to be ready...")
for i in range(15):
try:
health = requests.get("http://127.0.0.1:8000/healthz")
if health.status_code == 200:
print("Server is up! Sending request to KORA...")
break
except requests.exceptions.ConnectionError:
pass
time.sleep(5)
else:
print("Server failed to start in time.")
exit(1)
print("\nQuestion:", payload["messages"][0]["content"])
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
data = response.json()
print("\nKORA says:")
print("-------------------------")
print(data["choices"][0]["message"]["content"])
print("-------------------------")
else:
print(f"Error: {response.status_code}")
print(response.text)