Skip to content
Merged
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
7 changes: 7 additions & 0 deletions src/main/java/com/google/genai/Batches.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/google/genai/Caches.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
168 changes: 168 additions & 0 deletions src/main/java/com/google/genai/LiveConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"}));
Expand Down Expand Up @@ -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"}));
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/google/genai/Models.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/google/genai/types/FunctionResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -49,6 +53,13 @@ public abstract class FunctionResponse extends JsonSerializable {
@JsonProperty("scheduling")
public abstract Optional<FunctionResponseScheduling> scheduling();

/**
* List of parts that constitute a function response. Each part may have a different IANA MIME
* type.
*/
@JsonProperty("parts")
public abstract Optional<List<FunctionResponsePart>> parts();

/**
* Optional. The id of the function call this response is for. Populated by the client to match
* the corresponding function call `id`.
Expand Down Expand Up @@ -134,6 +145,38 @@ public Builder scheduling(String scheduling) {
return scheduling(new FunctionResponseScheduling(scheduling));
}

/**
* Setter for parts.
*
* <p>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<FunctionResponsePart> parts);

/**
* Setter for parts.
*
* <p>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.
*
* <p>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.
*
Expand Down
Loading
Loading