Skip to content

Commit 08c05bb

Browse files
MarkDaoustcopybara-github
authored andcommitted
feat: additional computer_use field support for vertex.
PiperOrigin-RevId: 922282731
1 parent bf99a92 commit 08c05bb

3 files changed

Lines changed: 3 additions & 142 deletions

File tree

src/main/java/com/google/genai/Caches.java

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.fasterxml.jackson.databind.ObjectMapper;
2323
import com.fasterxml.jackson.databind.node.ArrayNode;
2424
import com.fasterxml.jackson.databind.node.ObjectNode;
25-
import com.google.common.collect.ImmutableSet;
2625
import com.google.genai.Common.BuiltRequest;
2726
import com.google.genai.errors.GenAiIOException;
2827
import com.google.genai.types.CachedContent;
@@ -60,19 +59,6 @@ public Caches(ApiClient apiClient) {
6059
this.apiClient = apiClient;
6160
}
6261

63-
@ExcludeFromGeneratedCoverageReport
64-
void environmentVertexEnumValidate(Object enumValue) {
65-
ImmutableSet<String> invalidEnumValues =
66-
ImmutableSet.of("ENVIRONMENT_MOBILE", "ENVIRONMENT_DESKTOP");
67-
if (invalidEnumValues.contains(enumValue.toString().replace("\"", ""))) {
68-
throw new IllegalArgumentException(
69-
String.format(
70-
"%s enum value is only supported in Gemini Developer API mode, not in Gemini"
71-
+ " Enterprise Agent Platform mode.",
72-
enumValue));
73-
}
74-
}
75-
7662
@ExcludeFromGeneratedCoverageReport
7763
ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
7864
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -175,35 +161,6 @@ ObjectNode codeExecutionResultToVertex(JsonNode fromObject, ObjectNode parentObj
175161
return toObject;
176162
}
177163

178-
@ExcludeFromGeneratedCoverageReport
179-
ObjectNode computerUseToVertex(JsonNode fromObject, ObjectNode parentObject) {
180-
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
181-
if (Common.getValueByPath(fromObject, new String[] {"environment"}) != null) {
182-
environmentVertexEnumValidate(
183-
Common.getValueByPath(fromObject, new String[] {"environment"}));
184-
Common.setValueByPath(
185-
toObject,
186-
new String[] {"environment"},
187-
Common.getValueByPath(fromObject, new String[] {"environment"}));
188-
}
189-
190-
if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) {
191-
Common.setValueByPath(
192-
toObject,
193-
new String[] {"excludedPredefinedFunctions"},
194-
Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}));
195-
}
196-
197-
if (!Common.isZero(
198-
Common.getValueByPath(fromObject, new String[] {"enablePromptInjectionDetection"}))) {
199-
throw new IllegalArgumentException(
200-
"enablePromptInjectionDetection parameter is only supported in Gemini Developer API mode,"
201-
+ " not in Gemini Enterprise Agent Platform mode.");
202-
}
203-
204-
return toObject;
205-
}
206-
207164
@ExcludeFromGeneratedCoverageReport
208165
ObjectNode contentToMldev(JsonNode fromObject, ObjectNode parentObject) {
209166
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -1223,10 +1180,7 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
12231180
Common.setValueByPath(
12241181
toObject,
12251182
new String[] {"computerUse"},
1226-
computerUseToVertex(
1227-
JsonSerializable.toJsonNode(
1228-
Common.getValueByPath(fromObject, new String[] {"computerUse"})),
1229-
toObject));
1183+
Common.getValueByPath(fromObject, new String[] {"computerUse"}));
12301184
}
12311185

12321186
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"fileSearch"}))) {

src/main/java/com/google/genai/LiveConverters.java

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.fasterxml.jackson.databind.ObjectMapper;
2323
import com.fasterxml.jackson.databind.node.ArrayNode;
2424
import com.fasterxml.jackson.databind.node.ObjectNode;
25-
import com.google.common.collect.ImmutableSet;
2625

2726
/** Internal SDK converter functions. */
2827
final class LiveConverters {
@@ -32,19 +31,6 @@ public LiveConverters(ApiClient apiClient) {
3231
this.apiClient = apiClient;
3332
}
3433

35-
@ExcludeFromGeneratedCoverageReport
36-
void environmentVertexEnumValidate(Object enumValue) {
37-
ImmutableSet<String> invalidEnumValues =
38-
ImmutableSet.of("ENVIRONMENT_MOBILE", "ENVIRONMENT_DESKTOP");
39-
if (invalidEnumValues.contains(enumValue.toString().replace("\"", ""))) {
40-
throw new IllegalArgumentException(
41-
String.format(
42-
"%s enum value is only supported in Gemini Developer API mode, not in Gemini"
43-
+ " Enterprise Agent Platform mode.",
44-
enumValue));
45-
}
46-
}
47-
4834
@ExcludeFromGeneratedCoverageReport
4935
ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
5036
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -159,35 +145,6 @@ ObjectNode codeExecutionResultToVertex(JsonNode fromObject, ObjectNode parentObj
159145
return toObject;
160146
}
161147

162-
@ExcludeFromGeneratedCoverageReport
163-
ObjectNode computerUseToVertex(JsonNode fromObject, ObjectNode parentObject) {
164-
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
165-
if (Common.getValueByPath(fromObject, new String[] {"environment"}) != null) {
166-
environmentVertexEnumValidate(
167-
Common.getValueByPath(fromObject, new String[] {"environment"}));
168-
Common.setValueByPath(
169-
toObject,
170-
new String[] {"environment"},
171-
Common.getValueByPath(fromObject, new String[] {"environment"}));
172-
}
173-
174-
if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) {
175-
Common.setValueByPath(
176-
toObject,
177-
new String[] {"excludedPredefinedFunctions"},
178-
Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}));
179-
}
180-
181-
if (!Common.isZero(
182-
Common.getValueByPath(fromObject, new String[] {"enablePromptInjectionDetection"}))) {
183-
throw new IllegalArgumentException(
184-
"enablePromptInjectionDetection parameter is only supported in Gemini Developer API mode,"
185-
+ " not in Gemini Enterprise Agent Platform mode.");
186-
}
187-
188-
return toObject;
189-
}
190-
191148
@ExcludeFromGeneratedCoverageReport
192149
ObjectNode contentToMldev(JsonNode fromObject, ObjectNode parentObject) {
193150
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -2101,10 +2058,7 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
21012058
Common.setValueByPath(
21022059
toObject,
21032060
new String[] {"computerUse"},
2104-
computerUseToVertex(
2105-
JsonSerializable.toJsonNode(
2106-
Common.getValueByPath(fromObject, new String[] {"computerUse"})),
2107-
toObject));
2061+
Common.getValueByPath(fromObject, new String[] {"computerUse"}));
21082062
}
21092063

21102064
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"fileSearch"}))) {

src/main/java/com/google/genai/Models.java

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,6 @@ public Models(ApiClient apiClient) {
108108
this.apiClient = apiClient;
109109
}
110110

111-
@ExcludeFromGeneratedCoverageReport
112-
void environmentVertexEnumValidate(Object enumValue) {
113-
ImmutableSet<String> invalidEnumValues =
114-
ImmutableSet.of("ENVIRONMENT_MOBILE", "ENVIRONMENT_DESKTOP");
115-
if (invalidEnumValues.contains(enumValue.toString().replace("\"", ""))) {
116-
throw new IllegalArgumentException(
117-
String.format(
118-
"%s enum value is only supported in Gemini Developer API mode, not in Gemini"
119-
+ " Enterprise Agent Platform mode.",
120-
enumValue));
121-
}
122-
}
123-
124111
@ExcludeFromGeneratedCoverageReport
125112
void personGenerationMldevEnumValidate(Object enumValue) {
126113
ImmutableSet<String> invalidEnumValues = ImmutableSet.of("ALLOW_ALL");
@@ -403,36 +390,6 @@ ObjectNode computeTokensResponseFromVertex(
403390
return toObject;
404391
}
405392

406-
@ExcludeFromGeneratedCoverageReport
407-
ObjectNode computerUseToVertex(
408-
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
409-
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
410-
if (Common.getValueByPath(fromObject, new String[] {"environment"}) != null) {
411-
environmentVertexEnumValidate(
412-
Common.getValueByPath(fromObject, new String[] {"environment"}));
413-
Common.setValueByPath(
414-
toObject,
415-
new String[] {"environment"},
416-
Common.getValueByPath(fromObject, new String[] {"environment"}));
417-
}
418-
419-
if (Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}) != null) {
420-
Common.setValueByPath(
421-
toObject,
422-
new String[] {"excludedPredefinedFunctions"},
423-
Common.getValueByPath(fromObject, new String[] {"excludedPredefinedFunctions"}));
424-
}
425-
426-
if (!Common.isZero(
427-
Common.getValueByPath(fromObject, new String[] {"enablePromptInjectionDetection"}))) {
428-
throw new IllegalArgumentException(
429-
"enablePromptInjectionDetection parameter is only supported in Gemini Developer API mode,"
430-
+ " not in Gemini Enterprise Agent Platform mode.");
431-
}
432-
433-
return toObject;
434-
}
435-
436393
@ExcludeFromGeneratedCoverageReport
437394
ObjectNode contentEmbeddingFromVertex(
438395
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
@@ -5131,11 +5088,7 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject, JsonNode r
51315088
Common.setValueByPath(
51325089
toObject,
51335090
new String[] {"computerUse"},
5134-
computerUseToVertex(
5135-
JsonSerializable.toJsonNode(
5136-
Common.getValueByPath(fromObject, new String[] {"computerUse"})),
5137-
toObject,
5138-
rootObject));
5091+
Common.getValueByPath(fromObject, new String[] {"computerUse"}));
51395092
}
51405093

51415094
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"fileSearch"}))) {

0 commit comments

Comments
 (0)