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("""
""", unsafe_allow_html=True)
# --- Page Title ---
# Wrapped the title and introductory text in a centered-div
st.markdown('
', 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('
', unsafe_allow_html=True)
# --- Tabs ---
tab1, tab2 = st.tabs(["ποΈ E-commerce", "π¦ Bank"])
# ================= E-COMMERCE TAB =================
with tab1:
st.markdown('', 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: [chiraagpv2000@gmail.com](mailto:chiraagpv2000@gmail.com)")
st.markdown('
', unsafe_allow_html=True)
# ================= BANK TAB =================
with tab2:
st.markdown('', 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?: [chiraagpv2000@gmail.com](mailto:chiraagpv2000@gmail.com)")
st.markdown('
', unsafe_allow_html=True)