Spaces:
Runtime error
Runtime error
Upload factchecking_front.py
Browse files- factchecking_front.py +100 -0
factchecking_front.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio_client import Client
|
| 3 |
+
|
| 4 |
+
client = Client("Iker/FactChecking-Backend")
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def fact_checking(
|
| 8 |
+
article_topic: str,
|
| 9 |
+
):
|
| 10 |
+
result = client.predict(article_topic=article_topic, api_name="/partial")
|
| 11 |
+
|
| 12 |
+
return result
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
if __name__ == "__main__":
|
| 16 |
+
theme = gr.themes.Soft(
|
| 17 |
+
primary_hue="green",
|
| 18 |
+
secondary_hue="gray",
|
| 19 |
+
neutral_hue="neutral",
|
| 20 |
+
font=[
|
| 21 |
+
gr.themes.GoogleFont("Poppins"),
|
| 22 |
+
gr.themes.GoogleFont("Poppins"),
|
| 23 |
+
gr.themes.GoogleFont("Poppins"),
|
| 24 |
+
gr.themes.GoogleFont("Poppins"),
|
| 25 |
+
],
|
| 26 |
+
font_mono=[
|
| 27 |
+
gr.themes.GoogleFont("Poppins"),
|
| 28 |
+
gr.themes.GoogleFont("Poppins"),
|
| 29 |
+
gr.themes.GoogleFont("Poppins"),
|
| 30 |
+
gr.themes.GoogleFont("Poppins"),
|
| 31 |
+
],
|
| 32 |
+
).set(
|
| 33 |
+
body_text_color="*secondary_600",
|
| 34 |
+
button_border_width="*block_label_border_width",
|
| 35 |
+
button_primary_background_fill="*primary_600",
|
| 36 |
+
button_secondary_background_fill="*primary_500",
|
| 37 |
+
button_secondary_background_fill_hover="*primary_400",
|
| 38 |
+
button_secondary_border_color="*primary_500",
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
with gr.Blocks(
|
| 42 |
+
theme=theme,
|
| 43 |
+
title="🤖 Automated Fact-Checking Engine",
|
| 44 |
+
analytics_enabled=False,
|
| 45 |
+
) as demo:
|
| 46 |
+
gr_text = gr.Textbox(
|
| 47 |
+
label="Fact-Checking Statement",
|
| 48 |
+
# info="Write here the statement you want to fact-check",
|
| 49 |
+
show_label=False,
|
| 50 |
+
lines=1,
|
| 51 |
+
interactive=True,
|
| 52 |
+
placeholder="Electric cars produce more contamination than petrol cars",
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
gr_play = gr.Button("Fact-Checking")
|
| 56 |
+
|
| 57 |
+
gr_output = gr.Markdown(
|
| 58 |
+
label="Fact-Checking Results",
|
| 59 |
+
visible=True,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
gr_ft = gr.Textbox(
|
| 63 |
+
label="fact_checking",
|
| 64 |
+
info="String with fact checking text",
|
| 65 |
+
lines=1,
|
| 66 |
+
interactive=False,
|
| 67 |
+
visible=False,
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
gr_qa = gr.Textbox(
|
| 71 |
+
label="qa",
|
| 72 |
+
info="Questions and answers, first line is the question, second line is the answer, and so on",
|
| 73 |
+
lines=1,
|
| 74 |
+
interactive=False,
|
| 75 |
+
visible=False,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
gr_citations = gr.Textbox(
|
| 79 |
+
label="citations",
|
| 80 |
+
info="Here you will see the citations, first line is the citation id, second line is the url, and so on",
|
| 81 |
+
lines=1,
|
| 82 |
+
interactive=False,
|
| 83 |
+
visible=False,
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
gr_image = gr.Textbox(
|
| 87 |
+
label="image",
|
| 88 |
+
info="Contains the image url",
|
| 89 |
+
interactive=False,
|
| 90 |
+
visible=False,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
gr_play.click(
|
| 94 |
+
fact_checking,
|
| 95 |
+
inputs=[gr_text],
|
| 96 |
+
outputs=[gr_output, gr_ft, gr_qa, gr_citations, gr_image],
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
demo.queue(default_concurrency_limit=1)
|
| 100 |
+
demo.launch()
|