import gradio as gr from Deliverable2 import URLValidator # Instantiate the validator validator = URLValidator() # ✅ Updated queries and URLs queries = [ "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", "Python programming tutorials", "Mental health awareness" ] urls = [ "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://realpython.com", "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)