Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
generator = pipeline("text2text-generation", model="google/flan-t5-
|
6 |
|
7 |
-
#
|
8 |
TEMPLATE = (
|
9 |
-
"You are a
|
10 |
-
"
|
11 |
-
"{input}"
|
12 |
)
|
13 |
|
14 |
-
#
|
15 |
def generate_reply(user_input):
|
16 |
prompt = TEMPLATE.format(input=user_input)
|
17 |
-
response = generator(prompt, max_length=
|
18 |
return response.strip()
|
19 |
|
20 |
-
#
|
21 |
iface = gr.Interface(
|
22 |
fn=generate_reply,
|
23 |
inputs=gr.Textbox(lines=6, label="Customer Message", placeholder="Enter complaint or question..."),
|
24 |
-
outputs=gr.Textbox(label="
|
25 |
-
title="
|
26 |
-
description=
|
27 |
-
"Generate fast, polite, and professional replies to customer queries using Google's FLAN-T5 model. "
|
28 |
-
"Perfect for CRM bots, helpdesk automation, and ticket response."
|
29 |
-
),
|
30 |
examples=[
|
31 |
["I still haven't received my order and it's been 10 days."],
|
32 |
-
["
|
33 |
-
["
|
34 |
-
["
|
35 |
]
|
36 |
)
|
37 |
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# π Use lightweight, faster FLAN model
|
5 |
+
generator = pipeline("text2text-generation", model="google/flan-t5-xs")
|
6 |
|
7 |
+
# β¨ Prompt Template
|
8 |
TEMPLATE = (
|
9 |
+
"You are a polite and professional customer support agent. "
|
10 |
+
"Please respond to the customer's message:\n\n{input}"
|
|
|
11 |
)
|
12 |
|
13 |
+
# π― Response Function
|
14 |
def generate_reply(user_input):
|
15 |
prompt = TEMPLATE.format(input=user_input)
|
16 |
+
response = generator(prompt, max_length=80, do_sample=False)[0]["generated_text"]
|
17 |
return response.strip()
|
18 |
|
19 |
+
# π Interface
|
20 |
iface = gr.Interface(
|
21 |
fn=generate_reply,
|
22 |
inputs=gr.Textbox(lines=6, label="Customer Message", placeholder="Enter complaint or question..."),
|
23 |
+
outputs=gr.Textbox(label="Support Reply"),
|
24 |
+
title="β‘ Fast Auto-Reply Generator for Customer Support",
|
25 |
+
description="Fast & polite auto-replies to customer complaints using a tiny FLAN-T5 model. Perfect for CRM or helpdesk automation.",
|
|
|
|
|
|
|
26 |
examples=[
|
27 |
["I still haven't received my order and it's been 10 days."],
|
28 |
+
["Why was I charged twice for my subscription?"],
|
29 |
+
["Thanks for the quick response yesterday!"],
|
30 |
+
["My login isn't working since the update."]
|
31 |
]
|
32 |
)
|
33 |
|