diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceClient.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceClient.java
index 4f923340d666..961eae0f1a7e 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceClient.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceClient.java
@@ -73,19 +73,246 @@
* such as threads. In the example above, try-with-resources is used, which automatically calls
* close().
*
- *
The surface of this class includes several types of Java methods for each of the API's
- * methods:
- *
- *
- * - A "flattened" method. With this type of method, the fields of the request type have been
- * converted into function parameters. It may be the case that not all fields are available as
- * parameters, and not every API method will have a flattened method entry point.
- *
- A "request object" method. This type of method only takes one parameter, a request object,
- * which must be constructed before the call. Not every API method will have a request object
- * method.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable API
- * callable object, which can be used to initiate calls to the service.
- *
+ *
+ * Methods
+ *
+ * Method |
+ * Description |
+ * Method Variants |
+ *
+ *
+ * CreateEndpoint |
+ * Creates an Endpoint. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
+ *
+ * createEndpointAsync(LocationName parent, Endpoint endpoint)
+ * createEndpointAsync(String parent, Endpoint endpoint)
+ * createEndpointAsync(LocationName parent, Endpoint endpoint, String endpointId)
+ * createEndpointAsync(String parent, Endpoint endpoint, String endpointId)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * GetEndpoint |
+ * Gets an Endpoint. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * ListEndpoints |
+ * Lists Endpoints in a Location. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * UpdateEndpoint |
+ * Updates an Endpoint. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * DeleteEndpoint |
+ * Deletes an Endpoint. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * DeployModel |
+ * Deploys a Model into this Endpoint, creating a DeployedModel within it. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
+ *
+ * deployModelAsync(EndpointName endpoint, DeployedModel deployedModel, Map<String, Integer> trafficSplit)
+ * deployModelAsync(String endpoint, DeployedModel deployedModel, Map<String, Integer> trafficSplit)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * UndeployModel |
+ * Undeploys a Model from an Endpoint, removing a DeployedModel from it, and freeing all resources it's using. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
+ *
+ * undeployModelAsync(EndpointName endpoint, String deployedModelId, Map<String, Integer> trafficSplit)
+ * undeployModelAsync(String endpoint, String deployedModelId, Map<String, Integer> trafficSplit)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * MutateDeployedModel |
+ * Updates an existing deployed model. Updatable fields include `min_replica_count`, `max_replica_count`, `autoscaling_metric_specs`, `disable_container_logging` (v1 only), and `enable_container_logging` (v1beta1 only). |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
+ *
+ * mutateDeployedModelAsync(EndpointName endpoint, DeployedModel deployedModel, FieldMask updateMask)
+ * mutateDeployedModelAsync(String endpoint, DeployedModel deployedModel, FieldMask updateMask)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * ListLocations |
+ * Lists information about the supported locations for this service. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * GetLocation |
+ * Gets information about a location. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * SetIamPolicy |
+ * Sets the access control policy on the specified resource. Replacesany existing policy.
+ * Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * GetIamPolicy |
+ * Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * TestIamPermissions |
+ * Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.
+ * Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
*
* See the individual methods for example code.
*
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceSettings.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceSettings.java
index ad6cf08bae36..82303d127407 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceSettings.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/EndpointServiceSettings.java
@@ -232,7 +232,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() {
return EndpointServiceStubSettings.defaultTransportChannelProvider();
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
return EndpointServiceStubSettings.defaultApiClientHeaderProviderBuilder();
}
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceClient.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceClient.java
index 11605fca3e42..aca6a1d56e97 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceClient.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceClient.java
@@ -67,19 +67,125 @@
* such as threads. In the example above, try-with-resources is used, which automatically calls
* close().
*
- *
The surface of this class includes several types of Java methods for each of the API's
- * methods:
- *
- *
- * - A "flattened" method. With this type of method, the fields of the request type have been
- * converted into function parameters. It may be the case that not all fields are available as
- * parameters, and not every API method will have a flattened method entry point.
- *
- A "request object" method. This type of method only takes one parameter, a request object,
- * which must be constructed before the call. Not every API method will have a request object
- * method.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable API
- * callable object, which can be used to initiate calls to the service.
- *
+ *
+ * Methods
+ *
+ * Method |
+ * Description |
+ * Method Variants |
+ *
+ *
+ * CountTokens |
+ * Perform a token counting. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * countTokens(EndpointName endpoint, List<Value> instances)
+ * countTokens(String endpoint, List<Value> instances)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * ComputeTokens |
+ * Return a list of tokens based on the input text. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * computeTokens(EndpointName endpoint, List<Value> instances)
+ * computeTokens(String endpoint, List<Value> instances)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * ListLocations |
+ * Lists information about the supported locations for this service. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * GetLocation |
+ * Gets information about a location. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * SetIamPolicy |
+ * Sets the access control policy on the specified resource. Replacesany existing policy.
+ * Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * GetIamPolicy |
+ * Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * TestIamPermissions |
+ * Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.
+ * Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
*
* See the individual methods for example code.
*
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceSettings.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceSettings.java
index 0359e1da98d7..037071042839 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceSettings.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/LlmUtilityServiceSettings.java
@@ -162,7 +162,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() {
return LlmUtilityServiceStubSettings.defaultTransportChannelProvider();
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
return LlmUtilityServiceStubSettings.defaultApiClientHeaderProviderBuilder();
}
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceClient.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceClient.java
index 6432d7b04d84..dcd3fa135d65 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceClient.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceClient.java
@@ -71,19 +71,268 @@
* such as threads. In the example above, try-with-resources is used, which automatically calls
* close().
*
- *
The surface of this class includes several types of Java methods for each of the API's
- * methods:
- *
- *
- * - A "flattened" method. With this type of method, the fields of the request type have been
- * converted into function parameters. It may be the case that not all fields are available as
- * parameters, and not every API method will have a flattened method entry point.
- *
- A "request object" method. This type of method only takes one parameter, a request object,
- * which must be constructed before the call. Not every API method will have a request object
- * method.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable API
- * callable object, which can be used to initiate calls to the service.
- *
+ *
+ * Methods
+ *
+ * Method |
+ * Description |
+ * Method Variants |
+ *
+ *
+ * Predict |
+ * Perform an online prediction. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * predict(EndpointName endpoint, List<Value> instances, Value parameters)
+ * predict(String endpoint, List<Value> instances, Value parameters)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * predictCallable()
+ *
+ * |
+ *
+ *
+ * RawPredict |
+ * Perform an online prediction with an arbitrary HTTP payload.
+ * The response includes the following HTTP headers:
+ *
+ * - `X-Vertex-AI-Endpoint-Id`: ID of the [Endpoint][google.cloud.aiplatform.v1.Endpoint] that served this prediction.
+ *
+ *
+ * - `X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] that served this prediction.
+ *
|
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * rawPredict(EndpointName endpoint, HttpBody httpBody)
+ * rawPredict(String endpoint, HttpBody httpBody)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * rawPredictCallable()
+ *
+ * |
+ *
+ *
+ * StreamRawPredict |
+ * Perform a streaming online prediction with an arbitrary HTTP payload. |
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * DirectPredict |
+ * Perform an unary online prediction request to a gRPC model server for Vertex first-party products and frameworks. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * DirectRawPredict |
+ * Perform an unary online prediction request to a gRPC model server for custom containers. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * StreamDirectPredict |
+ * Perform a streaming online prediction request to a gRPC model server for Vertex first-party products and frameworks. |
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * StreamDirectRawPredict |
+ * Perform a streaming online prediction request to a gRPC model server for custom containers. |
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * StreamingPredict |
+ * Perform a streaming online prediction request for Vertex first-party products and frameworks. |
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * ServerStreamingPredict |
+ * Perform a server-side streaming online prediction request for Vertex LLM streaming. |
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * StreamingRawPredict |
+ * Perform a streaming online prediction request through gRPC. |
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * Explain |
+ * Perform an online explanation.
+ * If [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is specified, the corresponding DeployModel must have [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. If [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] is not specified, all DeployedModels must have [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] populated. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * explain(EndpointName endpoint, List<Value> instances, Value parameters, String deployedModelId)
+ * explain(String endpoint, List<Value> instances, Value parameters, String deployedModelId)
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * explainCallable()
+ *
+ * |
+ *
+ *
+ * GenerateContent |
+ * Generate content with multimodal inputs. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * StreamGenerateContent |
+ * Generate content with multimodal inputs with streaming support. |
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * ListLocations |
+ * Lists information about the supported locations for this service. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * GetLocation |
+ * Gets information about a location. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * SetIamPolicy |
+ * Sets the access control policy on the specified resource. Replacesany existing policy.
+ * Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * GetIamPolicy |
+ * Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
+ * TestIamPermissions |
+ * Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.
+ * Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call.
+ *
+ * Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
+ *
+ * |
+ *
+ *
*
* See the individual methods for example code.
*
@@ -554,7 +803,42 @@ public final UnaryCallable rawPredictCallable() {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Perform an unary online prediction request for Vertex first-party products and frameworks.
+ * Perform a streaming online prediction with an arbitrary HTTP payload.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
+ * StreamRawPredictRequest request =
+ * StreamRawPredictRequest.newBuilder()
+ * .setEndpoint(
+ * EndpointName.ofProjectLocationEndpointName(
+ * "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ * .toString())
+ * .setHttpBody(HttpBody.newBuilder().build())
+ * .build();
+ * ServerStream stream =
+ * predictionServiceClient.streamRawPredictCallable().call(request);
+ * for (HttpBody response : stream) {
+ * // Do something when a response is received.
+ * }
+ * }
+ * }
+ */
+ public final ServerStreamingCallable
+ streamRawPredictCallable() {
+ return stub.streamRawPredictCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Perform an unary online prediction request to a gRPC model server for Vertex first-party
+ * products and frameworks.
*
* Sample code:
*
@@ -587,7 +871,8 @@ public final DirectPredictResponse directPredict(DirectPredictRequest request) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Perform an unary online prediction request for Vertex first-party products and frameworks.
+ * Perform an unary online prediction request to a gRPC model server for Vertex first-party
+ * products and frameworks.
*
*
Sample code:
*
@@ -620,7 +905,7 @@ public final UnaryCallable directPr
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Perform an online prediction request through gRPC.
+ * Perform an unary online prediction request to a gRPC model server for custom containers.
*
* Sample code:
*
@@ -653,7 +938,7 @@ public final DirectRawPredictResponse directRawPredict(DirectRawPredictRequest r
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Perform an online prediction request through gRPC.
+ * Perform an unary online prediction request to a gRPC model server for custom containers.
*
*
Sample code:
*
@@ -685,6 +970,79 @@ public final DirectRawPredictResponse directRawPredict(DirectRawPredictRequest r
return stub.directRawPredictCallable();
}
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Perform a streaming online prediction request to a gRPC model server for Vertex first-party
+ * products and frameworks.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
+ * BidiStream bidiStream =
+ * predictionServiceClient.streamDirectPredictCallable().call();
+ * StreamDirectPredictRequest request =
+ * StreamDirectPredictRequest.newBuilder()
+ * .setEndpoint(
+ * EndpointName.ofProjectLocationEndpointName(
+ * "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ * .toString())
+ * .addAllInputs(new ArrayList())
+ * .setParameters(Tensor.newBuilder().build())
+ * .build();
+ * bidiStream.send(request);
+ * for (StreamDirectPredictResponse response : bidiStream) {
+ * // Do something when a response is received.
+ * }
+ * }
+ * }
+ */
+ public final BidiStreamingCallable
+ streamDirectPredictCallable() {
+ return stub.streamDirectPredictCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Perform a streaming online prediction request to a gRPC model server for custom containers.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
+ * BidiStream bidiStream =
+ * predictionServiceClient.streamDirectRawPredictCallable().call();
+ * StreamDirectRawPredictRequest request =
+ * StreamDirectRawPredictRequest.newBuilder()
+ * .setEndpoint(
+ * EndpointName.ofProjectLocationEndpointName(
+ * "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ * .toString())
+ * .setMethodName("methodName-723163380")
+ * .setInput(ByteString.EMPTY)
+ * .build();
+ * bidiStream.send(request);
+ * for (StreamDirectRawPredictResponse response : bidiStream) {
+ * // Do something when a response is received.
+ * }
+ * }
+ * }
+ */
+ public final BidiStreamingCallable
+ streamDirectRawPredictCallable() {
+ return stub.streamDirectRawPredictCallable();
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a streaming online prediction request for Vertex first-party products and frameworks.
@@ -1001,6 +1359,103 @@ public final UnaryCallable explainCallable() {
return stub.explainCallable();
}
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Generate content with multimodal inputs.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
+ * String model = "model104069929";
+ * List contents = new ArrayList<>();
+ * GenerateContentResponse response = predictionServiceClient.generateContent(model, contents);
+ * }
+ * }
+ *
+ * @param model Required. The name of the publisher model requested to serve the prediction.
+ * Format: `projects/{project}/locations/{location}/publishers/*/models/*`
+ * @param contents Required. The content of the current conversation with the model.
+ * For single-turn queries, this is a single instance. For multi-turn queries, this is a
+ * repeated field that contains conversation history + latest request.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final GenerateContentResponse generateContent(String model, List contents) {
+ GenerateContentRequest request =
+ GenerateContentRequest.newBuilder().setModel(model).addAllContents(contents).build();
+ return generateContent(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Generate content with multimodal inputs.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
+ * GenerateContentRequest request =
+ * GenerateContentRequest.newBuilder()
+ * .setModel("model104069929")
+ * .addAllContents(new ArrayList())
+ * .addAllTools(new ArrayList())
+ * .addAllSafetySettings(new ArrayList())
+ * .setGenerationConfig(GenerationConfig.newBuilder().build())
+ * .build();
+ * GenerateContentResponse response = predictionServiceClient.generateContent(request);
+ * }
+ * }
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final GenerateContentResponse generateContent(GenerateContentRequest request) {
+ return generateContentCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Generate content with multimodal inputs.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
+ * GenerateContentRequest request =
+ * GenerateContentRequest.newBuilder()
+ * .setModel("model104069929")
+ * .addAllContents(new ArrayList())
+ * .addAllTools(new ArrayList())
+ * .addAllSafetySettings(new ArrayList())
+ * .setGenerationConfig(GenerationConfig.newBuilder().build())
+ * .build();
+ * ApiFuture future =
+ * predictionServiceClient.generateContentCallable().futureCall(request);
+ * // Do something.
+ * GenerateContentResponse response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable
+ generateContentCallable() {
+ return stub.generateContentCallable();
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Generate content with multimodal inputs with streaming support.
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceSettings.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceSettings.java
index 05a9f5e480d7..7c24e5b9fe32 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceSettings.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/PredictionServiceSettings.java
@@ -97,6 +97,11 @@ public UnaryCallSettings rawPredictSettings() {
return ((PredictionServiceStubSettings) getStubSettings()).rawPredictSettings();
}
+ /** Returns the object with the settings used for calls to streamRawPredict. */
+ public ServerStreamingCallSettings streamRawPredictSettings() {
+ return ((PredictionServiceStubSettings) getStubSettings()).streamRawPredictSettings();
+ }
+
/** Returns the object with the settings used for calls to directPredict. */
public UnaryCallSettings directPredictSettings() {
return ((PredictionServiceStubSettings) getStubSettings()).directPredictSettings();
@@ -108,6 +113,18 @@ public UnaryCallSettings directPred
return ((PredictionServiceStubSettings) getStubSettings()).directRawPredictSettings();
}
+ /** Returns the object with the settings used for calls to streamDirectPredict. */
+ public StreamingCallSettings
+ streamDirectPredictSettings() {
+ return ((PredictionServiceStubSettings) getStubSettings()).streamDirectPredictSettings();
+ }
+
+ /** Returns the object with the settings used for calls to streamDirectRawPredict. */
+ public StreamingCallSettings
+ streamDirectRawPredictSettings() {
+ return ((PredictionServiceStubSettings) getStubSettings()).streamDirectRawPredictSettings();
+ }
+
/** Returns the object with the settings used for calls to streamingPredict. */
public StreamingCallSettings
streamingPredictSettings() {
@@ -131,6 +148,12 @@ public UnaryCallSettings explainSettings() {
return ((PredictionServiceStubSettings) getStubSettings()).explainSettings();
}
+ /** Returns the object with the settings used for calls to generateContent. */
+ public UnaryCallSettings
+ generateContentSettings() {
+ return ((PredictionServiceStubSettings) getStubSettings()).generateContentSettings();
+ }
+
/** Returns the object with the settings used for calls to streamGenerateContent. */
public ServerStreamingCallSettings
streamGenerateContentSettings() {
@@ -205,7 +228,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() {
return PredictionServiceStubSettings.defaultTransportChannelProvider();
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
return PredictionServiceStubSettings.defaultApiClientHeaderProviderBuilder();
}
@@ -289,6 +311,12 @@ public UnaryCallSettings.Builder rawPredictSettings
return getStubSettingsBuilder().rawPredictSettings();
}
+ /** Returns the builder for the settings used for calls to streamRawPredict. */
+ public ServerStreamingCallSettings.Builder
+ streamRawPredictSettings() {
+ return getStubSettingsBuilder().streamRawPredictSettings();
+ }
+
/** Returns the builder for the settings used for calls to directPredict. */
public UnaryCallSettings.Builder
directPredictSettings() {
@@ -301,6 +329,19 @@ public UnaryCallSettings.Builder rawPredictSettings
return getStubSettingsBuilder().directRawPredictSettings();
}
+ /** Returns the builder for the settings used for calls to streamDirectPredict. */
+ public StreamingCallSettings.Builder
+ streamDirectPredictSettings() {
+ return getStubSettingsBuilder().streamDirectPredictSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to streamDirectRawPredict. */
+ public StreamingCallSettings.Builder<
+ StreamDirectRawPredictRequest, StreamDirectRawPredictResponse>
+ streamDirectRawPredictSettings() {
+ return getStubSettingsBuilder().streamDirectRawPredictSettings();
+ }
+
/** Returns the builder for the settings used for calls to streamingPredict. */
public StreamingCallSettings.Builder
streamingPredictSettings() {
@@ -324,6 +365,12 @@ public UnaryCallSettings.Builder explainSetting
return getStubSettingsBuilder().explainSettings();
}
+ /** Returns the builder for the settings used for calls to generateContent. */
+ public UnaryCallSettings.Builder
+ generateContentSettings() {
+ return getStubSettingsBuilder().generateContentSettings();
+ }
+
/** Returns the builder for the settings used for calls to streamGenerateContent. */
public ServerStreamingCallSettings.Builder
streamGenerateContentSettings() {
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/gapic_metadata.json b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/gapic_metadata.json
index 6ad25921cf71..1b5c68bb76b2 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/gapic_metadata.json
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/gapic_metadata.json
@@ -97,6 +97,9 @@
"Explain": {
"methods": ["explain", "explain", "explain", "explainCallable"]
},
+ "GenerateContent": {
+ "methods": ["generateContent", "generateContent", "generateContentCallable"]
+ },
"GetIamPolicy": {
"methods": ["getIamPolicy", "getIamPolicyCallable"]
},
@@ -118,9 +121,18 @@
"SetIamPolicy": {
"methods": ["setIamPolicy", "setIamPolicyCallable"]
},
+ "StreamDirectPredict": {
+ "methods": ["streamDirectPredictCallable"]
+ },
+ "StreamDirectRawPredict": {
+ "methods": ["streamDirectRawPredictCallable"]
+ },
"StreamGenerateContent": {
"methods": ["streamGenerateContentCallable"]
},
+ "StreamRawPredict": {
+ "methods": ["streamRawPredictCallable"]
+ },
"StreamingPredict": {
"methods": ["streamingPredictCallable"]
},
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/EndpointServiceStubSettings.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/EndpointServiceStubSettings.java
index b0068895ebd0..8bdb2e4301f1 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/EndpointServiceStubSettings.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/EndpointServiceStubSettings.java
@@ -390,6 +390,21 @@ public EndpointServiceStub createStub() throws IOException {
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
}
+ /** Returns the endpoint set by the user or the the service's default endpoint. */
+ @Override
+ public String getEndpoint() {
+ if (super.getEndpoint() != null) {
+ return super.getEndpoint();
+ }
+ return getDefaultEndpoint();
+ }
+
+ /** Returns the default service name. */
+ @Override
+ public String getServiceName() {
+ return "aiplatform";
+ }
+
/** Returns a builder for the default ExecutorProvider for this service. */
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
return InstantiatingExecutorProvider.newBuilder();
@@ -434,7 +449,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
@@ -443,7 +457,6 @@ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProvider
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
@@ -652,7 +665,6 @@ private static Builder createDefault() {
builder.setTransportChannelProvider(defaultTransportChannelProvider());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
- builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
@@ -665,7 +677,6 @@ private static Builder createHttpJsonDefault() {
builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
- builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
@@ -997,6 +1008,15 @@ public UnaryCallSettings.Builder getIamPolicySettin
return testIamPermissionsSettings;
}
+ /** Returns the endpoint set by the user or the the service's default endpoint. */
+ @Override
+ public String getEndpoint() {
+ if (super.getEndpoint() != null) {
+ return super.getEndpoint();
+ }
+ return getDefaultEndpoint();
+ }
+
@Override
public EndpointServiceStubSettings build() throws IOException {
return new EndpointServiceStubSettings(this);
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/GrpcPredictionServiceStub.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/GrpcPredictionServiceStub.java
index 2ac6080d43be..7b0843c0f1ae 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/GrpcPredictionServiceStub.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/GrpcPredictionServiceStub.java
@@ -43,6 +43,11 @@
import com.google.cloud.vertexai.api.PredictRequest;
import com.google.cloud.vertexai.api.PredictResponse;
import com.google.cloud.vertexai.api.RawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictResponse;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictResponse;
+import com.google.cloud.vertexai.api.StreamRawPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictResponse;
import com.google.cloud.vertexai.api.StreamingRawPredictRequest;
@@ -83,6 +88,16 @@ public class GrpcPredictionServiceStub extends PredictionServiceStub {
.setResponseMarshaller(ProtoUtils.marshaller(HttpBody.getDefaultInstance()))
.build();
+ private static final MethodDescriptor
+ streamRawPredictMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.SERVER_STREAMING)
+ .setFullMethodName("google.cloud.aiplatform.v1.PredictionService/StreamRawPredict")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(StreamRawPredictRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(HttpBody.getDefaultInstance()))
+ .build();
+
private static final MethodDescriptor
directPredictMethodDescriptor =
MethodDescriptor.newBuilder()
@@ -105,6 +120,31 @@ public class GrpcPredictionServiceStub extends PredictionServiceStub {
ProtoUtils.marshaller(DirectRawPredictResponse.getDefaultInstance()))
.build();
+ private static final MethodDescriptor
+ streamDirectPredictMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.BIDI_STREAMING)
+ .setFullMethodName("google.cloud.aiplatform.v1.PredictionService/StreamDirectPredict")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(StreamDirectPredictRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(StreamDirectPredictResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor<
+ StreamDirectRawPredictRequest, StreamDirectRawPredictResponse>
+ streamDirectRawPredictMethodDescriptor =
+ MethodDescriptor
+ .newBuilder()
+ .setType(MethodDescriptor.MethodType.BIDI_STREAMING)
+ .setFullMethodName(
+ "google.cloud.aiplatform.v1.PredictionService/StreamDirectRawPredict")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(StreamDirectRawPredictRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(StreamDirectRawPredictResponse.getDefaultInstance()))
+ .build();
+
private static final MethodDescriptor
streamingPredictMethodDescriptor =
MethodDescriptor.newBuilder()
@@ -147,6 +187,17 @@ public class GrpcPredictionServiceStub extends PredictionServiceStub {
.setResponseMarshaller(ProtoUtils.marshaller(ExplainResponse.getDefaultInstance()))
.build();
+ private static final MethodDescriptor
+ generateContentMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.aiplatform.v1.PredictionService/GenerateContent")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(GenerateContentRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(GenerateContentResponse.getDefaultInstance()))
+ .build();
+
private static final MethodDescriptor
streamGenerateContentMethodDescriptor =
MethodDescriptor.newBuilder()
@@ -207,9 +258,14 @@ public class GrpcPredictionServiceStub extends PredictionServiceStub {
private final UnaryCallable predictCallable;
private final UnaryCallable rawPredictCallable;
+ private final ServerStreamingCallable streamRawPredictCallable;
private final UnaryCallable directPredictCallable;
private final UnaryCallable
directRawPredictCallable;
+ private final BidiStreamingCallable
+ streamDirectPredictCallable;
+ private final BidiStreamingCallable
+ streamDirectRawPredictCallable;
private final BidiStreamingCallable
streamingPredictCallable;
private final ServerStreamingCallable
@@ -217,6 +273,8 @@ public class GrpcPredictionServiceStub extends PredictionServiceStub {
private final BidiStreamingCallable
streamingRawPredictCallable;
private final UnaryCallable explainCallable;
+ private final UnaryCallable
+ generateContentCallable;
private final ServerStreamingCallable
streamGenerateContentCallable;
private final UnaryCallable listLocationsCallable;
@@ -292,6 +350,16 @@ protected GrpcPredictionServiceStub(
return builder.build();
})
.build();
+ GrpcCallSettings streamRawPredictTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(streamRawPredictMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("endpoint", String.valueOf(request.getEndpoint()));
+ return builder.build();
+ })
+ .build();
GrpcCallSettings directPredictTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(directPredictMethodDescriptor)
@@ -313,6 +381,17 @@ protected GrpcPredictionServiceStub(
return builder.build();
})
.build();
+ GrpcCallSettings
+ streamDirectPredictTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(streamDirectPredictMethodDescriptor)
+ .build();
+ GrpcCallSettings
+ streamDirectRawPredictTransportSettings =
+ GrpcCallSettings
+ .newBuilder()
+ .setMethodDescriptor(streamDirectRawPredictMethodDescriptor)
+ .build();
GrpcCallSettings
streamingPredictTransportSettings =
GrpcCallSettings.newBuilder()
@@ -344,6 +423,17 @@ protected GrpcPredictionServiceStub(
return builder.build();
})
.build();
+ GrpcCallSettings
+ generateContentTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(generateContentMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("model", String.valueOf(request.getModel()));
+ return builder.build();
+ })
+ .build();
GrpcCallSettings
streamGenerateContentTransportSettings =
GrpcCallSettings.newBuilder()
@@ -413,12 +503,25 @@ protected GrpcPredictionServiceStub(
this.rawPredictCallable =
callableFactory.createUnaryCallable(
rawPredictTransportSettings, settings.rawPredictSettings(), clientContext);
+ this.streamRawPredictCallable =
+ callableFactory.createServerStreamingCallable(
+ streamRawPredictTransportSettings, settings.streamRawPredictSettings(), clientContext);
this.directPredictCallable =
callableFactory.createUnaryCallable(
directPredictTransportSettings, settings.directPredictSettings(), clientContext);
this.directRawPredictCallable =
callableFactory.createUnaryCallable(
directRawPredictTransportSettings, settings.directRawPredictSettings(), clientContext);
+ this.streamDirectPredictCallable =
+ callableFactory.createBidiStreamingCallable(
+ streamDirectPredictTransportSettings,
+ settings.streamDirectPredictSettings(),
+ clientContext);
+ this.streamDirectRawPredictCallable =
+ callableFactory.createBidiStreamingCallable(
+ streamDirectRawPredictTransportSettings,
+ settings.streamDirectRawPredictSettings(),
+ clientContext);
this.streamingPredictCallable =
callableFactory.createBidiStreamingCallable(
streamingPredictTransportSettings, settings.streamingPredictSettings(), clientContext);
@@ -435,6 +538,9 @@ protected GrpcPredictionServiceStub(
this.explainCallable =
callableFactory.createUnaryCallable(
explainTransportSettings, settings.explainSettings(), clientContext);
+ this.generateContentCallable =
+ callableFactory.createUnaryCallable(
+ generateContentTransportSettings, settings.generateContentSettings(), clientContext);
this.streamGenerateContentCallable =
callableFactory.createServerStreamingCallable(
streamGenerateContentTransportSettings,
@@ -479,6 +585,11 @@ public UnaryCallable rawPredictCallable() {
return rawPredictCallable;
}
+ @Override
+ public ServerStreamingCallable streamRawPredictCallable() {
+ return streamRawPredictCallable;
+ }
+
@Override
public UnaryCallable directPredictCallable() {
return directPredictCallable;
@@ -490,6 +601,18 @@ public UnaryCallable directPredictC
return directRawPredictCallable;
}
+ @Override
+ public BidiStreamingCallable
+ streamDirectPredictCallable() {
+ return streamDirectPredictCallable;
+ }
+
+ @Override
+ public BidiStreamingCallable
+ streamDirectRawPredictCallable() {
+ return streamDirectRawPredictCallable;
+ }
+
@Override
public BidiStreamingCallable
streamingPredictCallable() {
@@ -513,6 +636,11 @@ public UnaryCallable explainCallable() {
return explainCallable;
}
+ @Override
+ public UnaryCallable generateContentCallable() {
+ return generateContentCallable;
+ }
+
@Override
public ServerStreamingCallable
streamGenerateContentCallable() {
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonEndpointServiceStub.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonEndpointServiceStub.java
index 56155d4b078f..cbf0e7c7aded 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonEndpointServiceStub.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonEndpointServiceStub.java
@@ -487,6 +487,7 @@ public class HttpJsonEndpointServiceStub extends EndpointServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy",
+ "/v1/{resource=projects/*/locations/*/models/*}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy",
@@ -531,6 +532,7 @@ public class HttpJsonEndpointServiceStub extends EndpointServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy",
+ "/v1/{resource=projects/*/locations/*/models/*}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy",
@@ -573,6 +575,7 @@ public class HttpJsonEndpointServiceStub extends EndpointServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions",
+ "/v1/{resource=projects/*/locations/*/models/*}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions",
"/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions",
@@ -771,6 +774,26 @@ protected HttpJsonEndpointServiceStub(
.setPost(
"/ui/{name=projects/*/locations/*/indexEndpoints/*/operations/*}:cancel")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/operations/*}:cancel")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}:cancel")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}:cancel")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}:cancel")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setPost(
@@ -925,6 +948,26 @@ protected HttpJsonEndpointServiceStub(
.setPost(
"/v1/{name=projects/*/locations/*/indexEndpoints/*/operations/*}:cancel")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/operations/*}:cancel")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}:cancel")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}:cancel")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}:cancel")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setPost(
@@ -1090,6 +1133,26 @@ protected HttpJsonEndpointServiceStub(
.setDelete(
"/ui/{name=projects/*/locations/*/indexEndpoints/*/operations/*}")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setDelete(
@@ -1264,6 +1327,26 @@ protected HttpJsonEndpointServiceStub(
.setDelete(
"/v1/{name=projects/*/locations/*/indexEndpoints/*/operations/*}")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setDelete(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setDelete(
@@ -1452,6 +1535,26 @@ protected HttpJsonEndpointServiceStub(
.setGet(
"/ui/{name=projects/*/locations/*/indexEndpoints/*/operations/*}")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setGet(
@@ -1622,6 +1725,26 @@ protected HttpJsonEndpointServiceStub(
.setGet(
"/v1/{name=projects/*/locations/*/indexEndpoints/*/operations/*}")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setGet(
@@ -1800,6 +1923,26 @@ protected HttpJsonEndpointServiceStub(
.setGet(
"/ui/{name=projects/*/locations/*/indexEndpoints/*}/operations")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*}/operations")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/artifacts/*}/operations")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/contexts/*}/operations")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/executions/*}/operations")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setGet(
@@ -1967,6 +2110,26 @@ protected HttpJsonEndpointServiceStub(
.setGet(
"/v1/{name=projects/*/locations/*/indexEndpoints/*}/operations")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*}/operations")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/artifacts/*}/operations")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/contexts/*}/operations")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/executions/*}/operations")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setGet(
@@ -2149,6 +2312,26 @@ protected HttpJsonEndpointServiceStub(
.setPost(
"/ui/{name=projects/*/locations/*/indexEndpoints/*/operations/*}:wait")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/operations/*}:wait")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}:wait")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}:wait")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/ui/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}:wait")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setPost(
@@ -2323,6 +2506,26 @@ protected HttpJsonEndpointServiceStub(
.setPost(
"/v1/{name=projects/*/locations/*/indexEndpoints/*/operations/*}:wait")
.build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/operations/*}:wait")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/artifacts/*/operations/*}:wait")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/contexts/*/operations/*}:wait")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setPost(
+ "/v1/{name=projects/*/locations/*/metadataStores/*/executions/*/operations/*}:wait")
+ .build())
.addAdditionalBindings(
HttpRule.newBuilder()
.setPost(
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonLlmUtilityServiceStub.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonLlmUtilityServiceStub.java
index 9de9fb12be0e..af7d16495cec 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonLlmUtilityServiceStub.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonLlmUtilityServiceStub.java
@@ -228,6 +228,7 @@ public class HttpJsonLlmUtilityServiceStub extends LlmUtilityServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy",
+ "/v1/{resource=projects/*/locations/*/models/*}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy",
@@ -272,6 +273,7 @@ public class HttpJsonLlmUtilityServiceStub extends LlmUtilityServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy",
+ "/v1/{resource=projects/*/locations/*/models/*}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy",
@@ -314,6 +316,7 @@ public class HttpJsonLlmUtilityServiceStub extends LlmUtilityServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions",
+ "/v1/{resource=projects/*/locations/*/models/*}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions",
"/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions",
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonPredictionServiceStub.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonPredictionServiceStub.java
index ba2a926fc0b9..f609806585d7 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonPredictionServiceStub.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/HttpJsonPredictionServiceStub.java
@@ -49,6 +49,11 @@
import com.google.cloud.vertexai.api.PredictRequest;
import com.google.cloud.vertexai.api.PredictResponse;
import com.google.cloud.vertexai.api.RawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictResponse;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictResponse;
+import com.google.cloud.vertexai.api.StreamRawPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictResponse;
import com.google.cloud.vertexai.api.StreamingRawPredictRequest;
@@ -153,6 +158,44 @@ public class HttpJsonPredictionServiceStub extends PredictionServiceStub {
.build())
.build();
+ private static final ApiMethodDescriptor
+ streamRawPredictMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.aiplatform.v1.PredictionService/StreamRawPredict")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{endpoint=projects/*/locations/*/endpoints/*}:streamRawPredict",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "endpoint", request.getEndpoint());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1/{endpoint=projects/*/locations/*/publishers/*/models/*}:streamRawPredict")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearEndpoint().build(), false))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(HttpBody.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
private static final ApiMethodDescriptor
directPredictMethodDescriptor =
ApiMethodDescriptor.newBuilder()
@@ -300,6 +343,44 @@ public class HttpJsonPredictionServiceStub extends PredictionServiceStub {
.build())
.build();
+ private static final ApiMethodDescriptor
+ generateContentMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.aiplatform.v1.PredictionService/GenerateContent")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{model=projects/*/locations/*/endpoints/*}:generateContent",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "model", request.getModel());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearModel().build(), false))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(GenerateContentResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
private static final ApiMethodDescriptor
streamGenerateContentMethodDescriptor =
ApiMethodDescriptor.newBuilder()
@@ -426,6 +507,7 @@ public class HttpJsonPredictionServiceStub extends PredictionServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy",
+ "/v1/{resource=projects/*/locations/*/models/*}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy",
@@ -470,6 +552,7 @@ public class HttpJsonPredictionServiceStub extends PredictionServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy",
+ "/v1/{resource=projects/*/locations/*/models/*}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy",
@@ -512,6 +595,7 @@ public class HttpJsonPredictionServiceStub extends PredictionServiceStub {
})
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions",
+ "/v1/{resource=projects/*/locations/*/models/*}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions",
"/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions",
"/ui/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions",
@@ -536,12 +620,15 @@ public class HttpJsonPredictionServiceStub extends PredictionServiceStub {
private final UnaryCallable predictCallable;
private final UnaryCallable rawPredictCallable;
+ private final ServerStreamingCallable streamRawPredictCallable;
private final UnaryCallable directPredictCallable;
private final UnaryCallable
directRawPredictCallable;
private final ServerStreamingCallable
serverStreamingPredictCallable;
private final UnaryCallable explainCallable;
+ private final UnaryCallable
+ generateContentCallable;
private final ServerStreamingCallable
streamGenerateContentCallable;
private final UnaryCallable listLocationsCallable;
@@ -617,6 +704,17 @@ protected HttpJsonPredictionServiceStub(
return builder.build();
})
.build();
+ HttpJsonCallSettings streamRawPredictTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(streamRawPredictMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("endpoint", String.valueOf(request.getEndpoint()));
+ return builder.build();
+ })
+ .build();
HttpJsonCallSettings
directPredictTransportSettings =
HttpJsonCallSettings.newBuilder()
@@ -664,6 +762,18 @@ protected HttpJsonPredictionServiceStub(
return builder.build();
})
.build();
+ HttpJsonCallSettings
+ generateContentTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(generateContentMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("model", String.valueOf(request.getModel()));
+ return builder.build();
+ })
+ .build();
HttpJsonCallSettings
streamGenerateContentTransportSettings =
HttpJsonCallSettings.newBuilder()
@@ -740,6 +850,9 @@ protected HttpJsonPredictionServiceStub(
this.rawPredictCallable =
callableFactory.createUnaryCallable(
rawPredictTransportSettings, settings.rawPredictSettings(), clientContext);
+ this.streamRawPredictCallable =
+ callableFactory.createServerStreamingCallable(
+ streamRawPredictTransportSettings, settings.streamRawPredictSettings(), clientContext);
this.directPredictCallable =
callableFactory.createUnaryCallable(
directPredictTransportSettings, settings.directPredictSettings(), clientContext);
@@ -754,6 +867,9 @@ protected HttpJsonPredictionServiceStub(
this.explainCallable =
callableFactory.createUnaryCallable(
explainTransportSettings, settings.explainSettings(), clientContext);
+ this.generateContentCallable =
+ callableFactory.createUnaryCallable(
+ generateContentTransportSettings, settings.generateContentSettings(), clientContext);
this.streamGenerateContentCallable =
callableFactory.createServerStreamingCallable(
streamGenerateContentTransportSettings,
@@ -789,10 +905,12 @@ public static List getMethodDescriptors() {
List methodDescriptors = new ArrayList<>();
methodDescriptors.add(predictMethodDescriptor);
methodDescriptors.add(rawPredictMethodDescriptor);
+ methodDescriptors.add(streamRawPredictMethodDescriptor);
methodDescriptors.add(directPredictMethodDescriptor);
methodDescriptors.add(directRawPredictMethodDescriptor);
methodDescriptors.add(serverStreamingPredictMethodDescriptor);
methodDescriptors.add(explainMethodDescriptor);
+ methodDescriptors.add(generateContentMethodDescriptor);
methodDescriptors.add(streamGenerateContentMethodDescriptor);
methodDescriptors.add(listLocationsMethodDescriptor);
methodDescriptors.add(getLocationMethodDescriptor);
@@ -812,6 +930,11 @@ public UnaryCallable rawPredictCallable() {
return rawPredictCallable;
}
+ @Override
+ public ServerStreamingCallable streamRawPredictCallable() {
+ return streamRawPredictCallable;
+ }
+
@Override
public UnaryCallable directPredictCallable() {
return directPredictCallable;
@@ -834,6 +957,11 @@ public UnaryCallable explainCallable() {
return explainCallable;
}
+ @Override
+ public UnaryCallable generateContentCallable() {
+ return generateContentCallable;
+ }
+
@Override
public ServerStreamingCallable
streamGenerateContentCallable() {
@@ -872,6 +1000,20 @@ public UnaryCallable getIamPolicyCallable() {
return testIamPermissionsCallable;
}
+ @Override
+ public BidiStreamingCallable
+ streamDirectPredictCallable() {
+ throw new UnsupportedOperationException(
+ "Not implemented: streamDirectPredictCallable(). REST transport is not implemented for this method yet.");
+ }
+
+ @Override
+ public BidiStreamingCallable
+ streamDirectRawPredictCallable() {
+ throw new UnsupportedOperationException(
+ "Not implemented: streamDirectRawPredictCallable(). REST transport is not implemented for this method yet.");
+ }
+
@Override
public BidiStreamingCallable
streamingPredictCallable() {
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/LlmUtilityServiceStubSettings.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/LlmUtilityServiceStubSettings.java
index 7ba1e1bf5c4c..afc0792f076c 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/LlmUtilityServiceStubSettings.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/LlmUtilityServiceStubSettings.java
@@ -226,6 +226,21 @@ public LlmUtilityServiceStub createStub() throws IOException {
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
}
+ /** Returns the endpoint set by the user or the the service's default endpoint. */
+ @Override
+ public String getEndpoint() {
+ if (super.getEndpoint() != null) {
+ return super.getEndpoint();
+ }
+ return getDefaultEndpoint();
+ }
+
+ /** Returns the default service name. */
+ @Override
+ public String getServiceName() {
+ return "aiplatform";
+ }
+
/** Returns a builder for the default ExecutorProvider for this service. */
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
return InstantiatingExecutorProvider.newBuilder();
@@ -270,7 +285,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
@@ -279,7 +293,6 @@ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProvider
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
@@ -415,7 +428,6 @@ private static Builder createDefault() {
builder.setTransportChannelProvider(defaultTransportChannelProvider());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
- builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
@@ -428,7 +440,6 @@ private static Builder createHttpJsonDefault() {
builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
- builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
@@ -529,6 +540,15 @@ public UnaryCallSettings.Builder getIamPolicySettin
return testIamPermissionsSettings;
}
+ /** Returns the endpoint set by the user or the the service's default endpoint. */
+ @Override
+ public String getEndpoint() {
+ if (super.getEndpoint() != null) {
+ return super.getEndpoint();
+ }
+ return getDefaultEndpoint();
+ }
+
@Override
public LlmUtilityServiceStubSettings build() throws IOException {
return new LlmUtilityServiceStubSettings(this);
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStub.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStub.java
index 103ab9743d4f..368c3ef411a1 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStub.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStub.java
@@ -38,6 +38,11 @@
import com.google.cloud.vertexai.api.PredictRequest;
import com.google.cloud.vertexai.api.PredictResponse;
import com.google.cloud.vertexai.api.RawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictResponse;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictResponse;
+import com.google.cloud.vertexai.api.StreamRawPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictResponse;
import com.google.cloud.vertexai.api.StreamingRawPredictRequest;
@@ -66,6 +71,10 @@ public UnaryCallable rawPredictCallable() {
throw new UnsupportedOperationException("Not implemented: rawPredictCallable()");
}
+ public ServerStreamingCallable streamRawPredictCallable() {
+ throw new UnsupportedOperationException("Not implemented: streamRawPredictCallable()");
+ }
+
public UnaryCallable directPredictCallable() {
throw new UnsupportedOperationException("Not implemented: directPredictCallable()");
}
@@ -75,6 +84,16 @@ public UnaryCallable directPredictC
throw new UnsupportedOperationException("Not implemented: directRawPredictCallable()");
}
+ public BidiStreamingCallable
+ streamDirectPredictCallable() {
+ throw new UnsupportedOperationException("Not implemented: streamDirectPredictCallable()");
+ }
+
+ public BidiStreamingCallable
+ streamDirectRawPredictCallable() {
+ throw new UnsupportedOperationException("Not implemented: streamDirectRawPredictCallable()");
+ }
+
public BidiStreamingCallable
streamingPredictCallable() {
throw new UnsupportedOperationException("Not implemented: streamingPredictCallable()");
@@ -94,6 +113,10 @@ public UnaryCallable explainCallable() {
throw new UnsupportedOperationException("Not implemented: explainCallable()");
}
+ public UnaryCallable generateContentCallable() {
+ throw new UnsupportedOperationException("Not implemented: generateContentCallable()");
+ }
+
public ServerStreamingCallable
streamGenerateContentCallable() {
throw new UnsupportedOperationException("Not implemented: streamGenerateContentCallable()");
diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStubSettings.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStubSettings.java
index 11f4bf8daf29..31d4683d731f 100644
--- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStubSettings.java
+++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/api/stub/PredictionServiceStubSettings.java
@@ -61,6 +61,11 @@
import com.google.cloud.vertexai.api.PredictRequest;
import com.google.cloud.vertexai.api.PredictResponse;
import com.google.cloud.vertexai.api.RawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectPredictResponse;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictRequest;
+import com.google.cloud.vertexai.api.StreamDirectRawPredictResponse;
+import com.google.cloud.vertexai.api.StreamRawPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictRequest;
import com.google.cloud.vertexai.api.StreamingPredictResponse;
import com.google.cloud.vertexai.api.StreamingRawPredictRequest;
@@ -124,10 +129,16 @@ public class PredictionServiceStubSettings extends StubSettings predictSettings;
private final UnaryCallSettings rawPredictSettings;
+ private final ServerStreamingCallSettings
+ streamRawPredictSettings;
private final UnaryCallSettings
directPredictSettings;
private final UnaryCallSettings
directRawPredictSettings;
+ private final StreamingCallSettings
+ streamDirectPredictSettings;
+ private final StreamingCallSettings
+ streamDirectRawPredictSettings;
private final StreamingCallSettings
streamingPredictSettings;
private final ServerStreamingCallSettings
@@ -135,6 +146,8 @@ public class PredictionServiceStubSettings extends StubSettings
streamingRawPredictSettings;
private final UnaryCallSettings explainSettings;
+ private final UnaryCallSettings
+ generateContentSettings;
private final ServerStreamingCallSettings
streamGenerateContentSettings;
private final PagedCallSettings<
@@ -209,6 +222,11 @@ public UnaryCallSettings rawPredictSettings() {
return rawPredictSettings;
}
+ /** Returns the object with the settings used for calls to streamRawPredict. */
+ public ServerStreamingCallSettings streamRawPredictSettings() {
+ return streamRawPredictSettings;
+ }
+
/** Returns the object with the settings used for calls to directPredict. */
public UnaryCallSettings directPredictSettings() {
return directPredictSettings;
@@ -220,6 +238,18 @@ public UnaryCallSettings directPred
return directRawPredictSettings;
}
+ /** Returns the object with the settings used for calls to streamDirectPredict. */
+ public StreamingCallSettings
+ streamDirectPredictSettings() {
+ return streamDirectPredictSettings;
+ }
+
+ /** Returns the object with the settings used for calls to streamDirectRawPredict. */
+ public StreamingCallSettings
+ streamDirectRawPredictSettings() {
+ return streamDirectRawPredictSettings;
+ }
+
/** Returns the object with the settings used for calls to streamingPredict. */
public StreamingCallSettings
streamingPredictSettings() {
@@ -243,6 +273,12 @@ public UnaryCallSettings explainSettings() {
return explainSettings;
}
+ /** Returns the object with the settings used for calls to generateContent. */
+ public UnaryCallSettings
+ generateContentSettings() {
+ return generateContentSettings;
+ }
+
/** Returns the object with the settings used for calls to streamGenerateContent. */
public ServerStreamingCallSettings
streamGenerateContentSettings() {
@@ -292,6 +328,21 @@ public PredictionServiceStub createStub() throws IOException {
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
}
+ /** Returns the endpoint set by the user or the the service's default endpoint. */
+ @Override
+ public String getEndpoint() {
+ if (super.getEndpoint() != null) {
+ return super.getEndpoint();
+ }
+ return getDefaultEndpoint();
+ }
+
+ /** Returns the default service name. */
+ @Override
+ public String getServiceName() {
+ return "aiplatform";
+ }
+
/** Returns a builder for the default ExecutorProvider for this service. */
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
return InstantiatingExecutorProvider.newBuilder();
@@ -336,7 +387,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
@@ -345,7 +395,6 @@ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProvider
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
@@ -384,12 +433,16 @@ protected PredictionServiceStubSettings(Builder settingsBuilder) throws IOExcept
predictSettings = settingsBuilder.predictSettings().build();
rawPredictSettings = settingsBuilder.rawPredictSettings().build();
+ streamRawPredictSettings = settingsBuilder.streamRawPredictSettings().build();
directPredictSettings = settingsBuilder.directPredictSettings().build();
directRawPredictSettings = settingsBuilder.directRawPredictSettings().build();
+ streamDirectPredictSettings = settingsBuilder.streamDirectPredictSettings().build();
+ streamDirectRawPredictSettings = settingsBuilder.streamDirectRawPredictSettings().build();
streamingPredictSettings = settingsBuilder.streamingPredictSettings().build();
serverStreamingPredictSettings = settingsBuilder.serverStreamingPredictSettings().build();
streamingRawPredictSettings = settingsBuilder.streamingRawPredictSettings().build();
explainSettings = settingsBuilder.explainSettings().build();
+ generateContentSettings = settingsBuilder.generateContentSettings().build();
streamGenerateContentSettings = settingsBuilder.streamGenerateContentSettings().build();
listLocationsSettings = settingsBuilder.listLocationsSettings().build();
getLocationSettings = settingsBuilder.getLocationSettings().build();
@@ -403,10 +456,18 @@ public static class Builder extends StubSettings.Builder> unaryMethodSettingsBuilders;
private final UnaryCallSettings.Builder predictSettings;
private final UnaryCallSettings.Builder rawPredictSettings;
+ private final ServerStreamingCallSettings.Builder
+ streamRawPredictSettings;
private final UnaryCallSettings.Builder
directPredictSettings;
private final UnaryCallSettings.Builder
directRawPredictSettings;
+ private final StreamingCallSettings.Builder<
+ StreamDirectPredictRequest, StreamDirectPredictResponse>
+ streamDirectPredictSettings;
+ private final StreamingCallSettings.Builder<
+ StreamDirectRawPredictRequest, StreamDirectRawPredictResponse>
+ streamDirectRawPredictSettings;
private final StreamingCallSettings.Builder
streamingPredictSettings;
private final ServerStreamingCallSettings.Builder<
@@ -416,6 +477,8 @@ public static class Builder extends StubSettings.Builder
streamingRawPredictSettings;
private final UnaryCallSettings.Builder explainSettings;
+ private final UnaryCallSettings.Builder
+ generateContentSettings;
private final ServerStreamingCallSettings.Builder<
GenerateContentRequest, GenerateContentResponse>
streamGenerateContentSettings;
@@ -456,12 +519,16 @@ protected Builder(ClientContext clientContext) {
predictSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
rawPredictSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ streamRawPredictSettings = ServerStreamingCallSettings.newBuilder();
directPredictSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
directRawPredictSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ streamDirectPredictSettings = StreamingCallSettings.newBuilder();
+ streamDirectRawPredictSettings = StreamingCallSettings.newBuilder();
streamingPredictSettings = StreamingCallSettings.newBuilder();
serverStreamingPredictSettings = ServerStreamingCallSettings.newBuilder();
streamingRawPredictSettings = StreamingCallSettings.newBuilder();
explainSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ generateContentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
streamGenerateContentSettings = ServerStreamingCallSettings.newBuilder();
listLocationsSettings = PagedCallSettings.newBuilder(LIST_LOCATIONS_PAGE_STR_FACT);
getLocationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
@@ -476,6 +543,7 @@ protected Builder(ClientContext clientContext) {
directPredictSettings,
directRawPredictSettings,
explainSettings,
+ generateContentSettings,
listLocationsSettings,
getLocationSettings,
setIamPolicySettings,
@@ -489,12 +557,16 @@ protected Builder(PredictionServiceStubSettings settings) {
predictSettings = settings.predictSettings.toBuilder();
rawPredictSettings = settings.rawPredictSettings.toBuilder();
+ streamRawPredictSettings = settings.streamRawPredictSettings.toBuilder();
directPredictSettings = settings.directPredictSettings.toBuilder();
directRawPredictSettings = settings.directRawPredictSettings.toBuilder();
+ streamDirectPredictSettings = settings.streamDirectPredictSettings.toBuilder();
+ streamDirectRawPredictSettings = settings.streamDirectRawPredictSettings.toBuilder();
streamingPredictSettings = settings.streamingPredictSettings.toBuilder();
serverStreamingPredictSettings = settings.serverStreamingPredictSettings.toBuilder();
streamingRawPredictSettings = settings.streamingRawPredictSettings.toBuilder();
explainSettings = settings.explainSettings.toBuilder();
+ generateContentSettings = settings.generateContentSettings.toBuilder();
streamGenerateContentSettings = settings.streamGenerateContentSettings.toBuilder();
listLocationsSettings = settings.listLocationsSettings.toBuilder();
getLocationSettings = settings.getLocationSettings.toBuilder();
@@ -509,6 +581,7 @@ protected Builder(PredictionServiceStubSettings settings) {
directPredictSettings,
directRawPredictSettings,
explainSettings,
+ generateContentSettings,
listLocationsSettings,
getLocationSettings,
setIamPolicySettings,
@@ -522,7 +595,6 @@ private static Builder createDefault() {
builder.setTransportChannelProvider(defaultTransportChannelProvider());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
- builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
@@ -535,7 +607,6 @@ private static Builder createHttpJsonDefault() {
builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
- builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
@@ -553,6 +624,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+ builder
+ .streamRawPredictSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+
builder
.directPredictSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
@@ -573,6 +649,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+ builder
+ .generateContentSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+
builder
.streamGenerateContentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
@@ -631,6 +712,12 @@ public UnaryCallSettings.Builder rawPredictSettings
return rawPredictSettings;
}
+ /** Returns the builder for the settings used for calls to streamRawPredict. */
+ public ServerStreamingCallSettings.Builder
+ streamRawPredictSettings() {
+ return streamRawPredictSettings;
+ }
+
/** Returns the builder for the settings used for calls to directPredict. */
public UnaryCallSettings.Builder
directPredictSettings() {
@@ -643,6 +730,19 @@ public UnaryCallSettings.Builder rawPredictSettings
return directRawPredictSettings;
}
+ /** Returns the builder for the settings used for calls to streamDirectPredict. */
+ public StreamingCallSettings.Builder
+ streamDirectPredictSettings() {
+ return streamDirectPredictSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to streamDirectRawPredict. */
+ public StreamingCallSettings.Builder<
+ StreamDirectRawPredictRequest, StreamDirectRawPredictResponse>
+ streamDirectRawPredictSettings() {
+ return streamDirectRawPredictSettings;
+ }
+
/** Returns the builder for the settings used for calls to streamingPredict. */
public StreamingCallSettings.Builder
streamingPredictSettings() {
@@ -666,6 +766,12 @@ public UnaryCallSettings.Builder explainSetting
return explainSettings;
}
+ /** Returns the builder for the settings used for calls to generateContent. */
+ public UnaryCallSettings.Builder
+ generateContentSettings() {
+ return generateContentSettings;
+ }
+
/** Returns the builder for the settings used for calls to streamGenerateContent. */
public ServerStreamingCallSettings.Builder
streamGenerateContentSettings() {
@@ -700,6 +806,15 @@ public UnaryCallSettings.Builder getIamPolicySettin
return testIamPermissionsSettings;
}
+ /** Returns the endpoint set by the user or the the service's default endpoint. */
+ @Override
+ public String getEndpoint() {
+ if (super.getEndpoint() != null) {
+ return super.getEndpoint();
+ }
+ return getDefaultEndpoint();
+ }
+
@Override
public PredictionServiceStubSettings build() throws IOException {
return new PredictionServiceStubSettings(this);
diff --git a/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/MockPredictionServiceImpl.java b/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/MockPredictionServiceImpl.java
index 4e05a2e5ef7a..edb08c93a6ec 100644
--- a/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/MockPredictionServiceImpl.java
+++ b/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/MockPredictionServiceImpl.java
@@ -99,6 +99,27 @@ public void rawPredict(RawPredictRequest request, StreamObserver respo
}
}
+ @Override
+ public void streamRawPredict(
+ StreamRawPredictRequest request, StreamObserver responseObserver) {
+ Object response = responses.poll();
+ if (response instanceof HttpBody) {
+ requests.add(request);
+ responseObserver.onNext(((HttpBody) response));
+ responseObserver.onCompleted();
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method StreamRawPredict, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ HttpBody.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
@Override
public void directPredict(
DirectPredictRequest request, StreamObserver responseObserver) {
@@ -141,6 +162,80 @@ public void directRawPredict(
}
}
+ @Override
+ public StreamObserver streamDirectPredict(
+ final StreamObserver responseObserver) {
+ StreamObserver requestObserver =
+ new StreamObserver() {
+ @Override
+ public void onNext(StreamDirectPredictRequest value) {
+ requests.add(value);
+ final Object response = responses.remove();
+ if (response instanceof StreamDirectPredictResponse) {
+ responseObserver.onNext(((StreamDirectPredictResponse) response));
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method StreamDirectPredict, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ StreamDirectPredictResponse.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ responseObserver.onError(t);
+ }
+
+ @Override
+ public void onCompleted() {
+ responseObserver.onCompleted();
+ }
+ };
+ return requestObserver;
+ }
+
+ @Override
+ public StreamObserver streamDirectRawPredict(
+ final StreamObserver responseObserver) {
+ StreamObserver requestObserver =
+ new StreamObserver() {
+ @Override
+ public void onNext(StreamDirectRawPredictRequest value) {
+ requests.add(value);
+ final Object response = responses.remove();
+ if (response instanceof StreamDirectRawPredictResponse) {
+ responseObserver.onNext(((StreamDirectRawPredictResponse) response));
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method StreamDirectRawPredict, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ StreamDirectRawPredictResponse.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ responseObserver.onError(t);
+ }
+
+ @Override
+ public void onCompleted() {
+ responseObserver.onCompleted();
+ }
+ };
+ return requestObserver;
+ }
+
@Override
public StreamObserver streamingPredict(
final StreamObserver responseObserver) {
@@ -256,6 +351,27 @@ public void explain(ExplainRequest request, StreamObserver resp
}
}
+ @Override
+ public void generateContent(
+ GenerateContentRequest request, StreamObserver responseObserver) {
+ Object response = responses.poll();
+ if (response instanceof GenerateContentResponse) {
+ requests.add(request);
+ responseObserver.onNext(((GenerateContentResponse) response));
+ responseObserver.onCompleted();
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method GenerateContent, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ GenerateContentResponse.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
@Override
public void streamGenerateContent(
GenerateContentRequest request, StreamObserver responseObserver) {
diff --git a/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientHttpJsonTest.java b/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientHttpJsonTest.java
index 14229d7109f7..382859a696ca 100644
--- a/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientHttpJsonTest.java
+++ b/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientHttpJsonTest.java
@@ -300,6 +300,17 @@ public void rawPredictExceptionTest2() throws Exception {
}
}
+ @Test
+ public void streamRawPredictTest() throws Exception {}
+
+ @Test
+ public void streamRawPredictExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+ }
+
@Test
public void directPredictTest() throws Exception {
DirectPredictResponse expectedResponse =
@@ -417,6 +428,18 @@ public void directRawPredictExceptionTest() throws Exception {
}
}
+ @Test
+ public void streamDirectPredictUnsupportedMethodTest() throws Exception {
+ // The streamDirectPredict() method is not supported in REST transport.
+ // This empty test is generated for technical reasons.
+ }
+
+ @Test
+ public void streamDirectRawPredictUnsupportedMethodTest() throws Exception {
+ // The streamDirectRawPredict() method is not supported in REST transport.
+ // This empty test is generated for technical reasons.
+ }
+
@Test
public void streamingPredictUnsupportedMethodTest() throws Exception {
// The streamingPredict() method is not supported in REST transport.
@@ -548,6 +571,54 @@ public void explainExceptionTest2() throws Exception {
}
}
+ @Test
+ public void generateContentTest() throws Exception {
+ GenerateContentResponse expectedResponse =
+ GenerateContentResponse.newBuilder()
+ .addAllCandidates(new ArrayList())
+ .setPromptFeedback(GenerateContentResponse.PromptFeedback.newBuilder().build())
+ .setUsageMetadata(GenerateContentResponse.UsageMetadata.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String model = "projects/project-1054/locations/location-1054/endpoints/endpoint-1054";
+ List contents = new ArrayList<>();
+
+ GenerateContentResponse actualResponse = client.generateContent(model, contents);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void generateContentExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String model = "projects/project-1054/locations/location-1054/endpoints/endpoint-1054";
+ List contents = new ArrayList<>();
+ client.generateContent(model, contents);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
@Test
public void streamGenerateContentTest() throws Exception {}
diff --git a/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientTest.java b/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientTest.java
index d8d23634db72..f61809b6dca1 100644
--- a/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientTest.java
+++ b/java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/api/PredictionServiceClientTest.java
@@ -296,6 +296,62 @@ public void rawPredictExceptionTest2() throws Exception {
}
}
+ @Test
+ public void streamRawPredictTest() throws Exception {
+ HttpBody expectedResponse =
+ HttpBody.newBuilder()
+ .setContentType("contentType-389131437")
+ .setData(ByteString.EMPTY)
+ .addAllExtensions(new ArrayList())
+ .build();
+ mockPredictionService.addResponse(expectedResponse);
+ StreamRawPredictRequest request =
+ StreamRawPredictRequest.newBuilder()
+ .setEndpoint(
+ EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ .toString())
+ .setHttpBody(HttpBody.newBuilder().build())
+ .build();
+
+ MockStreamObserver responseObserver = new MockStreamObserver<>();
+
+ ServerStreamingCallable callable =
+ client.streamRawPredictCallable();
+ callable.serverStreamingCall(request, responseObserver);
+
+ List actualResponses = responseObserver.future().get();
+ Assert.assertEquals(1, actualResponses.size());
+ Assert.assertEquals(expectedResponse, actualResponses.get(0));
+ }
+
+ @Test
+ public void streamRawPredictExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockPredictionService.addException(exception);
+ StreamRawPredictRequest request =
+ StreamRawPredictRequest.newBuilder()
+ .setEndpoint(
+ EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ .toString())
+ .setHttpBody(HttpBody.newBuilder().build())
+ .build();
+
+ MockStreamObserver responseObserver = new MockStreamObserver<>();
+
+ ServerStreamingCallable callable =
+ client.streamRawPredictCallable();
+ callable.serverStreamingCall(request, responseObserver);
+
+ try {
+ List actualResponses = responseObserver.future().get();
+ Assert.fail("No exception thrown");
+ } catch (ExecutionException e) {
+ Assert.assertTrue(e.getCause() instanceof InvalidArgumentException);
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
@Test
public void directPredictTest() throws Exception {
DirectPredictResponse expectedResponse =
@@ -405,6 +461,133 @@ public void directRawPredictExceptionTest() throws Exception {
}
}
+ @Test
+ public void streamDirectPredictTest() throws Exception {
+ StreamDirectPredictResponse expectedResponse =
+ StreamDirectPredictResponse.newBuilder()
+ .addAllOutputs(new ArrayList())
+ .setParameters(Tensor.newBuilder().build())
+ .build();
+ mockPredictionService.addResponse(expectedResponse);
+ StreamDirectPredictRequest request =
+ StreamDirectPredictRequest.newBuilder()
+ .setEndpoint(
+ EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ .toString())
+ .addAllInputs(new ArrayList())
+ .setParameters(Tensor.newBuilder().build())
+ .build();
+
+ MockStreamObserver responseObserver = new MockStreamObserver<>();
+
+ BidiStreamingCallable callable =
+ client.streamDirectPredictCallable();
+ ApiStreamObserver requestObserver =
+ callable.bidiStreamingCall(responseObserver);
+
+ requestObserver.onNext(request);
+ requestObserver.onCompleted();
+
+ List actualResponses = responseObserver.future().get();
+ Assert.assertEquals(1, actualResponses.size());
+ Assert.assertEquals(expectedResponse, actualResponses.get(0));
+ }
+
+ @Test
+ public void streamDirectPredictExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockPredictionService.addException(exception);
+ StreamDirectPredictRequest request =
+ StreamDirectPredictRequest.newBuilder()
+ .setEndpoint(
+ EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ .toString())
+ .addAllInputs(new ArrayList())
+ .setParameters(Tensor.newBuilder().build())
+ .build();
+
+ MockStreamObserver responseObserver = new MockStreamObserver<>();
+
+ BidiStreamingCallable callable =
+ client.streamDirectPredictCallable();
+ ApiStreamObserver requestObserver =
+ callable.bidiStreamingCall(responseObserver);
+
+ requestObserver.onNext(request);
+
+ try {
+ List actualResponses = responseObserver.future().get();
+ Assert.fail("No exception thrown");
+ } catch (ExecutionException e) {
+ Assert.assertTrue(e.getCause() instanceof InvalidArgumentException);
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
+ @Test
+ public void streamDirectRawPredictTest() throws Exception {
+ StreamDirectRawPredictResponse expectedResponse =
+ StreamDirectRawPredictResponse.newBuilder().setOutput(ByteString.EMPTY).build();
+ mockPredictionService.addResponse(expectedResponse);
+ StreamDirectRawPredictRequest request =
+ StreamDirectRawPredictRequest.newBuilder()
+ .setEndpoint(
+ EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ .toString())
+ .setMethodName("methodName-723163380")
+ .setInput(ByteString.EMPTY)
+ .build();
+
+ MockStreamObserver responseObserver =
+ new MockStreamObserver<>();
+
+ BidiStreamingCallable callable =
+ client.streamDirectRawPredictCallable();
+ ApiStreamObserver requestObserver =
+ callable.bidiStreamingCall(responseObserver);
+
+ requestObserver.onNext(request);
+ requestObserver.onCompleted();
+
+ List actualResponses = responseObserver.future().get();
+ Assert.assertEquals(1, actualResponses.size());
+ Assert.assertEquals(expectedResponse, actualResponses.get(0));
+ }
+
+ @Test
+ public void streamDirectRawPredictExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockPredictionService.addException(exception);
+ StreamDirectRawPredictRequest request =
+ StreamDirectRawPredictRequest.newBuilder()
+ .setEndpoint(
+ EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
+ .toString())
+ .setMethodName("methodName-723163380")
+ .setInput(ByteString.EMPTY)
+ .build();
+
+ MockStreamObserver responseObserver =
+ new MockStreamObserver<>();
+
+ BidiStreamingCallable callable =
+ client.streamDirectRawPredictCallable();
+ ApiStreamObserver requestObserver =
+ callable.bidiStreamingCall(responseObserver);
+
+ requestObserver.onNext(request);
+
+ try {
+ List actualResponses = responseObserver.future().get();
+ Assert.fail("No exception thrown");
+ } catch (ExecutionException e) {
+ Assert.assertTrue(e.getCause() instanceof InvalidArgumentException);
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
@Test
public void streamingPredictTest() throws Exception {
StreamingPredictResponse expectedResponse =
@@ -689,6 +872,49 @@ public void explainExceptionTest2() throws Exception {
}
}
+ @Test
+ public void generateContentTest() throws Exception {
+ GenerateContentResponse expectedResponse =
+ GenerateContentResponse.newBuilder()
+ .addAllCandidates(new ArrayList())
+ .setPromptFeedback(GenerateContentResponse.PromptFeedback.newBuilder().build())
+ .setUsageMetadata(GenerateContentResponse.UsageMetadata.newBuilder().build())
+ .build();
+ mockPredictionService.addResponse(expectedResponse);
+
+ String model = "model104069929";
+ List contents = new ArrayList<>();
+
+ GenerateContentResponse actualResponse = client.generateContent(model, contents);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockPredictionService.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ GenerateContentRequest actualRequest = ((GenerateContentRequest) actualRequests.get(0));
+
+ Assert.assertEquals(model, actualRequest.getModel());
+ Assert.assertEquals(contents, actualRequest.getContentsList());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void generateContentExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockPredictionService.addException(exception);
+
+ try {
+ String model = "model104069929";
+ List contents = new ArrayList<>();
+ client.generateContent(model, contents);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
@Test
public void streamGenerateContentTest() throws Exception {
GenerateContentResponse expectedResponse =
diff --git a/java-vertexai/grpc-google-cloud-vertexai-v1/src/main/java/com/google/cloud/vertexai/api/PredictionServiceGrpc.java b/java-vertexai/grpc-google-cloud-vertexai-v1/src/main/java/com/google/cloud/vertexai/api/PredictionServiceGrpc.java
index 287fa136b00f..a9cf1a910b55 100644
--- a/java-vertexai/grpc-google-cloud-vertexai-v1/src/main/java/com/google/cloud/vertexai/api/PredictionServiceGrpc.java
+++ b/java-vertexai/grpc-google-cloud-vertexai-v1/src/main/java/com/google/cloud/vertexai/api/PredictionServiceGrpc.java
@@ -121,6 +121,49 @@ private PredictionServiceGrpc() {}
return getRawPredictMethod;
}
+ private static volatile io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamRawPredictRequest, com.google.api.HttpBody>
+ getStreamRawPredictMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "StreamRawPredict",
+ requestType = com.google.cloud.vertexai.api.StreamRawPredictRequest.class,
+ responseType = com.google.api.HttpBody.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+ public static io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamRawPredictRequest, com.google.api.HttpBody>
+ getStreamRawPredictMethod() {
+ io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamRawPredictRequest, com.google.api.HttpBody>
+ getStreamRawPredictMethod;
+ if ((getStreamRawPredictMethod = PredictionServiceGrpc.getStreamRawPredictMethod) == null) {
+ synchronized (PredictionServiceGrpc.class) {
+ if ((getStreamRawPredictMethod = PredictionServiceGrpc.getStreamRawPredictMethod) == null) {
+ PredictionServiceGrpc.getStreamRawPredictMethod =
+ getStreamRawPredictMethod =
+ io.grpc.MethodDescriptor
+ .
+ newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+ .setFullMethodName(generateFullMethodName(SERVICE_NAME, "StreamRawPredict"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.cloud.vertexai.api.StreamRawPredictRequest
+ .getDefaultInstance()))
+ .setResponseMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.api.HttpBody.getDefaultInstance()))
+ .setSchemaDescriptor(
+ new PredictionServiceMethodDescriptorSupplier("StreamRawPredict"))
+ .build();
+ }
+ }
+ }
+ return getStreamRawPredictMethod;
+ }
+
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.vertexai.api.DirectPredictRequest,
com.google.cloud.vertexai.api.DirectPredictResponse>
@@ -215,6 +258,107 @@ private PredictionServiceGrpc() {}
return getDirectRawPredictMethod;
}
+ private static volatile io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamDirectPredictRequest,
+ com.google.cloud.vertexai.api.StreamDirectPredictResponse>
+ getStreamDirectPredictMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "StreamDirectPredict",
+ requestType = com.google.cloud.vertexai.api.StreamDirectPredictRequest.class,
+ responseType = com.google.cloud.vertexai.api.StreamDirectPredictResponse.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+ public static io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamDirectPredictRequest,
+ com.google.cloud.vertexai.api.StreamDirectPredictResponse>
+ getStreamDirectPredictMethod() {
+ io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamDirectPredictRequest,
+ com.google.cloud.vertexai.api.StreamDirectPredictResponse>
+ getStreamDirectPredictMethod;
+ if ((getStreamDirectPredictMethod = PredictionServiceGrpc.getStreamDirectPredictMethod)
+ == null) {
+ synchronized (PredictionServiceGrpc.class) {
+ if ((getStreamDirectPredictMethod = PredictionServiceGrpc.getStreamDirectPredictMethod)
+ == null) {
+ PredictionServiceGrpc.getStreamDirectPredictMethod =
+ getStreamDirectPredictMethod =
+ io.grpc.MethodDescriptor
+ .
+ newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+ .setFullMethodName(
+ generateFullMethodName(SERVICE_NAME, "StreamDirectPredict"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.cloud.vertexai.api.StreamDirectPredictRequest
+ .getDefaultInstance()))
+ .setResponseMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.cloud.vertexai.api.StreamDirectPredictResponse
+ .getDefaultInstance()))
+ .setSchemaDescriptor(
+ new PredictionServiceMethodDescriptorSupplier("StreamDirectPredict"))
+ .build();
+ }
+ }
+ }
+ return getStreamDirectPredictMethod;
+ }
+
+ private static volatile io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamDirectRawPredictRequest,
+ com.google.cloud.vertexai.api.StreamDirectRawPredictResponse>
+ getStreamDirectRawPredictMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "StreamDirectRawPredict",
+ requestType = com.google.cloud.vertexai.api.StreamDirectRawPredictRequest.class,
+ responseType = com.google.cloud.vertexai.api.StreamDirectRawPredictResponse.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+ public static io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamDirectRawPredictRequest,
+ com.google.cloud.vertexai.api.StreamDirectRawPredictResponse>
+ getStreamDirectRawPredictMethod() {
+ io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.StreamDirectRawPredictRequest,
+ com.google.cloud.vertexai.api.StreamDirectRawPredictResponse>
+ getStreamDirectRawPredictMethod;
+ if ((getStreamDirectRawPredictMethod = PredictionServiceGrpc.getStreamDirectRawPredictMethod)
+ == null) {
+ synchronized (PredictionServiceGrpc.class) {
+ if ((getStreamDirectRawPredictMethod =
+ PredictionServiceGrpc.getStreamDirectRawPredictMethod)
+ == null) {
+ PredictionServiceGrpc.getStreamDirectRawPredictMethod =
+ getStreamDirectRawPredictMethod =
+ io.grpc.MethodDescriptor
+ .
+ newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
+ .setFullMethodName(
+ generateFullMethodName(SERVICE_NAME, "StreamDirectRawPredict"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.cloud.vertexai.api.StreamDirectRawPredictRequest
+ .getDefaultInstance()))
+ .setResponseMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.cloud.vertexai.api.StreamDirectRawPredictResponse
+ .getDefaultInstance()))
+ .setSchemaDescriptor(
+ new PredictionServiceMethodDescriptorSupplier("StreamDirectRawPredict"))
+ .build();
+ }
+ }
+ }
+ return getStreamDirectRawPredictMethod;
+ }
+
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.vertexai.api.StreamingPredictRequest,
com.google.cloud.vertexai.api.StreamingPredictResponse>
@@ -407,6 +551,53 @@ private PredictionServiceGrpc() {}
return getExplainMethod;
}
+ private static volatile io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.GenerateContentRequest,
+ com.google.cloud.vertexai.api.GenerateContentResponse>
+ getGenerateContentMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "GenerateContent",
+ requestType = com.google.cloud.vertexai.api.GenerateContentRequest.class,
+ responseType = com.google.cloud.vertexai.api.GenerateContentResponse.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+ public static io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.GenerateContentRequest,
+ com.google.cloud.vertexai.api.GenerateContentResponse>
+ getGenerateContentMethod() {
+ io.grpc.MethodDescriptor<
+ com.google.cloud.vertexai.api.GenerateContentRequest,
+ com.google.cloud.vertexai.api.GenerateContentResponse>
+ getGenerateContentMethod;
+ if ((getGenerateContentMethod = PredictionServiceGrpc.getGenerateContentMethod) == null) {
+ synchronized (PredictionServiceGrpc.class) {
+ if ((getGenerateContentMethod = PredictionServiceGrpc.getGenerateContentMethod) == null) {
+ PredictionServiceGrpc.getGenerateContentMethod =
+ getGenerateContentMethod =
+ io.grpc.MethodDescriptor
+ .
+ newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GenerateContent"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.cloud.vertexai.api.GenerateContentRequest
+ .getDefaultInstance()))
+ .setResponseMarshaller(
+ io.grpc.protobuf.ProtoUtils.marshaller(
+ com.google.cloud.vertexai.api.GenerateContentResponse
+ .getDefaultInstance()))
+ .setSchemaDescriptor(
+ new PredictionServiceMethodDescriptorSupplier("GenerateContent"))
+ .build();
+ }
+ }
+ }
+ return getGenerateContentMethod;
+ }
+
private static volatile io.grpc.MethodDescriptor<
com.google.cloud.vertexai.api.GenerateContentRequest,
com.google.cloud.vertexai.api.GenerateContentResponse>
@@ -545,8 +736,22 @@ default void rawPredict(
*
*
*
- * Perform an unary online prediction request for Vertex first-party products
- * and frameworks.
+ * Perform a streaming online prediction with an arbitrary HTTP payload.
+ *
+ */
+ default void streamRawPredict(
+ com.google.cloud.vertexai.api.StreamRawPredictRequest request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
+ getStreamRawPredictMethod(), responseObserver);
+ }
+
+ /**
+ *
+ *
+ *
+ * Perform an unary online prediction request to a gRPC model server for
+ * Vertex first-party products and frameworks.
*
*/
default void directPredict(
@@ -561,7 +766,8 @@ default void directPredict(
*
*
*
- * Perform an online prediction request through gRPC.
+ * Perform an unary online prediction request to a gRPC model server for
+ * custom containers.
*
*/
default void directRawPredict(
@@ -572,6 +778,39 @@ default void directRawPredict(
getDirectRawPredictMethod(), responseObserver);
}
+ /**
+ *
+ *
+ *
+ * Perform a streaming online prediction request to a gRPC model server for
+ * Vertex first-party products and frameworks.
+ *
+ */
+ default io.grpc.stub.StreamObserver
+ streamDirectPredict(
+ io.grpc.stub.StreamObserver
+ responseObserver) {
+ return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall(
+ getStreamDirectPredictMethod(), responseObserver);
+ }
+
+ /**
+ *
+ *
+ *
+ * Perform a streaming online prediction request to a gRPC model server for
+ * custom containers.
+ *
+ */
+ default io.grpc.stub.StreamObserver
+ streamDirectRawPredict(
+ io.grpc.stub.StreamObserver<
+ com.google.cloud.vertexai.api.StreamDirectRawPredictResponse>
+ responseObserver) {
+ return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall(
+ getStreamDirectRawPredictMethod(), responseObserver);
+ }
+
/**
*
*
@@ -642,6 +881,21 @@ default void explain(
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getExplainMethod(), responseObserver);
}
+ /**
+ *
+ *
+ *
+ * Generate content with multimodal inputs.
+ *
+ */
+ default void generateContent(
+ com.google.cloud.vertexai.api.GenerateContentRequest request,
+ io.grpc.stub.StreamObserver
+ responseObserver) {
+ io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
+ getGenerateContentMethod(), responseObserver);
+ }
+
/**
*
*
@@ -733,8 +987,24 @@ public void rawPredict(
*
*
*
- * Perform an unary online prediction request for Vertex first-party products
- * and frameworks.
+ * Perform a streaming online prediction with an arbitrary HTTP payload.
+ *
+ */
+ public void streamRawPredict(
+ com.google.cloud.vertexai.api.StreamRawPredictRequest request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ io.grpc.stub.ClientCalls.asyncServerStreamingCall(
+ getChannel().newCall(getStreamRawPredictMethod(), getCallOptions()),
+ request,
+ responseObserver);
+ }
+
+ /**
+ *
+ *
+ *
+ * Perform an unary online prediction request to a gRPC model server for
+ * Vertex first-party products and frameworks.
*
*/
public void directPredict(
@@ -751,7 +1021,8 @@ public void directPredict(
*
*
*
- * Perform an online prediction request through gRPC.
+ * Perform an unary online prediction request to a gRPC model server for
+ * custom containers.
*
*/
public void directRawPredict(
@@ -764,6 +1035,40 @@ public void directRawPredict(
responseObserver);
}
+ /**
+ *
+ *
+ *
+ * Perform a streaming online prediction request to a gRPC model server for
+ * Vertex first-party products and frameworks.
+ *
+ */
+ public io.grpc.stub.StreamObserver
+ streamDirectPredict(
+ io.grpc.stub.StreamObserver
+ responseObserver) {
+ return io.grpc.stub.ClientCalls.asyncBidiStreamingCall(
+ getChannel().newCall(getStreamDirectPredictMethod(), getCallOptions()), responseObserver);
+ }
+
+ /**
+ *
+ *
+ *
+ * Perform a streaming online prediction request to a gRPC model server for
+ * custom containers.
+ *
+ */
+ public io.grpc.stub.StreamObserver
+ streamDirectRawPredict(
+ io.grpc.stub.StreamObserver<
+ com.google.cloud.vertexai.api.StreamDirectRawPredictResponse>
+ responseObserver) {
+ return io.grpc.stub.ClientCalls.asyncBidiStreamingCall(
+ getChannel().newCall(getStreamDirectRawPredictMethod(), getCallOptions()),
+ responseObserver);
+ }
+
/**
*
*
@@ -837,6 +1142,23 @@ public void explain(
getChannel().newCall(getExplainMethod(), getCallOptions()), request, responseObserver);
}
+ /**
+ *
+ *
+ *
+ * Generate content with multimodal inputs.
+ *
+ */
+ public void generateContent(
+ com.google.cloud.vertexai.api.GenerateContentRequest request,
+ io.grpc.stub.StreamObserver
+ responseObserver) {
+ io.grpc.stub.ClientCalls.asyncUnaryCall(
+ getChannel().newCall(getGenerateContentMethod(), getCallOptions()),
+ request,
+ responseObserver);
+ }
+
/**
*
*
@@ -912,8 +1234,21 @@ public com.google.api.HttpBody rawPredict(
*
*
*
- * Perform an unary online prediction request for Vertex first-party products
- * and frameworks.
+ * Perform a streaming online prediction with an arbitrary HTTP payload.
+ *
+ */
+ public java.util.Iterator streamRawPredict(
+ com.google.cloud.vertexai.api.StreamRawPredictRequest request) {
+ return io.grpc.stub.ClientCalls.blockingServerStreamingCall(
+ getChannel(), getStreamRawPredictMethod(), getCallOptions(), request);
+ }
+
+ /**
+ *
+ *
+ *
+ * Perform an unary online prediction request to a gRPC model server for
+ * Vertex first-party products and frameworks.
*
*/
public com.google.cloud.vertexai.api.DirectPredictResponse directPredict(
@@ -926,7 +1261,8 @@ public com.google.cloud.vertexai.api.DirectPredictResponse directPredict(
*
*
*
- * Perform an online prediction request through gRPC.
+ * Perform an unary online prediction request to a gRPC model server for
+ * custom containers.
*
*/
public com.google.cloud.vertexai.api.DirectRawPredictResponse directRawPredict(
@@ -971,6 +1307,19 @@ public com.google.cloud.vertexai.api.ExplainResponse explain(
getChannel(), getExplainMethod(), getCallOptions(), request);
}
+ /**
+ *
+ *
+ *
+ * Generate content with multimodal inputs.
+ *
+ */
+ public com.google.cloud.vertexai.api.GenerateContentResponse generateContent(
+ com.google.cloud.vertexai.api.GenerateContentRequest request) {
+ return io.grpc.stub.ClientCalls.blockingUnaryCall(
+ getChannel(), getGenerateContentMethod(), getCallOptions(), request);
+ }
+
/**
*
*
@@ -1042,8 +1391,8 @@ public com.google.common.util.concurrent.ListenableFuture
- * Perform an unary online prediction request for Vertex first-party products
- * and frameworks.
+ * Perform an unary online prediction request to a gRPC model server for
+ * Vertex first-party products and frameworks.
*
*/
public com.google.common.util.concurrent.ListenableFuture<
@@ -1057,7 +1406,8 @@ public com.google.common.util.concurrent.ListenableFuture
- * Perform an online prediction request through gRPC.
+ * Perform an unary online prediction request to a gRPC model server for
+ * custom containers.
*
*/
public com.google.common.util.concurrent.ListenableFuture<
@@ -1089,17 +1439,35 @@ public com.google.common.util.concurrent.ListenableFuture