|
3 | 3 | import org.slf4j.Logger;
|
4 | 4 | import org.slf4j.LoggerFactory;
|
5 | 5 | import org.springframework.ai.chat.client.ChatClient;
|
6 |
| -import org.springframework.ai.model.function.FunctionCallback; |
| 6 | +import org.springframework.ai.tool.function.FunctionToolCallback; |
7 | 7 | import org.springframework.web.bind.annotation.GetMapping;
|
8 | 8 | import org.springframework.web.bind.annotation.RestController;
|
9 | 9 |
|
@@ -92,8 +92,7 @@ String chatFunctionVoidInput() {
|
92 | 92 | String chatFunctionVoidInputCallback() {
|
93 | 93 | return chatClient.prompt()
|
94 | 94 | .user("Welcome the users to the library")
|
95 |
| - .toolCallbacks(FunctionCallback.builder() |
96 |
| - .function("sayWelcome", (input) -> { |
| 95 | + .toolCallbacks(FunctionToolCallback.builder("sayWelcome", (input) -> { |
97 | 96 | logger.info("CALLBACK - Welcoming users to the library");
|
98 | 97 | })
|
99 | 98 | .description("Welcome users to the library")
|
@@ -124,8 +123,7 @@ String chatFunctionVoidOutputCallback(String user) {
|
124 | 123 | .text(userPromptTemplate)
|
125 | 124 | .param("user", user)
|
126 | 125 | )
|
127 |
| - .toolCallbacks(FunctionCallback.builder() |
128 |
| - .function("welcomeUser", (input) -> { |
| 126 | + .toolCallbacks(FunctionToolCallback.builder("welcomeUser", (input) -> { |
129 | 127 | logger.info("CALLBACK - Welcoming {} to the library", ((Functions.User) input).name());
|
130 | 128 | })
|
131 | 129 | .description("Welcome a specific user to the library")
|
@@ -160,8 +158,7 @@ String chatFunctionSingleCallback(String authorName) {
|
160 | 158 | .text(userPromptTemplate)
|
161 | 159 | .param("author", authorName)
|
162 | 160 | )
|
163 |
| - .toolCallbacks(FunctionCallback.builder() |
164 |
| - .function("availableBooksByAuthor", function) |
| 161 | + .toolCallbacks(FunctionToolCallback.builder("availableBooksByAuthor", function) |
165 | 162 | .description("Get the list of books written by the given author available in the library")
|
166 | 163 | .inputType(BookService.Author.class)
|
167 | 164 | .build())
|
@@ -196,8 +193,7 @@ String chatFunctionListCallback(String bookTitle1, String bookTitle2) {
|
196 | 193 | .param("bookTitle1", bookTitle1)
|
197 | 194 | .param("bookTitle2", bookTitle2)
|
198 | 195 | )
|
199 |
| - .toolCallbacks(FunctionCallback.builder() |
200 |
| - .function("authorsByAvailableBooks", function) |
| 196 | + .toolCallbacks(FunctionToolCallback.builder("authorsByAvailableBooks", function) |
201 | 197 | .description("Get the list of authors who wrote the given books available in the library")
|
202 | 198 | .inputType(BookService.Books.class)
|
203 | 199 | .build())
|
|
0 commit comments