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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ public class GoogleGenAiChatOptions implements ToolCallingChatOptions, Structure
/**
* Use Google search Grounding feature
*/
private final Boolean googleSearchRetrieval;
private final @Nullable Boolean googleSearchRetrieval;

/**
* Optional. When true, the API response will include server-side tool calls and
* responses (e.g., Google Search invocations) within Content message parts.
* This allows clients to observe the server's tool invocations without executing them.
* Only supported with MLDev (Google AI) API, not Vertex AI.
*/
private final Boolean includeServerSideToolInvocations;
private final @Nullable Boolean includeServerSideToolInvocations;

private final @Nullable List<GoogleGenAiSafetySetting> safetySettings;

Expand Down Expand Up @@ -240,8 +240,8 @@ protected GoogleGenAiChatOptions(@Nullable String model, @Nullable Double freque
this.useCachedContent = useCachedContent;
this.autoCacheThreshold = autoCacheThreshold;
this.autoCacheTtl = autoCacheTtl;
this.googleSearchRetrieval = Boolean.TRUE.equals(googleSearchRetrieval);
this.includeServerSideToolInvocations = Boolean.TRUE.equals(includeServerSideToolInvocations);
this.googleSearchRetrieval = googleSearchRetrieval;
this.includeServerSideToolInvocations = includeServerSideToolInvocations;
this.safetySettings = (safetySettings != null ? List.copyOf(safetySettings) : null);
this.labels = (labels != null ? Map.copyOf(labels) : null);
this.serviceTier = serviceTier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,45 @@ public void testEqualsAndHashCodeWithIncludeServerSideToolInvocations() {
assertThat(options1).isNotEqualTo(options3);
}

@Test
public void testOptionalBooleanDefaultsRemainUnset() {
GoogleGenAiChatOptions options = GoogleGenAiChatOptions.builder().build();

assertThat(options.getGoogleSearchRetrieval()).isNull();
assertThat(options.getIncludeServerSideToolInvocations()).isNull();
}

@Test
public void testCombineWithPreservesOptionalBooleanDefaults() {
GoogleGenAiChatOptions defaults = GoogleGenAiChatOptions.builder()
.googleSearchRetrieval(true)
.includeServerSideToolInvocations(true)
.build();
GoogleGenAiChatOptions requestOptions = GoogleGenAiChatOptions.builder().temperature(0.2).build();

GoogleGenAiChatOptions merged = defaults.mutate().combineWith(requestOptions.mutate()).build();

assertThat(merged.getGoogleSearchRetrieval()).isTrue();
assertThat(merged.getIncludeServerSideToolInvocations()).isTrue();
}

@Test
public void testCombineWithOverridesOptionalBooleansWhenExplicitlySet() {
GoogleGenAiChatOptions defaults = GoogleGenAiChatOptions.builder()
.googleSearchRetrieval(true)
.includeServerSideToolInvocations(true)
.build();
GoogleGenAiChatOptions requestOptions = GoogleGenAiChatOptions.builder()
.googleSearchRetrieval(false)
.includeServerSideToolInvocations(false)
.build();

GoogleGenAiChatOptions merged = defaults.mutate().combineWith(requestOptions.mutate()).build();

assertThat(merged.getGoogleSearchRetrieval()).isFalse();
assertThat(merged.getIncludeServerSideToolInvocations()).isFalse();
}

@Test
public void testServiceTierWithBuilder() {
GoogleGenAiChatOptions options = GoogleGenAiChatOptions.builder()
Expand Down
Loading