File size: 5,030 Bytes
eaed23e
0dfc3de
3bb0a69
cff0d68
dcd88b4
322f2c4
cff0d68
 
c25b170
cff0d68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c25b170
 
cff0d68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c25b170
cff0d68
 
 
 
 
 
 
 
 
 
 
 
 
 
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import gradio as gr
from deliverable2 import URLValidator

# Initialize Validator
validator = URLValidator()

# Define queries and URLs
queries = [
    "What are the symptoms of the flu?",
    "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 side effects of caffeine?",
    "How does climate change impact global weather?",
    "What is the be    "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.mayoclinic.org/drugs-supplements/caffeine-oral-route/side-effects",
    "https://www.nationalgeographic.com/environment/article/climate-change",
    "https://www.duolingo.com/blog/best-way-to-learn-a-new-language",
    "https://www.tesla.com/blog/are-electric-cars-better-than-gasoline-cars",
    "https://www.healthline.com/nutrition/vegan-diet-benefits"
]

# 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)
st way to learn a new language?",
    "Are electric cars better than gasoline cars?",
    "What are the benefits of a vegan diet?"
]

urls = [
    "https://www.bbc.com/news/world-us-canada-64879434",
    "https://www.forbes.com/sites/forbestechcouncil/2023/02/20/ai-latest-developments
    "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.mayoclinic.org/drugs-supplements/caffeine-oral-route/side-effects",
    "https://www.nationalgeographic.com/environment/article/climate-change",
    "https://www.duolingo.com/blog/best-way-to-learn-a-new-language",
    "https://www.tesla.com/blog/are-electric-cars-better-than-gasoline-cars",
    "https://www.healthline.com/nutrition/vegan-diet-benefits"
]

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