import gradio as gr from transformers import pipeline # Load text generation model chatbot = pipeline("text-generation", model="distilgpt2") def respond(message, history): # Combine chat history into context prompt = "" for user, bot in history: prompt += f"User: {user}\nBot: {bot}\n" prompt += f"User: {message}\nBot:" # Generate response response = chatbot( prompt, max_length=200, do_sample=True, temperature=0.7 ) bot_reply = response[0]["generated_text"].split("Bot:")[-1].strip() return bot_reply # WhatsApp-style interface demo = gr.ChatInterface( respond, title="💬 WhatsApp-Style AI Chatbot", description="Type a message and chat with AI" ) demo.launch()