Skip to content

Spring PetClinic With OpenAI and Langchain4j - Launch Your First AI app on Azure Container Apps

License

Notifications You must be signed in to change notification settings

Azure-Samples/spring-petclinic-langchain4j

Repository files navigation

Spring PetClinic With OpenAI and Langchain4j - Launch Your First AI app on Azure Container Apps

Quick Start

The sample project is an AI application that uses Azure Container Apps and Azure OpenAI. The application provides AI assistant functionality in a Spring PetClinic application.

You can smoothly get help by having a natural language chat with the AI assistant. The AI assistant can assist you with the following tasks:

  1. Querying the registered pet owners
  2. Adding a new pet owner
  3. Updating the pet owner's information
  4. Adding a new pet
  5. Querying the vets' information

image

Deploy the project to Azure using GitHub Codespace

Prerequisites

For running this lab you will need:

  • A GitHub account
  • An Azure Subscription

Step by Step guide

  1. Navigate to the GitHub repository of this lab and select Fork.

    {: .note }

    In case you are using a GitHub EMU account, it might be you are not able to fork a public repository. In that case, create a new repository with the same name, clone the original repository, add your new repository as a remote and push to this new remote.

  2. Make sure your own username is indicated as the fork Owner

  3. Select Create fork. This will create a copy or fork of this project in your own account.

  4. Navigate to the newly forked GitHub project.

  5. Select Code and next Codespaces.

  6. Select Create a codespace.

Your codespace will now get created in your browser window. Once creation is done, you can start executing the next steps in the terminal:

  1. Run azd auth login, follow the prompts to login to Azure.
  2. Run azd up, input the environment name, select your subscription and location.

The project will be ready in 20 minutes.

The Sequence workflow of langchain4j

image

Understanding the Spring Petclinic application with a few diagrams

See the presentation here

Workthrough of the chat agent

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. image Go to the owner page, you can see you are registered as an owner with the help of the agent image

LLM Progamming

Normally a LLM application contains 5 parts: Prompt, Model, Memory, Native Functions (tools)and RAG (content retriever)

Prompt

The prompt is defined in agent

Model

The model is is defined in model, the model can be used for chat, or can be used for content augmentor

Memory

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

Interact with natives functions

The Demo provided two local tools to interactive with native functions

  1. 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
  2. Owner and Pets: he agent will know the system register new owner and their pets

Content Retriever

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

Talk with Other language

You can also talk with the agent with your own language, like Chinese image

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

About

Spring PetClinic With OpenAI and Langchain4j - Launch Your First AI app on Azure Container Apps

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •