Refactor Spring AI Bedrock options

- Refactor the options builder methods to remove `with` as the suffix
   - Update all the models under spring-ai-bedrock

 - Deprecate the existing methods
 - Update references and docs
This commit is contained in:
Ilayaperumal Gopinathan
2024-12-16 14:34:18 +00:00
committed by Mark Pollack
parent 58efee6d90
commit 65e7a1ddd9
43 changed files with 954 additions and 267 deletions

View File

@@ -30,6 +30,7 @@ import org.springframework.ai.chat.prompt.ChatOptions;
*
* @author Christian Tzolov
* @author Thomas Vitale
* @author Ilayaperumal Gopinathan
*/
@JsonInclude(Include.NON_NULL)
public class AnthropicChatOptions implements ChatOptions {
@@ -78,12 +79,12 @@ public class AnthropicChatOptions implements ChatOptions {
}
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 class AnthropicChatOptions implements ChatOptions {
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<String> 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<String> 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;

View File

@@ -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());
}

View File

@@ -39,6 +39,7 @@ import org.springframework.util.Assert;
* @author Christian Tzolov
* @author Thomas Vitale
* @author Wei Jiang
* @author Ilayaperumal Gopinathan
* @since 0.8.0
*/
// @formatter:off
@@ -215,31 +216,85 @@ public class AnthropicChatBedrockApi extends
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<String> 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<String> 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;

View File

@@ -92,12 +92,12 @@ public class Anthropic3ChatOptions implements ChatOptions {
* @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 @@ public class Anthropic3ChatOptions implements ChatOptions {
* @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 class Anthropic3ChatOptions implements ChatOptions {
* @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 class Anthropic3ChatOptions implements ChatOptions {
* @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 class Anthropic3ChatOptions implements ChatOptions {
* @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 class Anthropic3ChatOptions implements ChatOptions {
* @param stopSequences the stop sequences
* @return this {@link Builder} instance
*/
public Builder withStopSequences(List<String> stopSequences) {
public Builder stopSequences(List<String> stopSequences) {
this.options.setStopSequences(stopSequences);
return this;
}
@@ -306,6 +306,60 @@ public class Anthropic3ChatOptions implements ChatOptions {
* @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<String> 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;

View File

@@ -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 @@ public class BedrockAnthropic3ChatModel implements ChatModel, StreamingChatModel
AnthropicChatRequest createRequest(Prompt prompt) {
AnthropicChatRequest request = AnthropicChatRequest.builder(toAnthropicMessages(prompt))
.withSystem(toAnthropicSystemContext(prompt))
.system(toAnthropicSystemContext(prompt))
.build();
if (this.defaultOptions != null) {

View File

@@ -258,7 +258,7 @@ public class Anthropic3ChatBedrockApi extends
* @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 class Anthropic3ChatBedrockApi extends
* @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 class Anthropic3ChatBedrockApi extends
* @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 class Anthropic3ChatBedrockApi extends
* @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 class Anthropic3ChatBedrockApi extends
* @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 class Anthropic3ChatBedrockApi extends
* @param stopSequences The stop sequences
* @return this {@link Builder} instance
*/
public Builder withStopSequences(List<String> stopSequences) {
public Builder stopSequences(List<String> stopSequences) {
this.stopSequences = stopSequences;
return this;
}
@@ -318,11 +318,75 @@ public class Anthropic3ChatBedrockApi extends
* @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<String> 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}

View File

@@ -92,16 +92,16 @@ public class BedrockCohereChatModel implements ChatModel, StreamingChatModel {
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) {

View File

@@ -33,6 +33,7 @@ import org.springframework.ai.chat.prompt.ChatOptions;
*
* @author Christian Tzolov
* @author Thomas Vitale
* @author Ilayaperumal Gopinathan
* @since 0.8.0
*/
@JsonInclude(Include.NON_NULL)
@@ -98,15 +99,15 @@ public class BedrockCohereChatOptions implements ChatOptions {
}
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 class BedrockCohereChatOptions implements ChatOptions {
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<String> 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<String> 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;

View File

@@ -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 @@ public class BedrockCohereEmbeddingModel extends AbstractEmbeddingModel {
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)) {

View File

@@ -30,6 +30,7 @@ import org.springframework.ai.embedding.EmbeddingOptions;
*
* @author Christian Tzolov
* @author Thomas Vitale
* @author Ilayaperumal Gopinathan
*/
@JsonInclude(Include.NON_NULL)
public class BedrockCohereEmbeddingOptions implements EmbeddingOptions {
@@ -87,11 +88,29 @@ public class BedrockCohereEmbeddingOptions implements EmbeddingOptions {
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;

View File

@@ -42,6 +42,7 @@ import org.springframework.util.Assert;
* @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 class CohereChatBedrockApi extends
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<String> 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<String> 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;

View File

@@ -50,12 +50,7 @@ public class BedrockAi21Jurassic2ChatModel implements ChatModel {
}
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) {

View File

@@ -29,6 +29,7 @@ import org.springframework.ai.chat.prompt.ChatOptions;
*
* @author Ahmed Yousri
* @author Thomas Vitale
* @author Ilayaperumal Gopinathan
* @since 1.0.0
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -107,17 +108,17 @@ public class BedrockAi21Jurassic2ChatOptions implements ChatOptions {
}
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 class BedrockAi21Jurassic2ChatOptions implements ChatOptions {
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<String> 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<String> 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;

View File

@@ -268,7 +268,7 @@ public class Ai21Jurassic2ChatBedrockApi extends
* @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 class Ai21Jurassic2ChatBedrockApi extends
* @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 class Ai21Jurassic2ChatBedrockApi extends
* @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 class Ai21Jurassic2ChatBedrockApi extends
* @param stopSequences the stopSequences
* @return this {@link Builder} instance
*/
public Builder withStopSequences(List<String> stopSequences) {
public Builder stopSequences(List<String> stopSequences) {
this.stopSequences = stopSequences;
return this;
}
@@ -308,7 +308,7 @@ public class Ai21Jurassic2ChatBedrockApi extends
* @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 class Ai21Jurassic2ChatBedrockApi extends
* @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 class Ai21Jurassic2ChatBedrockApi extends
* @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<String> 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;

View File

@@ -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) {

View File

@@ -30,6 +30,7 @@ import org.springframework.ai.chat.prompt.ChatOptions;
*
* @author Christian Tzolov
* @author Thomas Vitale
* @author Ilayaperumal Gopinathan
*/
@JsonInclude(Include.NON_NULL)
public class BedrockLlamaChatOptions implements ChatOptions {
@@ -56,9 +57,9 @@ public class BedrockLlamaChatOptions implements ChatOptions {
}
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 class BedrockLlamaChatOptions implements ChatOptions {
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;

View File

@@ -41,6 +41,7 @@ import org.springframework.ai.model.ChatModelDescription;
* @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 class LlamaChatBedrockApi extends
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;

View File

@@ -119,16 +119,16 @@ public class BedrockTitanChatModel implements ChatModel, StreamingChatModel {
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;
}

View File

@@ -100,8 +100,8 @@ public class BedrockTitanEmbeddingModel extends AbstractEmbeddingModel {
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

View File

@@ -43,6 +43,7 @@ import org.springframework.ai.model.ChatModelDescription;
* @author Christian Tzolov
* @author Thomas Vitale
* @author Wei Jiang
* @author Ilayaperumal Gopinathan
* @since 0.8.0
*/
// @formatter:off
@@ -211,21 +212,57 @@ public class TitanChatBedrockApi extends
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<String> 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<String> stopSequences) {
this.stopSequences = stopSequences;
return this;

View File

@@ -143,16 +143,35 @@ public class TitanEmbeddingBedrockApi extends
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!");

View File

@@ -52,9 +52,9 @@ public class AnthropicChatBedrockApiIT {
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 class AnthropicChatBedrockApiIT {
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<AnthropicChatResponse> responseStream = this.anthropicChatApi.chatCompletionStream(request);

View File

@@ -41,12 +41,12 @@ public class BedrockAnthropic3CreateRequestTests {
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 class BedrockAnthropic3CreateRequestTests {
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()
));

View File

@@ -57,10 +57,10 @@ public class Anthropic3ChatBedrockApiIT {
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 class Anthropic3ChatBedrockApiIT {
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 class Anthropic3ChatBedrockApiIT {
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();

View File

@@ -48,15 +48,15 @@ public class BedrockCohereChatCreateRequestTests {
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 class BedrockCohereChatCreateRequestTests {
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

View File

@@ -154,7 +154,7 @@ class BedrockCohereEmbeddingModelIT {
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 @@ class BedrockCohereEmbeddingModelIT {
// 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 @@ class BedrockCohereEmbeddingModelIT {
// 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());
}

View File

@@ -55,16 +55,16 @@ public class CohereChatBedrockApiIT {
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 class CohereChatBedrockApiIT {
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 class CohereChatBedrockApiIT {
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<CohereChatResponse.Generation> responseStream = this.cohereChatApi.chatCompletionStream(request);
@@ -132,7 +132,7 @@ public class CohereChatBedrockApiIT {
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 class CohereChatBedrockApiIT {
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))

View File

@@ -88,7 +88,7 @@ class BedrockAi21Jurassic2ChatModelIT {
.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 @@ class BedrockAi21Jurassic2ChatModelIT {
// 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 @@ class BedrockAi21Jurassic2ChatModelIT {
Ai21Jurassic2ChatBedrockApi jurassic2ChatBedrockApi) {
return new BedrockAi21Jurassic2ChatModel(jurassic2ChatBedrockApi,
BedrockAi21Jurassic2ChatOptions.builder()
.withTemperature(0.5)
.withMaxTokens(500)
.temperature(0.5)
.maxTokens(500)
// .withTopP(0.9)
.build());
}

View File

@@ -218,7 +218,7 @@ class BedrockLlamaChatModelIT {
@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());
}
}

View File

@@ -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 class BedrockLlamaCreateRequestTests {
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);

View File

@@ -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);

View File

@@ -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

View File

@@ -47,7 +47,7 @@ public class TitanEmbeddingBedrockApiIT {
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 class TitanEmbeddingBedrockApiIT {
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 class TitanEmbeddingBedrockApiIT {
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);

View File

@@ -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

View File

@@ -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

View File

@@ -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<CohereChatResponse.Generation> responseStream = this.cohereChatApi.chatCompletionStream(this.request);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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;