File size: 1,292 Bytes
9b51e21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from transformers import pipeline

def generate_ticket(issue_description):
    model_name = "AventIQ-AI/bart_customer_ticket_raiser"
    generator = pipeline("text2text-generation", model=model_name)
    response = generator(issue_description, max_length=50, num_return_sequences=1)
    return response[0]['generated_text']

examples = [
    ["My internet is not working for the past 3 hours."],
    ["I am unable to log in to my account despite entering the correct credentials."],
    ["The mobile app keeps crashing whenever I try to make a payment."],
    ["I received a defective product and need a replacement."]
]

with gr.Blocks(theme=gr.themes.Soft()) as demo:
    gr.Markdown("# πŸ“© Customer Ticket Generator")
    gr.Markdown("Enter a customer issue, and the model will generate a structured support ticket.")
    
    with gr.Row():
        input_text = gr.Textbox(label="Customer Issue Description", placeholder="Describe your issue here...", lines=3)
    
    generate_btn = gr.Button("Generate Ticket πŸ“")
    output_text = gr.Textbox(label="Generated Support Ticket")
    
    generate_btn.click(generate_ticket, inputs=[input_text], outputs=[output_text])
    
    gr.Examples(examples, inputs=[input_text])

demo.launch()