cyberandy commited on
Commit
44183dc
1 Parent(s): 7c51387

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -29
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
- if "error" not in api_response:
71
- # Parse the outer JSON
72
- inner_json_str = api_response.get("response", "{}")
73
- # Parse the inner JSON string
74
- inner_json = json.loads(inner_json_str)
75
-
76
- # Extract relevant information
77
- claim_reviewed = inner_json.get("claimReviewed", "N/A")
78
- review_rating = inner_json.get("reviewRating", {})
79
- rating_value = review_rating.get("ratingValue", "N/A")
80
- alternate_name = review_rating.get("alternateName", "N/A") # Extract the alternateName
81
- review_body = inner_json.get("reviewBody", "N/A")
82
-
83
- # Display the results
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
- # Create a two-column layout
91
- col1, col2 = st.columns(2)
92
 
93
- # Use the metric widget to display the rating and alternate name
94
- col1.metric("Rating", rating_value)
95
- col2.metric("Verdict", alternate_name)
96
-
97
- #with st.expander("Here is the final JSON-LD"):
98
- # st.json(inner_json) # Display the entire JSON-LD data
99
 
100
- else:
101
- st.error("Error in fact-checking: " + api_response['error'])
 
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'])