From e68218467247daa5429d5f53cc676f9bed971aa4 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sun, 8 Dec 2024 11:04:17 +0100 Subject: [PATCH 1/2] Temporary fix for addPetToOwner, making the pet's name mandatory --- .../samples/petclinic/chat/AssistantTool.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/chat/AssistantTool.java b/src/main/java/org/springframework/samples/petclinic/chat/AssistantTool.java index d3c411a..02114af 100644 --- a/src/main/java/org/springframework/samples/petclinic/chat/AssistantTool.java +++ b/src/main/java/org/springframework/samples/petclinic/chat/AssistantTool.java @@ -48,7 +48,10 @@ public OwnersResponse getAllOwners() { @Tool("Add a pet with the specified petTypeId, to an owner identified by the ownerId") public AddedPetResponse addPetToOwner(AddPetRequest request) { Owner owner = ownerRepository.findById(request.ownerId()).orElseThrow(); - owner.addPet(request.pet()); + // Waiting for https://github.com/langchain4j/langchain4j/issues/2249 + Pet pet = request.pet(); + pet.setName(request.petName()); + owner.addPet(pet); this.ownerRepository.save(owner); return new AddedPetResponse(owner); } @@ -69,7 +72,7 @@ public OwnerResponse addOwnerToPetclinic(OwnerRequest ownerRequest) { } -record AddPetRequest(Pet pet, Integer ownerId) { +record AddPetRequest(Pet pet, String petName, Integer ownerId) { } record OwnerRequest(Owner owner) { From 89cd523b3a17d7eb37e529affeb85e8b2905fdcf Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sun, 8 Dec 2024 14:47:10 +0100 Subject: [PATCH 2/2] Rename artefactId to spring-petclinic-langchain4j --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 432c836..5885c8b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.springframework.samples - spring-petclinic + spring-petclinic-langchain4j 3.4.0-SNAPSHOT petclinic