A Blueprint for adapting JHipster / Spring Boot applications to LLM (Large Language Model)
This is a tool for quickly and easily generating Spring Boot application code using the LLM. For code generation, it utilizes JHipster, which can output various variations of Spring Boot application code. The code generation for LLM is achieved by using the Blueprint feature, which extends JHipster's code generation capabilities.
This tool outputs the following code:
- Code for a Spring Boot application server, including the development environment such as build tools (a feature of JHipster)
- Code for an OpenAI API compatible server
- Code for the OpenAI Chat Completions API using OpenAPI spec and OpenAPI Generator
- Depending on whether the user selects Flux or Spring MVC, it outputs code for chat responses using Server-Sent Events for streaming
- Code for the OpenAI Chat Completions API using OpenAPI spec and OpenAPI Generator
- Code using the LLM library supported by Spring AI and Langchain for Java. Currently, it supports the following:
- Download of the selected LLM model
- Introduction of a Chat UI client
- Installs BetterChatGPT
In the near future, we plan to support:
- Other LLM libraries of Spring AI
- RAG support using VectorDB
- Other Chat UI support
- Java 17 or later
- Node.js 20 or later
- Docker is required for running Ollama
The following command will install the code generator:
npm install -g generator-jhipster-llm
If you want to create the simplest application, execute the following command. After executing the command, you will be prompted with a series of questions to configure the code generation for the LLM-enabled Spring Boot application.
mkdir myLlmApp
cd myLlmApp
jhipster-llm generate-sample sample.jdl # This is for maven. For gradle, please use 'sample_gradle.jdl' instead.
(Note: Currently, only the minimal JHipster application configuration written in .blueprint/generate-sample/templates/samples/sample.jdl
is supported. We plan to support various other configurations in the future.)
Answer the following questions. By default, Spring AI, llama.cpp and mistral 7B are selected.
Which LLM framwork do you want to use?
Which LLM library do you want to use?
Which LLM model do you want to use?
Execute the following to start Spring Boot. The necessary LLM model will be downloaded at startup.
./mvnw
After starting, access the following URL. The chat application will be displayed. http://localhost:8080/chat-ui/index.html
When you open the BetterChatGPT screen, open the API menu,check Use custom API endpoint
, and enter http://localhost:8080/api/llm/v1/chat/completions
in the API Endpoint.
Try typing something. Congratulations if you get a response! Enjoy building applications with LLM and Java!
Ollama runs on Docker.
./mvnw
before executing the following command: various services, including Ollama, will be started by Docker.
npm run services:up