41 – Real-World Python Projects – AI Chat Summarizer

This project creates an AI system that:

✔ Reads long chat conversations
✔ Automatically summarizes key points
✔ Extracts decisions, tasks, and action items
✔ Highlights important messages
✔ Exports the summary
✔ Works with chat files (WhatsApp, Telegram, Teams, Slack, Messenger)

This is extremely useful for:

  • Meeting summaries
  • Customer support chat logs
  • WhatsApp group archives
  • Telegram export files
  • Long AI discussion threads

🧠 What You Will Build

Your AI Chat Summarizer will:

✔ Allow user to upload a chat/text file

✔ Clean and preprocess conversation

✔ Run AI summarization

✔ Generate bullet points + detailed summary

✔ Identify key action items

✔ Display summary in UI (Streamlit)

✔ Export summary as PDF or TXT


🧰 Tech Stack

  • Python
  • Transformers (HuggingFace) or GPT API
  • Streamlit (dashboard UI)
  • Pandas
  • NLTK/TextBlob (optional cleaning)
  • pypdf (optional PDF export)

📁 Folder Structure

AIChatSummarizer/
│── app.py
│── summarizer.py
│── requirements.txt
│── sample_chat.txt

📦 requirements.txt

streamlit
transformers
torch
pandas
nltk

Install:

pip install -r requirements.txt

🧩 Full Working Code — summarizer.py

from transformers import pipeline

summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

def clean_text(text):
    lines = text.split("\n")
    cleaned = [line for line in lines if line.strip() != ""]
    return " ".join(cleaned)

def summarize_chat(text, max_len=200):
    text = clean_text(text)

    summary = summarizer(
        text,
        max_length=max_len,
        min_length=80,
        do_sample=False
    )[0]['summary_text']

    return summary

🧩 Streamlit App (app.py)

import streamlit as st
from summarizer import summarize_chat

st.title("AI Chat Summarizer")
st.write("Upload any chat log to automatically generate a summary.")

file = st.file_uploader("Upload chat file (.txt)", type=['txt'])

if file:
    text = file.read().decode("utf-8")
    st.subheader("Original Chat Preview")
    st.text(text[:1000] + " ...")

    if st.button("Generate Summary"):
        with st.spinner("Summarizing..."):
            summary = summarize_chat(text)

        st.success("Summary Generated")
        st.subheader("Chat Summary")
        st.write(summary)

▶ Run the dashboard

streamlit run app.py

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *