From 3d2dcc1c303a7352f681892bb0871dbea1daaebd Mon Sep 17 00:00:00 2001 From: showpune Date: Wed, 15 May 2024 11:04:36 +0800 Subject: [PATCH 1/2] Add Keyvalut support in Azure --- pom.xml | 6 ++++ .../resources/application.properties.azure | 29 +++++++++++++++++++ .../resources/application.properties.sample | 1 - 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/application.properties.azure diff --git a/pom.xml b/pom.xml index 697c126..9076fdb 100644 --- a/pom.xml +++ b/pom.xml @@ -173,6 +173,12 @@ ${langchain4j.version} + + com.azure.spring + spring-cloud-azure-starter-keyvault + 5.11.0 + + diff --git a/src/main/resources/application.properties.azure b/src/main/resources/application.properties.azure new file mode 100644 index 0000000..71db162 --- /dev/null +++ b/src/main/resources/application.properties.azure @@ -0,0 +1,29 @@ +# database init, supports mysql too +database=h2 +spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql +spring.sql.init.data-locations=classpath*:db/${database}/data.sql +# Web +spring.thymeleaf.mode=HTML +# JPA +spring.jpa.hibernate.ddl-auto=none +spring.jpa.open-in-view=true +# Internationalization +spring.messages.basename=messages/messages +# Actuator +management.endpoints.web.exposure.include=* +# Logging +logging.level.org.springframework=INFO +# logging.level.org.springframework.web=DEBUG +# logging.level.org.springframework.context.annotation=TRACE +# Maximum time static resources should be cached +spring.web.resources.cache.cachecontrol.max-age=12h + +langchain4j.local.spring.memory.use-local=true +langchain4j.local.spring.memory.memory-size=20 +langchain4j.local.spring.content-retriever.use-local=true +langchain4j.local.spring.content-retriever.max-results=1 +langchain4j.local.spring.content-retriever.min-score=0.6 +langchain4j.local.spring.content-retriever.content-path=classpath:petclinic-terms-of-use.txt +spring.cloud.azure.keyvault.secret.property-sources[0].endpoint=https://kv-kaiqian-petclinic.vault.azure.net/ +#spring.cloud.azure.keyvault.secret.property-sources[0].credential.managed-identity-enabled=true +petclinic.agent.name=Petclinic Agent diff --git a/src/main/resources/application.properties.sample b/src/main/resources/application.properties.sample index 6b3b05d..cc0d73a 100644 --- a/src/main/resources/application.properties.sample +++ b/src/main/resources/application.properties.sample @@ -26,5 +26,4 @@ langchain4j.local.spring.content-retriever.use-local=true langchain4j.local.spring.content-retriever.max-results=1 langchain4j.local.spring.content-retriever.min-score=0.6 langchain4j.local.spring.content-retriever.content-path=classpath:petclinic-terms-of-use.txt - petclinic.agent.name=petclinic From c1cf40aa727d0129dbc00e1bcac8080dc788009e Mon Sep 17 00:00:00 2001 From: Zhiyong Li Date: Tue, 21 May 2024 22:39:17 +0800 Subject: [PATCH 2/2] Update readme.md --- readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.md b/readme.md index a3544ea..e4abafb 100644 --- a/readme.md +++ b/readme.md @@ -40,9 +40,15 @@ You can talk with the agent, it can help to recommend the vet according to the s Go to the owner page, you can see you are registered as an owner with the help of the agent ![image](https://github.com/showpune/spring-petclinic-langchain4j/assets/1787505/e7da4ede-5405-437d-a35f-fcd60af45ba7) +## 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](https://github.com/showpune/spring-petclinic-langchain4j/blob/master/src/main/java/org/springframework/samples/petclinic/chat/Agent.java) +### Model +The model is is defined in [model](https://github.com/showpune/spring-petclinic-langchain4j/blob/3d2dcc1c303a7352f681892bb0871dbea1daaebd/src/main/java/org/springframework/samples/petclinic/chat/AgentConfig.java#L36), the model can be used for [chat](https://github.com/showpune/spring-petclinic-langchain4j/blob/3d2dcc1c303a7352f681892bb0871dbea1daaebd/src/main/java/org/springframework/samples/petclinic/chat/AgentConfig.java#L26), or can be used for [content augmentor](https://github.com/showpune/spring-petclinic-langchain4j/blob/3d2dcc1c303a7352f681892bb0871dbea1daaebd/src/main/java/org/springframework/samples/petclinic/chat/AgentConfig.java#L50) + ### Memory Memory Store: The demo still use the local memory defined in [memory store](https://github.com/showpune/spring-petclinic-langchain4j/blob/c95a598f4fdaf68a3f331b32ca42ef5ef95e5c17/src/main/java/org/springframework/samples/petclinic/chat/LocalConfig.java#L39), it means it can not share memory between instances, you can enhance it use memory on Redis