Spaces:
Runtime error
Runtime error
Download test_kora.py from ProfessorCEO/Kora-API: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/ProfessorCEO/Kora-API/resolve/main/test_kora.py
- Command line
-
hf download hf://spaces/ProfessorCEO/Kora-API/test_kora.py
-
curl -L -o test_kora.py https://huggingface.co/spaces/ProfessorCEO/Kora-API/resolve/main/test_kora.py
1.21 kB
| 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) | |