Skip to content

RohinV/Customer-Support-Chatbot

Repository files navigation

Customer Support Chatbot

An AI-powered customer support chatbot with REST API.

Installation

Windows

  1. Create conda environment and install dependencies:
conda env create -f environment-cpu.yml
conda activate chatbot
  1. Fix PyTorch DLL issue (Windows only):
pip uninstall torch torchvision torchaudio -y
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
  1. Install API dependencies:
pip install fastapi uvicorn[standard] pydantic python-multipart

Usage

Start API Server

conda activate chatbot
python scripts/start_api.py

The server will start at:

Interactive Chat

python scripts/run_chat.py

Train Model

python scripts/train_model.py

Test the API

Option 1: Use the built-in test client (Recommended)

# Start API in one terminal
python scripts/start_api.py

# Run test client in another terminal
python test_api_client.py

Option 2: Use Python requests

import requests

# Health check
response = requests.get("http://localhost:8000/health")
print(response.json())

# Multi-turn conversation
session_id = "user123"

# First message
response1 = requests.post(
    "http://localhost:8000/chat",
    json={"message": "Hi, I'm having trouble logging in", "session_id": session_id}
)
print("Bot:", response1.json()["response"])

# Follow-up (bot remembers the context)
response2 = requests.post(
    "http://localhost:8000/chat",
    json={"message": "My email is user@example.com", "session_id": session_id}
)
print("Bot:", response2.json()["response"])

API Features

  • Multi-turn Conversations: The API maintains conversation history per session_id
  • Automatic Escalation: Detects when human intervention is needed
  • Session Management: Each conversation keeps its own context
  • Metrics Tracking: Monitor response times, escalation rates, and satisfaction scores

Configuration

Edit config.py to modify model settings and parameters.

Note: For Windows users, quantization is disabled by default in config.py (USE_4BIT_QUANTIZATION = False). If you need to restart the API after changing config, press Ctrl+C in the terminal running the API server and start it again.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages