Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,36 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
from deliverable2 import URLValidator
|
4 |
|
5 |
# Instantiate Validator
|
6 |
validator = URLValidator()
|
7 |
|
8 |
# Define function for Gradio UI
|
9 |
def validate_url(user_query, url_to_check):
|
|
|
10 |
result = validator.rate_url_validity(user_query, url_to_check)
|
11 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Create Gradio Interface
|
14 |
iface = gr.Interface(
|
15 |
fn=validate_url,
|
16 |
-
inputs=[
|
|
|
|
|
|
|
17 |
outputs="json",
|
18 |
-
title="URL
|
19 |
-
description="Enter a query and a URL to check its credibility."
|
20 |
)
|
21 |
|
22 |
-
# Launch
|
23 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
+
from deliverable2 import URLValidator # Ensure this file exists in the same directory
|
4 |
|
5 |
# Instantiate Validator
|
6 |
validator = URLValidator()
|
7 |
|
8 |
# Define function for Gradio UI
|
9 |
def validate_url(user_query, url_to_check):
|
10 |
+
""" Validate URL credibility based on user query. """
|
11 |
result = validator.rate_url_validity(user_query, url_to_check)
|
12 |
+
return {
|
13 |
+
"Domain Trust": result["raw_score"]["Domain Trust"],
|
14 |
+
"Content Relevance": result["raw_score"]["Content Relevance"],
|
15 |
+
"Fact-Check Score": result["raw_score"]["Fact-Check Score"],
|
16 |
+
"Bias Score": result["raw_score"]["Bias Score"],
|
17 |
+
"Citation Score": result["raw_score"]["Citation Score"],
|
18 |
+
"Final Validity Score": result["raw_score"]["Final Validity Score"],
|
19 |
+
"Star Rating": result["stars"]["icon"],
|
20 |
+
"Explanation": result["explanation"]
|
21 |
+
}
|
22 |
|
23 |
# Create Gradio Interface
|
24 |
iface = gr.Interface(
|
25 |
fn=validate_url,
|
26 |
+
inputs=[
|
27 |
+
gr.Textbox(label="Enter Your Search Query"),
|
28 |
+
gr.Textbox(label="Enter the URL to Check")
|
29 |
+
],
|
30 |
outputs="json",
|
31 |
+
title="URL Credibility Checker",
|
32 |
+
description="Enter a query and a URL to check its credibility.",
|
33 |
)
|
34 |
|
35 |
+
# Launch Gradio App
|
36 |
iface.launch()
|