-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
I define a tool as a function (FaT) as described in the documentation and pass it to the chat model as described in the documentation. However, I then receive the following error message.
Caused by: java.lang.IllegalStateException: No @Tool annotated methods found in get_ProductDetailsByCustomer.Did you mean to pass a ToolCallback or ToolCallbackProvider? If so, you have to use .toolCallbacks() instead of .tool()
When I debug it in Spring AI, it quickly becomes clear why. It always goes to the following method and doesn't distinguish between a MaT and a FaT. It always looks for the @tool annotation.
public final class ToolCallbacks {
private ToolCallbacks() {
}
public static ToolCallback[] from(Object... sources) {
return MethodToolCallbackProvider.builder().toolObjects(sources).build().getToolCallbacks();
}
}
I'm using Java 21, Spring Boot 3.5, and Spring AI 1.0.0.
Here's the code again:
Tool as Function
@Configuration
public class InsuranceProductDetailsByCustomerFunctionConfiguration {
@Bean("get_ProductDetailsByCustomer")
@Description("Stellt eine Anfrage an den Versicherungsservice, um Produktdaten zu erhalten.")
public Function<String,Product> createProductDetailsByCustomerFunction(InsuranceProductService insuranceProductService) {
return customer -> insuranceProductService.getProductDetailsByCustomer(customer);
}
}
Passing the tool as a function to the chat client
var chatClient = builder.defaultAdvisors( MessageChatMemoryAdvisor.builder(chatMemory).build())
.defaultSystem(prompt.getContents())
.defaultTools(insuranceCustomerDetailsTool)
.defaultTools("get_ProductDetailsByCustomer")
.build();
Thank you for your support!!