Spaces:
Sleeping
Sleeping
Update checks/endpoint_check.py
Browse files- checks/endpoint_check.py +12 -2
checks/endpoint_check.py
CHANGED
@@ -7,11 +7,21 @@ def is_public_endpoint(endpoint: str):
|
|
7 |
try:
|
8 |
# No Authorization header required for public models
|
9 |
response = requests.get(endpoint)
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
# Check if the response status code is 200 and it returns inference data
|
12 |
if response.status_code == 200:
|
13 |
# Public models will return inference data without needing an API key
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
return True
|
16 |
else:
|
17 |
print("The response does not contain inference-related data.")
|
|
|
7 |
try:
|
8 |
# No Authorization header required for public models
|
9 |
response = requests.get(endpoint)
|
10 |
+
|
11 |
+
# Log the response status and headers for better insight
|
12 |
+
print(f"Response status code: {response.status_code}")
|
13 |
+
print(f"Response headers: {response.headers}")
|
14 |
+
|
15 |
# Check if the response status code is 200 and it returns inference data
|
16 |
if response.status_code == 200:
|
17 |
# Public models will return inference data without needing an API key
|
18 |
+
# Attempt to parse JSON response
|
19 |
+
response_json = response.json()
|
20 |
+
# Print the first few keys of the response JSON for debugging
|
21 |
+
print(f"Response JSON keys: {list(response_json.keys())[:5]}")
|
22 |
+
|
23 |
+
# Public models will return inference data without needing an API key
|
24 |
+
if "model" in response_json or "error" in response_json:
|
25 |
return True
|
26 |
else:
|
27 |
print("The response does not contain inference-related data.")
|