refactor: revise function callback API deprecation messages and documentation
- Update deprecated annotation messages to correctly reference functions() instead of function() - Add detailed documentation for FunctionCallback.Builder hierarchy - Deprecate FunctionCallbackWrapper class in favor of Builder pattern - Fix typos and improve code documentation
This commit is contained in:
@@ -213,14 +213,14 @@ public interface ChatClient {
|
||||
<T extends ChatOptions> ChatClientRequestSpec options(T options);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #function(FunctionCallback)} instead.
|
||||
* @deprecated use {@link #functions(FunctionCallback...)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
<I, O> ChatClientRequestSpec function(String name, String description,
|
||||
java.util.function.Function<I, O> function);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #function(FunctionCallback)} instead.
|
||||
* @deprecated use {@link #functions(FunctionCallback...)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
<I, O> ChatClientRequestSpec function(String name, String description,
|
||||
@@ -229,7 +229,7 @@ public interface ChatClient {
|
||||
<I, O> ChatClientRequestSpec functions(FunctionCallback... functionCallbacks);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #function(FunctionCallback)} instead.
|
||||
* @deprecated use {@link #functions(FunctionCallback...)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
<I, O> ChatClientRequestSpec function(String name, String description, Class<I> inputType,
|
||||
@@ -291,13 +291,13 @@ public interface ChatClient {
|
||||
Builder defaultSystem(Consumer<PromptSystemSpec> systemSpecConsumer);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #defaultFunction(FunctionCallback)} instead.
|
||||
* @deprecated use {@link #defaultFunctions(FunctionCallback...)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
<I, O> Builder defaultFunction(String name, String description, java.util.function.Function<I, O> function);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #defaultFunction(FunctionCallback)} instead.
|
||||
* @deprecated use {@link #defaultFunctions(FunctionCallback...)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
<I, O> Builder defaultFunction(String name, String description,
|
||||
|
||||
@@ -82,13 +82,22 @@ public interface FunctionCallback {
|
||||
|
||||
/**
|
||||
* Creates a new {@link FunctionCallback.Builder} instance used to build a default
|
||||
* {@link FunctionCallback} instance. *
|
||||
* {@link FunctionCallback} instance.
|
||||
* @return Returns a new {@link FunctionCallback.Builder} instance.
|
||||
*/
|
||||
static FunctionCallback.Builder builder() {
|
||||
return new DefaultFunctionCallbackBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for creating a {@link FunctionCallback} instance. This is a hierarchical
|
||||
* builder with the following structure:
|
||||
* <ul>
|
||||
* <li>{@link Builder} - The root builder interface.
|
||||
* <li>{@link FunctionInvokingSpec} - The function invoking builder interface.
|
||||
* <li>{@link MethodInvokingSpec} - The method invoking builder interface.
|
||||
* </ul>
|
||||
*/
|
||||
interface Builder {
|
||||
|
||||
/**
|
||||
@@ -122,14 +131,26 @@ public interface FunctionCallback {
|
||||
*/
|
||||
Builder objectMapper(ObjectMapper objectMapper);
|
||||
|
||||
/**
|
||||
* Builds a {@link Function} invoking {@link FunctionCallback} instance.
|
||||
*/
|
||||
<I, O> FunctionInvokingSpec<I, O> function(String name, Function<I, O> function);
|
||||
|
||||
/**
|
||||
* Builds a {@link BiFunction} invoking {@link FunctionCallback} instance.
|
||||
*/
|
||||
<I, O> FunctionInvokingSpec<I, O> function(String name, BiFunction<I, ToolContext, O> biFunction);
|
||||
|
||||
/**
|
||||
* Builds a {@link Method} invoking {@link FunctionCallback} instance.
|
||||
*/
|
||||
MethodInvokingSpec method(String methodName, Class<?>... argumentTypes);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Function} invoking builder interface.
|
||||
*/
|
||||
interface FunctionInvokingSpec<I, O> {
|
||||
|
||||
/**
|
||||
@@ -152,6 +173,9 @@ public interface FunctionCallback {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Method} invoking builder interface.
|
||||
*/
|
||||
interface MethodInvokingSpec {
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,9 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Christian Tzolov
|
||||
* @author Sebastien Deleuze
|
||||
* @deprecated in favor of {@link FunctionCallbackWrapper.Builder}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class FunctionCallbackWrapper<I, O> extends AbstractFunctionCallback<I, O> {
|
||||
|
||||
private final BiFunction<I, ToolContext, O> biFunction;
|
||||
@@ -57,7 +59,7 @@ public final class FunctionCallbackWrapper<I, O> extends AbstractFunctionCallbac
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link FunctionCallback#builder(BiFunction)} instead.
|
||||
* @deprecated use {@link FunctionCallback#builder()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static <I, O> Builder<I, O> builder(BiFunction<I, ToolContext, O> biFunction) {
|
||||
@@ -65,7 +67,7 @@ public final class FunctionCallbackWrapper<I, O> extends AbstractFunctionCallbac
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link FunctionCallback#builder(Function)} instead.
|
||||
* @deprecated use {@link FunctionCallback#builder()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static <I, O> Builder<I, O> builder(Function<I, O> function) {
|
||||
|
||||
Reference in New Issue
Block a user