ZennyKenny commited on
Commit
cbcd78b
Β·
verified Β·
1 Parent(s): 625bc0e

initial commit

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ import pandas as pd
4
+
5
+ # Load the dataset
6
+ DATASET_URL = 'https://huggingface.co/datasets/ZennyKenny/demo_customer_nps/resolve/main/customer_feedback_dataset.csv'
7
+ df = pd.read_csv(DATASET_URL)
8
+
9
+ # Initialize the model pipeline
10
+ pipe = pipeline("text-generation", model="mistralai/Mistral-Small-24B-Base-2501")
11
+
12
+ # Function to classify customer comments
13
+ def classify_comments():
14
+ results = []
15
+ for comment in df['customer_comment']:
16
+ prompt = f"Classify this customer feedback: '{comment}' into one of five categories."
17
+ category = pipe(prompt, max_length=30)[0]['generated_text']
18
+ results.append(category)
19
+ df['comment_category'] = results
20
+ return df[['customer_comment', 'comment_category']].to_html(index=False)
21
+
22
+ # Gradio Interface
23
+ with gr.Blocks() as nps:
24
+ gr.Markdown("# NPS Comment Categorization")
25
+ classify_btn = gr.Button("Classify Comments")
26
+ output = gr.HTML()
27
+
28
+ classify_btn.click(fn=classify_comments, outputs=output)
29
+
30
+ nps.launch()