From cf846688af4d208a4045390e8d9ec65508aa37f7 Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Sat, 21 Dec 2024 19:38:01 -0500 Subject: [PATCH] Add deprecated with* methods to FunctionCallingOptions Add backwards compatibility methods from FunctionCallingOptionsBuilder to the Builder interface in FunctionCallingOptions. This allows users to gradually migrate from the old builder style (with* methods) to the new style while maintaining the same functionality. Each deprecated method is marked for removal in 1.0.0-M5 and includes proper Javadoc directing users to the new method names. The methods are implemented as default methods that delegate to their new counterparts. --- .../function/FunctionCallingOptions.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/spring-ai-core/src/main/java/org/springframework/ai/model/function/FunctionCallingOptions.java b/spring-ai-core/src/main/java/org/springframework/ai/model/function/FunctionCallingOptions.java index ba8529e68..539cefa70 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/model/function/FunctionCallingOptions.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/model/function/FunctionCallingOptions.java @@ -172,6 +172,86 @@ public interface FunctionCallingOptions extends ChatOptions { @Override Builder topP(Double topP); + /** + * @deprecated Use {@link #model(String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withModel(String model) { + return model(model); + } + + /** + * @deprecated Use {@link #frequencyPenalty(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withFrequencyPenalty(Double frequencyPenalty) { + return frequencyPenalty(frequencyPenalty); + } + + /** + * @deprecated Use {@link #maxTokens(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withMaxTokens(Integer maxTokens) { + return maxTokens(maxTokens); + } + + /** + * @deprecated Use {@link #presencePenalty(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withPresencePenalty(Double presencePenalty) { + return presencePenalty(presencePenalty); + } + + /** + * @deprecated Use {@link #stopSequences(List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withStopSequences(List stopSequences) { + return stopSequences(stopSequences); + } + + /** + * @deprecated Use {@link #temperature(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withTemperature(Double temperature) { + return temperature(temperature); + } + + /** + * @deprecated Use {@link #functionCallbacks(List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withFunctionCallbacks(List functionCallbacks) { + return functionCallbacks(functionCallbacks); + } + + /** + * @deprecated Use {@link #functionCallbacks(FunctionCallback...)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withFunctionCallbacks(FunctionCallback... functionCallbacks) { + return functionCallbacks(functionCallbacks); + } + + /** + * @deprecated Use {@link #functions(Set)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withFunctions(Set functions) { + return functions(functions); + } + + /** + * @deprecated Use {@link #function(String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + default Builder withFunction(String function) { + return function(function); + } + } }