Remove deprecations from 1.0.0-M6
- Remove deprecations from models, vector stores and usage - Deprecations from FunctionCallback and ObservationContext/Convention will be in a separate PR Models updates - Remove AbstractToolCallSupport from the models which use ToolCallingManager - Remove deprecated constructors and their usage - Remove FunctionCallbackResolver and FunctionCallbacks usage in the models - Add back deprecations for VectorStoreChatMemoryAdvisor until builder is fixed - Update OpenAiPaymentTransactionIT to use ToolCallbackResolver in config Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
This commit is contained in:
committed by
Mark Pollack
parent
a1e417f350
commit
ded9facfe5
@@ -73,7 +73,6 @@ import org.springframework.ai.chat.metadata.PromptMetadata;
|
||||
import org.springframework.ai.chat.metadata.PromptMetadata.PromptFilterMetadata;
|
||||
import org.springframework.ai.chat.metadata.Usage;
|
||||
import org.springframework.ai.chat.metadata.UsageUtils;
|
||||
import org.springframework.ai.chat.model.AbstractToolCallSupport;
|
||||
import org.springframework.ai.chat.model.ChatModel;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.ai.chat.model.Generation;
|
||||
@@ -86,16 +85,12 @@ import org.springframework.ai.chat.prompt.ChatOptions;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.model.Media;
|
||||
import org.springframework.ai.model.ModelOptionsUtils;
|
||||
import org.springframework.ai.model.function.FunctionCallback;
|
||||
import org.springframework.ai.model.function.FunctionCallbackResolver;
|
||||
import org.springframework.ai.model.function.FunctionCallingOptions;
|
||||
import org.springframework.ai.model.tool.LegacyToolCallingManager;
|
||||
import org.springframework.ai.model.tool.ToolCallingChatOptions;
|
||||
import org.springframework.ai.model.tool.ToolCallingManager;
|
||||
import org.springframework.ai.model.tool.ToolExecutionResult;
|
||||
import org.springframework.ai.observation.conventions.AiProvider;
|
||||
import org.springframework.ai.tool.definition.ToolDefinition;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -120,7 +115,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @see com.azure.ai.openai.OpenAIClient
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AzureOpenAiChatModel extends AbstractToolCallSupport implements ChatModel {
|
||||
public class AzureOpenAiChatModel implements ChatModel {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AzureOpenAiChatModel.class);
|
||||
|
||||
@@ -162,53 +157,8 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
|
||||
*/
|
||||
private final ToolCallingManager toolCallingManager;
|
||||
|
||||
@Deprecated
|
||||
public AzureOpenAiChatModel(OpenAIClientBuilder openAIClientBuilder) {
|
||||
this(openAIClientBuilder,
|
||||
AzureOpenAiChatOptions.builder()
|
||||
.deploymentName(DEFAULT_DEPLOYMENT_NAME)
|
||||
.temperature(DEFAULT_TEMPERATURE)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AzureOpenAiChatModel(OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions options) {
|
||||
this(openAIClientBuilder, options, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AzureOpenAiChatModel(OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions options,
|
||||
FunctionCallbackResolver functionCallbackResolver) {
|
||||
this(openAIClientBuilder, options, functionCallbackResolver, List.of());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AzureOpenAiChatModel(OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions options,
|
||||
@Nullable FunctionCallbackResolver functionCallbackResolver,
|
||||
@Nullable List<FunctionCallback> toolFunctionCallbacks) {
|
||||
this(openAIClientBuilder, options, functionCallbackResolver, toolFunctionCallbacks, ObservationRegistry.NOOP);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AzureOpenAiChatModel(OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions options,
|
||||
@Nullable FunctionCallbackResolver functionCallbackResolver,
|
||||
@Nullable List<FunctionCallback> toolFunctionCallbacks, ObservationRegistry observationRegistry) {
|
||||
this(openAIClientBuilder, options,
|
||||
LegacyToolCallingManager.builder()
|
||||
.functionCallbackResolver(functionCallbackResolver)
|
||||
.functionCallbacks(toolFunctionCallbacks)
|
||||
.build(),
|
||||
observationRegistry);
|
||||
logger.warn("This constructor is deprecated and will be removed in the next milestone. "
|
||||
+ "Please use the AzureOpenAiChatModel.Builder or the new constructor accepting ToolCallingManager instead.");
|
||||
}
|
||||
|
||||
public AzureOpenAiChatModel(OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions defaultOptions,
|
||||
ToolCallingManager toolCallingManager, ObservationRegistry observationRegistry) {
|
||||
// We do not pass the 'defaultOptions' to the AbstractToolSupport,
|
||||
// because it modifies them. We are using ToolCallingManager instead,
|
||||
// so we just pass empty options here.
|
||||
super(null, AzureOpenAiChatOptions.builder().build(), List.of());
|
||||
Assert.notNull(openAIClientBuilder, "com.azure.ai.openai.OpenAIClient must not be null");
|
||||
Assert.notNull(defaultOptions, "defaultOptions cannot be null");
|
||||
Assert.notNull(toolCallingManager, "toolCallingManager cannot be null");
|
||||
@@ -534,10 +484,6 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
|
||||
|
||||
if (prompt.getOptions() != null) {
|
||||
AzureOpenAiChatOptions updatedRuntimeOptions;
|
||||
if (prompt.getOptions() instanceof FunctionCallingOptions functionCallingOptions) {
|
||||
updatedRuntimeOptions = ModelOptionsUtils.copyToTarget(functionCallingOptions,
|
||||
FunctionCallingOptions.class, AzureOpenAiChatOptions.class);
|
||||
}
|
||||
if (prompt.getOptions() instanceof ToolCallingChatOptions toolCallingChatOptions) {
|
||||
updatedRuntimeOptions = ModelOptionsUtils.copyToTarget(toolCallingChatOptions,
|
||||
ToolCallingChatOptions.class, AzureOpenAiChatOptions.class);
|
||||
@@ -668,10 +614,6 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
|
||||
runtimeOptions = ModelOptionsUtils.copyToTarget(toolCallingChatOptions, ToolCallingChatOptions.class,
|
||||
AzureOpenAiChatOptions.class);
|
||||
}
|
||||
else if (prompt.getOptions() instanceof FunctionCallingOptions functionCallingOptions) {
|
||||
runtimeOptions = ModelOptionsUtils.copyToTarget(functionCallingOptions, FunctionCallingOptions.class,
|
||||
AzureOpenAiChatOptions.class);
|
||||
}
|
||||
else {
|
||||
runtimeOptions = ModelOptionsUtils.copyToTarget(prompt.getOptions(), ChatOptions.class,
|
||||
AzureOpenAiChatOptions.class);
|
||||
@@ -978,10 +920,6 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
|
||||
|
||||
private ToolCallingManager toolCallingManager;
|
||||
|
||||
private FunctionCallbackResolver functionCallbackResolver;
|
||||
|
||||
private List<FunctionCallback> toolFunctionCallbacks;
|
||||
|
||||
private ObservationRegistry observationRegistry = ObservationRegistry.NOOP;
|
||||
|
||||
private Builder() {
|
||||
@@ -1002,18 +940,6 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder functionCallbackResolver(FunctionCallbackResolver functionCallbackResolver) {
|
||||
this.functionCallbackResolver = functionCallbackResolver;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder toolFunctionCallbacks(List<FunctionCallback> toolFunctionCallbacks) {
|
||||
this.toolFunctionCallbacks = toolFunctionCallbacks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder observationRegistry(ObservationRegistry observationRegistry) {
|
||||
this.observationRegistry = observationRegistry;
|
||||
return this;
|
||||
@@ -1021,29 +947,9 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
|
||||
|
||||
public AzureOpenAiChatModel build() {
|
||||
if (toolCallingManager != null) {
|
||||
Assert.isNull(functionCallbackResolver,
|
||||
"functionCallbackResolver cannot be set when toolCallingManager is set");
|
||||
Assert.isNull(toolFunctionCallbacks,
|
||||
"toolFunctionCallbacks cannot be set when toolCallingManager is set");
|
||||
|
||||
return new AzureOpenAiChatModel(openAIClientBuilder, defaultOptions, toolCallingManager,
|
||||
observationRegistry);
|
||||
}
|
||||
|
||||
if (functionCallbackResolver != null) {
|
||||
Assert.isNull(toolCallingManager,
|
||||
"toolCallingManager cannot be set when functionCallbackResolver is set");
|
||||
List<FunctionCallback> toolCallbacks = this.toolFunctionCallbacks != null ? this.toolFunctionCallbacks
|
||||
: List.of();
|
||||
|
||||
return new Builder().openAIClientBuilder(openAIClientBuilder)
|
||||
.defaultOptions(defaultOptions)
|
||||
.functionCallbackResolver(functionCallbackResolver)
|
||||
.toolFunctionCallbacks(toolCallbacks)
|
||||
.observationRegistry(observationRegistry)
|
||||
.build();
|
||||
}
|
||||
|
||||
return new AzureOpenAiChatModel(openAIClientBuilder, defaultOptions, DEFAULT_TOOL_CALLING_MANAGER,
|
||||
observationRegistry);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user