File size: 3,080 Bytes
eaed23e
0dfc3de
3bb0a69
ed3a47f
dcd88b4
322f2c4
ed3a47f
cff0d68
ed3a47f
cff0d68
 
 
 
 
 
 
 
 
ed3a47f
cff0d68
ed3a47f
 
 
cff0d68
 
 
ed3a47f
 
cff0d68
 
 
 
 
 
 
 
 
ed3a47f
 
 
 
c25b170
 
cff0d68
0dfc3de
 
 
c25b170
cff0d68
c25b170
cff0d68
 
 
 
 
babc141
cff0d68
babc141
c25b170
cff0d68
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
import gradio as gr
from deliverable2 import URLValidator

# Instantiate the validator
validator = URLValidator()

# ✅ Ensure queries and URLs are properly formatted
queries = [
    "How does climate change impact global weather?",
    "What are the latest advancements in AI?",
    "How does diet influence mental health?",
    "What are the effects of space travel on astronauts?",
    "Is cryptocurrency a safe investment?",
    "What are the advantages of renewable energy?",
    "How does deep learning work?",
    "What are the health risks of 5G technology?",
    "Is intermittent fasting effective for weight loss?",
    "How do electric vehicles compare to gas cars?",
    "What are the best ways to learn a new language?",
    "What are the side effects of caffeine?",
    "How does exercise affect mental health?",
    "Is a vegan diet good for your health?",
    "What is the best way to improve sleep quality?"
]

urls = [
    "https://www.nationalgeographic.com/environment/article/climate-change",
    "https://www.technologyreview.com/2023/05/01/latest-ai-advancements/",
    "https://www.health.harvard.edu/mind-and-mood/foods-linked-to-better-brainpower",
    "https://www.nasa.gov/hrp/long-term-health-risks-of-space-travel",
    "https://www.investopedia.com/terms/c/cryptocurrency.asp",
    "https://www.energy.gov/eere/renewable-energy",
    "https://www.ibm.com/cloud/deep-learning",
    "https://www.who.int/news-room/questions-and-answers/item/radiation-5g-mobile-networks-and-health",
    "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6167940/",
    "https://www.tesla.com/blog/benefits-of-electric-vehicles",
    "https://www.duolingo.com/blog/best-way-to-learn-a-new-language",
    "https://www.mayoclinic.org/drugs-supplements/caffeine-oral-route/side-effects",
    "https://www.cdc.gov/physicalactivity/basics/pa-health/index.htm",
    "https://www.healthline.com/nutrition/vegan-diet-benefits",
    "https://www.sleepfoundation.org/how-sleep-works/how-to-get-better-sleep"
]

# 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)