This project serves as a boilerplate and an illustration of an RAG chatbot built in Java using the LangChain4j library. The chatbot utilizes Qdrant Db as its vectorstore. Within this project, you will find implementations of both a Basic RAG chatbot and an Advanced RAG chatbot.
- Java
- Spring Boot (Maven)
- Langchain4j
- Qdrant DB
- OpenAI
Before you start working with this project, make sure you have the following prerequisites installed:
-
- Compatible with Windows, macOS, or Linux.
-
- A machine with at least 4GB RAM and a dual-core processor.
-
- Install Java 17 or a compatible version.
-
- (Optional) Choose a Java IDE of your preference:
- Eclipse
- IntelliJ IDEA
- (Optional) Choose a Java IDE of your preference:
-
- Apache Maven for building and managing dependencies.
-
- Postman for testing APIs.
- First download the project using the git clone command.
git clone https://github.com/ritobrotos/java-langchain-rag-chatbot.git
- Launch IntelliJ IDEA on your machine.
- Open the project in IntelliJ. Importing project in IntelliJ doc.
- Since its a Maven project IntelliJ IDEA will detect the pom.xml file and automatically download the dependencies.
- In the
ChatConstants
file we have declared the variablesQDRANT_GRPC_HOST
,QDRANT_API_KEY
andOPENAI_API_KEY
which read their values from the environment.t. - Set all the 3 values in the IntelliJ environment. Environment variable setup doc.
- Locate the main class of your Spring Boot application, which is
RagChatbotApplication
. - Right-click on the main class file and select
Run RagChatbotApplication
to initiate the Spring Boot application. - Check the console output for any errors. Upon successful startup, you should observe messages indicating that the application has started on port 8080.
- Open a web browser and navigate to
http://localhost:8080/chat
. You should receive the messageWelcome to Chat Bot
, confirming the successful launch of your application.