import gradio as gr from transformers import pipeline # 🚀 Use lightweight, faster FLAN model generator = pipeline("text2text-generation", model="google/flan-t5-xs") # ✨ Prompt Template TEMPLATE = ( "You are a polite and professional customer support agent. " "Please respond to the customer's message:\n\n{input}" ) # 🎯 Response Function def generate_reply(user_input): prompt = TEMPLATE.format(input=user_input) response = generator(prompt, max_length=80, do_sample=False)[0]["generated_text"] return response.strip() # 🎛 Interface iface = gr.Interface( fn=generate_reply, inputs=gr.Textbox(lines=6, label="Customer Message", placeholder="Enter complaint or question..."), outputs=gr.Textbox(label="Support Reply"), title="⚡ Fast Auto-Reply Generator for Customer Support", description="Fast & polite auto-replies to customer complaints using a tiny FLAN-T5 model. Perfect for CRM or helpdesk automation.", examples=[ ["I still haven't received my order and it's been 10 days."], ["Why was I charged twice for my subscription?"], ["Thanks for the quick response yesterday!"], ["My login isn't working since the update."] ] ) iface.launch()