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
141 changes: 65 additions & 76 deletions src/main/java/com/google/cloud/agentplatform/AgentEngines.java

Large diffs are not rendered by default.

161 changes: 77 additions & 84 deletions src/main/java/com/google/cloud/agentplatform/Memories.java

Large diffs are not rendered by default.

27 changes: 12 additions & 15 deletions src/main/java/com/google/cloud/agentplatform/MemoryRevisions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.google.genai.ApiResponse;
import com.google.genai.Common;
import com.google.genai.Common.BuiltRequest;
import com.google.genai.JsonSerializable;
import com.google.genai.errors.GenAiIOException;
import com.google.genai.types.HttpOptions;
import java.io.IOException;
Expand All @@ -48,7 +47,7 @@ public MemoryRevisions(ApiClient apiClient) {
@ExcludeFromGeneratedCoverageReport
ObjectNode getAgentEngineMemoryRevisionRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -62,7 +61,7 @@ ObjectNode getAgentEngineMemoryRevisionRequestParametersToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode listAgentEngineMemoryRevisionsConfigToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();

if (Common.getValueByPath(fromObject, new String[] {"pageSize"}) != null) {
Common.setValueByPath(
Expand Down Expand Up @@ -91,7 +90,7 @@ ObjectNode listAgentEngineMemoryRevisionsConfigToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode listAgentEngineMemoryRevisionsRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -102,8 +101,7 @@ ObjectNode listAgentEngineMemoryRevisionsRequestParametersToVertex(
if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
JsonNode unused =
listAgentEngineMemoryRevisionsConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"config"})),
Common.toJsonNode(Common.getValueByPath(fromObject, new String[] {"config"})),
toObject);
}

Expand All @@ -122,7 +120,7 @@ BuiltRequest buildRequestForGet(String name, GetAgentEngineMemoryRevisionConfig
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -148,7 +146,7 @@ BuiltRequest buildRequestForGet(String name, GetAgentEngineMemoryRevisionConfig
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -162,15 +160,15 @@ MemoryRevision processResponseForGet(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(responseNode, MemoryRevision.class);
return Common.fromJsonNode(responseNode, MemoryRevision.class);
}

public MemoryRevision get(String name, GetAgentEngineMemoryRevisionConfig config) {
Expand All @@ -196,7 +194,7 @@ BuiltRequest buildRequestForPrivateList(
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -222,7 +220,7 @@ BuiltRequest buildRequestForPrivateList(
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -236,16 +234,15 @@ ListAgentEngineMemoryRevisionsResponse processResponseForPrivateList(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(
responseNode, ListAgentEngineMemoryRevisionsResponse.class);
return Common.fromJsonNode(responseNode, ListAgentEngineMemoryRevisionsResponse.class);
}

public ListAgentEngineMemoryRevisionsResponse privateList(
Expand Down
Loading
Loading