It'd be great to have greater control on the FunctionCallbackWrapper created when dynamically providing functions to the ChatClient.
Expected Behavior
interface ChatClientRequestSpec {
//...other interface methods
<I, O> ChatClientRequestSpec function(FunctionCallbackWrapper fcw);
//...other interface methods
}
Current Behavior
Currently, it is not possible to customize the FunctionCallbackWrapper created when using the methods below. For example, a custom ObjectMapper can not be set. This means that custom Jackson modules can not be registed such as the com.fasterxml.jackson.module.kotlin.kotlinModule.
interface ChatClientRequestSpec {
//...other interface methods
<I, O> ChatClientRequestSpec function(String name, String description,
java.util.function.Function<I, O> function);
\<I, O> ChatClientRequestSpec function(String name, String description, Class<I> inputType,
java.util.function.Function<I, O> function);
//...other interface methods
}
Context
The workaround at the moment is to register the FunctionCallbackWrapper using the ChatModel interface directly rather than the ChatClient interface. ChatOptions can be used as well via model specific implementation.
If this change makes sense, I can submit a PR.
Comment From: tzolov
@PedroAlvarado with https://github.com/spring-projects/spring-ai/commit/9c10a08bef839ef045cc23881db6810b62a29ae9 we extended the ChatClient API with ChatClientRequestSpec functions(FunctionCallback... functionCallbacks). Would this solve your case?
Comment From: tzolov
@PedroAlvarado I'm closing this issue as resolved by https://github.com/spring-projects/spring-ai/commit/9c10a08bef839ef045cc23881db6810b62a29ae9 Feel free to reopen if it doesn't address your case.