diff --git a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/common/VertexAiGeminiSafetySetting.java b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/common/VertexAiGeminiSafetySetting.java index 9a513cfa5f0..6d46b9d9e5b 100644 --- a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/common/VertexAiGeminiSafetySetting.java +++ b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/common/VertexAiGeminiSafetySetting.java @@ -18,6 +18,10 @@ public class VertexAiGeminiSafetySetting { + public static Builder builder() { + return new Builder(); + } + /** * Enum representing different threshold levels for blocking harmful content. */ @@ -77,51 +81,30 @@ public int getValue() { } - private HarmCategory category; + private final HarmCategory category; - private HarmBlockThreshold threshold; + private final HarmBlockThreshold threshold; - private HarmBlockMethod method; - - // Default constructor - public VertexAiGeminiSafetySetting() { - this.category = HarmCategory.HARM_CATEGORY_UNSPECIFIED; - this.threshold = HarmBlockThreshold.HARM_BLOCK_THRESHOLD_UNSPECIFIED; - this.method = HarmBlockMethod.HARM_BLOCK_METHOD_UNSPECIFIED; - } + private final HarmBlockMethod method; - // Constructor with all fields - public VertexAiGeminiSafetySetting(HarmCategory category, HarmBlockThreshold threshold, HarmBlockMethod method) { + private VertexAiGeminiSafetySetting(HarmCategory category, HarmBlockThreshold threshold, HarmBlockMethod method) { this.category = category; this.threshold = threshold; this.method = method; } - // Getters and setters public HarmCategory getCategory() { return this.category; } - public void setCategory(HarmCategory category) { - this.category = category; - } - public HarmBlockThreshold getThreshold() { return this.threshold; } - public void setThreshold(HarmBlockThreshold threshold) { - this.threshold = threshold; - } - public HarmBlockMethod getMethod() { return this.method; } - public void setMethod(HarmBlockMethod method) { - this.method = method; - } - @Override public String toString() { return "SafetySetting{" + "category=" + this.category + ", threshold=" + this.threshold + ", method=" diff --git a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModelIT.java b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModelIT.java index 2c37f0608a6..7249abd0387 100644 --- a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModelIT.java +++ b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModelIT.java @@ -117,7 +117,7 @@ void googleSearchToolFlash() { @Test @Disabled void testSafetySettings() { - List safetySettings = List.of(new VertexAiGeminiSafetySetting.Builder() + List safetySettings = List.of(VertexAiGeminiSafetySetting.builder() .withCategory(VertexAiGeminiSafetySetting.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT) .withThreshold(VertexAiGeminiSafetySetting.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE) .build());