Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# β Fast model | |
generator = pipeline("text2text-generation", model="google/flan-t5-small") | |
# π§ Prompt Template | |
TEMPLATE = ( | |
"You are a polite, humble, and professional customer support agent. " | |
"Respond to the following customer message:\n\n{input}\n\nReply:" | |
) | |
# π Generate Reply | |
def generate_reply(user_input): | |
prompt = TEMPLATE.format(input=user_input) | |
response = generator(prompt, max_length=60, do_sample=False)[0]["generated_text"] | |
return response.strip() | |
# ποΈ Gradio Interface | |
iface = gr.Interface( | |
fn=generate_reply, | |
inputs=gr.Textbox(lines=6, label="Customer Message", placeholder="Enter complaint or question..."), | |
outputs=gr.Textbox(label="Polite Support Reply"), | |
title="β‘ Ultra-Fast Auto-Reply Generator for Customer Support", | |
description="Get polite, helpful replies in seconds using FLAN-T5-small. Built for speed + tone.", | |
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() | |