diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/AnthropicChatOptions.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/AnthropicChatOptions.java index e40b05cdf6b..1bc32acc4aa 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/AnthropicChatOptions.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/AnthropicChatOptions.java @@ -30,6 +30,7 @@ * * @author Christian Tzolov * @author Thomas Vitale + * @author Ilayaperumal Gopinathan */ @JsonInclude(Include.NON_NULL) public class AnthropicChatOptions implements ChatOptions { @@ -78,12 +79,12 @@ public static Builder builder() { } public static AnthropicChatOptions fromOptions(AnthropicChatOptions fromOptions) { - return builder().withTemperature(fromOptions.getTemperature()) - .withMaxTokensToSample(fromOptions.getMaxTokensToSample()) - .withTopK(fromOptions.getTopK()) - .withTopP(fromOptions.getTopP()) - .withStopSequences(fromOptions.getStopSequences()) - .withAnthropicVersion(fromOptions.getAnthropicVersion()) + return builder().temperature(fromOptions.getTemperature()) + .maxTokensToSample(fromOptions.getMaxTokensToSample()) + .topK(fromOptions.getTopK()) + .topP(fromOptions.getTopP()) + .stopSequences(fromOptions.getStopSequences()) + .anthropicVersion(fromOptions.getAnthropicVersion()) .build(); } @@ -177,31 +178,85 @@ public static class Builder { private final AnthropicChatOptions options = new AnthropicChatOptions(); + public Builder temperature(Double temperature) { + this.options.setTemperature(temperature); + return this; + } + + public Builder maxTokensToSample(Integer maxTokensToSample) { + this.options.setMaxTokensToSample(maxTokensToSample); + return this; + } + + public Builder topK(Integer topK) { + this.options.setTopK(topK); + return this; + } + + public Builder topP(Double topP) { + this.options.setTopP(topP); + return this; + } + + public Builder stopSequences(List stopSequences) { + this.options.setStopSequences(stopSequences); + return this; + } + + public Builder anthropicVersion(String anthropicVersion) { + this.options.setAnthropicVersion(anthropicVersion); + return this; + } + + /** + * @deprecated use {@link #temperature(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.options.setTemperature(temperature); return this; } + /** + * @deprecated use {@link #maxTokensToSample(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxTokensToSample(Integer maxTokensToSample) { this.options.setMaxTokensToSample(maxTokensToSample); return this; } + /** + * @deprecated use {@link #topK(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopK(Integer topK) { this.options.setTopK(topK); return this; } + /** + * @deprecated use {@link #topP(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double topP) { this.options.setTopP(topP); return this; } + /** + * @deprecated use {@link #stopSequences(List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withStopSequences(List stopSequences) { this.options.setStopSequences(stopSequences); return this; } + /** + * @deprecated use {@link #anthropicVersion(String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withAnthropicVersion(String anthropicVersion) { this.options.setAnthropicVersion(anthropicVersion); return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicChatModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicChatModel.java index 61f2e7fa4c9..27d5548a84e 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicChatModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicChatModel.java @@ -50,10 +50,10 @@ public class BedrockAnthropicChatModel implements ChatModel, StreamingChatModel public BedrockAnthropicChatModel(AnthropicChatBedrockApi chatApi) { this(chatApi, AnthropicChatOptions.builder() - .withTemperature(0.8) - .withMaxTokensToSample(500) - .withTopK(10) - .withAnthropicVersion(AnthropicChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) + .temperature(0.8) + .maxTokensToSample(500) + .topK(10) + .anthropicVersion(AnthropicChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) .build()); } diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApi.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApi.java index b712583dc86..1c7a98cd183 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApi.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApi.java @@ -39,6 +39,7 @@ * @author Christian Tzolov * @author Thomas Vitale * @author Wei Jiang + * @author Ilayaperumal Gopinathan * @since 0.8.0 */ // @formatter:off @@ -215,31 +216,85 @@ private Builder(String prompt) { this.prompt = prompt; } + public Builder temperature(Double temperature) { + this.temperature = temperature; + return this; + } + + public Builder maxTokensToSample(Integer maxTokensToSample) { + this.maxTokensToSample = maxTokensToSample; + return this; + } + + public Builder topK(Integer topK) { + this.topK = topK; + return this; + } + + public Builder topP(Double tpoP) { + this.topP = tpoP; + return this; + } + + public Builder stopSequences(List stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + public Builder anthropicVersion(String anthropicVersion) { + this.anthropicVersion = anthropicVersion; + return this; + } + + /** + * @deprecated use {@link #temperature( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.temperature = temperature; return this; } + /** + * @deprecated use {@link #maxTokensToSample( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxTokensToSample(Integer maxTokensToSample) { this.maxTokensToSample = maxTokensToSample; return this; } + /** + * @deprecated use {@link #topK( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopK(Integer topK) { this.topK = topK; return this; } + /** + * @deprecated use {@link #topP( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double tpoP) { this.topP = tpoP; return this; } + /** + * @deprecated use {@link #stopSequences( List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withStopSequences(List stopSequences) { this.stopSequences = stopSequences; return this; } + /** + * @deprecated use {@link #anthropicVersion( String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withAnthropicVersion(String anthropicVersion) { this.anthropicVersion = anthropicVersion; return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/Anthropic3ChatOptions.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/Anthropic3ChatOptions.java index 2a66efd9f5a..7c8892f5677 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/Anthropic3ChatOptions.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/Anthropic3ChatOptions.java @@ -92,12 +92,12 @@ public static Builder builder() { * @return a new {@link Anthropic3ChatOptions} */ public static Anthropic3ChatOptions fromOptions(Anthropic3ChatOptions fromOptions) { - return builder().withTemperature(fromOptions.getTemperature()) - .withMaxTokens(fromOptions.getMaxTokens()) - .withTopK(fromOptions.getTopK()) - .withTopP(fromOptions.getTopP()) - .withStopSequences(fromOptions.getStopSequences()) - .withAnthropicVersion(fromOptions.getAnthropicVersion()) + return builder().temperature(fromOptions.getTemperature()) + .maxTokens(fromOptions.getMaxTokens()) + .topK(fromOptions.getTopK()) + .topP(fromOptions.getTopP()) + .stopSequences(fromOptions.getStopSequences()) + .anthropicVersion(fromOptions.getAnthropicVersion()) .build(); } @@ -256,7 +256,7 @@ private Builder() { * @param temperature the temperature * @return this {@link Builder} instance */ - public Builder withTemperature(Double temperature) { + public Builder temperature(Double temperature) { this.options.setTemperature(temperature); return this; } @@ -266,7 +266,7 @@ public Builder withTemperature(Double temperature) { * @param maxTokens the maximum number of tokens * @return this {@link Builder} instance */ - public Builder withMaxTokens(Integer maxTokens) { + public Builder maxTokens(Integer maxTokens) { this.options.setMaxTokens(maxTokens); return this; } @@ -276,7 +276,7 @@ public Builder withMaxTokens(Integer maxTokens) { * @param topK the top k * @return this {@link Builder} instance */ - public Builder withTopK(Integer topK) { + public Builder topK(Integer topK) { this.options.setTopK(topK); return this; } @@ -286,7 +286,7 @@ public Builder withTopK(Integer topK) { * @param topP the top p * @return this {@link Builder} instance */ - public Builder withTopP(Double topP) { + public Builder topP(Double topP) { this.options.setTopP(topP); return this; } @@ -296,7 +296,7 @@ public Builder withTopP(Double topP) { * @param stopSequences the stop sequences * @return this {@link Builder} instance */ - public Builder withStopSequences(List stopSequences) { + public Builder stopSequences(List stopSequences) { this.options.setStopSequences(stopSequences); return this; } @@ -306,6 +306,60 @@ public Builder withStopSequences(List stopSequences) { * @param anthropicVersion the version of the generative to use * @return this {@link Builder} instance */ + public Builder anthropicVersion(String anthropicVersion) { + this.options.setAnthropicVersion(anthropicVersion); + return this; + } + + /** + * @deprecated use {@link #temperature(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTemperature(Double temperature) { + this.options.setTemperature(temperature); + return this; + } + + /** + * @deprecated use {@link #maxTokens(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withMaxTokens(Integer maxTokens) { + this.options.setMaxTokens(maxTokens); + return this; + } + + /** + * @deprecated use {@link #topK(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTopK(Integer topK) { + this.options.setTopK(topK); + return this; + } + + /** + * @deprecated use {@link #topP(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTopP(Double topP) { + this.options.setTopP(topP); + return this; + } + + /** + * @deprecated use {@link #stopSequences(List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withStopSequences(List stopSequences) { + this.options.setStopSequences(stopSequences); + return this; + } + + /** + * @deprecated use {@link #anthropicVersion(String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withAnthropicVersion(String anthropicVersion) { this.options.setAnthropicVersion(anthropicVersion); return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ChatModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ChatModel.java index 9a5b35da8fe..c000a88b15c 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ChatModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ChatModel.java @@ -66,10 +66,10 @@ public class BedrockAnthropic3ChatModel implements ChatModel, StreamingChatModel public BedrockAnthropic3ChatModel(Anthropic3ChatBedrockApi chatApi) { this(chatApi, Anthropic3ChatOptions.builder() - .withTemperature(0.8) - .withMaxTokens(500) - .withTopK(10) - .withAnthropicVersion(Anthropic3ChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) + .temperature(0.8) + .maxTokens(500) + .topK(10) + .anthropicVersion(Anthropic3ChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) .build()); } @@ -138,7 +138,7 @@ protected Usage extractUsage(AnthropicChatResponse response) { AnthropicChatRequest createRequest(Prompt prompt) { AnthropicChatRequest request = AnthropicChatRequest.builder(toAnthropicMessages(prompt)) - .withSystem(toAnthropicSystemContext(prompt)) + .system(toAnthropicSystemContext(prompt)) .build(); if (this.defaultOptions != null) { diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApi.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApi.java index 79103b4c2e8..9ac35caa443 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApi.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApi.java @@ -258,7 +258,7 @@ private Builder(List messages) { * @param system A system prompt * @return this {@link Builder} instance */ - public Builder withSystem(String system) { + public Builder system(String system) { this.system = system; return this; } @@ -268,7 +268,7 @@ public Builder withSystem(String system) { * @param temperature The temperature * @return this {@link Builder} instance */ - public Builder withTemperature(Double temperature) { + public Builder temperature(Double temperature) { this.temperature = temperature; return this; } @@ -278,7 +278,7 @@ public Builder withTemperature(Double temperature) { * @param maxTokens The max tokens * @return this {@link Builder} instance */ - public Builder withMaxTokens(Integer maxTokens) { + public Builder maxTokens(Integer maxTokens) { this.maxTokens = maxTokens; return this; } @@ -288,7 +288,7 @@ public Builder withMaxTokens(Integer maxTokens) { * @param topK The top k * @return this {@link Builder} instance */ - public Builder withTopK(Integer topK) { + public Builder topK(Integer topK) { this.topK = topK; return this; } @@ -298,7 +298,7 @@ public Builder withTopK(Integer topK) { * @param tpoP The top p * @return this {@link Builder} instance */ - public Builder withTopP(Double tpoP) { + public Builder topP(Double tpoP) { this.topP = tpoP; return this; } @@ -308,7 +308,7 @@ public Builder withTopP(Double tpoP) { * @param stopSequences The stop sequences * @return this {@link Builder} instance */ - public Builder withStopSequences(List stopSequences) { + public Builder stopSequences(List stopSequences) { this.stopSequences = stopSequences; return this; } @@ -318,11 +318,75 @@ public Builder withStopSequences(List stopSequences) { * @param anthropicVersion The anthropic version * @return this {@link Builder} instance */ + public Builder anthropicVersion(String anthropicVersion) { + this.anthropicVersion = anthropicVersion; + return this; + } + + /** + * @deprecated use {@link #system( String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withSystem(String system) { + this.system = system; + return this; + } + + /** + * @deprecated use {@link #temperature( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * @deprecated use {@link #maxTokens( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withMaxTokens(Integer maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + /** + * @deprecated use {@link #topK( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTopK(Integer topK) { + this.topK = topK; + return this; + } + + /** + * @deprecated use {@link #topP( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTopP(Double tpoP) { + this.topP = tpoP; + return this; + } + + /** + * @deprecated use {@link #stopSequences( List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withStopSequences(List stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + /** + * @deprecated use {@link #anthropicVersion( String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withAnthropicVersion(String anthropicVersion) { this.anthropicVersion = anthropicVersion; return this; } + /** * Build the {@link AnthropicChatRequest}. * @return the {@link AnthropicChatRequest} diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatModel.java index ed73af42c99..f3a3a552a2f 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatModel.java @@ -92,16 +92,16 @@ CohereChatRequest createRequest(Prompt prompt, boolean stream) { final String promptValue = MessageToPromptConverter.create().toPrompt(prompt.getInstructions()); var request = CohereChatRequest.builder(promptValue) - .withTemperature(this.defaultOptions.getTemperature()) - .withTopP(this.defaultOptions.getTopP()) - .withTopK(this.defaultOptions.getTopK()) - .withMaxTokens(this.defaultOptions.getMaxTokens()) - .withStopSequences(this.defaultOptions.getStopSequences()) - .withReturnLikelihoods(this.defaultOptions.getReturnLikelihoods()) - .withStream(stream) - .withNumGenerations(this.defaultOptions.getNumGenerations()) - .withLogitBias(this.defaultOptions.getLogitBias()) - .withTruncate(this.defaultOptions.getTruncate()) + .temperature(this.defaultOptions.getTemperature()) + .topP(this.defaultOptions.getTopP()) + .topK(this.defaultOptions.getTopK()) + .maxTokens(this.defaultOptions.getMaxTokens()) + .stopSequences(this.defaultOptions.getStopSequences()) + .returnLikelihoods(this.defaultOptions.getReturnLikelihoods()) + .stream(stream) + .numGenerations(this.defaultOptions.getNumGenerations()) + .logitBias(this.defaultOptions.getLogitBias()) + .truncate(this.defaultOptions.getTruncate()) .build(); if (prompt.getOptions() != null) { diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatOptions.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatOptions.java index 37c782799d7..0bec0913e84 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatOptions.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatOptions.java @@ -33,6 +33,7 @@ * * @author Christian Tzolov * @author Thomas Vitale + * @author Ilayaperumal Gopinathan * @since 0.8.0 */ @JsonInclude(Include.NON_NULL) @@ -98,15 +99,15 @@ public static Builder builder() { } public static BedrockCohereChatOptions fromOptions(BedrockCohereChatOptions fromOptions) { - return builder().withTemperature(fromOptions.getTemperature()) - .withTopP(fromOptions.getTopP()) - .withTopK(fromOptions.getTopK()) - .withMaxTokens(fromOptions.getMaxTokens()) - .withStopSequences(fromOptions.getStopSequences()) - .withReturnLikelihoods(fromOptions.getReturnLikelihoods()) - .withNumGenerations(fromOptions.getNumGenerations()) - .withLogitBias(fromOptions.getLogitBias()) - .withTruncate(fromOptions.getTruncate()) + return builder().temperature(fromOptions.getTemperature()) + .topP(fromOptions.getTopP()) + .topK(fromOptions.getTopK()) + .maxTokens(fromOptions.getMaxTokens()) + .stopSequences(fromOptions.getStopSequences()) + .returnLikelihoods(fromOptions.getReturnLikelihoods()) + .numGenerations(fromOptions.getNumGenerations()) + .logitBias(fromOptions.getLogitBias()) + .truncate(fromOptions.getTruncate()) .build(); } @@ -214,46 +215,127 @@ public static class Builder { private final BedrockCohereChatOptions options = new BedrockCohereChatOptions(); + public Builder temperature(Double temperature) { + this.options.setTemperature(temperature); + return this; + } + + public Builder topP(Double topP) { + this.options.setTopP(topP); + return this; + } + + public Builder topK(Integer topK) { + this.options.setTopK(topK); + return this; + } + + public Builder maxTokens(Integer maxTokens) { + this.options.setMaxTokens(maxTokens); + return this; + } + + public Builder stopSequences(List stopSequences) { + this.options.setStopSequences(stopSequences); + return this; + } + + public Builder returnLikelihoods(ReturnLikelihoods returnLikelihoods) { + this.options.setReturnLikelihoods(returnLikelihoods); + return this; + } + + public Builder numGenerations(Integer numGenerations) { + this.options.setNumGenerations(numGenerations); + return this; + } + + public Builder logitBias(LogitBias logitBias) { + this.options.setLogitBias(logitBias); + return this; + } + + public Builder truncate(Truncate truncate) { + this.options.setTruncate(truncate); + return this; + } + + /** + * @deprecated use {@link #temperature(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.options.setTemperature(temperature); return this; } + /** + * @deprecated use {@link #topP(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double topP) { this.options.setTopP(topP); return this; } + /** + * @deprecated use {@link #topK(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopK(Integer topK) { this.options.setTopK(topK); return this; } + /** + * @deprecated use {@link #maxTokens(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxTokens(Integer maxTokens) { this.options.setMaxTokens(maxTokens); return this; } + /** + * @deprecated use {@link #stopSequences(List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withStopSequences(List stopSequences) { this.options.setStopSequences(stopSequences); return this; } + /** + * @deprecated use {@link #returnLikelihoods(ReturnLikelihoods)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withReturnLikelihoods(ReturnLikelihoods returnLikelihoods) { this.options.setReturnLikelihoods(returnLikelihoods); return this; } + /** + * @deprecated use {@link #numGenerations(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withNumGenerations(Integer numGenerations) { this.options.setNumGenerations(numGenerations); return this; } + /** + * @deprecated use {@link #logitBias(LogitBias)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withLogitBias(LogitBias logitBias) { this.options.setLogitBias(logitBias); return this; } + /** + * @deprecated use {@link #truncate(Truncate)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTruncate(Truncate truncate) { this.options.setTruncate(truncate); return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModel.java index 3623260bcbb..d3b66dfacbc 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModel.java @@ -58,8 +58,8 @@ public class BedrockCohereEmbeddingModel extends AbstractEmbeddingModel { public BedrockCohereEmbeddingModel(CohereEmbeddingBedrockApi cohereEmbeddingBedrockApi) { this(cohereEmbeddingBedrockApi, BedrockCohereEmbeddingOptions.builder() - .withInputType(CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) - .withTruncate(CohereEmbeddingRequest.Truncate.NONE) + .inputType(CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) + .truncate(CohereEmbeddingRequest.Truncate.NONE) .build()); } @@ -126,8 +126,8 @@ BedrockCohereEmbeddingOptions mergeOptions(EmbeddingOptions requestOptions) { BedrockCohereEmbeddingOptions options = (this.defaultOptions != null) ? this.defaultOptions : BedrockCohereEmbeddingOptions.builder() - .withInputType(CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) - .withTruncate(CohereEmbeddingRequest.Truncate.NONE) + .inputType(CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) + .truncate(CohereEmbeddingRequest.Truncate.NONE) .build(); if (requestOptions != null && !EmbeddingOptions.EMPTY.equals(requestOptions)) { diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingOptions.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingOptions.java index e78783a4939..c226fe12a9f 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingOptions.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingOptions.java @@ -30,6 +30,7 @@ * * @author Christian Tzolov * @author Thomas Vitale + * @author Ilayaperumal Gopinathan */ @JsonInclude(Include.NON_NULL) public class BedrockCohereEmbeddingOptions implements EmbeddingOptions { @@ -87,11 +88,29 @@ public static class Builder { private BedrockCohereEmbeddingOptions options = new BedrockCohereEmbeddingOptions(); + public Builder inputType(InputType inputType) { + this.options.setInputType(inputType); + return this; + } + + public Builder truncate(Truncate truncate) { + this.options.setTruncate(truncate); + return this; + } + + /** + * @deprecated use {@link #inputType(InputType)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withInputType(InputType inputType) { this.options.setInputType(inputType); return this; } + /** + * @deprecated use {@link #truncate(Truncate)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTruncate(Truncate truncate) { this.options.setTruncate(truncate); return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApi.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApi.java index 44443905328..c63c12b1835 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApi.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApi.java @@ -42,6 +42,7 @@ * @author Christian Tzolov * @author Thomas Vitale * @author Wei Jiang + * @author Ilayaperumal Gopinathan * @since 0.8.0 */ public class CohereChatBedrockApi extends @@ -268,51 +269,141 @@ public Builder(String prompt) { this.prompt = prompt; } + public Builder temperature(Double temperature) { + this.temperature = temperature; + return this; + } + + public Builder topP(Double topP) { + this.topP = topP; + return this; + } + + public Builder topK(Integer topK) { + this.topK = topK; + return this; + } + + public Builder maxTokens(Integer maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + public Builder stopSequences(List stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + public Builder returnLikelihoods(ReturnLikelihoods returnLikelihoods) { + this.returnLikelihoods = returnLikelihoods; + return this; + } + + public Builder stream(boolean stream) { + this.stream = stream; + return this; + } + + public Builder numGenerations(Integer numGenerations) { + this.numGenerations = numGenerations; + return this; + } + + public Builder logitBias(LogitBias logitBias) { + this.logitBias = logitBias; + return this; + } + + public Builder truncate(Truncate truncate) { + this.truncate = truncate; + return this; + } + + /** + * @deprecated use {@link #temperature( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.temperature = temperature; return this; } + /** + * @deprecated use {@link #topP( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double topP) { this.topP = topP; return this; } + /** + * @deprecated use {@link #topK( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopK(Integer topK) { this.topK = topK; return this; } + /** + * @deprecated use {@link #maxTokens( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxTokens(Integer maxTokens) { this.maxTokens = maxTokens; return this; } + /** + * @deprecated use {@link #stopSequences( List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withStopSequences(List stopSequences) { this.stopSequences = stopSequences; return this; } + /** + * @deprecated use {@link #returnLikelihoods( ReturnLikelihoods)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withReturnLikelihoods(ReturnLikelihoods returnLikelihoods) { this.returnLikelihoods = returnLikelihoods; return this; } + /** + * @deprecated use {@link #stream(boolean)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withStream(boolean stream) { this.stream = stream; return this; } + /** + * @deprecated use {@link #numGenerations( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withNumGenerations(Integer numGenerations) { this.numGenerations = numGenerations; return this; } + /** + * @deprecated use {@link #logitBias( LogitBias)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withLogitBias(LogitBias logitBias) { this.logitBias = logitBias; return this; } + /** + * @deprecated use {@link #truncate( Truncate)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTruncate(Truncate truncate) { this.truncate = truncate; return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModel.java index 2258dbd84ca..5312d0a17c5 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModel.java @@ -50,12 +50,7 @@ public BedrockAi21Jurassic2ChatModel(Ai21Jurassic2ChatBedrockApi chatApi, Bedroc } public BedrockAi21Jurassic2ChatModel(Ai21Jurassic2ChatBedrockApi chatApi) { - this(chatApi, - BedrockAi21Jurassic2ChatOptions.builder() - .withTemperature(0.8) - .withTopP(0.9) - .withMaxTokens(100) - .build()); + this(chatApi, BedrockAi21Jurassic2ChatOptions.builder().temperature(0.8).topP(0.9).maxTokens(100).build()); } public static Builder builder(Ai21Jurassic2ChatBedrockApi chatApi) { diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatOptions.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatOptions.java index 024577fad41..8775e21cde6 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatOptions.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatOptions.java @@ -29,6 +29,7 @@ * * @author Ahmed Yousri * @author Thomas Vitale + * @author Ilayaperumal Gopinathan * @since 1.0.0 */ @JsonInclude(JsonInclude.Include.NON_NULL) @@ -107,17 +108,17 @@ public static Builder builder() { } public static BedrockAi21Jurassic2ChatOptions fromOptions(BedrockAi21Jurassic2ChatOptions fromOptions) { - return builder().withPrompt(fromOptions.getPrompt()) - .withNumResults(fromOptions.getNumResults()) - .withMaxTokens(fromOptions.getMaxTokens()) - .withMinTokens(fromOptions.getMinTokens()) - .withTemperature(fromOptions.getTemperature()) - .withTopP(fromOptions.getTopP()) - .withTopK(fromOptions.getTopK()) - .withStopSequences(fromOptions.getStopSequences()) - .withFrequencyPenaltyOptions(fromOptions.getFrequencyPenaltyOptions()) - .withPresencePenaltyOptions(fromOptions.getPresencePenaltyOptions()) - .withCountPenaltyOptions(fromOptions.getCountPenaltyOptions()) + return builder().prompt(fromOptions.getPrompt()) + .numResults(fromOptions.getNumResults()) + .maxTokens(fromOptions.getMaxTokens()) + .minTokens(fromOptions.getMinTokens()) + .temperature(fromOptions.getTemperature()) + .topP(fromOptions.getTopP()) + .topK(fromOptions.getTopK()) + .stopSequences(fromOptions.getStopSequences()) + .frequencyPenaltyOptions(fromOptions.getFrequencyPenaltyOptions()) + .presencePenaltyOptions(fromOptions.getPresencePenaltyOptions()) + .countPenaltyOptions(fromOptions.getCountPenaltyOptions()) .build(); } @@ -345,56 +346,155 @@ public static class Builder { private final BedrockAi21Jurassic2ChatOptions request = new BedrockAi21Jurassic2ChatOptions(); + public Builder prompt(String prompt) { + this.request.setPrompt(prompt); + return this; + } + + public Builder numResults(Integer numResults) { + this.request.setNumResults(numResults); + return this; + } + + public Builder maxTokens(Integer maxTokens) { + this.request.setMaxTokens(maxTokens); + return this; + } + + public Builder minTokens(Integer minTokens) { + this.request.setMinTokens(minTokens); + return this; + } + + public Builder temperature(Double temperature) { + this.request.setTemperature(temperature); + return this; + } + + public Builder topP(Double topP) { + this.request.setTopP(topP); + return this; + } + + public Builder stopSequences(List stopSequences) { + this.request.setStopSequences(stopSequences); + return this; + } + + public Builder topK(Integer topKReturn) { + this.request.setTopK(topKReturn); + return this; + } + + public Builder frequencyPenaltyOptions(BedrockAi21Jurassic2ChatOptions.Penalty frequencyPenalty) { + this.request.setFrequencyPenaltyOptions(frequencyPenalty); + return this; + } + + public Builder presencePenaltyOptions(BedrockAi21Jurassic2ChatOptions.Penalty presencePenalty) { + this.request.setPresencePenaltyOptions(presencePenalty); + return this; + } + + public Builder countPenaltyOptions(BedrockAi21Jurassic2ChatOptions.Penalty countPenalty) { + this.request.setCountPenaltyOptions(countPenalty); + return this; + } + + /** + * @deprecated use {@link #prompt(String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withPrompt(String prompt) { this.request.setPrompt(prompt); return this; } + /** + * @deprecated use {@link #numResults(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withNumResults(Integer numResults) { this.request.setNumResults(numResults); return this; } + /** + * @deprecated use {@link #maxTokens(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxTokens(Integer maxTokens) { this.request.setMaxTokens(maxTokens); return this; } + /** + * @deprecated use {@link #minTokens(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMinTokens(Integer minTokens) { this.request.setMinTokens(minTokens); return this; } + /** + * @deprecated use {@link #temperature(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.request.setTemperature(temperature); return this; } + /** + * @deprecated use {@link #topP(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double topP) { this.request.setTopP(topP); return this; } + /** + * @deprecated use {@link #stopSequences(List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withStopSequences(List stopSequences) { this.request.setStopSequences(stopSequences); return this; } + /** + * @deprecated use {@link #topK(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopK(Integer topKReturn) { this.request.setTopK(topKReturn); return this; } + /** + * @deprecated use {@link #frequencyPenaltyOptions(Penalty)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withFrequencyPenaltyOptions(BedrockAi21Jurassic2ChatOptions.Penalty frequencyPenalty) { this.request.setFrequencyPenaltyOptions(frequencyPenalty); return this; } + /** + * @deprecated use {@link #presencePenaltyOptions(Penalty)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withPresencePenaltyOptions(BedrockAi21Jurassic2ChatOptions.Penalty presencePenalty) { this.request.setPresencePenaltyOptions(presencePenalty); return this; } + /** + * @deprecated use {@link #countPenaltyOptions(Penalty)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withCountPenaltyOptions(BedrockAi21Jurassic2ChatOptions.Penalty countPenalty) { this.request.setCountPenaltyOptions(countPenalty); return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/api/Ai21Jurassic2ChatBedrockApi.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/api/Ai21Jurassic2ChatBedrockApi.java index bbf5efcf8ef..5fc48bf737f 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/api/Ai21Jurassic2ChatBedrockApi.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/api/Ai21Jurassic2ChatBedrockApi.java @@ -268,7 +268,7 @@ private Builder(String prompt) { * @param temperature the temperature * @return this {@link Builder} instance */ - public Builder withTemperature(Double temperature) { + public Builder temperature(Double temperature) { this.temperature = temperature; return this; } @@ -278,7 +278,7 @@ public Builder withTemperature(Double temperature) { * @param topP the topP * @return this {@link Builder} instance */ - public Builder withTopP(Double topP) { + public Builder topP(Double topP) { this.topP = topP; return this; } @@ -288,7 +288,7 @@ public Builder withTopP(Double topP) { * @param maxTokens the maxTokens * @return this {@link Builder} instance */ - public Builder withMaxTokens(Integer maxTokens) { + public Builder maxTokens(Integer maxTokens) { this.maxTokens = maxTokens; return this; } @@ -298,7 +298,7 @@ public Builder withMaxTokens(Integer maxTokens) { * @param stopSequences the stopSequences * @return this {@link Builder} instance */ - public Builder withStopSequences(List stopSequences) { + public Builder stopSequences(List stopSequences) { this.stopSequences = stopSequences; return this; } @@ -308,7 +308,7 @@ public Builder withStopSequences(List stopSequences) { * @param countPenalty the countPenalty * @return this {@link Builder} instance */ - public Builder withCountPenalty(IntegerScalePenalty countPenalty) { + public Builder countPenalty(IntegerScalePenalty countPenalty) { this.countPenalty = countPenalty; return this; } @@ -318,7 +318,7 @@ public Builder withCountPenalty(IntegerScalePenalty countPenalty) { * @param presencePenalty the presencePenalty * @return this {@link Builder} instance */ - public Builder withPresencePenalty(FloatScalePenalty presencePenalty) { + public Builder presencePenalty(FloatScalePenalty presencePenalty) { this.presencePenalty = presencePenalty; return this; } @@ -328,6 +328,69 @@ public Builder withPresencePenalty(FloatScalePenalty presencePenalty) { * @param frequencyPenalty the frequencyPenalty * @return this {@link Builder} instance */ + public Builder frequencyPenalty(IntegerScalePenalty frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + /** + * @deprecated Use {@link #temperature( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * @deprecated Use {@link #topP( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * @deprecated Use {@link #maxTokens( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withMaxTokens(Integer maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + /** + * @deprecated Use {@link #stopSequences( List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withStopSequences(List stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + /** + * @deprecated Use {@link #countPenalty( IntegerScalePenalty)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withCountPenalty(IntegerScalePenalty countPenalty) { + this.countPenalty = countPenalty; + return this; + } + + /** + * @deprecated Use {@link #presencePenalty( FloatScalePenalty)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") + public Builder withPresencePenalty(FloatScalePenalty presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + /** + * @deprecated Use {@link #frequencyPenalty( IntegerScalePenalty)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withFrequencyPenalty(IntegerScalePenalty frequencyPenalty) { this.frequencyPenalty = frequencyPenalty; return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModel.java index c6658641c43..b54b4e5c92c 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModel.java @@ -51,7 +51,7 @@ public class BedrockLlamaChatModel implements ChatModel, StreamingChatModel { private final BedrockLlamaChatOptions defaultOptions; public BedrockLlamaChatModel(LlamaChatBedrockApi chatApi) { - this(chatApi, BedrockLlamaChatOptions.builder().withTemperature(0.8).withTopP(0.9).withMaxGenLen(100).build()); + this(chatApi, BedrockLlamaChatOptions.builder().temperature(0.8).topP(0.9).maxGenLen(100).build()); } public BedrockLlamaChatModel(LlamaChatBedrockApi chatApi, BedrockLlamaChatOptions options) { diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatOptions.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatOptions.java index 3f2b4f555e1..9247571c09a 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatOptions.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatOptions.java @@ -30,6 +30,7 @@ * * @author Christian Tzolov * @author Thomas Vitale + * @author Ilayaperumal Gopinathan */ @JsonInclude(Include.NON_NULL) public class BedrockLlamaChatOptions implements ChatOptions { @@ -56,9 +57,9 @@ public static Builder builder() { } public static BedrockLlamaChatOptions fromOptions(BedrockLlamaChatOptions fromOptions) { - return builder().withTemperature(fromOptions.getTemperature()) - .withTopP(fromOptions.getTopP()) - .withMaxGenLen(fromOptions.getMaxGenLen()) + return builder().temperature(fromOptions.getTemperature()) + .topP(fromOptions.getTopP()) + .maxGenLen(fromOptions.getMaxGenLen()) .build(); } @@ -138,16 +139,43 @@ public static class Builder { private BedrockLlamaChatOptions options = new BedrockLlamaChatOptions(); + public Builder temperature(Double temperature) { + this.options.setTemperature(temperature); + return this; + } + + public Builder topP(Double topP) { + this.options.setTopP(topP); + return this; + } + + public Builder maxGenLen(Integer maxGenLen) { + this.options.setMaxGenLen(maxGenLen); + return this; + } + + /** + * @deprecated use {@link #temperature(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.options.setTemperature(temperature); return this; } + /** + * @deprecated use {@link #topP(Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double topP) { this.options.setTopP(topP); return this; } + /** + * @deprecated use {@link #maxGenLen(Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxGenLen(Integer maxGenLen) { this.options.setMaxGenLen(maxGenLen); return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApi.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApi.java index c800a768d4a..972413de9b4 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApi.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApi.java @@ -41,6 +41,7 @@ * @author Christian Tzolov * @author Thomas Vitale * @author Wei Jiang + * @author Ilayaperumal Gopinathan * @since 1.0.0 */ public class LlamaChatBedrockApi extends @@ -235,16 +236,43 @@ public Builder(String prompt) { this.prompt = prompt; } + public Builder temperature(Double temperature) { + this.temperature = temperature; + return this; + } + + public Builder topP(Double topP) { + this.topP = topP; + return this; + } + + public Builder maxGenLen(Integer maxGenLen) { + this.maxGenLen = maxGenLen; + return this; + } + + /** + * @deprecated use {@link #temperature( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.temperature = temperature; return this; } + /** + * @deprecated use {@link #topP( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double topP) { this.topP = topP; return this; } + /** + * @deprecated use {@link #maxGenLen( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxGenLen(Integer maxGenLen) { this.maxGenLen = maxGenLen; return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanChatModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanChatModel.java index 7d259ff9c7d..42544212556 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanChatModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanChatModel.java @@ -119,16 +119,16 @@ TitanChatRequest createRequest(Prompt prompt) { private TitanChatRequest.Builder update(TitanChatRequest.Builder builder, BedrockTitanChatOptions options) { if (options.getTemperature() != null) { - builder.withTemperature(options.getTemperature()); + builder.temperature(options.getTemperature()); } if (options.getTopP() != null) { - builder.withTopP(options.getTopP()); + builder.topP(options.getTopP()); } if (options.getMaxTokenCount() != null) { - builder.withMaxTokenCount(options.getMaxTokenCount()); + builder.maxTokenCount(options.getMaxTokenCount()); } if (options.getStopSequences() != null) { - builder.withStopSequences(options.getStopSequences()); + builder.stopSequences(options.getStopSequences()); } return builder; } diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanEmbeddingModel.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanEmbeddingModel.java index 609a6244124..cf01aea8194 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanEmbeddingModel.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanEmbeddingModel.java @@ -100,8 +100,8 @@ private TitanEmbeddingRequest createTitanEmbeddingRequest(String inputContent, E inputType = bedrockTitanEmbeddingOptions.getInputType(); } - return (inputType == InputType.IMAGE) ? new TitanEmbeddingRequest.Builder().withInputImage(inputContent).build() - : new TitanEmbeddingRequest.Builder().withInputText(inputContent).build(); + return (inputType == InputType.IMAGE) ? new TitanEmbeddingRequest.Builder().inputImage(inputContent).build() + : new TitanEmbeddingRequest.Builder().inputText(inputContent).build(); } @Override diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApi.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApi.java index 73c4fbbade1..5c78261d3cd 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApi.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApi.java @@ -43,6 +43,7 @@ * @author Christian Tzolov * @author Thomas Vitale * @author Wei Jiang + * @author Ilayaperumal Gopinathan * @since 0.8.0 */ // @formatter:off @@ -211,21 +212,57 @@ public Builder(String inputText) { this.inputText = inputText; } + public Builder temperature(Double temperature) { + this.temperature = temperature; + return this; + } + + public Builder topP(Double topP) { + this.topP = topP; + return this; + } + + public Builder maxTokenCount(Integer maxTokenCount) { + this.maxTokenCount = maxTokenCount; + return this; + } + + public Builder stopSequences(List stopSequences) { + this.stopSequences = stopSequences; + return this; + } + + /** + * @deprecated use {@link #temperature( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTemperature(Double temperature) { this.temperature = temperature; return this; } + /** + * @deprecated use {@link #topP( Double)} ( Double)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withTopP(Double topP) { this.topP = topP; return this; } + /** + * @deprecated use {@link #maxTokenCount( Integer)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withMaxTokenCount(Integer maxTokenCount) { this.maxTokenCount = maxTokenCount; return this; } + /** + * @deprecated use {@link #stopSequences( List)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withStopSequences(List stopSequences) { this.stopSequences = stopSequences; return this; diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApi.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApi.java index 41833f56a35..c7f3c440958 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApi.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApi.java @@ -143,16 +143,35 @@ public static class Builder { private String inputText; private String inputImage; + public Builder inputText(String inputText) { + this.inputText = inputText; + return this; + } + + public Builder inputImage(String inputImage) { + this.inputImage = inputImage; + return this; + } + + /** + * @deprecated use {@link #inputText( String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withInputText(String inputText) { this.inputText = inputText; return this; } + /** + * @deprecated use {@link #inputImage( String)} instead. + */ + @Deprecated(forRemoval = true, since = "1.0.0-M5") public Builder withInputImage(String inputImage) { this.inputImage = inputImage; return this; } + public TitanEmbeddingRequest build() { Assert.isTrue(this.inputText != null || this.inputImage != null, "At least one of the inputText or inputImage parameters must be provided!"); diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApiIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApiIT.java index e03f661333a..42e9b910394 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApiIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/api/AnthropicChatBedrockApiIT.java @@ -52,9 +52,9 @@ public void chatCompletion() { AnthropicChatRequest request = AnthropicChatRequest .builder(String.format(AnthropicChatBedrockApi.PROMPT_TEMPLATE, "Name 3 famous pirates")) - .withTemperature(0.8) - .withMaxTokensToSample(300) - .withTopK(10) + .temperature(0.8) + .maxTokensToSample(300) + .topK(10) .build(); AnthropicChatResponse response = this.anthropicChatApi.chatCompletion(request); @@ -75,10 +75,10 @@ public void chatCompletionStream() { AnthropicChatRequest request = AnthropicChatRequest .builder(String.format(AnthropicChatBedrockApi.PROMPT_TEMPLATE, "Name 3 famous pirates")) - .withTemperature(0.8) - .withMaxTokensToSample(300) - .withTopK(10) - .withStopSequences(List.of("\n\nHuman:")) + .temperature(0.8) + .maxTokensToSample(300) + .topK(10) + .stopSequences(List.of("\n\nHuman:")) .build(); Flux responseStream = this.anthropicChatApi.chatCompletionStream(request); diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java index 1a3aedfe387..3b4431fdaa8 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java @@ -41,12 +41,12 @@ public void createRequestWithChatOptions() { var client = new BedrockAnthropic3ChatModel(this.anthropicChatApi, Anthropic3ChatOptions.builder() - .withTemperature(66.6) - .withTopK(66) - .withTopP(0.66) - .withMaxTokens(666) - .withAnthropicVersion("X.Y.Z") - .withStopSequences(List.of("stop1", "stop2")) + .temperature(66.6) + .topK(66) + .topP(0.66) + .maxTokens(666) + .anthropicVersion("X.Y.Z") + .stopSequences(List.of("stop1", "stop2")) .build()); var request = client.createRequest(new Prompt("Test message content")); @@ -61,11 +61,11 @@ public void createRequestWithChatOptions() { request = client.createRequest(new Prompt("Test message content", Anthropic3ChatOptions.builder() - .withTemperature(99.9) - .withTopP(0.99) - .withMaxTokens(999) - .withAnthropicVersion("zzz") - .withStopSequences(List.of("stop3", "stop4")) + .temperature(99.9) + .topP(0.99) + .maxTokens(999) + .anthropicVersion("zzz") + .stopSequences(List.of("stop3", "stop4")) .build() )); diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApiIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApiIT.java index 3257ef671d8..529a5e898e7 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApiIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/api/Anthropic3ChatBedrockApiIT.java @@ -57,10 +57,10 @@ public void chatCompletion() { MediaContent anthropicMessage = new MediaContent("Name 3 famous pirates"); ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage(List.of(anthropicMessage), Role.USER); AnthropicChatRequest request = AnthropicChatRequest.builder(List.of(chatCompletionMessage)) - .withTemperature(0.8) - .withMaxTokens(300) - .withTopK(10) - .withAnthropicVersion( + .temperature(0.8) + .maxTokens(300) + .topK(10) + .anthropicVersion( org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) .build(); @@ -98,10 +98,10 @@ public void chatMultiCompletion() { AnthropicChatRequest request = AnthropicChatRequest .builder(List.of(chatCompletionInitialMessage, chatCompletionAssistantMessage, chatCompletionFollowupMessage)) - .withTemperature(0.8) - .withMaxTokens(400) - .withTopK(10) - .withAnthropicVersion( + .temperature(0.8) + .maxTokens(400) + .topK(10) + .anthropicVersion( org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) .build(); @@ -125,10 +125,10 @@ public void chatCompletionStream() { ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage(List.of(anthropicMessage), Role.USER); AnthropicChatRequest request = AnthropicChatRequest.builder(List.of(chatCompletionMessage)) - .withTemperature(0.8) - .withMaxTokens(300) - .withTopK(10) - .withAnthropicVersion( + .temperature(0.8) + .maxTokens(300) + .topK(10) + .anthropicVersion( org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) .build(); diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java index a1e3d7a3f7b..8b1056bc682 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java @@ -48,15 +48,15 @@ public void createRequestWithChatOptions() { var client = new BedrockCohereChatModel(this.chatApi, BedrockCohereChatOptions.builder() - .withTemperature(66.6) - .withTopK(66) - .withTopP(0.66) - .withMaxTokens(678) - .withStopSequences(List.of("stop1", "stop2")) - .withReturnLikelihoods(ReturnLikelihoods.ALL) - .withNumGenerations(3) - .withLogitBias(new LogitBias("t", 6.6f)) - .withTruncate(Truncate.END) + .temperature(66.6) + .topK(66) + .topP(0.66) + .maxTokens(678) + .stopSequences(List.of("stop1", "stop2")) + .returnLikelihoods(ReturnLikelihoods.ALL) + .numGenerations(3) + .logitBias(new LogitBias("t", 6.6f)) + .truncate(Truncate.END) .build()); CohereChatRequest request = client.createRequest(new Prompt("Test message content"), true); @@ -76,15 +76,15 @@ public void createRequestWithChatOptions() { request = client.createRequest(new Prompt("Test message content", BedrockCohereChatOptions.builder() - .withTemperature(99.9) - .withTopK(99) - .withTopP(0.99) - .withMaxTokens(888) - .withStopSequences(List.of("stop3", "stop4")) - .withReturnLikelihoods(ReturnLikelihoods.GENERATION) - .withNumGenerations(13) - .withLogitBias(new LogitBias("t", 9.9f)) - .withTruncate(Truncate.START) + .temperature(99.9) + .topK(99) + .topP(0.99) + .maxTokens(888) + .stopSequences(List.of("stop3", "stop4")) + .returnLikelihoods(ReturnLikelihoods.GENERATION) + .numGenerations(13) + .logitBias(new LogitBias("t", 9.9f)) + .truncate(Truncate.START) .build()), false diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModelIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModelIT.java index e2d5d514a55..1de5873885d 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModelIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereEmbeddingModelIT.java @@ -154,7 +154,7 @@ void embeddingWthOptions() { assertThat(this.embeddingModel).isNotNull(); EmbeddingResponse embeddingResponse = this.embeddingModel .call(new EmbeddingRequest(List.of("Hello World", "World is big and salvation is near"), - BedrockCohereEmbeddingOptions.builder().withInputType(InputType.SEARCH_DOCUMENT).build())); + BedrockCohereEmbeddingOptions.builder().inputType(InputType.SEARCH_DOCUMENT).build())); assertThat(embeddingResponse.getResults()).hasSize(2); assertThat(embeddingResponse.getResults().get(0).getOutput()).isNotEmpty(); assertThat(embeddingResponse.getResults().get(0).getIndex()).isEqualTo(0); @@ -180,8 +180,8 @@ public BedrockCohereEmbeddingModel cohereAiEmbedding(CohereEmbeddingBedrockApi c // NONE. return new BedrockCohereEmbeddingModel(cohereEmbeddingApi, BedrockCohereEmbeddingOptions.builder() - .withInputType(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) - .withTruncate(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.Truncate.END) + .inputType(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) + .truncate(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.Truncate.END) .build()); } @@ -192,8 +192,8 @@ public BedrockCohereEmbeddingModel cohereAiEmbeddingStartTruncate( // default NONE. return new BedrockCohereEmbeddingModel(cohereEmbeddingApi, BedrockCohereEmbeddingOptions.builder() - .withInputType(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) - .withTruncate(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.Truncate.START) + .inputType(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.InputType.SEARCH_DOCUMENT) + .truncate(CohereEmbeddingBedrockApi.CohereEmbeddingRequest.Truncate.START) .build()); } diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApiIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApiIT.java index 378b1e89d91..5029acf74a4 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApiIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApiIT.java @@ -55,16 +55,16 @@ public void requestBuilder() { var request2 = CohereChatRequest .builder("What is the capital of Bulgaria and what is the size? What it the national anthem?") - .withTemperature(0.5) - .withTopP(0.9) - .withTopK(15) - .withMaxTokens(40) - .withStopSequences(List.of("END")) - .withReturnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) - .withStream(false) - .withNumGenerations(1) - .withLogitBias(null) - .withTruncate(Truncate.NONE) + .temperature(0.5) + .topP(0.9) + .topK(15) + .maxTokens(40) + .stopSequences(List.of("END")) + .returnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) + .stream(false) + .numGenerations(1) + .logitBias(null) + .truncate(Truncate.NONE) .build(); assertThat(request1).isEqualTo(request2); @@ -76,16 +76,16 @@ public void chatCompletion() { var request = CohereChatRequest .builder("What is the capital of Bulgaria and what is the size? What it the national anthem?") - .withStream(false) - .withTemperature(0.5) - .withTopP(0.8) - .withTopK(15) - .withMaxTokens(100) - .withStopSequences(List.of("END")) - .withReturnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) - .withNumGenerations(3) - .withLogitBias(null) - .withTruncate(Truncate.NONE) + .stream(false) + .temperature(0.5) + .topP(0.8) + .topK(15) + .maxTokens(100) + .stopSequences(List.of("END")) + .returnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) + .numGenerations(3) + .logitBias(null) + .truncate(Truncate.NONE) .build(); CohereChatResponse response = this.cohereChatApi.chatCompletion(request); @@ -102,16 +102,16 @@ public void chatCompletionStream() { var request = CohereChatRequest .builder("What is the capital of Bulgaria and what is the size? What it the national anthem?") - .withStream(true) - .withTemperature(0.5) - .withTopP(0.8) - .withTopK(15) - .withMaxTokens(100) - .withStopSequences(List.of("END")) - .withReturnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) - .withNumGenerations(3) - .withLogitBias(null) - .withTruncate(Truncate.NONE) + .stream(true) + .temperature(0.5) + .topP(0.8) + .topK(15) + .maxTokens(100) + .stopSequences(List.of("END")) + .returnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) + .numGenerations(3) + .logitBias(null) + .truncate(Truncate.NONE) .build(); Flux responseStream = this.cohereChatApi.chatCompletionStream(request); @@ -132,7 +132,7 @@ public void chatCompletionStream() { public void testStreamConfigurations() { var streamRequest = CohereChatRequest .builder("What is the capital of Bulgaria and what is the size? What it the national anthem?") - .withStream(true) + .stream(true) .build(); assertThatThrownBy(() -> this.cohereChatApi.chatCompletion(streamRequest)) @@ -141,7 +141,7 @@ public void testStreamConfigurations() { var notStreamRequest = CohereChatRequest .builder("What is the capital of Bulgaria and what is the size? What it the national anthem?") - .withStream(false) + .stream(false) .build(); assertThatThrownBy(() -> this.cohereChatApi.chatCompletionStream(notStreamRequest)) diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModelIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModelIT.java index defc5afc8e5..d33f3db3fd2 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModelIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModelIT.java @@ -88,7 +88,7 @@ void testEmojiPenaltyFalse() { .applyToEmojis(false) .build(); BedrockAi21Jurassic2ChatOptions options = new BedrockAi21Jurassic2ChatOptions.Builder() - .withPresencePenaltyOptions(penalty) + .presencePenaltyOptions(penalty) .build(); UserMessage userMessage = new UserMessage("Can you express happiness using an emoji like 😄 ?"); @@ -106,7 +106,7 @@ void emojiPenaltyWhenTrueByDefaultApplyPenaltyTest() { // applyToEmojis is by default true BedrockAi21Jurassic2ChatOptions.Penalty penalty = new BedrockAi21Jurassic2ChatOptions.Penalty.Builder().build(); BedrockAi21Jurassic2ChatOptions options = new BedrockAi21Jurassic2ChatOptions.Builder() - .withPresencePenaltyOptions(penalty) + .presencePenaltyOptions(penalty) .build(); UserMessage userMessage = new UserMessage("Can you express happiness using an emoji like 😄?"); @@ -169,8 +169,8 @@ public BedrockAi21Jurassic2ChatModel bedrockAi21Jurassic2ChatModel( Ai21Jurassic2ChatBedrockApi jurassic2ChatBedrockApi) { return new BedrockAi21Jurassic2ChatModel(jurassic2ChatBedrockApi, BedrockAi21Jurassic2ChatOptions.builder() - .withTemperature(0.5) - .withMaxTokens(500) + .temperature(0.5) + .maxTokens(500) // .withTopP(0.9) .build()); } diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModelIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModelIT.java index c2a69b9345b..20e33963c97 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModelIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaChatModelIT.java @@ -218,7 +218,7 @@ public LlamaChatBedrockApi llamaApi() { @Bean public BedrockLlamaChatModel llamaChatModel(LlamaChatBedrockApi llamaApi) { return new BedrockLlamaChatModel(llamaApi, - BedrockLlamaChatOptions.builder().withTemperature(0.5).withMaxGenLen(100).withTopP(0.9).build()); + BedrockLlamaChatOptions.builder().temperature(0.5).maxGenLen(100).topP(0.9).build()); } } diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java index 52f4ac3d570..679fcc5f1e1 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java @@ -45,7 +45,7 @@ public class BedrockLlamaCreateRequestTests { public void createRequestWithChatOptions() { var client = new BedrockLlamaChatModel(this.api, - BedrockLlamaChatOptions.builder().withTemperature(66.6).withMaxGenLen(666).withTopP(0.66).build()); + BedrockLlamaChatOptions.builder().temperature(66.6).maxGenLen(666).topP(0.66).build()); var request = client.createRequest(new Prompt("Test message content")); @@ -55,7 +55,7 @@ public void createRequestWithChatOptions() { assertThat(request.maxGenLen()).isEqualTo(666); request = client.createRequest(new Prompt("Test message content", - BedrockLlamaChatOptions.builder().withTemperature(99.9).withMaxGenLen(999).withTopP(0.99).build())); + BedrockLlamaChatOptions.builder().temperature(99.9).maxGenLen(999).topP(0.99).build())); assertThat(request.prompt()).isNotEmpty(); assertThat(request.temperature()).isEqualTo(99.9); diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApiIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApiIT.java index e6bd75f38b5..23367d6bf63 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApiIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/api/LlamaChatBedrockApiIT.java @@ -47,9 +47,9 @@ public class LlamaChatBedrockApiIT { public void chatCompletion() { LlamaChatRequest request = LlamaChatRequest.builder("Hello, my name is") - .withTemperature(0.9) - .withTopP(0.9) - .withMaxGenLen(20) + .temperature(0.9) + .topP(0.9) + .maxGenLen(20) .build(); LlamaChatResponse response = this.llamaChatApi.chatCompletion(request); diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApiIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApiIT.java index 4ee57c162b8..5ce71a7ff5c 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApiIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApiIT.java @@ -45,10 +45,10 @@ public class TitanChatBedrockApiIT { Duration.ofMinutes(2)); TitanChatRequest titanChatRequest = TitanChatRequest.builder("Give me the names of 3 famous pirates?") - .withTemperature(0.5) - .withTopP(0.9) - .withMaxTokenCount(100) - .withStopSequences(List.of("|")) + .temperature(0.5) + .topP(0.9) + .maxTokenCount(100) + .stopSequences(List.of("|")) .build(); @Test diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApiIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApiIT.java index 73715a411ab..a7b55ff138b 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApiIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanEmbeddingBedrockApiIT.java @@ -47,7 +47,7 @@ public void embedTextV1() { TitanEmbeddingModel.TITAN_EMBED_TEXT_V1.id(), EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(), Duration.ofMinutes(2)); - TitanEmbeddingRequest request = TitanEmbeddingRequest.builder().withInputText("I like to eat apples.").build(); + TitanEmbeddingRequest request = TitanEmbeddingRequest.builder().inputText("I like to eat apples.").build(); TitanEmbeddingResponse response = titanEmbedApi.embedding(request); @@ -63,7 +63,7 @@ public void embedTextV2() { TitanEmbeddingModel.TITAN_EMBED_TEXT_V2.id(), EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(), Duration.ofMinutes(2)); - TitanEmbeddingRequest request = TitanEmbeddingRequest.builder().withInputText("I like to eat apples.").build(); + TitanEmbeddingRequest request = TitanEmbeddingRequest.builder().inputText("I like to eat apples.").build(); TitanEmbeddingResponse response = titanEmbedApi.embedding(request); @@ -85,7 +85,7 @@ public void embedImage() throws IOException { String imageBase64 = Base64.getEncoder().encodeToString(image); System.out.println(imageBase64.length()); - TitanEmbeddingRequest request = TitanEmbeddingRequest.builder().withInputImage(imageBase64).build(); + TitanEmbeddingRequest request = TitanEmbeddingRequest.builder().inputImage(imageBase64).build(); TitanEmbeddingResponse response = titanEmbedApi.embedding(request); diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic.adoc index 72945c2f731..56389f71f2f 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic.adoc @@ -124,7 +124,7 @@ ChatResponse response = chatModel.call( new Prompt( "Generate the names of 5 famous pirates.", AnthropicChatOptions.builder() - .withTemperature(0.4) + .temperature(0.4) .build() )); ---- @@ -217,11 +217,11 @@ AnthropicChatBedrockApi anthropicApi = new AnthropicChatBedrockApi( BedrockAnthropicChatModel chatModel = new BedrockAnthropicChatModel(this.anthropicApi, AnthropicChatOptions.builder() - .withTemperature(0.6) - .withTopK(10) - .withTopP(0.8) - .withMaxTokensToSample(100) - .withAnthropicVersion(AnthropicChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) + .temperature(0.6) + .topK(10) + .topP(0.8) + .maxTokensToSample(100) + .anthropicVersion(AnthropicChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) .build()); ChatResponse response = this.chatModel.call( @@ -251,9 +251,9 @@ AnthropicChatBedrockApi anthropicChatApi = new AnthropicChatBedrockApi( AnthropicChatRequest request = AnthropicChatRequest .builder(String.format(AnthropicChatBedrockApi.PROMPT_TEMPLATE, "Name 3 famous pirates")) - .withTemperature(0.8) - .withMaxTokensToSample(300) - .withTopK(10) + .temperature(0.8) + .maxTokensToSample(300) + .topK(10) .build(); // Sync request diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic3.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic3.adoc index 23cd6ce3201..e8a4ed0cb06 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic3.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-anthropic3.adoc @@ -121,7 +121,7 @@ ChatResponse response = chatModel.call( new Prompt( "Generate the names of 5 famous pirates.", Anthropic3ChatOptions.builder() - .withTemperature(0.4) + .temperature(0.4) .build() )); ---- @@ -258,11 +258,11 @@ Anthropic3ChatBedrockApi anthropicApi = new Anthropic3ChatBedrockApi( BedrockAnthropic3ChatModel chatModel = new BedrockAnthropic3ChatModel(this.anthropicApi, AnthropicChatOptions.builder() - .withTemperature(0.6) - .withTopK(10) - .withTopP(0.8) - .withMaxTokensToSample(100) - .withAnthropicVersion(AnthropicChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) + .temperature(0.6) + .topK(10) + .topP(0.8) + .maxTokensToSample(100) + .anthropicVersion(AnthropicChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) .build()); ChatResponse response = this.chatModel.call( @@ -288,9 +288,9 @@ Anthropic3ChatBedrockApi anthropicChatApi = new Anthropic3ChatBedrockApi( AnthropicChatRequest request = AnthropicChatRequest .builder(String.format(Anthropic3ChatBedrockApi.PROMPT_TEMPLATE, "Name 3 famous pirates")) - .withTemperature(0.8) - .withMaxTokensToSample(300) - .withTopK(10) + .temperature(0.8) + .maxTokensToSample(300) + .topK(10) .build(); // Sync request diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-cohere.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-cohere.adoc index a467560e9d9..6ab0800b49d 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-cohere.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-cohere.adoc @@ -117,7 +117,7 @@ ChatResponse response = chatModel.call( new Prompt( "Generate the names of 5 famous pirates.", BedrockCohereChatOptions.builder() - .withTemperature(0.4) + .temperature(0.4) .build() )); ---- @@ -208,10 +208,10 @@ CohereChatBedrockApi api = new CohereChatBedrockApi(CohereChatModel.COHERE_COMMA BedrockCohereChatModel chatModel = new BedrockCohereChatModel(this.api, BedrockCohereChatOptions.builder() - .withTemperature(0.6) - .withTopK(10) - .withTopP(0.5) - .withMaxTokens(678) + .temperature(0.6) + .topK(10) + .topP(0.5) + .maxTokens(678) .build()); ChatResponse response = this.chatModel.call( @@ -243,32 +243,32 @@ CohereChatBedrockApi cohereChatApi = new CohereChatBedrockApi( var request = CohereChatRequest .builder("What is the capital of Bulgaria and what is the size? What is the national anthem?") - .withStream(false) - .withTemperature(0.5) - .withTopP(0.8) - .withTopK(15) - .withMaxTokens(100) - .withStopSequences(List.of("END")) - .withReturnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) - .withNumGenerations(3) - .withLogitBias(null) - .withTruncate(Truncate.NONE) + .stream(false) + .temperature(0.5) + .topP(0.8) + .topK(15) + .maxTokens(100) + .stopSequences(List.of("END")) + .returnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) + .numGenerations(3) + .logitBias(null) + .truncate(Truncate.NONE) .build(); CohereChatResponse response = this.cohereChatApi.chatCompletion(this.request); var request = CohereChatRequest .builder("What is the capital of Bulgaria and what is the size? What it the national anthem?") - .withStream(true) - .withTemperature(0.5) - .withTopP(0.8) - .withTopK(15) - .withMaxTokens(100) - .withStopSequences(List.of("END")) - .withReturnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) - .withNumGenerations(3) - .withLogitBias(null) - .withTruncate(Truncate.NONE) + .stream(true) + .temperature(0.5) + .topP(0.8) + .topK(15) + .maxTokens(100) + .stopSequences(List.of("END")) + .returnLikelihoods(CohereChatRequest.ReturnLikelihoods.ALL) + .numGenerations(3) + .logitBias(null) + .truncate(Truncate.NONE) .build(); Flux responseStream = this.cohereChatApi.chatCompletionStream(this.request); diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-jurassic2.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-jurassic2.adoc index 86f2eed814f..07a2214bc52 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-jurassic2.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-jurassic2.adoc @@ -110,7 +110,7 @@ ChatResponse response = chatModel.call( new Prompt( "Generate the names of 5 famous pirates.", BedrockAi21Jurassic2ChatOptions.builder() - .withTemperature(0.4) + .temperature(0.4) .build() )); ---- @@ -196,9 +196,9 @@ Ai21Jurassic2ChatBedrockApi api = new Ai21Jurassic2ChatBedrockApi(Ai21Jurassic2C BedrockAi21Jurassic2ChatModel chatModel = new BedrockAi21Jurassic2ChatModel(this.api, BedrockAi21Jurassic2ChatOptions.builder() - .withTemperature(0.5) - .withMaxTokens(100) - .withTopP(0.9).build()); + .temperature(0.5) + .maxTokens(100) + .topP(0.9).build()); ChatResponse response = this.chatModel.call( new Prompt("Generate the names of 5 famous pirates.")); @@ -222,9 +222,9 @@ Ai21Jurassic2ChatBedrockApi jurassic2ChatApi = new Ai21Jurassic2ChatBedrockApi( Duration.ofMillis(1000L)); Ai21Jurassic2ChatRequest request = Ai21Jurassic2ChatRequest.builder("Hello, my name is") - .withTemperature(0.9) - .withTopP(0.9) - .withMaxTokens(20) + .temperature(0.9) + .topP(0.9) + .maxTokens(20) .build(); Ai21Jurassic2ChatResponse response = this.jurassic2ChatApi.chatCompletion(this.request); diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-llama.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-llama.adoc index 26beae1f8e8..e5a9c61a46f 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-llama.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-llama.adoc @@ -115,7 +115,7 @@ ChatResponse response = chatModel.call( new Prompt( "Generate the names of 5 famous pirates.", BedrockLlamaChatOptions.builder() - .withTemperature(0.4) + .temperature(0.4) .build() )); ---- @@ -206,9 +206,9 @@ LlamaChatBedrockApi api = new LlamaChatBedrockApi(LlamaChatModel.LLAMA2_70B_CHAT BedrockLlamaChatModel chatModel = new BedrockLlamaChatModel(this.api, BedrockLlamaChatOptions.builder() - .withTemperature(0.5) - .withMaxGenLen(100) - .withTopP(0.9).build()); + .temperature(0.5) + .maxGenLen(100) + .topP(0.9).build()); ChatResponse response = this.chatModel.call( new Prompt("Generate the names of 5 famous pirates.")); @@ -238,9 +238,9 @@ LlamaChatBedrockApi llamaChatApi = new LlamaChatBedrockApi( Duration.ofMillis(1000L)); LlamaChatRequest request = LlamaChatRequest.builder("Hello, my name is") - .withTemperature(0.9) - .withTopP(0.9) - .withMaxGenLen(20) + .temperature(0.9) + .topP(0.9) + .maxGenLen(20) .build(); LlamaChatResponse response = this.llamaChatApi.chatCompletion(this.request); diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-titan.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-titan.adoc index 64b5dca3258..98d184c5d71 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-titan.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/bedrock/bedrock-titan.adoc @@ -113,7 +113,7 @@ ChatResponse response = chatModel.call( new Prompt( "Generate the names of 5 famous pirates.", BedrockTitanChatOptions.builder() - .withTemperature(0.4) + .temperature(0.4) .build() )); ---- @@ -205,9 +205,9 @@ TitanChatBedrockApi titanApi = new TitanChatBedrockApi( BedrockTitanChatModel chatModel = new BedrockTitanChatModel(this.titanApi, BedrockTitanChatOptions.builder() - .withTemperature(0.6) - .withTopP(0.8) - .withMaxTokenCount(100) + .temperature(0.6) + .topP(0.8) + .maxTokenCount(100) .build()); ChatResponse response = this.chatModel.call( @@ -236,10 +236,10 @@ TitanChatBedrockApi titanBedrockApi = new TitanChatBedrockApi(TitanChatCompletio Region.US_EAST_1.id(), Duration.ofMillis(1000L)); TitanChatRequest titanChatRequest = TitanChatRequest.builder("Give me the names of 3 famous pirates?") - .withTemperature(0.5) - .withTopP(0.9) - .withMaxTokenCount(100) - .withStopSequences(List.of("|")) + .temperature(0.5) + .topP(0.9) + .maxTokenCount(100) + .stopSequences(List.of("|")) .build(); TitanChatResponse response = this.titanBedrockApi.chatCompletion(this.titanChatRequest); diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatProperties.java index aff62571194..4feb0fb7de5 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatProperties.java @@ -47,10 +47,10 @@ public class BedrockAnthropic3ChatProperties { @NestedConfigurationProperty private Anthropic3ChatOptions options = Anthropic3ChatOptions.builder() - .withTemperature(0.7) - .withMaxTokens(300) - .withTopK(10) - .withAnthropicVersion(Anthropic3ChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) + .temperature(0.7) + .maxTokens(300) + .topK(10) + .anthropicVersion(Anthropic3ChatBedrockApi.DEFAULT_ANTHROPIC_VERSION) // .withStopSequences(List.of("\n\nHuman:")) .build(); diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereEmbeddingProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereEmbeddingProperties.java index 3841fb6f38a..9e2752dfc09 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereEmbeddingProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereEmbeddingProperties.java @@ -47,8 +47,8 @@ public class BedrockCohereEmbeddingProperties { @NestedConfigurationProperty private BedrockCohereEmbeddingOptions options = BedrockCohereEmbeddingOptions.builder() - .withInputType(InputType.SEARCH_DOCUMENT) - .withTruncate(CohereEmbeddingRequest.Truncate.NONE) + .inputType(InputType.SEARCH_DOCUMENT) + .truncate(CohereEmbeddingRequest.Truncate.NONE) .build(); public boolean isEnabled() { diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatProperties.java index 6ed3f46181c..6c6b0ffed2e 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatProperties.java @@ -45,8 +45,8 @@ public class BedrockAi21Jurassic2ChatProperties { @NestedConfigurationProperty private BedrockAi21Jurassic2ChatOptions options = BedrockAi21Jurassic2ChatOptions.builder() - .withTemperature(0.7) - .withMaxTokens(500) + .temperature(0.7) + .maxTokens(500) .build(); public boolean isEnabled() { diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatProperties.java index 979e4fae472..29d367c8e18 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatProperties.java @@ -43,10 +43,7 @@ public class BedrockLlamaChatProperties { private String model = LlamaChatModel.LLAMA3_70B_INSTRUCT_V1.id(); @NestedConfigurationProperty - private BedrockLlamaChatOptions options = BedrockLlamaChatOptions.builder() - .withTemperature(0.7) - .withMaxGenLen(300) - .build(); + private BedrockLlamaChatOptions options = BedrockLlamaChatOptions.builder().temperature(0.7).maxGenLen(300).build(); public boolean isEnabled() { return this.enabled;