File size: 2,329 Bytes
a96aba1
fb6022f
992f04e
a96aba1
 
639d80a
b2c9ae3
992f04e
 
 
 
 
 
 
 
 
 
 
639d80a
992f04e
 
639d80a
992f04e
 
 
 
 
 
 
 
 
 
 
 
 
 
a96aba1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13bc62d
a96aba1
 
13bc62d
a96aba1
 
 
 
639d80a
a96aba1
 
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
import gradio as gr
from deliverable2 import URLValidator

# Instantiate the validator
validator = URLValidator()

# List of queries
queries = [
    "How blockchain works",
    "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",
    "Nutritional benefits of a vegan diet",
    "Mental health awareness"
]

# Corresponding URLs
urls = [
    "https://www.ibm.com/topics/what-is-blockchain",
    "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://www.hsph.harvard.edu/nutritionsource/healthy-weight/diet-reviews/vegan-diet/",
    "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)