SaiKumar1627 commited on
Commit
ed3a47f
·
verified ·
1 Parent(s): 841ac1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -56
app.py CHANGED
@@ -1,12 +1,12 @@
1
  import gradio as gr
2
  from deliverable2 import URLValidator
3
 
4
- # Initialize Validator
5
  validator = URLValidator()
6
 
7
- # Define queries and URLs
8
  queries = [
9
- "What are the symptoms of the flu?",
10
  "What are the latest advancements in AI?",
11
  "How does diet influence mental health?",
12
  "What are the effects of space travel on astronauts?",
@@ -16,59 +16,16 @@ queries = [
16
  "What are the health risks of 5G technology?",
17
  "Is intermittent fasting effective for weight loss?",
18
  "How do electric vehicles compare to gas cars?",
 
19
  "What are the side effects of caffeine?",
20
- "How does climate change impact global weather?",
21
- "What is the be "https://www.health.harvard.edu/mind-and-mood/foods-linked-to-better-brainpower",
22
- "https://www.nasa.gov/hrp/long-term-health-risks-of-space-travel",
23
- "https://www.investopedia.com/terms/c/cryptocurrency.asp",
24
- "https://www.energy.gov/eere/renewable-energy",
25
- "https://www.ibm.com/cloud/deep-learning",
26
- "https://www.who.int/news-room/questions-and-answers/item/radiation-5g-mobile-networks-and-health",
27
- "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6167940/",
28
- "https://www.tesla.com/blog/benefits-of-electric-vehicles",
29
- "https://www.mayoclinic.org/drugs-supplements/caffeine-oral-route/side-effects",
30
- "https://www.nationalgeographic.com/environment/article/climate-change",
31
- "https://www.duolingo.com/blog/best-way-to-learn-a-new-language",
32
- "https://www.tesla.com/blog/are-electric-cars-better-than-gasoline-cars",
33
- "https://www.healthline.com/nutrition/vegan-diet-benefits"
34
- ]
35
-
36
- # Function to validate URL
37
- def validate_url(user_query, url_to_check):
38
- result = validator.rate_url_validity(user_query, url_to_check)
39
-
40
- if "Validation Error" in result:
41
- return {"Error": result["Validation Error"]}
42
-
43
- return {
44
- "Content Relevance Score": f"{result['raw_score']['Content Relevance']} / 100",
45
- "Bias Score": f"{result['raw_score']['Bias Score']} / 100",
46
- "Final Validity Score": f"{result['raw_score']['Final Validity Score']} / 100"
47
- }
48
-
49
- # Gradio UI
50
- with gr.Blocks() as app:
51
- gr.Markdown("# 🌍 URL Credibility Validator")
52
- gr.Markdown("### Validate the credibility of any webpage using AI")
53
-
54
- user_query = gr.Dropdown(queries, label="Select a search query:")
55
- url_to_check = gr.Dropdown(urls, label="Select a URL to validate:")
56
-
57
- result_output = gr.JSON(label="Validation Results")
58
-
59
- submit_button = gr.Button("Validate URL")
60
- submit_button.click(validate_url, inputs=[user_query, url_to_check], outputs=result_output)
61
-
62
- # Launch the app
63
- app.launch(server_name="0.0.0.0", server_port=7860)
64
- st way to learn a new language?",
65
- "Are electric cars better than gasoline cars?",
66
- "What are the benefits of a vegan diet?"
67
  ]
68
 
69
  urls = [
70
- "https://www.bbc.com/news/world-us-canada-64879434",
71
- "https://www.forbes.com/sites/forbestechcouncil/2023/02/20/ai-latest-developments
72
  "https://www.health.harvard.edu/mind-and-mood/foods-linked-to-better-brainpower",
73
  "https://www.nasa.gov/hrp/long-term-health-risks-of-space-travel",
74
  "https://www.investopedia.com/terms/c/cryptocurrency.asp",
@@ -77,11 +34,11 @@ urls = [
77
  "https://www.who.int/news-room/questions-and-answers/item/radiation-5g-mobile-networks-and-health",
78
  "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6167940/",
79
  "https://www.tesla.com/blog/benefits-of-electric-vehicles",
80
- "https://www.mayoclinic.org/drugs-supplements/caffeine-oral-route/side-effects",
81
- "https://www.nationalgeographic.com/environment/article/climate-change",
82
  "https://www.duolingo.com/blog/best-way-to-learn-a-new-language",
83
- "https://www.tesla.com/blog/are-electric-cars-better-than-gasoline-cars",
84
- "https://www.healthline.com/nutrition/vegan-diet-benefits"
 
 
85
  ]
86
 
87
  # Function to validate URL
 
1
  import gradio as gr
2
  from deliverable2 import URLValidator
3
 
4
+ # Instantiate the validator
5
  validator = URLValidator()
6
 
7
+ # Ensure queries and URLs are properly formatted
8
  queries = [
9
+ "How does climate change impact global weather?",
10
  "What are the latest advancements in AI?",
11
  "How does diet influence mental health?",
12
  "What are the effects of space travel on astronauts?",
 
16
  "What are the health risks of 5G technology?",
17
  "Is intermittent fasting effective for weight loss?",
18
  "How do electric vehicles compare to gas cars?",
19
+ "What are the best ways to learn a new language?",
20
  "What are the side effects of caffeine?",
21
+ "How does exercise affect mental health?",
22
+ "Is a vegan diet good for your health?",
23
+ "What is the best way to improve sleep quality?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  ]
25
 
26
  urls = [
27
+ "https://www.nationalgeographic.com/environment/article/climate-change",
28
+ "https://www.technologyreview.com/2023/05/01/latest-ai-advancements/",
29
  "https://www.health.harvard.edu/mind-and-mood/foods-linked-to-better-brainpower",
30
  "https://www.nasa.gov/hrp/long-term-health-risks-of-space-travel",
31
  "https://www.investopedia.com/terms/c/cryptocurrency.asp",
 
34
  "https://www.who.int/news-room/questions-and-answers/item/radiation-5g-mobile-networks-and-health",
35
  "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6167940/",
36
  "https://www.tesla.com/blog/benefits-of-electric-vehicles",
 
 
37
  "https://www.duolingo.com/blog/best-way-to-learn-a-new-language",
38
+ "https://www.mayoclinic.org/drugs-supplements/caffeine-oral-route/side-effects",
39
+ "https://www.cdc.gov/physicalactivity/basics/pa-health/index.htm",
40
+ "https://www.healthline.com/nutrition/vegan-diet-benefits",
41
+ "https://www.sleepfoundation.org/how-sleep-works/how-to-get-better-sleep"
42
  ]
43
 
44
  # Function to validate URL