File size: 702 Bytes
61af0ed | 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 | import os
import requests
API_BASE_URL = os.environ.get("API_BASE_URL", "http://localhost:8000")
def call_predict(samples: list[dict]) -> list[dict]:
response = requests.post(f"{API_BASE_URL}/predict", json=samples)
response.raise_for_status()
return response.json()
def call_predict_all(samples: list[dict]) -> dict[str, list[dict]]:
response = requests.post(f"{API_BASE_URL}/predict-all-models", json=samples)
response.raise_for_status()
return response.json()
def check_health() -> bool:
try:
response = requests.get(f"{API_BASE_URL}/health", timeout=3)
return response.status_code == 200
except requests.ConnectionError:
return False
|