Reputation: 11
I tried to define a function call in Spring AI:
@Bean
@Description("return list of Vets, include their specialist")
public Function<Void, Collection<Vet>> queryVets() {
return request -> {
return vetRepository.findAll();
};
}
The input parameter is Void
as the function has no input parameter.
But I got the error:
com.azure.core.exception.HttpResponseException: Status code 400,
{ "error": { "message": "Invalid schema for function 'queryVets': In context=(), object schema missing properties", "type": "invalid_request_error", "param": null, "code": null } }
How can I define a function without input parameters?
Upvotes: 1
Views: 78
Reputation: 604
Starting with 1.0.0-M4, Spring AI provides support for functions without input parameters.
You can use both Supplier<O>
or Function<Void, O>
more here.
Also you can use plain Java Methods without input parameters:
FunctionCallback callback = FunctionCallback.builder()
.description("Get weather information for a city")
.method("getWeather") // method name with empty varargs argument types
.targetClass(WeatherService.class)
.build();
Find more about the plain method invoking here.
Upvotes: 0