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
- Clone the repository
- Install required dependencies:
python3 -m pip install -r requirements.txt
- Make sure your OpenAI API key is set in the code (search_questions.py)
- 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
- Make sure the Qdrant server is running and accessible
- Start the Flask API server:
python3 api.py
- 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:
- Open
standalone.html
in your browser - Configure the API endpoint if needed (defaults to http://localhost:5000/api/ask)
- 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