Issue Description:
Hello Hugging Face Support Team,
I am experiencing an issue where my application can successfully connect to the PromptLayer API (https://api.promptlayer.com/ping
) from my local environment, but the same code fails to establish a connection when running on the Hugging Face environment.
Key Details:
- Functionality Affected: API calls to
https://api.promptlayer.com/ping
- Observations:
- The
check_internet
function (which accesseshttps://www.google.com
) works correctly on both environments. - The
check_promptlayer
function only works locally but fails in the Hugging Face environment.
- The
- Past: This huggingface space was able to connect to promptlayer prior. But this space was doing burst requests to promptlayer. And then after 10 days, was not able to access promptlayer anymore.
Suspected Causes:
- Possible network restrictions in the Hugging Face environment (e.g., domain or port blocking).
- Rate limiting or IP restrictions applied by the PromptLayer API for Hugging Face’s shared environment: jon@promptlayer.com from promptlayer has confirmed this is not the case.
What has been tried
- I tried duplicating the space, creating a new space in hope of if the connection gets resolved. But didn’t work out.
Code
def check_internet(url="https://www.google.com"):
try:
response = requests.get(url, timeout=5)
if response.status_code == 200:
print("Internet is working. Status code:", response.status_code)
else:
print("Connected to the internet, but the server returned an error. Status code:", response.status_code)
except requests.ConnectionError:
print("No internet connection.")
except requests.Timeout:
print("Request timed out.")
except Exception as e:
print(f"An error occurred: {e}")
def check_promptlayer(url="https://api.promptlayer.com/ping"):
try:
response = requests.get(url, timeout=5)
if response.status_code == 200:
print("Promptlayer is working. Status code:", response.status_code)
else:
print("Connected to the Promptlayer, but the server returned an error. Status code:", response.status_code)
except requests.ConnectionError:
print("No Promptlayer connection.")
except requests.Timeout:
print("Request timed out.")
except Exception as e:
print(f"An error occurred: {e}")