Spaces:
Running
Running
File size: 2,039 Bytes
9e66f5e 86dc617 9e66f5e 86dc617 9e66f5e 86dc617 9e66f5e 2bde752 9e66f5e 2bde752 9e66f5e |
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 49 |
# debug_network.py
import os, socket, requests
from urllib.parse import urlsplit
def debug_connectivity():
print("DEBUG: OPENAI_API_KEY present:", bool(os.getenv("OPENAI_API_KEY")))
print("DEBUG: ANTHROPIC_API_KEY present:", bool(os.getenv("ANTHROPIC_API_KEY")))
print("DEBUG: BLAXEL key present:", bool(os.getenv("BLAXEL_MCP_1ST_BDAY")))
print("DEBUG: SAMBA_NOVA key present:", bool(os.getenv("SAMBA_NOVA_MCP_1ST_BDAY")))
print("DEBUG: NEBIUS key present:", bool(os.getenv("NEBIUS_MCP_1ST_BDAY")))
print("DEBUG: HUGGING_FACE key present:", bool(os.getenv("HUGGING_FACE_MCP_1ST_BDAY")))
print("DEBUG: MODAL key present:", bool(os.getenv("MODAL_API_KEY") or os.getenv("MODAL_TOKEN")))
for host in ["api.openai.com", "api.anthropic.com"]:
try:
ip = socket.gethostbyname(host)
print(f"DEBUG: DNS for {host} -> {ip}")
except Exception as e:
print(f"DEBUG: DNS FAILED for {host}: {e}")
# Probe sponsor endpoints if configured
def _check_host_from_url(env_var):
base = os.getenv(env_var)
if not base:
return
host = urlsplit(base).hostname
if not host:
return
try:
ip = socket.gethostbyname(host)
print(f"DEBUG: DNS for {env_var} ({host}) -> {ip}")
except Exception as e:
print(f"DEBUG: DNS FAILED for {env_var} ({host}): {e}")
for env_var in ["BLAXEL_BASE_URL", "SAMBA_NOVA_BASE_URL", "NEBIUS_BASE_URL", "HUGGINGFACE_MODEL", "MODAL_BASE_URL"]:
_check_host_from_url(env_var)
try:
r = requests.get("https://api.openai.com/v1/models", timeout=3)
print("DEBUG: OpenAI /v1/models status:", r.status_code)
except Exception as e:
print("DEBUG: OpenAI GET failed:", repr(e))
try:
r = requests.get("https://api.anthropic.com/health", timeout=3)
print("DEBUG: Anthropic /health status:", r.status_code)
except Exception as e:
print("DEBUG: Anthropic GET failed:", repr(e))
|