Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,35 +67,30 @@ if submit_button and text_input:
|
|
| 67 |
api_key = os.environ.get('WL_KEY', 'default_key') # Use a default or handle the case where the key is not set
|
| 68 |
api_response = fact_check_statement(text_input, api_key)
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
if rating_value.isdigit():
|
| 85 |
-
st.progress(int(rating_value) / 5, "Fact-checking in progress.")
|
| 86 |
-
else:
|
| 87 |
-
st.write("Rating Value: ", rating_value)
|
| 88 |
-
st.write(f"**Review Body**: {review_body}")
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
|
|
|
| 67 |
api_key = os.environ.get('WL_KEY', 'default_key') # Use a default or handle the case where the key is not set
|
| 68 |
api_response = fact_check_statement(text_input, api_key)
|
| 69 |
|
| 70 |
+
if "error" not in api_response:
|
| 71 |
+
# Access the fields directly from api_response
|
| 72 |
+
claim_reviewed = api_response.get("claimReviewed", "N/A")
|
| 73 |
+
review_rating = api_response.get("reviewRating", {})
|
| 74 |
+
rating_value = review_rating.get("ratingValue", "N/A")
|
| 75 |
+
alternate_name = review_rating.get("alternateName", "N/A") # Extract the alternateName
|
| 76 |
+
review_body = api_response.get("reviewBody", "N/A")
|
| 77 |
+
|
| 78 |
+
# Display the results
|
| 79 |
+
if rating_value.isdigit():
|
| 80 |
+
st.progress(int(rating_value) / 5, "Fact-checking in progress.")
|
| 81 |
+
else:
|
| 82 |
+
st.write("Rating Value: ", rating_value)
|
| 83 |
+
st.write(f"**Review Body**: {review_body}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
# Create a two-column layout
|
| 86 |
+
col1, col2 = st.columns(2)
|
| 87 |
|
| 88 |
+
# Use the metric widget to display the rating and alternate name
|
| 89 |
+
col1.metric("Rating", rating_value)
|
| 90 |
+
col2.metric("Verdict", alternate_name)
|
| 91 |
+
|
| 92 |
+
#with st.expander("Here is the final JSON-LD"):
|
| 93 |
+
# st.json(api_response) # Display the entire JSON-LD data
|
| 94 |
|
| 95 |
+
else:
|
| 96 |
+
st.error("Error in fact-checking: " + api_response['error'])
|