This is the spring langchain4j version for spring petclinic, if you want to see a springai version, please refer to spring-petclinic-springai
Spring Petclinic is a Spring Boot application built
using Maven. You can build a jar
file and run it from the command line (it should work just as well with Java 17 or newer), Before you build the application, you need to setup some openai properties in src/main/resources/application.properties
:
git clone https://github.com/showpune/spring-petclinic-langchain4j.git
cd spring-petclinic-langchain4j
mv src/main/resources/application.properties.example src/main/resources/application.properties
edit the src/main/resources/application.properties
file and add the following properties:
langchain4j.azure.open-ai.chat-model.endpoint=https://*****.openai.azure.com/
langchain4j.azure.open-ai.chat-model.deployment-name=gpt-4
langchain4j.azure.open-ai.chat-model.api-key=**
You can build the application by running the following command:
./mvnw package
java -jar target/*.jar
You can then access the Petclinic at http://localhost:8080/
And the OpenAI chatbot at http://localhost:8080/chat.html.
You can talk with the agent, it can help to recommend the vet according to the symptoms of the pet. The agent can also help to book an appointment with the vet. Go to the owner page, you can see you are registered as an owner with the help of the agent
Normally a LLM application contains 5 parts: Prompt, Model, Memory, Native Functions( tools )and RAG (content retriever)
The prompt is defined in agent
The model is is defined in model, the model can be used for chat, or can be used for content augmentor
Memory Store: The demo still use the local memory defined in memory store, it means it can not share memory between instances, you can enhance it use memory on Redis
Memory ID: It use the username as memory id Memory ID
The Demo provided two local tools to interactive with native functions
- Vets and their specialist: The agent will know the system can return list of Vets, include their specialist, it can be used to recommend a vet
- Owner and Pets: he agent will know the system register new owner and their pets
It still use the local file as content retriever, it provided the guideline how the agent should work, which is in Term of Use, the content is ingest when the store in initialized here. If you have lots of content, tried to use the AI Search to create the RAG
You can also talk with the agent with your own language, like Chinese
The problem is that your Term of Use is in English, the traditional way is that provide a localized term of use for each language, but you can use openAI to make it easier
We can define a Retrieval Augmentor, and translate your ask into English before you retrieve the content
The Spring PetClinic sample application is released under version 2.0 of the Apache License.