Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.

Expected Behavior

ChatClient.ChatClientRequestSpec need a function like ChatClientRequestSpec function(FunctionCallbackWrapper<?,?> wrapper);

Current Behavior not have a function

Context we use lamda function and the function can not get the inputType,so if add the ChatClientRequestSpec function(FunctionCallbackWrapper<?,?> wrapper); we can set the inputType self

Comment From: xixingya

public static Function createFunction(Object obj, Method method) { return (T t) -> { try { return (R) method.invoke(obj, t); } catch (Exception e) { throw new RuntimeException(e); } }; } I use this code to create the function but the inputType will be the object

Comment From: xixingya

we need a function like this to register a FunctionCallbackWrapper direct at ChatClient, so we can set the inputType at FunctionCallbackWrapper

Comment From: tzolov

@xixingya the FunctionCallbackWrapper and even the FunctionCallback interface are implementation details that we should not be expose those in the chat client API.

If I understand your use case, you need an abstraction that can pass the input type explicitly?

Would something like this work for you:

interface FunctionSpec<I> {
     String getName();
     String getDescription();
     Class<I> getInputType; // optional explicit type
     String getInputTypeSchema(); // optional
}

and ChatCient api like this:

<I2, I, O> ChatClientRequestSpec function(FunctionSpec<I2> functionSpec, java.util.function.Function<I, O> function);

This would allow your to pass an explicit input type (I2)

Comment From: xixingya

@xixingya the FunctionCallbackWrapper and even the FunctionCallback interface are implementation details that we should not be expose those in the chat client API.

If I understand your use case, you need an abstraction that can pass the input type explicitly?

Would something like this work for you:

java interface FunctionSpec<I> { String getName(); String getDescription(); Class<I> getInputType; // optional explicit type String getInputTypeSchema(); // optional }

and ChatCient api like this:

java <I2, I, O> ChatClientRequestSpec function(FunctionSpec<I2> functionSpec, java.util.function.Function<I, O> function);

This would allow your to pass an explicit input type (I2)

ok. I will change the pr to add function like this.

Comment From: xixingya

@tzolov I have change the pr