Spaces:
Sleeping
Sleeping
File size: 2,170 Bytes
0eafe79 ae1571a 4dcc3f2 7ffd915 4dcc3f2 7ffd915 bd6448d 7ffd915 5764761 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import gradio as gr
from Deliverable2 import URLValidator
# Instantiate the validator
validator = URLValidator()
# ✅ Updated queries and URLs
queries = [
"Climate change effects",
"COVID-19 vaccine effectiveness",
"Latest AI advancements",
"Stock market trends",
"Healthy diet tips",
"Space exploration missions",
"Electric vehicle benefits",
"History of the internet",
"Python programming tutorials",
"Mental health awareness"
]
urls = [
"https://www.nationalgeographic.com/environment/article/climate-change-overview",
"https://www.cdc.gov/coronavirus/2019-ncov/vaccines/effectiveness.html",
"https://www.technologyreview.com/topic/artificial-intelligence",
"https://www.bloomberg.com/markets",
"https://www.healthline.com/nutrition/healthy-eating-tips",
"https://www.nasa.gov/missions",
"https://www.tesla.com/benefits",
"https://www.history.com/topics/inventions/history-of-the-internet",
"https://realpython.com",
"https://www.who.int/news-room/fact-sheets/detail/mental-health-strengthening-our-response"
]
# Function to validate URL
def validate_url(user_query, url_to_check):
result = validator.rate_url_validity(user_query, url_to_check)
if "Validation Error" in result:
return {"Error": result["Validation Error"]}
return {
"Content Relevance Score": f"{result['raw_score']['Content Relevance']} / 100",
"Bias Score": f"{result['raw_score']['Bias Score']} / 100",
"Final Validity Score": f"{result['raw_score']['Final Validity Score']} / 100"
}
# Gradio UI
with gr.Blocks() as app:
gr.Markdown("# 🌍 URL Credibility Validator")
gr.Markdown("### Validate the credibility of any webpage using AI")
user_query = gr.Dropdown(queries, label="Select a search query:")
url_to_check = gr.Dropdown(urls, label="Select a URL to validate:")
result_output = gr.JSON(label="Validation Results")
submit_button = gr.Button("Validate URL")
submit_button.click(validate_url, inputs=[user_query, url_to_check], outputs=result_output)
# Launch the app
app.launch(server_name="0.0.0.0", server_port=7860)
|