Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,21 +7,28 @@ validator = URLValidator()
|
|
7 |
def validate_url(user_query, url_to_check):
|
8 |
result = validator.rate_url_validity(user_query, url_to_check)
|
9 |
|
|
|
|
|
|
|
|
|
10 |
# ✅ Check if an error occurred before accessing "raw_score"
|
11 |
if "Validation Error" in result:
|
12 |
-
return
|
13 |
|
14 |
-
# ✅
|
|
|
|
|
15 |
return {
|
16 |
-
"Domain Trust":
|
17 |
-
"Content Relevance":
|
18 |
-
"Fact-Check Score":
|
19 |
-
"Bias Score":
|
20 |
-
"Final Validity Score":
|
21 |
"Star Rating": result.get("stars", {}).get("icon", "N/A"),
|
22 |
"Explanation": result.get("explanation", "No explanation available.")
|
23 |
}
|
24 |
|
|
|
25 |
# UI Components
|
26 |
query_options = [
|
27 |
"How does climate change impact global weather?",
|
|
|
7 |
def validate_url(user_query, url_to_check):
|
8 |
result = validator.rate_url_validity(user_query, url_to_check)
|
9 |
|
10 |
+
# ✅ Ensure result is always a dictionary
|
11 |
+
if not isinstance(result, dict):
|
12 |
+
return {"error": "Unexpected error occurred, please try again."}
|
13 |
+
|
14 |
# ✅ Check if an error occurred before accessing "raw_score"
|
15 |
if "Validation Error" in result:
|
16 |
+
return {"error": result["Validation Error"]}
|
17 |
|
18 |
+
# ✅ Ensure "raw_score" exists in result
|
19 |
+
raw_score = result.get("raw_score", {})
|
20 |
+
|
21 |
return {
|
22 |
+
"Domain Trust": raw_score.get("Domain Trust", "N/A"),
|
23 |
+
"Content Relevance": raw_score.get("Content Relevance", "N/A"),
|
24 |
+
"Fact-Check Score": raw_score.get("Fact-Check Score", "N/A"),
|
25 |
+
"Bias Score": raw_score.get("Bias Score", "N/A"),
|
26 |
+
"Final Validity Score": raw_score.get("Final Validity Score", "N/A"),
|
27 |
"Star Rating": result.get("stars", {}).get("icon", "N/A"),
|
28 |
"Explanation": result.get("explanation", "No explanation available.")
|
29 |
}
|
30 |
|
31 |
+
|
32 |
# UI Components
|
33 |
query_options = [
|
34 |
"How does climate change impact global weather?",
|