File size: 1,098 Bytes
b7098e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29790d1
b7098e7
29790d1
b7098e7
 
 
 
29790d1
 
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
import os
import requests


def is_huggingface_endpoint(endpoint):
    if not endpoint:
        return False
    
    try:
        # Send a simple GET or POST request to the endpoint
        headers = {"Authorization": "Bearer YOUR_HUGGINGFACE_API_KEY"}  # Replace with your Hugging Face API key if needed
        response = requests.get(endpoint, headers=headers)
        
        if response.status_code == 200:
            # Check if the response contains Hugging Face-specific data
            if "model" in response.json():
                return True
        elif response.status_code == 404:
            print("Endpoint not found, make sure the endpoint is correct.")
        else:
            print(f"Error: Received status code {response.status_code}")
        
        return False
    
    except requests.exceptions.RequestException as e:
        print(f"Request failed: {e}")
        return False

'''
# Test the endpoint

if is_huggingface_endpoint(my_id):
    print("This is a Hugging Face Inference Endpoint.")
else:
    print("This is NOT a Hugging Face Inference Endpoint.")

'''