From 1a24bedc752851236b0a7239a7dba7090e4ac4e8 Mon Sep 17 00:00:00 2001 From: Kaituo Huang Date: Thu, 25 Sep 2025 10:43:52 -0700 Subject: [PATCH] feat: Add FunctionResponsePart & ToolComputerUse.excludedPredefinedFunctions FunctionResponsePart could be used to support the computer use tool with browser screenshot PiperOrigin-RevId: 811412522 --- src/main/java/com/google/genai/Batches.java | 7 + src/main/java/com/google/genai/Caches.java | 14 ++ .../java/com/google/genai/LiveConverters.java | 168 ++++++++++++++++++ src/main/java/com/google/genai/Models.java | 14 ++ .../google/genai/types/FunctionResponse.java | 43 +++++ .../genai/types/FunctionResponseBlob.java | 86 +++++++++ .../genai/types/FunctionResponseFileData.java | 82 +++++++++ .../genai/types/FunctionResponsePart.java | 108 +++++++++++ .../google/genai/types/ToolComputerUse.java | 34 ++++ 9 files changed, 556 insertions(+) create mode 100644 src/main/java/com/google/genai/types/FunctionResponseBlob.java create mode 100644 src/main/java/com/google/genai/types/FunctionResponseFileData.java create mode 100644 src/main/java/com/google/genai/types/FunctionResponsePart.java diff --git a/src/main/java/com/google/genai/Batches.java b/src/main/java/com/google/genai/Batches.java index e6727448f7f..71a5fd4e09c 100644 --- a/src/main/java/com/google/genai/Batches.java +++ b/src/main/java/com/google/genai/Batches.java @@ -2245,6 +2245,13 @@ ObjectNode toolComputerUseToMldev(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"environment"})); } + if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"excludedPredefinedFunctions"}, + Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/Caches.java b/src/main/java/com/google/genai/Caches.java index 2f2d615f336..8d8a1cb041f 100644 --- a/src/main/java/com/google/genai/Caches.java +++ b/src/main/java/com/google/genai/Caches.java @@ -1470,6 +1470,13 @@ ObjectNode toolComputerUseToMldev(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"environment"})); } + if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"excludedPredefinedFunctions"}, + Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"})); + } + return toObject; } @@ -1483,6 +1490,13 @@ ObjectNode toolComputerUseToVertex(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"environment"})); } + if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"excludedPredefinedFunctions"}, + Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java index db2ed8f693d..0dc2e83f832 100644 --- a/src/main/java/com/google/genai/LiveConverters.java +++ b/src/main/java/com/google/genai/LiveConverters.java @@ -818,6 +818,138 @@ ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObj return toObject; } + @ExcludeFromGeneratedCoverageReport + ObjectNode functionResponseBlobToMldev(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"mimeType"}, + Common.getValueByPath(fromObject, new String[] {"mimeType"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"data"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"data"}, + Common.getValueByPath(fromObject, new String[] {"data"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode functionResponseBlobToVertex(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"mimeType"}, + Common.getValueByPath(fromObject, new String[] {"mimeType"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"data"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"data"}, + Common.getValueByPath(fromObject, new String[] {"data"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode functionResponseFileDataToMldev(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"fileUri"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"fileUri"}, + Common.getValueByPath(fromObject, new String[] {"fileUri"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"mimeType"}, + Common.getValueByPath(fromObject, new String[] {"mimeType"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode functionResponseFileDataToVertex(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"fileUri"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"fileUri"}, + Common.getValueByPath(fromObject, new String[] {"fileUri"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"mimeType"}, + Common.getValueByPath(fromObject, new String[] {"mimeType"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode functionResponsePartToMldev(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"inlineData"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"inlineData"}, + functionResponseBlobToMldev( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"inlineData"})), + toObject)); + } + + if (Common.getValueByPath(fromObject, new String[] {"fileData"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"fileData"}, + functionResponseFileDataToMldev( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"fileData"})), + toObject)); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode functionResponsePartToVertex(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"inlineData"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"inlineData"}, + functionResponseBlobToVertex( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"inlineData"})), + toObject)); + } + + if (Common.getValueByPath(fromObject, new String[] {"fileData"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"fileData"}, + functionResponseFileDataToVertex( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"fileData"})), + toObject)); + } + + return toObject; + } + @ExcludeFromGeneratedCoverageReport ObjectNode functionResponseToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); @@ -835,6 +967,17 @@ ObjectNode functionResponseToMldev(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"scheduling"})); } + if (Common.getValueByPath(fromObject, new String[] {"parts"}) != null) { + ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"parts"}); + ObjectMapper objectMapper = new ObjectMapper(); + ArrayNode result = objectMapper.createArrayNode(); + + for (JsonNode item : keyArray) { + result.add(functionResponsePartToMldev(JsonSerializable.toJsonNode(item), toObject)); + } + Common.setValueByPath(toObject, new String[] {"parts"}, result); + } + if (Common.getValueByPath(fromObject, new String[] {"id"}) != null) { Common.setValueByPath( toObject, new String[] {"id"}, Common.getValueByPath(fromObject, new String[] {"id"})); @@ -868,6 +1011,17 @@ ObjectNode functionResponseToVertex(JsonNode fromObject, ObjectNode parentObject throw new IllegalArgumentException("scheduling parameter is not supported in Vertex AI."); } + if (Common.getValueByPath(fromObject, new String[] {"parts"}) != null) { + ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"parts"}); + ObjectMapper objectMapper = new ObjectMapper(); + ArrayNode result = objectMapper.createArrayNode(); + + for (JsonNode item : keyArray) { + result.add(functionResponsePartToVertex(JsonSerializable.toJsonNode(item), toObject)); + } + Common.setValueByPath(toObject, new String[] {"parts"}, result); + } + if (Common.getValueByPath(fromObject, new String[] {"id"}) != null) { Common.setValueByPath( toObject, new String[] {"id"}, Common.getValueByPath(fromObject, new String[] {"id"})); @@ -3206,6 +3360,13 @@ ObjectNode toolComputerUseToMldev(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"environment"})); } + if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"excludedPredefinedFunctions"}, + Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"})); + } + return toObject; } @@ -3219,6 +3380,13 @@ ObjectNode toolComputerUseToVertex(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"environment"})); } + if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"excludedPredefinedFunctions"}, + Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/Models.java b/src/main/java/com/google/genai/Models.java index fd37c9da1c4..d9196ea1970 100644 --- a/src/main/java/com/google/genai/Models.java +++ b/src/main/java/com/google/genai/Models.java @@ -5602,6 +5602,13 @@ ObjectNode toolComputerUseToMldev(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"environment"})); } + if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"excludedPredefinedFunctions"}, + Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"})); + } + return toObject; } @@ -5615,6 +5622,13 @@ ObjectNode toolComputerUseToVertex(JsonNode fromObject, ObjectNode parentObject) Common.getValueByPath(fromObject, new String[] {"environment"})); } + if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"excludedPredefinedFunctions"}, + Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/types/FunctionResponse.java b/src/main/java/com/google/genai/types/FunctionResponse.java index 50d14349d8d..e5f11e8438d 100644 --- a/src/main/java/com/google/genai/types/FunctionResponse.java +++ b/src/main/java/com/google/genai/types/FunctionResponse.java @@ -18,12 +18,16 @@ package com.google.genai.types; +import static com.google.common.collect.ImmutableList.toImmutableList; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.auto.value.AutoValue; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.genai.JsonSerializable; +import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -49,6 +53,13 @@ public abstract class FunctionResponse extends JsonSerializable { @JsonProperty("scheduling") public abstract Optional scheduling(); + /** + * List of parts that constitute a function response. Each part may have a different IANA MIME + * type. + */ + @JsonProperty("parts") + public abstract Optional> parts(); + /** * Optional. The id of the function call this response is for. Populated by the client to match * the corresponding function call `id`. @@ -134,6 +145,38 @@ public Builder scheduling(String scheduling) { return scheduling(new FunctionResponseScheduling(scheduling)); } + /** + * Setter for parts. + * + *

parts: List of parts that constitute a function response. Each part may have a different + * IANA MIME type. + */ + @JsonProperty("parts") + public abstract Builder parts(List parts); + + /** + * Setter for parts. + * + *

parts: List of parts that constitute a function response. Each part may have a different + * IANA MIME type. + */ + public Builder parts(FunctionResponsePart... parts) { + return parts(Arrays.asList(parts)); + } + + /** + * Setter for parts builder. + * + *

parts: List of parts that constitute a function response. Each part may have a different + * IANA MIME type. + */ + public Builder parts(FunctionResponsePart.Builder... partsBuilders) { + return parts( + Arrays.asList(partsBuilders).stream() + .map(FunctionResponsePart.Builder::build) + .collect(toImmutableList())); + } + /** * Setter for id. * diff --git a/src/main/java/com/google/genai/types/FunctionResponseBlob.java b/src/main/java/com/google/genai/types/FunctionResponseBlob.java new file mode 100644 index 00000000000..4da5207fad0 --- /dev/null +++ b/src/main/java/com/google/genai/types/FunctionResponseBlob.java @@ -0,0 +1,86 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** + * Raw media bytes for function response. + * + *

Text should not be sent as raw bytes, use the FunctionResponse.response field. + */ +@AutoValue +@JsonDeserialize(builder = FunctionResponseBlob.Builder.class) +public abstract class FunctionResponseBlob extends JsonSerializable { + /** Required. The IANA standard MIME type of the source data. */ + @JsonProperty("mimeType") + public abstract Optional mimeType(); + + /** Required. Inline media bytes. */ + @JsonProperty("data") + public abstract Optional data(); + + /** Instantiates a builder for FunctionResponseBlob. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_FunctionResponseBlob.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for FunctionResponseBlob. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `FunctionResponseBlob.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_FunctionResponseBlob.Builder(); + } + + /** + * Setter for mimeType. + * + *

mimeType: Required. The IANA standard MIME type of the source data. + */ + @JsonProperty("mimeType") + public abstract Builder mimeType(String mimeType); + + /** + * Setter for data. + * + *

data: Required. Inline media bytes. + */ + @JsonProperty("data") + public abstract Builder data(byte[] data); + + public abstract FunctionResponseBlob build(); + } + + /** Deserializes a JSON string to a FunctionResponseBlob object. */ + @ExcludeFromGeneratedCoverageReport + public static FunctionResponseBlob fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, FunctionResponseBlob.class); + } +} diff --git a/src/main/java/com/google/genai/types/FunctionResponseFileData.java b/src/main/java/com/google/genai/types/FunctionResponseFileData.java new file mode 100644 index 00000000000..5b4de4a8a8e --- /dev/null +++ b/src/main/java/com/google/genai/types/FunctionResponseFileData.java @@ -0,0 +1,82 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** URI based data for function response. */ +@AutoValue +@JsonDeserialize(builder = FunctionResponseFileData.Builder.class) +public abstract class FunctionResponseFileData extends JsonSerializable { + /** Required. URI. */ + @JsonProperty("fileUri") + public abstract Optional fileUri(); + + /** Required. The IANA standard MIME type of the source data. */ + @JsonProperty("mimeType") + public abstract Optional mimeType(); + + /** Instantiates a builder for FunctionResponseFileData. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_FunctionResponseFileData.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for FunctionResponseFileData. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `FunctionResponseFileData.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_FunctionResponseFileData.Builder(); + } + + /** + * Setter for fileUri. + * + *

fileUri: Required. URI. + */ + @JsonProperty("fileUri") + public abstract Builder fileUri(String fileUri); + + /** + * Setter for mimeType. + * + *

mimeType: Required. The IANA standard MIME type of the source data. + */ + @JsonProperty("mimeType") + public abstract Builder mimeType(String mimeType); + + public abstract FunctionResponseFileData build(); + } + + /** Deserializes a JSON string to a FunctionResponseFileData object. */ + @ExcludeFromGeneratedCoverageReport + public static FunctionResponseFileData fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, FunctionResponseFileData.class); + } +} diff --git a/src/main/java/com/google/genai/types/FunctionResponsePart.java b/src/main/java/com/google/genai/types/FunctionResponsePart.java new file mode 100644 index 00000000000..9c2a6a021b8 --- /dev/null +++ b/src/main/java/com/google/genai/types/FunctionResponsePart.java @@ -0,0 +1,108 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** + * A datatype containing media that is part of a `FunctionResponse` message. + * + *

A `FunctionResponsePart` consists of data which has an associated datatype. A + * `FunctionResponsePart` can only contain one of the accepted types in `FunctionResponsePart.data`. + * + *

A `FunctionResponsePart` must have a fixed IANA MIME type identifying the type and subtype of + * the media if the `inline_data` field is filled with raw bytes. + */ +@AutoValue +@JsonDeserialize(builder = FunctionResponsePart.Builder.class) +public abstract class FunctionResponsePart extends JsonSerializable { + /** Optional. Inline media bytes. */ + @JsonProperty("inlineData") + public abstract Optional inlineData(); + + /** Optional. URI based data. */ + @JsonProperty("fileData") + public abstract Optional fileData(); + + /** Instantiates a builder for FunctionResponsePart. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_FunctionResponsePart.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for FunctionResponsePart. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `FunctionResponsePart.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_FunctionResponsePart.Builder(); + } + + /** + * Setter for inlineData. + * + *

inlineData: Optional. Inline media bytes. + */ + @JsonProperty("inlineData") + public abstract Builder inlineData(FunctionResponseBlob inlineData); + + /** + * Setter for inlineData builder. + * + *

inlineData: Optional. Inline media bytes. + */ + public Builder inlineData(FunctionResponseBlob.Builder inlineDataBuilder) { + return inlineData(inlineDataBuilder.build()); + } + + /** + * Setter for fileData. + * + *

fileData: Optional. URI based data. + */ + @JsonProperty("fileData") + public abstract Builder fileData(FunctionResponseFileData fileData); + + /** + * Setter for fileData builder. + * + *

fileData: Optional. URI based data. + */ + public Builder fileData(FunctionResponseFileData.Builder fileDataBuilder) { + return fileData(fileDataBuilder.build()); + } + + public abstract FunctionResponsePart build(); + } + + /** Deserializes a JSON string to a FunctionResponsePart object. */ + @ExcludeFromGeneratedCoverageReport + public static FunctionResponsePart fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, FunctionResponsePart.class); + } +} diff --git a/src/main/java/com/google/genai/types/ToolComputerUse.java b/src/main/java/com/google/genai/types/ToolComputerUse.java index 6f844d34d00..5a9652269ca 100644 --- a/src/main/java/com/google/genai/types/ToolComputerUse.java +++ b/src/main/java/com/google/genai/types/ToolComputerUse.java @@ -24,6 +24,8 @@ import com.google.auto.value.AutoValue; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.genai.JsonSerializable; +import java.util.Arrays; +import java.util.List; import java.util.Optional; /** Tool to support computer use. */ @@ -34,6 +36,15 @@ public abstract class ToolComputerUse extends JsonSerializable { @JsonProperty("environment") public abstract Optional environment(); + /** + * By default, predefined functions are included in the final model call. Some of them can be + * explicitly excluded from being automatically included. This can serve two purposes: 1. Using a + * more restricted / different action space. 2. Improving the definitions / instructions of + * predefined functions. + */ + @JsonProperty("excludedPredefinedFunctions") + public abstract Optional> excludedPredefinedFunctions(); + /** Instantiates a builder for ToolComputerUse. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -80,6 +91,29 @@ public Builder environment(String environment) { return environment(new Environment(environment)); } + /** + * Setter for excludedPredefinedFunctions. + * + *

excludedPredefinedFunctions: By default, predefined functions are included in the final + * model call. Some of them can be explicitly excluded from being automatically included. This + * can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the + * definitions / instructions of predefined functions. + */ + @JsonProperty("excludedPredefinedFunctions") + public abstract Builder excludedPredefinedFunctions(List excludedPredefinedFunctions); + + /** + * Setter for excludedPredefinedFunctions. + * + *

excludedPredefinedFunctions: By default, predefined functions are included in the final + * model call. Some of them can be explicitly excluded from being automatically included. This + * can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the + * definitions / instructions of predefined functions. + */ + public Builder excludedPredefinedFunctions(String... excludedPredefinedFunctions) { + return excludedPredefinedFunctions(Arrays.asList(excludedPredefinedFunctions)); + } + public abstract ToolComputerUse build(); }