ss
Joe Chen authored
3fc5e3e4
Name Last commit Last update
__pycache__ ss
static ss
.DS_Store ss
.env ss
.gitignore Initial commit
README.md Initial commit
chat_history_cleaned.xlsx ss
extract_excel_data.py ss
main.py ss
merged.xlsx ss
new_logic.py ss
qa_pairs.xlsx ss
qdrant_test.py ss
requirements.txt ss
search_questions.py ss
search_result.json ss
search_result_new.json ss
test.py ss

Customer Support Q&A System

A question answering system for customer support that uses semantic search to find relevant chat histories and generates answers based on the retrieved information.

Features

  • Semantic search using OpenAI embeddings and Qdrant vector database
  • Flask API backend for handling question answering
  • Modern web interface for asking questions
  • Combined context from multiple chat histories for better answers
  • GPT-4o-mini powered answer generation

Prerequisites

  • Python 3.x
  • OpenAI API key
  • Qdrant server running (URL configured in the code)

Installation

  1. Clone the repository
  2. Install required dependencies:
python3 -m pip install -r requirements.txt
  1. Make sure your OpenAI API key is set in the code (search_questions.py)
  2. Ensure the Qdrant server URL is correctly configured (default: http://10.80.7.190:6333)

Running the Application

Quick Start

Use the provided startup script:

./start_app.sh

This script will check for dependencies, install them if needed, and start the server.

Manual Start

  1. Make sure the Qdrant server is running and accessible
  2. Start the Flask API server:
python3 api.py
  1. Access the web interface at http://localhost:5000

Using the Standalone HTML

If you prefer not to run the Flask server, you can use the standalone.html file:

  1. Open standalone.html in your browser
  2. Configure the API endpoint if needed (defaults to http://localhost:5000/api/ask)
  3. Ask questions and get answers

API Usage

The system exposes a simple API endpoint at /api/ask that accepts POST requests with a JSON body:

{
  "question": "How do I reset my password?"
}

The response is a JSON object with the following structure:

{
  "question": "How do I reset my password?",
  "answer": "To reset your password, go to the login page and click on 'Forgot Password'. Then follow the instructions sent to your email.",
  "results": [
    {
      "score": 0.89,
      "question": "What's the process to reset my password?",
      "answer": "Click on 'Forgot Password' on the login screen and follow email instructions.",
      "chat_id": 123,
      "preview": "2024-10-30 16:00:00 - Customer: How do I reset my password?..."
    }
  ]
}

Configuration

The system uses the following default settings (configured in search_questions.py):

  • Default threshold: 0.5 (minimum similarity score)
  • Default result limit: 4 (maximum number of results to return)
  • Embedding model: text-embedding-3-small
  • LLM for answer generation: gpt-4o-mini

Files Overview

  • api.py - Flask API server
  • search_questions.py - Core search and question-answering functionality
  • main.py - Data processing and vector database preparation
  • static/index.html - Web interface for the Flask server
  • standalone.html - Standalone web interface that can be used independently
  • requirements.txt - List of required Python packages
  • start_app.sh - Startup script to check dependencies and launch the server