Skip to content

Latest commit

Β 

History

38 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NexusSupport AI Logo

NexusSupport AI

Intelligent Support Orchestration with ML, RAG, LLMs & AI Agents

Classify Β· Retrieve Β· Decide Β· Generate Β· Escalate Β· Monitor


✦ Overview

NexusSupport AI is an end-to-end AI engineering project that brings together classical machine learning, transformer-based deep learning, Retrieval-Augmented Generation (RAG), large language models, agentic decision-making, API serving, monitoring and containerization.

The goal is simple:

Build a support system that can understand a request, find trusted information, produce a grounded response and know when it should stop and ask for human help.

Unlike a simple chatbot, NexusSupport AI is designed as a complete AI application pipeline.

Customer Request
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Text Preprocessing  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Ticket Classificationβ”‚
β”‚ TF-IDF + Logistic Regβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
   Confidence Check
      /          \
    Low           Good
     β”‚              β”‚
     β–Ό              β–Ό
 Escalate      RAG Retrieval
                  β”‚
                  β–Ό
            Evidence Check
              /       \
            Weak      Strong
             β”‚          β”‚
             β–Ό          β–Ό
          Escalate      LLM
                           β”‚
                           β–Ό
                    Grounded Answer
                           β”‚
                           β–Ό
                       Metrics

✨ Why NexusSupport AI?

A real AI product needs more than a model.

It needs a way to:

  • understand incoming data,
  • select an appropriate prediction model,
  • retrieve reliable information,
  • use an LLM safely,
  • make decisions based on intermediate results,
  • expose the system as a service,
  • monitor system behavior,
  • and package the application for deployment.

NexusSupport AI combines these responsibilities in one modular project.

It is especially useful as a portfolio project because it demonstrates the full path from data β†’ model β†’ GenAI β†’ API β†’ monitoring β†’ deployment.



πŸš€ What Can It Do?

Imagine a customer sends:

"I was charged twice for my Pro plan. Can I get a refund?"

NexusSupport AI can:

Stage What happens
🧹 Preprocess Cleans and prepares the message
🧠 Classify Predicts the support category
🎯 Evaluate confidence Checks whether the prediction is reliable
πŸ”Ž Retrieve Searches the FAQ knowledge base
πŸ“š Ground Supplies relevant evidence to the LLM
✍️ Generate Produces a natural-language response
πŸ›‘οΈ Escalate Avoids guessing when confidence/evidence is weak
πŸ“Š Monitor Records request and latency metrics

The system currently supports four demonstration ticket categories:

billing
technical
account
general


🧩 Core Capabilities

01 Β· Classical Machine Learning

The baseline classifier uses:

Raw Ticket
    ↓
Text Cleaning
    ↓
TF-IDF
    ↓
Logistic Regression
    ↓
Category + Confidence

Why use a baseline?

A strong ML engineering workflow does not begin with the most complicated model.

The classical model provides a fast and interpretable reference point. The project can then compare it against a transformer model.

Evaluation includes:

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Confusion matrix
  • Class distribution

The trained pipeline is saved to:

models/ticket_classifier.joblib

02 Β· Transformer Deep Learning

The project also fine-tunes DistilBERT for the same classification problem.

Support Ticket
      ↓
Tokenizer
      ↓
DistilBERT
      ↓
Classification Head
      ↓
Predicted Category

This creates a useful comparison:

Approach Main idea
TF-IDF + Logistic Regression Fast classical NLP baseline
DistilBERT Context-aware transformer model

The purpose is not simply to use a transformer because it is larger.

The purpose is to evaluate whether its additional complexity provides a meaningful improvement.


03 Β· Retrieval-Augmented Generation

The RAG system gives the LLM access to the project's knowledge base.

FAQ Documents
      ↓
Chunking
      ↓
Sentence Embeddings
      ↓
FAISS Index
      ↓
Semantic Retrieval
      ↓
Relevant Context
      ↓
LLM
      ↓
Grounded Answer

Knowledge-base documents are stored under:

data/knowledge_base/
β”œβ”€β”€ account_faq.txt
β”œβ”€β”€ billing_faq.txt
β”œβ”€β”€ general_faq.txt
└── technical_faq.txt

The current pipeline uses:

  • Sentence Transformers
  • all-MiniLM-L6-v2
  • FAISS
  • Anthropic Claude

Why RAG?

Instead of asking the LLM to answer from memory alone:

Question β†’ LLM β†’ Answer

NexusSupport AI uses:

Question
   ↓
Search trusted documents
   ↓
Relevant evidence
   ↓
LLM
   ↓
Grounded answer

This also means the knowledge base can be updated without retraining the LLM.


04 Β· AI Agent

The agent is the orchestration layer.

It connects classification, retrieval, decision-making and generation.

                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚ Incoming Request β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚   Classify       β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚ Confidence OK?   β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       No / \ Yes
                         /   \
                        β–Ό     β–Ό
                   Escalate  Retrieve
                               β”‚
                               β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚ Evidence OK?  β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                           No / \ Yes
                             /   \
                            β–Ό     β–Ό
                       Escalate   LLM
                                   β”‚
                                   β–Ό
                                Answer

The agent uses explicit decision points rather than blindly generating a response.

This is an important difference between a simple chatbot and an agentic workflow.



πŸ—οΈ System Architecture

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚        USER         β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚       FastAPI       β”‚
                         β”‚       app.py        β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚    SupportAgent     β”‚
                         β”‚      agent.py       β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                     β”‚                     β”‚
              β–Ό                     β–Ό                     β–Ό
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚ Classical ML  β”‚     β”‚      RAG      β”‚     β”‚      LLM      β”‚
      β”‚ TF-IDF + LR   β”‚     β”‚ Embeddings    β”‚     β”‚    Claude     β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚ + FAISS       β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β–Ό
                              Final Response
                                     β”‚
                                     β–Ό
                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                           β”‚ Streamlit Monitor β”‚
                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ DistilBERT Comparison    β”‚
                    β”‚ deep_learning.py         β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                    Docker β†’ AWS / GCP


πŸ“ Project Structure

nexussupport-ai/
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ generate_sample_data.py
β”‚   β”œβ”€β”€ support_tickets.csv
β”‚   └── knowledge_base/
β”‚       β”œβ”€β”€ account_faq.txt
β”‚       β”œβ”€β”€ billing_faq.txt
β”‚       β”œβ”€β”€ general_faq.txt
β”‚       └── technical_faq.txt
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ preprocessing.py
β”‚   β”œβ”€β”€ classical_ml.py
β”‚   β”œβ”€β”€ deep_learning.py
β”‚   β”œβ”€β”€ rag_pipeline.py
β”‚   β”œβ”€β”€ agent.py
β”‚   └── app.py
β”‚
β”œβ”€β”€ dashboard/
β”‚   └── dashboard.py
β”‚
β”œβ”€β”€ deploy/
β”‚   └── README.md
β”‚
β”œβ”€β”€ models/
β”‚   └── ticket_classifier.joblib
β”‚
β”œβ”€β”€ assets/
β”‚   └── nexussupport-ai-logo.png
β”‚
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
└── README.md


πŸ› οΈ Technology Stack

Layer Technology
Language 🐍 Python
Data Pandas Β· NumPy
Classical ML Scikit-learn
NLP TF-IDF
Deep Learning PyTorch
Transformer DistilBERT
Embeddings Sentence Transformers
Vector Search FAISS
Generative AI Anthropic Claude
Agent Custom Agent Workflow
API FastAPI + Uvicorn
Dashboard Streamlit
Visualization Plotly
Model Storage Joblib
Container Docker
Cloud AWS / GCP


βš™οΈ Installation

Prerequisites

Recommended environment:

  • Python 3.11
  • Git
  • Internet connection for model downloads
  • Anthropic API key for LLM-based features
  • Docker (optional)

1. Clone the repository

git clone https://github.com/DewmikaSenarathna/NexusSupport-AI
cd nexussupport-ai

2. Create a virtual environment

Windows PowerShell

python -m venv venv
.\venv\Scripts\Activate.ps1

Windows CMD

python -m venv venv
venv\Scripts\activate

Linux / macOS

python3 -m venv venv
source venv/bin/activate

3. Install dependencies

python -m pip install --upgrade pip
pip install -r requirements.txt

4. Configure the LLM API key

Windows PowerShell

$env:GOOGLE_API_KEY="YOUR_API_KEY"

Linux / macOS

export GOOGLE_API_KEY="YOUR_API_KEY"


▢️ Run the Project

For the cleanest learning experience, run the components in this order.

Step 1 - Generate demonstration data

python data/generate_sample_data.py

This creates the synthetic support-ticket dataset and the FAQ knowledge base.


Step 2 - Run preprocessing

python src/preprocessing.py

This checks:

  • text cleaning,
  • data splitting,
  • class distribution,
  • knowledge-base chunking.

Step 3 - Train the classical ML model

python src/classical_ml.py

This trains:

TF-IDF + Logistic Regression

and saves:

models/ticket_classifier.joblib

Step 4 - Test the RAG pipeline

python src/rag_pipeline.py

This:

  1. loads FAQ documents,
  2. creates chunks,
  3. creates embeddings,
  4. searches with FAISS,
  5. sends relevant context to the LLM,
  6. generates an answer.

The first run may download the embedding model.


Step 5 - Test the AI agent

python src/agent.py

This runs the complete:

Classify
   ↓
Confidence Check
   ↓
Retrieve
   ↓
Evidence Check
   ↓
Generate / Escalate

workflow.


Step 6 - Start the FastAPI service

uvicorn src.app:app --reload --port 8000

Open:

http://localhost:8000/docs

FastAPI provides interactive documentation for the available endpoints.


Step 7 - Start the monitoring dashboard

Keep FastAPI running and open another terminal.

streamlit run dashboard/dashboard.py

The dashboard normally opens at:

http://localhost:8501

Step 8 - Run DistilBERT

When the main system is working:

python src/deep_learning.py

This fine-tunes DistilBERT and evaluates it against the classical ML approach.

A GPU is recommended for faster training.



πŸ”Œ API Endpoints

Method Endpoint Purpose
GET /health Check API status
POST /classify Classify a support ticket
POST /ask Run RAG + LLM answering
POST /agent Run the complete agent workflow
GET /metrics View API metrics

Example: /classify

{
  "text": "I was charged twice for my subscription"
}

Possible response:

{
  "category": "billing",
  "confidence": 0.94,
  "all_scores": {
    "account": 0.01,
    "billing": 0.94,
    "general": 0.02,
    "technical": 0.03
  }
}

The exact values depend on the trained model.



πŸ“Š Monitoring

The Streamlit dashboard provides two main views.

Model Performance

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        MODEL PERFORMANCE            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                     β”‚
β”‚  Accuracy                           β”‚
β”‚  Confusion Matrix                   β”‚
β”‚  Class Distribution                 β”‚
β”‚                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Live API Metrics

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          LIVE API METRICS           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Total Requests                      β”‚
β”‚ Average Latency                     β”‚
β”‚ Requests by Endpoint                β”‚
β”‚ Latency by Endpoint                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

These metrics are currently stored in application memory and are intended for demonstration and learning.



🐳 Docker

Build:

docker build -t nexussupport-ai .

Run:

docker run -p 8000:8000 \
  -e GOOGLE_API_KEY=YOUR_API_KEY \
  nexussupport-ai

Then open:

http://localhost:8000/docs

The project also contains deployment guidance under:

deploy/README.md


πŸ”¬ ML vs Deep Learning

One of the useful experiments in this project is comparing two different approaches to the same classification task.

                 SUPPORT TICKET
                       β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                 β”‚
              β–Ό                 β–Ό
        Classical ML       Deep Learning
              β”‚                 β”‚
        TF-IDF + LR          DistilBERT
              β”‚                 β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β–Ό
                 Compare Results

Compare:

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Training time
  • Inference behavior
  • Model complexity

This helps demonstrate model selection based on evidence, rather than choosing a model simply because it is more advanced.



🧠 Why RAG?

A language model by itself follows:

Question β†’ LLM β†’ Answer

NexusSupport AI adds a knowledge layer:

Question
   ↓
Semantic Search
   ↓
Trusted Context
   ↓
LLM
   ↓
Grounded Answer

This is useful when the answer depends on private, changing or domain-specific documents.



πŸ€– Why an Agent?

A fixed chatbot normally follows one path.

An agent can make decisions.

           "Do I understand this?"
                    β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
             β”‚             β”‚
            No            Yes
             β”‚             β”‚
             β–Ό             β–Ό
         Escalate       Retrieve
                            β”‚
                     "Is evidence good?"
                            β”‚
                       β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
                       β”‚         β”‚
                      No        Yes
                       β”‚         β”‚
                       β–Ό         β–Ό
                   Escalate     LLM
                                  β”‚
                                  β–Ό
                               Answer

This makes the workflow more controlled and explainable.



πŸ” Reliability & Safety

NexusSupport AI uses confidence and retrieval thresholds to reduce unsupported answers.

If:

classification confidence < threshold

the system can escalate.

If:

retrieval relevance < threshold

the system can also escalate.

The current values are demonstration settings and should be tuned and validated using real evaluation data before production use.



🎯 Engineering Principles

Modular design

Each major responsibility has its own module.

Preprocessing
ML
Deep Learning
RAG
Agent
API
Dashboard
Deployment

Baseline first

A simple model is established before comparing it with a transformer.

Grounded generation

The LLM receives retrieved context rather than relying only on its pretrained knowledge.

Fail safely

Low confidence can lead to human escalation instead of an unsupported answer.

Separate training from inference

The API is designed to load trained models once and reuse them for requests.

Observable system

The project records agent traces and basic API metrics.



πŸ“Œ Current Scope

NexusSupport AI is a portfolio and learning-oriented AI engineering prototype.

Current limitations

  • Support-ticket data is synthetic.
  • FAQ documents are demonstration documents.
  • API metrics are stored in memory.
  • Authentication is not implemented.
  • Long-term monitoring storage is not implemented.
  • Automated model-drift detection is not implemented.
  • Agent thresholds are fixed demonstration values.
  • Production-grade security controls are not included.

These limitations provide clear paths for future development.



πŸš€ Future Roadmap

Data & ML

  • Replace synthetic tickets with a real, properly licensed dataset
  • Add more ticket categories
  • Add multilingual support
  • Add cross-validation
  • Add hyperparameter optimization
  • Add confidence calibration

RAG

  • Add persistent vector storage
  • Add metadata filtering
  • Improve document chunking
  • Add retrieval evaluation
  • Add citation validation
  • Build automated document ingestion

Agent

  • Add ticket summarization
  • Add human approval workflow
  • Add conversation memory
  • Add additional tools
  • Improve decision policies

MLOps

  • Add experiment tracking
  • Add model versioning
  • Add model drift detection
  • Store metrics in a database
  • Add automated evaluation
  • Add CI/CD

Security

  • Add API authentication
  • Add rate limiting
  • Use a secret manager
  • Add stronger request validation
  • Add production logging and audit trails

⭐ If you find this project useful, consider starring the repository.

NexusSupport AI
From prediction to retrieval. From retrieval to reasoning.

About

End-to-end AI support platform combining ML, DistilBERT, RAG, LLM agents, FastAPI and real-time monitoring.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages