From 5b5abc4a8bad4842821bb1c7f8b07de98c6d2e4d Mon Sep 17 00:00:00 2001 From: Ilayaperumal Gopinathan Date: Thu, 13 Feb 2025 22:56:24 +0000 Subject: [PATCH] Fix for FunctionToolCallbackTests - Add more deterministic test data for assertion --- .../ai/integration/tests/tool/FunctionToolCallbackTests.java | 4 ++-- .../ai/integration/tests/tool/domain/BookService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java index d93d3d31e..4f30de7c6 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java @@ -158,7 +158,7 @@ public class FunctionToolCallbackTests { var content = ChatClient.builder(this.openAiChatModel) .build() .prompt() - .user("What authors wrote the books %s and %s available in the library?".formatted("The Hobbit", "Narnia")) + .user("What authors wrote the books %s and %s available in the library?".formatted("The Hobbit", "The Lion, the Witch and the Wardrobe")) .tools(Tools.AUTHORS_BY_BOOKS) .call() .content(); @@ -174,7 +174,7 @@ public class FunctionToolCallbackTests { var content = ChatClient.builder(this.openAiChatModel) .build() .prompt() - .user("What authors wrote the books %s and %s available in the library?".formatted("The Hobbit", "Narnia")) + .user("What authors wrote the books %s and %s available in the library?".formatted("The Hobbit", "The Lion, the Witch and the Wardrobe")) .tools(FunctionToolCallback.builder("authorsByAvailableBooks", function) .description("Get the list of authors who wrote the given books available in the library") .inputType(Books.class) diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java index c19ae634b..641fd84d4 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java @@ -28,7 +28,7 @@ public class BookService { private static final ConcurrentHashMap books = new ConcurrentHashMap<>(Map .of( // @formatter:off 1, new Book("His Dark Materials", "Philip Pullman"), - 2, new Book("Narnia", "C.S. Lewis"), + 2, new Book("The Lion, the Witch and the Wardrobe", "C.S. Lewis"), 3, new Book("The Hobbit", "J.R.R. Tolkien"), 4, new Book("The Lord of The Rings", "J.R.R. Tolkien"), 5, new Book("The Silmarillion", "J.R.R. Tolkien"))); // @formatter:on