File size: 1,212 Bytes
e251d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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)