Chiraag P V
Updating code.
3f0c0dc
import streamlit as st
from transformers import pipeline
import warnings
warnings.filterwarnings('ignore')
st.set_page_config(
page_title="AI Solutions for Customer Complaints",
layout="wide",
initial_sidebar_state="expanded"
)
# --- CSS for centering content and enlarging tabs ---
st.markdown("""
<style>
/* Center all content inside the page */
.centered-div {
text-align: center !important;
max-width: 800px;
margin: auto;
}
/* Center tabs */
div[role="tablist"] {
justify-content: center;
}
/* Increase tab size */
button[role="tab"] {
font-size: 20px !important;
padding: 12px 30px !important;
height: 60px !important;
}
/* Center all Streamlit headers and text elements inside the div */
.centered-div h1,
.centered-div h2,
.centered-div h3,
.centered-div h4,
.centered-div h5,
.centered-div h6,
.centered-div p {
text-align: center !important;
}
</style>
""", unsafe_allow_html=True)
# --- Page Title ---
# Wrapped the title and introductory text in a centered-div
st.markdown('<div class="centered-div">', unsafe_allow_html=True)
st.title("πŸ€– AI Customer Support Solutions")
st.markdown("""
Welcome! Explore AI-powered classification for customer complaints in **E-commerce** and **Banking**. Β 
Select a tab below to get started.
""")
st.markdown('</div>', unsafe_allow_html=True)
# --- Tabs ---
tab1, tab2 = st.tabs(["πŸ›οΈ E-commerce", "🏦 Bank"])
# ================= E-COMMERCE TAB =================
with tab1:
st.markdown('<div class="centered-div">', unsafe_allow_html=True)
st.header("E-commerce Customer Support Classification")
st.subheader("πŸ“‚ Categories You Can Explore:")
st.markdown("""
- πŸ“¦ **Delivery Problem** – Delays, lost packages, or damaged goods.
- πŸ’Έ **Returns and Refunds** – Queries about refunds or return policies.
- πŸ›’ **Product Inquiry** – Asking about product details, specifications, or availability.
- πŸ’³ **Payment Issue** – Failed transactions, double charges, or payment errors.
- πŸ—‚οΈ **...and 11 more categories fine-tuned in the model!**
""")
# --- Try It Yourself Section ---
st.subheader("πŸ”Ž Try It Yourself!")
try:
ecommerce_classifier = pipeline(
'text-classification',
model='E-commerce-customer-query-classifier',
trust_remote_code=True
)
except Exception:
st.error("⚠️ Could not load the E-commerce model.")
st.stop()
text = st.text_area("✍️ Enter the customer query:", height=150, placeholder="I haven’t received my order yet.")
if st.button("Classify E-commerce Query", use_container_width=True, type="primary"):
if text.strip():
with st.spinner('πŸ€” Analyzing the query...'):
try:
result = ecommerce_classifier(text)
st.success(f"βœ… The query has been classified as: **{result[0]['label']}**")
st.info(f"πŸ”’ Confidence Level: **{result[0]['score']:.4f}**")
except Exception as e:
st.error(f"❌ Classification error: {e}")
else:
st.warning("⚠️ Please enter a query to classify.")
st.subheader("πŸ”§ Technical Overview & Features")
st.markdown("""
**Model & Dataset:**
- Fine-tuned `distilbert-base-uncased`
- Dataset: [`Ataur77/ecommerce-customer-support`](https://huggingface.co/datasets/Ataur77/ecommerce-customer-support)
**Framework & Libraries:**
- Streamlit for interactive UI
- Hugging Face Transformers
**Features:**
- πŸš€ Quick Classification – Queries are categorized instantly.
- πŸ”Œ Offline Deployment – Works with locally stored models.
- 🧩 Scalable Design – Extendable to more categories or data.
- πŸ˜€ User-Friendly – Minimal clicks, maximum insight.
""")
st.image("e-comm-accuracy.png", caption="πŸ“Š Model Accuracy", width=700)
st.subheader("πŸ“© Contact")
st.markdown("If you’d like to collaborate or learn more: [[email protected]](mailto:[email protected])")
st.markdown('</div>', unsafe_allow_html=True)
# ================= BANK TAB =================
with tab2:
st.markdown('<div class="centered-div">', unsafe_allow_html=True)
st.header("Bank Customer Complaint Classification")
st.subheader("πŸ“‚ Example Categories:")
st.markdown("""
- πŸ’³ **Credit Card or Prepaid Card** – Fraud, charges, or transaction disputes.
- 🏦 **Checking or Savings Account** – Account balance, overdrafts, or account access.
- 🏑 **Mortgage** – Loan approvals, EMI, foreclosure, or rate queries.
""")
# --- Try It Yourself Section ---
st.subheader("πŸ”Ž Try It Yourself!")
bank_classifier = pipeline('text-classification', model='bank_customer_ticket_category_classifier')
text = st.text_area("✍️ Please describe your issue:", placeholder="My credit card was charged twice for one purchase.")
if st.button("Classify Bank Complaint", use_container_width=True, type="primary"):
if text.strip():
with st.spinner('πŸ” Analyzing complaint...'):
result = bank_classifier(text)
st.success(f"βœ… Your issue is classified under: **{result[0]['label']}**")
st.info(f"πŸ”’ Confidence Level: **{result[0]['score']:.4f}**")
else:
st.warning("⚠️ Please enter your complaint.")
st.subheader("πŸ”§ Technical Overview & Features")
st.markdown("""
**Model & Framework:**
- Fine-tuned Transformer
- Streamlit for rapid prototyping
**Libraries:**
- Hugging Face Transformers
**Features:**
- ⏱️ Faster Processing – No waiting for manual triage.
- πŸ“Š High Accuracy – Reliable complaint classification.
- πŸ“‘ Scalability – Handles thousands of inputs seamlessly.
""")
st.image("bank-accuracy.png", caption="πŸ“Š Model Accuracy", width=700)
st.subheader("πŸ“© Contact")
st.markdown("Reach out?: [[email protected]](mailto:[email protected])")
st.markdown('</div>', unsafe_allow_html=True)