from huggingface_hub import InferenceClient import gradio as gr import random # Set up the client for FLAN-T5-XL model inference client = InferenceClient("google/flan-t5-xl") def generate_text(prompt, max_length=500): response = client.text_generation(prompt, max_new_tokens=max_length, temperature=0.7) return response def debate_assistant(topic, stance): # Generate the main argument argument_prompt = f"""Generate a comprehensive argument for the following debate topic: Topic: {topic} Stance: {stance} Include: 1. Main claim 2. Three supporting points 3. Potential counterargument 4. Rebuttal 5. Conclusion""" argument = generate_text(argument_prompt, max_length=600) # Generate a counterargument counter_prompt = f"""Generate a counterargument for the following debate topic: Topic: {topic} Original Stance: {stance} Include: 1. Counter-claim 2. Three rebuttals 3. New supporting point 4. Conclusion""" counterargument = generate_text(counter_prompt, max_length=600) # Generate analysis analysis_prompt = f"""Analyze the debate on the following topic: Topic: {topic} Provide: 1. Topic categorization 2. Two ethical considerations 3. Three discussion questions""" analysis = generate_text(analysis_prompt, max_length=400) return f"""Argument ({stance}): {argument} Counterargument: {counterargument} Analysis: {analysis}""" def suggest_topic(): topics = [ "Should artificial intelligence be regulated?", "Is universal basic income a viable economic policy?", "Should voting be mandatory?", "Is space exploration a worthwhile investment?", "Should gene editing in humans be allowed?", "Is nuclear energy the solution to climate change?", "Should social media platforms be held responsible for user content?", "Is a four-day work week beneficial for society?", "Should animal testing be banned?", "Is globalization overall positive or negative for developing countries?" ] return random.choice(topics) # Create the Gradio interface iface = gr.Interface( fn=debate_assistant, inputs=[ gr.Textbox(label="Debate Topic", placeholder="Enter a topic or click 'Suggest Topic'"), gr.Radio(["For", "Against"], label="Stance") ], outputs=gr.Textbox(label="Generated Debate Content"), title="AI-powered Debate Assistant (FLAN-T5-XL)", description="Enter a debate topic and choose a stance to generate arguments, counterarguments, and analysis.", examples=[ ["Should artificial intelligence be regulated?", "For"], ["Is universal basic income a viable economic policy?", "Against"], ["Should gene editing in humans be allowed?", "For"] ] ) iface.launch()