Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
from deliverable2 import URLValidator # Ensure this file exists in the same directory | |
# Instantiate Validator | |
validator = URLValidator() | |
# Define function for Gradio UI | |
def validate_url(user_query, url_to_check): | |
""" Validate URL credibility based on user query. """ | |
result = validator.rate_url_validity(user_query, url_to_check) | |
return { | |
"Domain Trust": result["raw_score"]["Domain Trust"], | |
"Content Relevance": result["raw_score"]["Content Relevance"], | |
"Fact-Check Score": result["raw_score"]["Fact-Check Score"], | |
"Bias Score": result["raw_score"]["Bias Score"], | |
"Citation Score": result["raw_score"]["Citation Score"], | |
"Final Validity Score": result["raw_score"]["Final Validity Score"], | |
"Star Rating": result["stars"]["icon"], | |
"Explanation": result["explanation"] | |
} | |
# Create Gradio Interface | |
iface = gr.Interface( | |
fn=validate_url, | |
inputs=[ | |
gr.Textbox(label="Enter Your Search Query"), | |
gr.Textbox(label="Enter the URL to Check") | |
], | |
outputs="json", | |
title="URL Credibility Checker", | |
description="Enter a query and a URL to check its credibility.", | |
) | |
# Launch Gradio App | |
iface.launch(share=True) | |