This repository contains an AI-powered bot built to serve an imaginary e-commerce platform by answering Frequently Asked Questions (FAQs). The bot is designed with a specific business purpose in mind: to provide accurate and timely answers to customer queries, enhancing the overall user experience.
The following technologies were used to develop this AI-powered bot:
- Java 21: The latest version of Java, offering enhanced performance, including the use of:
- Virtual Threads: For lightweight, high-concurrency processing.
- Records: For simplifying immutable data carrier classes.
- JDBC Client: For efficient interaction with the PGVector database.
- Spring Boot 3.3: A robust framework for building Java applications, used for structuring the backend.
- Spring AI: Seamless integration of AI capabilities within the Spring Boot ecosystem.
- OpenAI's GPT-4: The cutting-edge natural language model powering the bot's responses.
- Docker: Containerization for easy deployment and environment consistency.
- PGVector Database: A vector database used to store and retrieve embeddings for efficient querying.
- AI-Powered Responses: Uses OpenAI's GPT-4 model to generate intelligent and context-aware responses to user queries.
- Business-Specific Focus: Tailored to address FAQs related to the e-commerce domain, with a focus on improving customer support.
- Scalable Architecture: Built using Spring Boot and Docker, allowing for easy scaling and deployment.
- Virtual Threads: High-concurrency management using Java 21’s virtual threads to handle large numbers of concurrent requests efficiently.
- Records for Data Handling: Simplifies data structures, making the code more maintainable and concise.
- JDBC Client: Enables direct interaction with the PGVector database for fast and reliable data retrieval.
- Vector-Based Search: Utilizes PGVector for fast and relevant query results.
The AI-powered bot was built to cater to an e-commerce platform, where providing fast and accurate responses to FAQs is crucial for enhancing customer satisfaction and reducing manual support efforts. It is designed to handle common customer queries, providing instant and relevant answers.
-
Install Java 21: Ensure Java 21 is installed.
-
Clone the Repository:
git clone https://github.com/your-repo/ai-powered-faq-bot.git cd ai-powered-faq-bot
-
Set Environment Variables:
OPENAI_API_KEY
: Set this to your OpenAI API secret key.
-
Install Docker:
- The Postgres database will be created and initialized on the first run via Docker Compose.
-
Create Vector Table: Run the following SQL commands in your Postgres database:
CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS hstore; CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE IF NOT EXISTS vector_store ( id uuid DEFAULT uuid_generate_v4() PRIMARY KEY, content text, metadata json, embedding vector(1536) -- 1536 is the default embedding size ); CREATE INDEX ON vector_store USING HNSW (embedding vector_cosine_ops);
-
Open the Project in IntelliJ: Import the project in IntelliJ IDEA.
-
Run Maven Clean and Install:
mvn clean install
-
Run the Project: The project runs on port
:8080
.