Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,46 +14,7 @@ def is_token_configured():
|
|
14 |
return "⚠️ Warning: HF_API_TOKEN is not configured. The app won't work until you add this secret in your Space settings."
|
15 |
return "✅ API token is configured"
|
16 |
|
17 |
-
|
18 |
-
# def check_safety(input_text):
|
19 |
-
# if not input_text.strip():
|
20 |
-
# return "Please enter some text to check"
|
21 |
-
|
22 |
-
# # Prepare the payload for your endpoint
|
23 |
-
# payload = {
|
24 |
-
# "inputs": input_text
|
25 |
-
# }
|
26 |
-
|
27 |
-
# # Set headers with authentication token
|
28 |
-
# headers = {
|
29 |
-
# "Content-Type": "application/json",
|
30 |
-
# "Authorization": f"Bearer {HF_API_TOKEN}"
|
31 |
-
# }
|
32 |
-
|
33 |
-
# try:
|
34 |
-
# # Make the request to your endpoint
|
35 |
-
# response = requests.post(ENDPOINT_URL, json=payload, headers=headers, timeout=30)
|
36 |
-
|
37 |
-
# # Check if the request was successful
|
38 |
-
# if response.status_code == 200:
|
39 |
-
# result = response.json()
|
40 |
-
|
41 |
-
# # Format the result based on your endpoint's response format
|
42 |
-
# is_safe = result.get("is_safe", False)
|
43 |
-
# safety_result = result.get("safety_result", "No result received")
|
44 |
-
|
45 |
-
# if is_safe:
|
46 |
-
# return f"✅ {safety_result}"
|
47 |
-
# else:
|
48 |
-
# return f"❌ {safety_result}"
|
49 |
-
# else:
|
50 |
-
# return f"Error: Request failed with status code {response.status_code}. Details: {response.text}"
|
51 |
-
# except requests.exceptions.Timeout:
|
52 |
-
# return "Error: Request timed out. The endpoint may be overloaded or unavailable."
|
53 |
-
# except requests.exceptions.ConnectionError:
|
54 |
-
# return "Error: Failed to connect to the endpoint. Please check the endpoint URL."
|
55 |
-
# except Exception as e:
|
56 |
-
# return f"Error: {str(e)}"
|
57 |
def check_safety(input_text, uploaded_image):
|
58 |
if not input_text.strip() and uploaded_image is None:
|
59 |
return "⚠️ Please enter text or upload an image to check."
|
|
|
14 |
return "⚠️ Warning: HF_API_TOKEN is not configured. The app won't work until you add this secret in your Space settings."
|
15 |
return "✅ API token is configured"
|
16 |
|
17 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def check_safety(input_text, uploaded_image):
|
19 |
if not input_text.strip() and uploaded_image is None:
|
20 |
return "⚠️ Please enter text or upload an image to check."
|