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)