Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ public class QuestionAnswerAdvisor implements BaseAdvisor {

private final int order;

/**
* Construct instance by given VectorStore
* @param vectorStore the given VectorStore
* @deprecated in favor of {@link #builder(VectorStore)}}
*/
@Deprecated
public QuestionAnswerAdvisor(VectorStore vectorStore) {
this(vectorStore, SearchRequest.builder().build(), DEFAULT_PROMPT_TEMPLATE, BaseAdvisor.DEFAULT_SCHEDULER,
DEFAULT_ORDER);
}

QuestionAnswerAdvisor(VectorStore vectorStore, SearchRequest searchRequest, @Nullable PromptTemplate promptTemplate,
@Nullable Scheduler scheduler, int order) {
Assert.notNull(vectorStore, "vectorStore cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.DocumentEmbeddingRequest;
import org.springframework.ai.embedding.EmbeddingOptionsBuilder;
import org.springframework.ai.embedding.EmbeddingOptions;
import org.springframework.ai.embedding.EmbeddingResponse;
import org.springframework.ai.embedding.EmbeddingResultMetadata;
import org.springframework.ai.utils.SpringAiTestAutoConfigurations;
Expand Down Expand Up @@ -118,7 +118,7 @@ public void multimodalEmbedding() {
var document = new Document("Hello World");

DocumentEmbeddingRequest embeddingRequest = new DocumentEmbeddingRequest(List.of(document),
EmbeddingOptionsBuilder.builder().build());
EmbeddingOptions.builder().build());

EmbeddingResponse embeddingResponse = multiModelEmbeddingModel.call(embeddingRequest);
assertThat(embeddingResponse.getResults()).hasSize(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private Message mapToMessage(Map<String, Object> doc) {
}

return switch (messageType) {
case ASSISTANT -> new AssistantMessage(content, metadata);
case ASSISTANT -> AssistantMessage.builder().content(content).properties(metadata).build();
case USER -> UserMessage.builder().text(content).metadata(metadata).build();
case SYSTEM -> SystemMessage.builder().text(content).metadata(metadata).build();
case TOOL -> ToolResponseMessage.builder().responses(List.of()).metadata(metadata).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public static final class Builder {

private BedrockTitanEmbeddingOptions options = new BedrockTitanEmbeddingOptions();

@Deprecated
public Builder withInputType(InputType inputType) {
return this.inputType(inputType);
}

public Builder inputType(InputType inputType) {
Assert.notNull(inputType, "input type can not be null.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,6 @@ public class DeepSeekAssistantMessage extends AssistantMessage {

private String reasoningContent;

/**
* @deprecated in favor of {@link DeepSeekAssistantMessage.Builder}
*/
@Deprecated
public DeepSeekAssistantMessage(String content) {
super(content);
}

/**
* @deprecated in favor of {@link DeepSeekAssistantMessage.Builder}
*/
@Deprecated
public DeepSeekAssistantMessage(String content, String reasoningContent) {
super(content);
this.reasoningContent = reasoningContent;
}

/**
* @deprecated in favor of {@link DeepSeekAssistantMessage.Builder}
*/
@Deprecated
public DeepSeekAssistantMessage(String content, Map<String, Object> properties) {
super(content, properties);
}

/**
* @deprecated in favor of {@link DeepSeekAssistantMessage.Builder}
*/
@Deprecated
public DeepSeekAssistantMessage(String content, Map<String, Object> properties, List<ToolCall> toolCalls) {
super(content, properties, toolCalls);
}

/**
* @deprecated in favor of {@link DeepSeekAssistantMessage.Builder}
*/
@Deprecated
public DeepSeekAssistantMessage(String content, String reasoningContent, Map<String, Object> properties,
List<ToolCall> toolCalls) {
this(content, reasoningContent, properties, toolCalls, List.of());
}

/**
* @deprecated in favor of {@link DeepSeekAssistantMessage.Builder}
*/
@Deprecated
public DeepSeekAssistantMessage(String content, String reasoningContent, Map<String, Object> properties,
List<ToolCall> toolCalls, List<Media> media) {
this(content, reasoningContent, null, properties, toolCalls, media);
}

protected DeepSeekAssistantMessage(String content, String reasoningContent, Boolean prefix,
Map<String, Object> properties, List<ToolCall> toolCalls, List<Media> media) {
super(content, properties, toolCalls, media);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DeepSeekAssistantMessageTests {
@Test
public void testConstructorWithContentOnly() {
String content = "Hello, world!";
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage(content);
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage.Builder().content(content).build();

assertThat(message.getText()).isEqualTo(content);
assertThat(message.getReasoningContent()).isNull();
Expand All @@ -49,7 +49,9 @@ public void testConstructorWithContentOnly() {
public void testConstructorWithContentAndReasoningContent() {
String content = "Hello, world!";
String reasoningContent = "This is my reasoning";
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage(content, reasoningContent);
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage.Builder().content(content)
.reasoningContent(reasoningContent)
.build();

assertThat(message.getText()).isEqualTo(content);
assertThat(message.getReasoningContent()).isEqualTo(reasoningContent);
Expand All @@ -63,7 +65,9 @@ public void testConstructorWithContentAndProperties() {
properties.put("key1", "value1");
properties.put("key2", 123);

DeepSeekAssistantMessage message = new DeepSeekAssistantMessage(content, properties);
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage.Builder().content(content)
.properties(properties)
.build();

assertThat(message.getText()).isEqualTo(content);
assertThat(message.getMetadata()).containsAllEntriesOf(properties);
Expand All @@ -79,7 +83,10 @@ public void testConstructorWithContentPropertiesAndToolCalls() {

List<ToolCall> toolCalls = List.of(new ToolCall("1", "function", "myFunction", "{}"));

DeepSeekAssistantMessage message = new DeepSeekAssistantMessage(content, properties, toolCalls);
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage.Builder().content(content)
.properties(properties)
.toolCalls(toolCalls)
.build();

assertThat(message.getText()).isEqualTo(content);
assertThat(message.getMetadata()).containsAllEntriesOf(properties);
Expand All @@ -97,8 +104,12 @@ public void testConstructorWithAllParameters() {
properties.put("key1", "value1");
List<ToolCall> toolCalls = List.of(new ToolCall("1", "function", "myFunction", "{}"));

DeepSeekAssistantMessage message = new DeepSeekAssistantMessage(content, reasoningContent, prefix, properties,
toolCalls, List.of());
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage.Builder().content(content)
.reasoningContent(reasoningContent)
.properties(properties)
.toolCalls(toolCalls)
.prefix(prefix)
.build();

assertThat(message.getText()).isEqualTo(content);
assertThat(message.getReasoningContent()).isEqualTo(reasoningContent);
Expand Down Expand Up @@ -128,7 +139,7 @@ public void testPrefixAssistantMessageFactoryMethodWithReasoning() {

@Test
public void testSettersAndGetters() {
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage("test");
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage.Builder().build();

String reasoningContent = "New reasoning content";
Boolean prefix = false;
Expand Down Expand Up @@ -157,7 +168,9 @@ public void testEqualsAndHashCode() {

@Test
public void testToString() {
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage("content", "reasoning");
DeepSeekAssistantMessage message = new DeepSeekAssistantMessage.Builder().content("content")
.reasoningContent("reasoning")
.build();
message.setPrefix(true);

assertThatNoException().isThrownBy(message::toString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ void prefixCompletionTest() {
```
""";
UserMessage userMessage = new UserMessage(userMessageContent);
Message assistantMessage = new DeepSeekAssistantMessage("{\"code\":200,\"result\":{\"total\":1,\"data\":[1");
Message assistantMessage = AssistantMessage.builder()
.content("{\"code\":200,\"result\":{\"total\":1,\"data\":[1")
.build();
Prompt prompt = new Prompt(List.of(userMessage, assistantMessage));
ChatResponse response = this.chatModel.call(prompt);
assertThat(response.getResult().getOutput().getText().equals(",2,3]}}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ public class MistralAiChatModel implements ChatModel {
*/
private ChatModelObservationConvention observationConvention = DEFAULT_OBSERVATION_CONVENTION;

@Deprecated
public MistralAiChatModel(MistralAiApi mistralAiApi, MistralAiChatOptions defaultOptions,
ToolCallingManager toolCallingManager, RetryTemplate retryTemplate,
ObservationRegistry observationRegistry) {
this(mistralAiApi, defaultOptions, toolCallingManager, retryTemplate, observationRegistry,
new DefaultToolExecutionEligibilityPredicate());
}

public MistralAiChatModel(MistralAiApi mistralAiApi, MistralAiChatOptions defaultOptions,
ToolCallingManager toolCallingManager, RetryTemplate retryTemplate, ObservationRegistry observationRegistry,
ToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,6 @@ public class MistralAiEmbeddingModel extends AbstractEmbeddingModel {
*/
private EmbeddingModelObservationConvention observationConvention = DEFAULT_OBSERVATION_CONVENTION;

@Deprecated
public MistralAiEmbeddingModel(MistralAiApi mistralAiApi) {
this(mistralAiApi, MetadataMode.EMBED);
}

@Deprecated
public MistralAiEmbeddingModel(MistralAiApi mistralAiApi, MetadataMode metadataMode) {
this(mistralAiApi, metadataMode,
MistralAiEmbeddingOptions.builder().withModel(MistralAiApi.EmbeddingModel.EMBED.getValue()).build(),
RetryUtils.DEFAULT_RETRY_TEMPLATE);
}

@Deprecated
public MistralAiEmbeddingModel(MistralAiApi mistralAiApi, MistralAiEmbeddingOptions options) {
this(mistralAiApi, MetadataMode.EMBED, options, RetryUtils.DEFAULT_RETRY_TEMPLATE);
}

@Deprecated
public MistralAiEmbeddingModel(MistralAiApi mistralAiApi, MetadataMode metadataMode,
MistralAiEmbeddingOptions options, RetryTemplate retryTemplate) {
this(mistralAiApi, metadataMode, options, retryTemplate, ObservationRegistry.NOOP);
}

public MistralAiEmbeddingModel(MistralAiApi mistralAiApi, MetadataMode metadataMode,
MistralAiEmbeddingOptions options, RetryTemplate retryTemplate, ObservationRegistry observationRegistry) {
Assert.notNull(mistralAiApi, "mistralAiApi must not be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,38 +83,6 @@ public static Builder builder() {

private final MistralAiStreamFunctionCallingHelper chunkMerger = new MistralAiStreamFunctionCallingHelper();

/**
* Create a new client api with DEFAULT_BASE_URL
* @param apiKey Mistral api Key.
*/
@Deprecated
public MistralAiApi(String apiKey) {
this(DEFAULT_BASE_URL, apiKey);
}

/**
* Create a new client api.
* @param baseUrl api base URL.
* @param apiKey Mistral api Key.
*/
@Deprecated
public MistralAiApi(String baseUrl, String apiKey) {
this(baseUrl, apiKey, RestClient.builder(), RetryUtils.DEFAULT_RESPONSE_ERROR_HANDLER);
}

/**
* Create a new client api.
* @param baseUrl api base URL.
* @param apiKey Mistral api Key.
* @param restClientBuilder RestClient builder.
* @param responseErrorHandler Response error handler.
*/
@Deprecated
public MistralAiApi(String baseUrl, String apiKey, RestClient.Builder restClientBuilder,
ResponseErrorHandler responseErrorHandler) {
this(baseUrl, apiKey, restClientBuilder, WebClient.builder(), responseErrorHandler);
}

/**
* Create a new client api.
* @param baseUrl api base URL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public class MistralAiModerationApi {

private final RestClient restClient;

@Deprecated
public MistralAiModerationApi(String apiKey) {
this(DEFAULT_BASE_URL, apiKey, RestClient.builder(), RetryUtils.DEFAULT_RESPONSE_ERROR_HANDLER);
}

public MistralAiModerationApi(String baseUrl, String apiKey, RestClient.Builder restClientBuilder,
ResponseErrorHandler responseErrorHandler) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ public class MistralAiModerationModel implements ModerationModel {

private final MistralAiModerationOptions defaultOptions;

@Deprecated
public MistralAiModerationModel(MistralAiModerationApi mistralAiModerationApi) {
this(mistralAiModerationApi, RetryUtils.DEFAULT_RETRY_TEMPLATE,
MistralAiModerationOptions.builder()
.model(MistralAiModerationApi.Model.MISTRAL_MODERATION.getValue())
.build());
}

@Deprecated
public MistralAiModerationModel(MistralAiModerationApi mistralAiModerationApi, MistralAiModerationOptions options) {
this(mistralAiModerationApi, RetryUtils.DEFAULT_RETRY_TEMPLATE, options);
}

public MistralAiModerationModel(MistralAiModerationApi mistralAiModerationApi, RetryTemplate retryTemplate,
MistralAiModerationOptions options) {
Assert.notNull(mistralAiModerationApi, "mistralAiModerationApi must not be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MistralAiChatCompletionRequestTests {
private static final Media IMAGE_MEDIA = new Media(Media.Format.IMAGE_PNG, URI.create(IMAGE_URL));

private final MistralAiChatModel chatModel = MistralAiChatModel.builder()
.mistralAiApi(new MistralAiApi(BASE_URL, API_KEY))
.mistralAiApi(MistralAiApi.builder().baseUrl(BASE_URL).apiKey(API_KEY).build())
.build();

@Test
Expand Down Expand Up @@ -100,7 +100,7 @@ void whenToolRuntimeOptionsThenMergeWithDefaults() {
.build();

MistralAiChatModel anotherChatModel = MistralAiChatModel.builder()
.mistralAiApi(new MistralAiApi(BASE_URL, API_KEY))
.mistralAiApi(MistralAiApi.builder().baseUrl(BASE_URL).apiKey(API_KEY).build())
.defaultOptions(defaultOptions)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ void testDimensionsForMistralEmbedModel() {
.withModel(MistralAiApi.EmbeddingModel.EMBED.getValue())
.build();

MistralAiEmbeddingModel model = new MistralAiEmbeddingModel(mockApi, MetadataMode.EMBED, options,
RetryUtils.DEFAULT_RETRY_TEMPLATE);
MistralAiEmbeddingModel model = MistralAiEmbeddingModel.builder()
.mistralAiApi(mockApi)
.metadataMode(MetadataMode.EMBED)
.options(options)
.retryTemplate(RetryUtils.DEFAULT_RETRY_TEMPLATE)
.build();

assertThat(model.dimensions()).isEqualTo(1024);
}
Expand All @@ -59,8 +63,12 @@ void testDimensionsForCodestralEmbedModel() {
.withModel(MistralAiApi.EmbeddingModel.CODESTRAL_EMBED.getValue())
.build();

MistralAiEmbeddingModel model = new MistralAiEmbeddingModel(mockApi, MetadataMode.EMBED, options,
RetryUtils.DEFAULT_RETRY_TEMPLATE);
MistralAiEmbeddingModel model = MistralAiEmbeddingModel.builder()
.mistralAiApi(mockApi)
.metadataMode(MetadataMode.EMBED)
.options(options)
.retryTemplate(RetryUtils.DEFAULT_RETRY_TEMPLATE)
.build();

assertThat(model.dimensions()).isEqualTo(1536);
}
Expand All @@ -72,8 +80,12 @@ void testDimensionsFallbackForUnknownModel() {
// Use a model name that doesn't exist in KNOWN_EMBEDDING_DIMENSIONS
MistralAiEmbeddingOptions options = MistralAiEmbeddingOptions.builder().withModel("unknown-model").build();

MistralAiEmbeddingModel model = new MistralAiEmbeddingModel(mockApi, MetadataMode.EMBED, options,
RetryUtils.DEFAULT_RETRY_TEMPLATE);
MistralAiEmbeddingModel model = MistralAiEmbeddingModel.builder()
.mistralAiApi(mockApi)
.metadataMode(MetadataMode.EMBED)
.options(options)
.retryTemplate(RetryUtils.DEFAULT_RETRY_TEMPLATE)
.build();

// Should fall back to super.dimensions() which detects dimensions from the API
// response
Expand All @@ -93,8 +105,12 @@ void testAllEmbeddingModelsHaveDimensionMapping() {
.withModel(embeddingModel.getValue())
.build();

MistralAiEmbeddingModel model = new MistralAiEmbeddingModel(mockApi, MetadataMode.EMBED, options,
RetryUtils.DEFAULT_RETRY_TEMPLATE);
MistralAiEmbeddingModel model = MistralAiEmbeddingModel.builder()
.mistralAiApi(mockApi)
.metadataMode(MetadataMode.EMBED)
.options(options)
.retryTemplate(RetryUtils.DEFAULT_RETRY_TEMPLATE)
.build();

// Each model should have a valid dimension (not the fallback -1)
assertThat(model.dimensions()).as("Model %s should have a dimension mapping", embeddingModel.getValue())
Expand Down
Loading