Sanjayraju30 commited on
Commit
40afb3a
Β·
verified Β·
1 Parent(s): 985bcdd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -1,21 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # βœ… Use Google's FLAN-T5 small (fast + publicly available)
5
  generator = pipeline("text2text-generation", model="google/flan-t5-small")
6
 
7
- # 🧠 Refined Prompt Template for Polite, Humble Tone
8
  TEMPLATE = (
9
- "You are a courteous, humble, and professional customer support agent. "
10
- "Please write a polite and helpful response to this customer message:\n\n"
11
- "{input}\n\nResponse:"
12
  )
13
 
14
- # πŸ” Generate Reply Function
15
  def generate_reply(user_input):
16
  prompt = TEMPLATE.format(input=user_input)
17
- response = generator(prompt, max_length=100, do_sample=False)[0]["generated_text"]
18
-
19
  return response.strip()
20
 
21
  # πŸŽ›οΈ Gradio Interface
@@ -23,8 +21,8 @@ iface = gr.Interface(
23
  fn=generate_reply,
24
  inputs=gr.Textbox(lines=6, label="Customer Message", placeholder="Enter complaint or question..."),
25
  outputs=gr.Textbox(label="Polite Support Reply"),
26
- title="πŸ’¬ Polite Auto-Reply Generator for Customer Support",
27
- description="Generate humble, polite, and brand-consistent replies using FLAN-T5. Ideal for CRM and helpdesk automation.",
28
  examples=[
29
  ["I still haven't received my order and it's been 10 days."],
30
  ["Why was I charged twice for my subscription?"],
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # βœ… Fast model
5
  generator = pipeline("text2text-generation", model="google/flan-t5-small")
6
 
7
+ # 🧠 Prompt Template
8
  TEMPLATE = (
9
+ "You are a polite, humble, and professional customer support agent. "
10
+ "Respond to the following customer message:\n\n{input}\n\nReply:"
 
11
  )
12
 
13
+ # πŸ” Generate Reply
14
  def generate_reply(user_input):
15
  prompt = TEMPLATE.format(input=user_input)
16
+ response = generator(prompt, max_length=60, do_sample=False)[0]["generated_text"]
 
17
  return response.strip()
18
 
19
  # πŸŽ›οΈ Gradio Interface
 
21
  fn=generate_reply,
22
  inputs=gr.Textbox(lines=6, label="Customer Message", placeholder="Enter complaint or question..."),
23
  outputs=gr.Textbox(label="Polite Support Reply"),
24
+ title="⚑ Ultra-Fast Auto-Reply Generator for Customer Support",
25
+ description="Get polite, helpful replies in seconds using FLAN-T5-small. Built for speed + tone.",
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?"],