import gradio as gr from transformers import pipeline # This loads the AI model that understands logic classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") def analyze(topic, statement): labels = ["supports", "opposes", "neutral"] template = f"This statement is about {topic} and it {{}} it." # Running the AI logic output = classifier(statement, labels, hypothesis_template=template) # Cleaning up the result for the user verdict = output['labels'][0].upper() confidence = round(output['scores'][0] * 100, 1) return f"THE AI VERDICT: {verdict}\nCONFIDENCE: {confidence}%" # Building the visual interface with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown("# ⚖️ Argument Stance Detector") gr.Markdown("Identify if a statement is **For** or **Against** a specific topic.") with gr.Row(): with gr.Column(): topic_input = gr.Textbox(label="The Topic", placeholder="e.g. Electric Vehicles") statement_input = gr.Textbox(label="The Argument", placeholder="Type the argument here...", lines=4) submit_btn = gr.Button("Analyze Stance", variant="primary") with gr.Column(): output_text = gr.Textbox(label="AI Analysis Result", interactive=False) submit_btn.click(fn=analyze, inputs=[topic_input, statement_input], outputs=output_text) demo.launch()