Skip to content

Commit

Permalink
Merge pull request #16 from arey/bugfix/pet-name-mandatory
Browse files Browse the repository at this point in the history
Temporary fix for addPetToOwner, making the pet's name mandatory
  • Loading branch information
arey authored Dec 28, 2024
2 parents d11dac0 + 89cd523 commit e39f8a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<groupId>org.springframework.samples</groupId>
<artifactId>spring-petclinic</artifactId>
<artifactId>spring-petclinic-langchain4j</artifactId>
<version>3.4.0-SNAPSHOT</version>

<name>petclinic</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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) {
Expand Down

0 comments on commit e39f8a3

Please sign in to comment.