Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,10 +32,8 @@ API_GOOGLE_SEARCH_KEY = "AIzaSyA4oDDFtPxAfmPC8EcfQrkByb9xKm2QfMc"
|
|
32 |
|
33 |
def query_fact_check_api(claim):
|
34 |
"""Queries the Google Fact Check Tools API for a given claim.
|
35 |
-
|
36 |
Args:
|
37 |
claim (str): The claim to search for fact checks.
|
38 |
-
|
39 |
Returns:
|
40 |
dict: The API response parsed as a JSON object.
|
41 |
"""
|
@@ -54,13 +52,15 @@ def query_fact_check_api(claim):
|
|
54 |
def response_break_out(response):
|
55 |
if response.get("claims"):
|
56 |
iteration = 0
|
57 |
-
answer = """Below is the searched result"""
|
58 |
for claim in response["claims"]:
|
59 |
-
answer =
|
60 |
for review in claim["claimReview"]:
|
61 |
-
answer =
|
62 |
-
answer =
|
63 |
-
|
|
|
|
|
64 |
else:
|
65 |
answer = """No fact checks found for this claim."""
|
66 |
|
@@ -111,7 +111,7 @@ def main():
|
|
111 |
"""
|
112 |
new_prompt = st.text_area(prompt)
|
113 |
|
114 |
-
result = query_fact_check_api(
|
115 |
facts = response_break_out(result)
|
116 |
|
117 |
if new_prompt:
|
|
|
32 |
|
33 |
def query_fact_check_api(claim):
|
34 |
"""Queries the Google Fact Check Tools API for a given claim.
|
|
|
35 |
Args:
|
36 |
claim (str): The claim to search for fact checks.
|
|
|
37 |
Returns:
|
38 |
dict: The API response parsed as a JSON object.
|
39 |
"""
|
|
|
52 |
def response_break_out(response):
|
53 |
if response.get("claims"):
|
54 |
iteration = 0
|
55 |
+
answer = """Below is the searched result: \n"""
|
56 |
for claim in response["claims"]:
|
57 |
+
answer = answer + """claim: """ + claim['text'] + "\n"
|
58 |
for review in claim["claimReview"]:
|
59 |
+
answer = answer + """publisher: """ + review['publisher']['name'] + "\n"
|
60 |
+
answer = answer + """rating: """ + review['textualRating'] + "\n"
|
61 |
+
if iteration >= 1:
|
62 |
+
break
|
63 |
+
iteration += 1
|
64 |
else:
|
65 |
answer = """No fact checks found for this claim."""
|
66 |
|
|
|
111 |
"""
|
112 |
new_prompt = st.text_area(prompt)
|
113 |
|
114 |
+
result = query_fact_check_api(claim_to_check)
|
115 |
facts = response_break_out(result)
|
116 |
|
117 |
if new_prompt:
|