import gradio as gr from transformers import pipeline # Load text generation model chatbot = pipeline( "text-generation", model="distilgpt2" ) def human_chat(user_input): prompt = ( "You are a friendly, polite, and helpful human assistant. " "Answer clearly and naturally.\n\n" f"User: {user_input}\nAssistant:" ) response = chatbot( prompt, max_length=150, do_sample=True, temperature=0.7, top_p=0.9 ) reply = response[0]["generated_text"] reply = reply.split("Assistant:")[-1].strip() return reply # Gradio UI iface = gr.Interface( fn=human_chat, inputs=gr.Textbox(lines=2, placeholder="Type your message here..."), outputs="text", title="Human-Like AI Chatbot 🤖", description="This chatbot responds in friendly, human-style language." ) iface.launch()