Fix builder methods not to use deprecated methods
This commit is contained in:
@@ -337,8 +337,8 @@ class AnthropicChatModelIT {
|
||||
List<Message> messages = new ArrayList<>(List.of(userMessage));
|
||||
|
||||
var promptOptions = AnthropicChatOptions.builder()
|
||||
.withModel(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName())
|
||||
.withFunctionCallbacks(List.of(FunctionCallback.builder()
|
||||
.model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName())
|
||||
.functionCallbacks(List.of(FunctionCallback.builder()
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.description(
|
||||
"Get the weather in location. Return temperature in 36°F or 36°C format. Use multi-turn if needed.")
|
||||
|
||||
@@ -158,13 +158,13 @@ class AzureOpenAiChatModelFunctionCallIT {
|
||||
streamOptions.setIncludeUsage(true);
|
||||
|
||||
var promptOptions = AzureOpenAiChatOptions.builder()
|
||||
.withDeploymentName(this.selectedModel)
|
||||
.withFunctionCallbacks(List.of(FunctionCallback.builder()
|
||||
.deploymentName(this.selectedModel)
|
||||
.functionCallbacks(List.of(FunctionCallback.builder()
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.description("Get the current weather in a given location")
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
.build()))
|
||||
.withStreamOptions(streamOptions)
|
||||
.streamOptions(streamOptions)
|
||||
.build();
|
||||
|
||||
Flux<ChatResponse> response = this.chatModel.stream(new Prompt(messages, promptOptions));
|
||||
|
||||
@@ -41,12 +41,12 @@ public class BedrockAnthropicCreateRequestTests {
|
||||
|
||||
var client = new BedrockAnthropicChatModel(this.anthropicChatApi,
|
||||
AnthropicChatOptions.builder()
|
||||
.withTemperature(66.6)
|
||||
.withTopK(66)
|
||||
.withTopP(0.66)
|
||||
.withMaxTokensToSample(666)
|
||||
.withAnthropicVersion("X.Y.Z")
|
||||
.withStopSequences(List.of("stop1", "stop2"))
|
||||
.temperature(66.6)
|
||||
.topK(66)
|
||||
.topP(0.66)
|
||||
.maxTokensToSample(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 BedrockAnthropicCreateRequestTests {
|
||||
|
||||
request = client.createRequest(new Prompt("Test message content",
|
||||
AnthropicChatOptions.builder()
|
||||
.withTemperature(99.9)
|
||||
.withTopP(0.99)
|
||||
.withMaxTokensToSample(999)
|
||||
.withAnthropicVersion("zzz")
|
||||
.withStopSequences(List.of("stop3", "stop4"))
|
||||
.temperature(99.9)
|
||||
.topP(0.99)
|
||||
.maxTokensToSample(999)
|
||||
.anthropicVersion("zzz")
|
||||
.stopSequences(List.of("stop3", "stop4"))
|
||||
.build()
|
||||
|
||||
));
|
||||
|
||||
@@ -251,8 +251,8 @@ class MistralAiChatModelIT {
|
||||
List<Message> messages = new ArrayList<>(List.of(userMessage));
|
||||
|
||||
var promptOptions = MistralAiChatOptions.builder()
|
||||
.withModel(MistralAiApi.ChatModel.SMALL.getValue())
|
||||
.withFunctionCallbacks(List.of(FunctionCallback.builder()
|
||||
.model(MistralAiApi.ChatModel.SMALL.getValue())
|
||||
.functionCallbacks(List.of(FunctionCallback.builder()
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.description("Get the weather in location")
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
|
||||
@@ -120,6 +120,7 @@ public class OpenAiEmbeddingOptions implements EmbeddingOptions {
|
||||
/**
|
||||
* @deprecated use {@link #model(String)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.0.0-M5")
|
||||
public Builder withModel(String model) {
|
||||
this.options.setModel(model);
|
||||
return this;
|
||||
@@ -128,6 +129,7 @@ public class OpenAiEmbeddingOptions implements EmbeddingOptions {
|
||||
/**
|
||||
* @deprecated use {@link #encodingFormat(String)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.0.0-M5")
|
||||
public Builder withEncodingFormat(String encodingFormat) {
|
||||
this.options.setEncodingFormat(encodingFormat);
|
||||
return this;
|
||||
@@ -136,6 +138,7 @@ public class OpenAiEmbeddingOptions implements EmbeddingOptions {
|
||||
/**
|
||||
* @deprecated use {@link #dimensions(Integer)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.0.0-M5")
|
||||
public Builder withDimensions(Integer dimensions) {
|
||||
this.options.dimensions = dimensions;
|
||||
return this;
|
||||
@@ -144,6 +147,7 @@ public class OpenAiEmbeddingOptions implements EmbeddingOptions {
|
||||
/**
|
||||
* @deprecated use {@link #user(String)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.0.0-M5")
|
||||
public Builder withUser(String user) {
|
||||
this.options.setUser(user);
|
||||
return this;
|
||||
|
||||
@@ -118,32 +118,32 @@ public class OpenAiModerationModel implements ModerationModel {
|
||||
CategoryScores categoryScores = null;
|
||||
if (result.categories() != null) {
|
||||
categories = Categories.builder()
|
||||
.withSexual(result.categories().sexual())
|
||||
.withHate(result.categories().hate())
|
||||
.withHarassment(result.categories().harassment())
|
||||
.withSelfHarm(result.categories().selfHarm())
|
||||
.withSexualMinors(result.categories().sexualMinors())
|
||||
.withHateThreatening(result.categories().hateThreatening())
|
||||
.withViolenceGraphic(result.categories().violenceGraphic())
|
||||
.withSelfHarmIntent(result.categories().selfHarmIntent())
|
||||
.withSelfHarmInstructions(result.categories().selfHarmInstructions())
|
||||
.withHarassmentThreatening(result.categories().harassmentThreatening())
|
||||
.withViolence(result.categories().violence())
|
||||
.sexual(result.categories().sexual())
|
||||
.hate(result.categories().hate())
|
||||
.harassment(result.categories().harassment())
|
||||
.selfHarm(result.categories().selfHarm())
|
||||
.sexualMinors(result.categories().sexualMinors())
|
||||
.hateThreatening(result.categories().hateThreatening())
|
||||
.violenceGraphic(result.categories().violenceGraphic())
|
||||
.selfHarmIntent(result.categories().selfHarmIntent())
|
||||
.selfHarmInstructions(result.categories().selfHarmInstructions())
|
||||
.harassmentThreatening(result.categories().harassmentThreatening())
|
||||
.violence(result.categories().violence())
|
||||
.build();
|
||||
}
|
||||
if (result.categoryScores() != null) {
|
||||
categoryScores = CategoryScores.builder()
|
||||
.withHate(result.categoryScores().hate())
|
||||
.withHateThreatening(result.categoryScores().hateThreatening())
|
||||
.withHarassment(result.categoryScores().harassment())
|
||||
.withHarassmentThreatening(result.categoryScores().harassmentThreatening())
|
||||
.withSelfHarm(result.categoryScores().selfHarm())
|
||||
.withSelfHarmIntent(result.categoryScores().selfHarmIntent())
|
||||
.withSelfHarmInstructions(result.categoryScores().selfHarmInstructions())
|
||||
.withSexual(result.categoryScores().sexual())
|
||||
.withSexualMinors(result.categoryScores().sexualMinors())
|
||||
.withViolence(result.categoryScores().violence())
|
||||
.withViolenceGraphic(result.categoryScores().violenceGraphic())
|
||||
.hate(result.categoryScores().hate())
|
||||
.hateThreatening(result.categoryScores().hateThreatening())
|
||||
.harassment(result.categoryScores().harassment())
|
||||
.harassmentThreatening(result.categoryScores().harassmentThreatening())
|
||||
.selfHarm(result.categoryScores().selfHarm())
|
||||
.selfHarmIntent(result.categoryScores().selfHarmIntent())
|
||||
.selfHarmInstructions(result.categoryScores().selfHarmInstructions())
|
||||
.sexual(result.categoryScores().sexual())
|
||||
.sexualMinors(result.categoryScores().sexualMinors())
|
||||
.violence(result.categoryScores().violence())
|
||||
.violenceGraphic(result.categoryScores().violenceGraphic())
|
||||
.build();
|
||||
}
|
||||
ModerationResult moderationResult = ModerationResult.builder()
|
||||
@@ -157,9 +157,9 @@ public class OpenAiModerationModel implements ModerationModel {
|
||||
}
|
||||
|
||||
Moderation moderation = Moderation.builder()
|
||||
.withId(moderationApiResponse.id())
|
||||
.withModel(moderationApiResponse.model())
|
||||
.withResults(moderationResults)
|
||||
.id(moderationApiResponse.id())
|
||||
.model(moderationApiResponse.model())
|
||||
.results(moderationResults)
|
||||
.build();
|
||||
|
||||
return new ModerationResponse(new Generation(moderation));
|
||||
|
||||
@@ -67,6 +67,7 @@ public class OpenAiModerationOptions implements ModerationOptions {
|
||||
/**
|
||||
* @deprecated use {@link #model(String)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.0.0-M5")
|
||||
public Builder withModel(String model) {
|
||||
this.options.setModel(model);
|
||||
return this;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class OpenAiModerationModelIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
void moderationAsUrlTestPositive() {
|
||||
var options = ModerationOptionsBuilder.builder().withModel("text-moderation-stable").build();
|
||||
var options = ModerationOptionsBuilder.builder().model("text-moderation-stable").build();
|
||||
|
||||
var instructions = """
|
||||
I want to kill them.!".""";
|
||||
@@ -97,7 +97,7 @@ public class OpenAiModerationModelIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
void moderationAsUrlTestNegative() {
|
||||
var options = ModerationOptionsBuilder.builder().withModel("text-moderation-stable").build();
|
||||
var options = ModerationOptionsBuilder.builder().model("text-moderation-stable").build();
|
||||
|
||||
var instructions = """
|
||||
A light cream colored mini golden doodle with a sign that contains the message "I'm on my way to BARCADE!".""";
|
||||
|
||||
@@ -100,7 +100,7 @@ class VertexAiGeminiChatModelIT {
|
||||
.withThreshold(VertexAiGeminiSafetySetting.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE)
|
||||
.build());
|
||||
Prompt prompt = new Prompt("What are common digital attack vectors?",
|
||||
VertexAiGeminiChatOptions.builder().withSafetySettings(safetySettings).build());
|
||||
VertexAiGeminiChatOptions.builder().safetySettings(safetySettings).build());
|
||||
ChatResponse response = this.chatModel.call(prompt);
|
||||
assertThat(response.getResult().getMetadata().getFinishReason()).isEqualTo("SAFETY");
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ public class BedrockAnthropicChatProperties {
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private AnthropicChatOptions options = AnthropicChatOptions.builder()
|
||||
.withTemperature(0.7)
|
||||
.withMaxTokensToSample(300)
|
||||
.withTopK(10)
|
||||
.withStopSequences(List.of("\n\nHuman:"))
|
||||
.temperature(0.7)
|
||||
.maxTokensToSample(300)
|
||||
.topK(10)
|
||||
.stopSequences(List.of("\n\nHuman:"))
|
||||
.build();
|
||||
|
||||
public boolean isEnabled() {
|
||||
|
||||
Reference in New Issue
Block a user