From 8722b3190d0a20ebd19308c9fd8c426c417f5e4e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:02:23 -0500 Subject: [PATCH] feat: Add generateContent Unary API for aiplatform_v1 (#5003) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add generateContent Unary API for aiplatform_v1beta1 docs: Update comment for DirectPredict and DirectRawPredict PiperOrigin-RevId: 603497761 Source-Link: https://github.com/googleapis/googleapis/commit/4f5f442a1b0eea843ebd179f2b4673ae67332ed9 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f1d6d8b375f1dbf6d5df26bcae3bf0c8b8cfddf7 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFpcGxhdGZvcm0vLk93bEJvdC55YW1sIiwiaCI6ImYxZDZkOGIzNzVmMWRiZjZkNWRmMjZiY2FlM2JmMGM4YjhjZmRkZjcifQ== * feat: Add generateContent Unary API for aiplatform_v1 docs: Update comment for DirectPredict and DirectRawPredict PiperOrigin-RevId: 603498510 Source-Link: https://github.com/googleapis/googleapis/commit/49815f4d9ce5603b56207018e44255599ae68bd9 Source-Link: https://github.com/googleapis/googleapis-gen/commit/893e2e072e7aa54f3fb0425a3c2da9a2668c701b Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFpcGxhdGZvcm0vLk93bEJvdC55YW1sIiwiaCI6Ijg5M2UyZTA3MmU3YWE1NGYzZmIwNDI1YTNjMmRhOWEyNjY4YzcwMWIifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- packages/google-cloud-aiplatform/README.md | 7 + .../aiplatform/v1/prediction_service.proto | 141 +- .../v1beta1/prediction_service.proto | 110 +- .../protos/protos.d.ts | 1086 +++++++ .../google-cloud-aiplatform/protos/protos.js | 2543 ++++++++++++++++- .../protos/protos.json | 267 ++ .../google-cloud-aiplatform/samples/README.md | 126 + .../v1/prediction_service.generate_content.js | 89 + ...rediction_service.stream_direct_predict.js | 75 + ...ction_service.stream_direct_raw_predict.js | 80 + .../prediction_service.stream_raw_predict.js | 69 + ...t_metadata_google.cloud.aiplatform.v1.json | 200 +- .../prediction_service.generate_content.js | 89 + ...rediction_service.stream_direct_predict.js | 75 + ...ction_service.stream_direct_raw_predict.js | 80 + ...adata_google.cloud.aiplatform.v1beta1.json | 156 +- .../src/v1/gapic_metadata.json | 25 + .../src/v1/prediction_service_client.ts | 213 +- .../v1/prediction_service_client_config.json | 16 + .../src/v1beta1/gapic_metadata.json | 20 + .../src/v1beta1/prediction_service_client.ts | 177 +- .../prediction_service_client_config.json | 12 + .../test/gapic_prediction_service_v1.ts | 427 +++ .../test/gapic_prediction_service_v1beta1.ts | 318 +++ 24 files changed, 6346 insertions(+), 55 deletions(-) create mode 100644 packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js create mode 100644 packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js create mode 100644 packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js create mode 100644 packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js create mode 100644 packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js create mode 100644 packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js create mode 100644 packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js diff --git a/packages/google-cloud-aiplatform/README.md b/packages/google-cloud-aiplatform/README.md index 02165e24e79..77c03f6a53d 100644 --- a/packages/google-cloud-aiplatform/README.md +++ b/packages/google-cloud-aiplatform/README.md @@ -301,10 +301,14 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Prediction_service.direct_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.direct_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.direct_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.direct_raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.direct_raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.direct_raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.explain | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.explain.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.explain.js,packages/google-cloud-aiplatform/samples/README.md) | +| Prediction_service.generate_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.server_streaming_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.server_streaming_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.server_streaming_predict.js,packages/google-cloud-aiplatform/samples/README.md) | +| Prediction_service.stream_direct_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js,packages/google-cloud-aiplatform/samples/README.md) | +| Prediction_service.stream_direct_raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.stream_generate_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_generate_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_generate_content.js,packages/google-cloud-aiplatform/samples/README.md) | +| Prediction_service.stream_raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.streaming_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.streaming_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.streaming_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.streaming_raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.streaming_raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.streaming_raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Schedule_service.create_schedule | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/schedule_service.create_schedule.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/schedule_service.create_schedule.js,packages/google-cloud-aiplatform/samples/README.md) | @@ -572,9 +576,12 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Prediction_service.direct_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.direct_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.direct_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.direct_raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.direct_raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.direct_raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.explain | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.explain.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.explain.js,packages/google-cloud-aiplatform/samples/README.md) | +| Prediction_service.generate_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.server_streaming_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.server_streaming_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.server_streaming_predict.js,packages/google-cloud-aiplatform/samples/README.md) | +| Prediction_service.stream_direct_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js,packages/google-cloud-aiplatform/samples/README.md) | +| Prediction_service.stream_direct_raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.stream_generate_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_generate_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_generate_content.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.streaming_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.streaming_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.streaming_predict.js,packages/google-cloud-aiplatform/samples/README.md) | | Prediction_service.streaming_raw_predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.streaming_raw_predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.streaming_raw_predict.js,packages/google-cloud-aiplatform/samples/README.md) | diff --git a/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1/prediction_service.proto b/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1/prediction_service.proto index a06264d48b3..725f6d29c21 100644 --- a/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1/prediction_service.proto +++ b/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1/prediction_service.proto @@ -77,8 +77,22 @@ service PredictionService { option (google.api.method_signature) = "endpoint,http_body"; } - // Perform an unary online prediction request for Vertex first-party products - // and frameworks. + // Perform a streaming online prediction with an arbitrary HTTP payload. + rpc StreamRawPredict(StreamRawPredictRequest) + returns (stream google.api.HttpBody) { + option (google.api.http) = { + post: "/v1/{endpoint=projects/*/locations/*/endpoints/*}:streamRawPredict" + body: "*" + additional_bindings { + post: "/v1/{endpoint=projects/*/locations/*/publishers/*/models/*}:streamRawPredict" + body: "*" + } + }; + option (google.api.method_signature) = "endpoint,http_body"; + } + + // Perform an unary online prediction request to a gRPC model server for + // Vertex first-party products and frameworks. rpc DirectPredict(DirectPredictRequest) returns (DirectPredictResponse) { option (google.api.http) = { post: "/v1/{endpoint=projects/*/locations/*/endpoints/*}:directPredict" @@ -86,7 +100,8 @@ service PredictionService { }; } - // Perform an online prediction request through gRPC. + // Perform an unary online prediction request to a gRPC model server for + // custom containers. rpc DirectRawPredict(DirectRawPredictRequest) returns (DirectRawPredictResponse) { option (google.api.http) = { @@ -95,6 +110,16 @@ service PredictionService { }; } + // Perform a streaming online prediction request to a gRPC model server for + // Vertex first-party products and frameworks. + rpc StreamDirectPredict(stream StreamDirectPredictRequest) + returns (stream StreamDirectPredictResponse) {} + + // Perform a streaming online prediction request to a gRPC model server for + // custom containers. + rpc StreamDirectRawPredict(stream StreamDirectRawPredictRequest) + returns (stream StreamDirectRawPredictResponse) {} + // Perform a streaming online prediction request for Vertex first-party // products and frameworks. rpc StreamingPredict(stream StreamingPredictRequest) @@ -138,6 +163,20 @@ service PredictionService { "endpoint,instances,parameters,deployed_model_id"; } + // Generate content with multimodal inputs. + rpc GenerateContent(GenerateContentRequest) + returns (GenerateContentResponse) { + option (google.api.http) = { + post: "/v1/{model=projects/*/locations/*/endpoints/*}:generateContent" + body: "*" + additional_bindings { + post: "/v1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent" + body: "*" + } + }; + option (google.api.method_signature) = "model,contents"; + } + // Generate content with multimodal inputs with streaming support. rpc StreamGenerateContent(GenerateContentRequest) returns (stream GenerateContentResponse) { @@ -254,6 +293,23 @@ message RawPredictRequest { google.api.HttpBody http_body = 2; } +// Request message for +// [PredictionService.StreamRawPredict][google.cloud.aiplatform.v1.PredictionService.StreamRawPredict]. +message StreamRawPredictRequest { + // Required. The name of the Endpoint requested to serve the prediction. + // Format: + // `projects/{project}/locations/{location}/endpoints/{endpoint}` + string endpoint = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "aiplatform.googleapis.com/Endpoint" + } + ]; + + // The prediction input. Supports HTTP headers and arbitrary data payload. + google.api.HttpBody http_body = 2; +} + // Request message for // [PredictionService.DirectPredict][google.cloud.aiplatform.v1.PredictionService.DirectPredict]. message DirectPredictRequest { @@ -317,6 +373,85 @@ message DirectRawPredictResponse { bytes output = 1; } +// Request message for +// [PredictionService.StreamDirectPredict][google.cloud.aiplatform.v1.PredictionService.StreamDirectPredict]. +// +// The first message must contain +// [endpoint][google.cloud.aiplatform.v1.StreamDirectPredictRequest.endpoint] +// field and optionally [input][]. The subsequent messages must contain +// [input][]. +message StreamDirectPredictRequest { + // Required. The name of the Endpoint requested to serve the prediction. + // Format: + // `projects/{project}/locations/{location}/endpoints/{endpoint}` + string endpoint = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "aiplatform.googleapis.com/Endpoint" + } + ]; + + // Optional. The prediction input. + repeated Tensor inputs = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The parameters that govern the prediction. + Tensor parameters = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response message for +// [PredictionService.StreamDirectPredict][google.cloud.aiplatform.v1.PredictionService.StreamDirectPredict]. +message StreamDirectPredictResponse { + // The prediction output. + repeated Tensor outputs = 1; + + // The parameters that govern the prediction. + Tensor parameters = 2; +} + +// Request message for +// [PredictionService.StreamDirectRawPredict][google.cloud.aiplatform.v1.PredictionService.StreamDirectRawPredict]. +// +// The first message must contain +// [endpoint][google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.endpoint] +// and +// [method_name][google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.method_name] +// fields and optionally +// [input][google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.input]. The +// subsequent messages must contain +// [input][google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.input]. +// [method_name][google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.method_name] +// in the subsequent messages have no effect. +message StreamDirectRawPredictRequest { + // Required. The name of the Endpoint requested to serve the prediction. + // Format: + // `projects/{project}/locations/{location}/endpoints/{endpoint}` + string endpoint = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "aiplatform.googleapis.com/Endpoint" + } + ]; + + // Optional. Fully qualified name of the API method being invoked to perform + // predictions. + // + // Format: + // `/namespace.Service/Method/` + // Example: + // `/tensorflow.serving.PredictionService/Predict` + string method_name = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The prediction input. + bytes input = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response message for +// [PredictionService.StreamDirectRawPredict][google.cloud.aiplatform.v1.PredictionService.StreamDirectRawPredict]. +message StreamDirectRawPredictResponse { + // The prediction output. + bytes output = 1; +} + // Request message for // [PredictionService.StreamingPredict][google.cloud.aiplatform.v1.PredictionService.StreamingPredict]. // diff --git a/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1beta1/prediction_service.proto b/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1beta1/prediction_service.proto index 42e91e47d25..60c132457e6 100644 --- a/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1beta1/prediction_service.proto +++ b/packages/google-cloud-aiplatform/protos/google/cloud/aiplatform/v1beta1/prediction_service.proto @@ -77,8 +77,8 @@ service PredictionService { option (google.api.method_signature) = "endpoint,http_body"; } - // 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. rpc DirectPredict(DirectPredictRequest) returns (DirectPredictResponse) { option (google.api.http) = { post: "/v1beta1/{endpoint=projects/*/locations/*/endpoints/*}:directPredict" @@ -86,7 +86,8 @@ service PredictionService { }; } - // Perform an online prediction request through gRPC. + // Perform an unary online prediction request to a gRPC model server for + // custom containers. rpc DirectRawPredict(DirectRawPredictRequest) returns (DirectRawPredictResponse) { option (google.api.http) = { @@ -95,6 +96,16 @@ service PredictionService { }; } + // Perform a streaming online prediction request to a gRPC model server for + // Vertex first-party products and frameworks. + rpc StreamDirectPredict(stream StreamDirectPredictRequest) + returns (stream StreamDirectPredictResponse) {} + + // Perform a streaming online prediction request to a gRPC model server for + // custom containers. + rpc StreamDirectRawPredict(stream StreamDirectRawPredictRequest) + returns (stream StreamDirectRawPredictResponse) {} + // Perform a streaming online prediction request for Vertex first-party // products and frameworks. rpc StreamingPredict(stream StreamingPredictRequest) @@ -151,6 +162,20 @@ service PredictionService { option (google.api.method_signature) = "endpoint,instances"; } + // Generate content with multimodal inputs. + rpc GenerateContent(GenerateContentRequest) + returns (GenerateContentResponse) { + option (google.api.http) = { + post: "/v1beta1/{model=projects/*/locations/*/endpoints/*}:generateContent" + body: "*" + additional_bindings { + post: "/v1beta1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent" + body: "*" + } + }; + option (google.api.method_signature) = "model,contents"; + } + // Generate content with multimodal inputs with streaming support. rpc StreamGenerateContent(GenerateContentRequest) returns (stream GenerateContentResponse) { @@ -332,6 +357,85 @@ message DirectRawPredictResponse { bytes output = 1; } +// Request message for +// [PredictionService.StreamDirectPredict][google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectPredict]. +// +// The first message must contain +// [endpoint][google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.endpoint] +// field and optionally [input][]. The subsequent messages must contain +// [input][]. +message StreamDirectPredictRequest { + // Required. The name of the Endpoint requested to serve the prediction. + // Format: + // `projects/{project}/locations/{location}/endpoints/{endpoint}` + string endpoint = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "aiplatform.googleapis.com/Endpoint" + } + ]; + + // Optional. The prediction input. + repeated Tensor inputs = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The parameters that govern the prediction. + Tensor parameters = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response message for +// [PredictionService.StreamDirectPredict][google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectPredict]. +message StreamDirectPredictResponse { + // The prediction output. + repeated Tensor outputs = 1; + + // The parameters that govern the prediction. + Tensor parameters = 2; +} + +// Request message for +// [PredictionService.StreamDirectRawPredict][google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectRawPredict]. +// +// The first message must contain +// [endpoint][google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.endpoint] +// and +// [method_name][google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.method_name] +// fields and optionally +// [input][google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.input]. +// The subsequent messages must contain +// [input][google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.input]. +// [method_name][google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.method_name] +// in the subsequent messages have no effect. +message StreamDirectRawPredictRequest { + // Required. The name of the Endpoint requested to serve the prediction. + // Format: + // `projects/{project}/locations/{location}/endpoints/{endpoint}` + string endpoint = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "aiplatform.googleapis.com/Endpoint" + } + ]; + + // Optional. Fully qualified name of the API method being invoked to perform + // predictions. + // + // Format: + // `/namespace.Service/Method/` + // Example: + // `/tensorflow.serving.PredictionService/Predict` + string method_name = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The prediction input. + bytes input = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response message for +// [PredictionService.StreamDirectRawPredict][google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectRawPredict]. +message StreamDirectRawPredictResponse { + // The prediction output. + bytes output = 1; +} + // Request message for // [PredictionService.StreamingPredict][google.cloud.aiplatform.v1beta1.PredictionService.StreamingPredict]. // diff --git a/packages/google-cloud-aiplatform/protos/protos.d.ts b/packages/google-cloud-aiplatform/protos/protos.d.ts index d234a48f0f0..6ed89e2302f 100644 --- a/packages/google-cloud-aiplatform/protos/protos.d.ts +++ b/packages/google-cloud-aiplatform/protos/protos.d.ts @@ -53527,6 +53527,20 @@ export namespace google { */ public rawPredict(request: google.cloud.aiplatform.v1.IRawPredictRequest): Promise; + /** + * Calls StreamRawPredict. + * @param request StreamRawPredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and HttpBody + */ + public streamRawPredict(request: google.cloud.aiplatform.v1.IStreamRawPredictRequest, callback: google.cloud.aiplatform.v1.PredictionService.StreamRawPredictCallback): void; + + /** + * Calls StreamRawPredict. + * @param request StreamRawPredictRequest message or plain object + * @returns Promise + */ + public streamRawPredict(request: google.cloud.aiplatform.v1.IStreamRawPredictRequest): Promise; + /** * Calls DirectPredict. * @param request DirectPredictRequest message or plain object @@ -53555,6 +53569,34 @@ export namespace google { */ public directRawPredict(request: google.cloud.aiplatform.v1.IDirectRawPredictRequest): Promise; + /** + * Calls StreamDirectPredict. + * @param request StreamDirectPredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and StreamDirectPredictResponse + */ + public streamDirectPredict(request: google.cloud.aiplatform.v1.IStreamDirectPredictRequest, callback: google.cloud.aiplatform.v1.PredictionService.StreamDirectPredictCallback): void; + + /** + * Calls StreamDirectPredict. + * @param request StreamDirectPredictRequest message or plain object + * @returns Promise + */ + public streamDirectPredict(request: google.cloud.aiplatform.v1.IStreamDirectPredictRequest): Promise; + + /** + * Calls StreamDirectRawPredict. + * @param request StreamDirectRawPredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and StreamDirectRawPredictResponse + */ + public streamDirectRawPredict(request: google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest, callback: google.cloud.aiplatform.v1.PredictionService.StreamDirectRawPredictCallback): void; + + /** + * Calls StreamDirectRawPredict. + * @param request StreamDirectRawPredictRequest message or plain object + * @returns Promise + */ + public streamDirectRawPredict(request: google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest): Promise; + /** * Calls StreamingPredict. * @param request StreamingPredictRequest message or plain object @@ -53611,6 +53653,20 @@ export namespace google { */ public explain(request: google.cloud.aiplatform.v1.IExplainRequest): Promise; + /** + * Calls GenerateContent. + * @param request GenerateContentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and GenerateContentResponse + */ + public generateContent(request: google.cloud.aiplatform.v1.IGenerateContentRequest, callback: google.cloud.aiplatform.v1.PredictionService.GenerateContentCallback): void; + + /** + * Calls GenerateContent. + * @param request GenerateContentRequest message or plain object + * @returns Promise + */ + public generateContent(request: google.cloud.aiplatform.v1.IGenerateContentRequest): Promise; + /** * Calls StreamGenerateContent. * @param request GenerateContentRequest message or plain object @@ -53642,6 +53698,13 @@ export namespace google { */ type RawPredictCallback = (error: (Error|null), response?: google.api.HttpBody) => void; + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamRawPredict}. + * @param error Error, if any + * @param [response] HttpBody + */ + type StreamRawPredictCallback = (error: (Error|null), response?: google.api.HttpBody) => void; + /** * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|directPredict}. * @param error Error, if any @@ -53656,6 +53719,20 @@ export namespace google { */ type DirectRawPredictCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1.DirectRawPredictResponse) => void; + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamDirectPredict}. + * @param error Error, if any + * @param [response] StreamDirectPredictResponse + */ + type StreamDirectPredictCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1.StreamDirectPredictResponse) => void; + + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamDirectRawPredict}. + * @param error Error, if any + * @param [response] StreamDirectRawPredictResponse + */ + type StreamDirectRawPredictCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1.StreamDirectRawPredictResponse) => void; + /** * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamingPredict}. * @param error Error, if any @@ -53684,6 +53761,13 @@ export namespace google { */ type ExplainCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1.ExplainResponse) => void; + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|generateContent}. + * @param error Error, if any + * @param [response] GenerateContentResponse + */ + type GenerateContentCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1.GenerateContentResponse) => void; + /** * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamGenerateContent}. * @param error Error, if any @@ -54031,6 +54115,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a StreamRawPredictRequest. */ + interface IStreamRawPredictRequest { + + /** StreamRawPredictRequest endpoint */ + endpoint?: (string|null); + + /** StreamRawPredictRequest httpBody */ + httpBody?: (google.api.IHttpBody|null); + } + + /** Represents a StreamRawPredictRequest. */ + class StreamRawPredictRequest implements IStreamRawPredictRequest { + + /** + * Constructs a new StreamRawPredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1.IStreamRawPredictRequest); + + /** StreamRawPredictRequest endpoint. */ + public endpoint: string; + + /** StreamRawPredictRequest httpBody. */ + public httpBody?: (google.api.IHttpBody|null); + + /** + * Creates a new StreamRawPredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamRawPredictRequest instance + */ + public static create(properties?: google.cloud.aiplatform.v1.IStreamRawPredictRequest): google.cloud.aiplatform.v1.StreamRawPredictRequest; + + /** + * Encodes the specified StreamRawPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamRawPredictRequest.verify|verify} messages. + * @param message StreamRawPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1.IStreamRawPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamRawPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamRawPredictRequest.verify|verify} messages. + * @param message StreamRawPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1.IStreamRawPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamRawPredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1.StreamRawPredictRequest; + + /** + * Decodes a StreamRawPredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1.StreamRawPredictRequest; + + /** + * Verifies a StreamRawPredictRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamRawPredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamRawPredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1.StreamRawPredictRequest; + + /** + * Creates a plain object from a StreamRawPredictRequest message. Also converts values to other types if specified. + * @param message StreamRawPredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1.StreamRawPredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamRawPredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamRawPredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a DirectPredictRequest. */ interface IDirectPredictRequest { @@ -54449,6 +54636,424 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a StreamDirectPredictRequest. */ + interface IStreamDirectPredictRequest { + + /** StreamDirectPredictRequest endpoint */ + endpoint?: (string|null); + + /** StreamDirectPredictRequest inputs */ + inputs?: (google.cloud.aiplatform.v1.ITensor[]|null); + + /** StreamDirectPredictRequest parameters */ + parameters?: (google.cloud.aiplatform.v1.ITensor|null); + } + + /** Represents a StreamDirectPredictRequest. */ + class StreamDirectPredictRequest implements IStreamDirectPredictRequest { + + /** + * Constructs a new StreamDirectPredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1.IStreamDirectPredictRequest); + + /** StreamDirectPredictRequest endpoint. */ + public endpoint: string; + + /** StreamDirectPredictRequest inputs. */ + public inputs: google.cloud.aiplatform.v1.ITensor[]; + + /** StreamDirectPredictRequest parameters. */ + public parameters?: (google.cloud.aiplatform.v1.ITensor|null); + + /** + * Creates a new StreamDirectPredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectPredictRequest instance + */ + public static create(properties?: google.cloud.aiplatform.v1.IStreamDirectPredictRequest): google.cloud.aiplatform.v1.StreamDirectPredictRequest; + + /** + * Encodes the specified StreamDirectPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictRequest.verify|verify} messages. + * @param message StreamDirectPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1.IStreamDirectPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictRequest.verify|verify} messages. + * @param message StreamDirectPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1.IStreamDirectPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1.StreamDirectPredictRequest; + + /** + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1.StreamDirectPredictRequest; + + /** + * Verifies a StreamDirectPredictRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectPredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectPredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1.StreamDirectPredictRequest; + + /** + * Creates a plain object from a StreamDirectPredictRequest message. Also converts values to other types if specified. + * @param message StreamDirectPredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1.StreamDirectPredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectPredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectPredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamDirectPredictResponse. */ + interface IStreamDirectPredictResponse { + + /** StreamDirectPredictResponse outputs */ + outputs?: (google.cloud.aiplatform.v1.ITensor[]|null); + + /** StreamDirectPredictResponse parameters */ + parameters?: (google.cloud.aiplatform.v1.ITensor|null); + } + + /** Represents a StreamDirectPredictResponse. */ + class StreamDirectPredictResponse implements IStreamDirectPredictResponse { + + /** + * Constructs a new StreamDirectPredictResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1.IStreamDirectPredictResponse); + + /** StreamDirectPredictResponse outputs. */ + public outputs: google.cloud.aiplatform.v1.ITensor[]; + + /** StreamDirectPredictResponse parameters. */ + public parameters?: (google.cloud.aiplatform.v1.ITensor|null); + + /** + * Creates a new StreamDirectPredictResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectPredictResponse instance + */ + public static create(properties?: google.cloud.aiplatform.v1.IStreamDirectPredictResponse): google.cloud.aiplatform.v1.StreamDirectPredictResponse; + + /** + * Encodes the specified StreamDirectPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictResponse.verify|verify} messages. + * @param message StreamDirectPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1.IStreamDirectPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictResponse.verify|verify} messages. + * @param message StreamDirectPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1.IStreamDirectPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1.StreamDirectPredictResponse; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1.StreamDirectPredictResponse; + + /** + * Verifies a StreamDirectPredictResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectPredictResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectPredictResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1.StreamDirectPredictResponse; + + /** + * Creates a plain object from a StreamDirectPredictResponse message. Also converts values to other types if specified. + * @param message StreamDirectPredictResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1.StreamDirectPredictResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectPredictResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectPredictResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamDirectRawPredictRequest. */ + interface IStreamDirectRawPredictRequest { + + /** StreamDirectRawPredictRequest endpoint */ + endpoint?: (string|null); + + /** StreamDirectRawPredictRequest methodName */ + methodName?: (string|null); + + /** StreamDirectRawPredictRequest input */ + input?: (Uint8Array|string|null); + } + + /** Represents a StreamDirectRawPredictRequest. */ + class StreamDirectRawPredictRequest implements IStreamDirectRawPredictRequest { + + /** + * Constructs a new StreamDirectRawPredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest); + + /** StreamDirectRawPredictRequest endpoint. */ + public endpoint: string; + + /** StreamDirectRawPredictRequest methodName. */ + public methodName: string; + + /** StreamDirectRawPredictRequest input. */ + public input: (Uint8Array|string); + + /** + * Creates a new StreamDirectRawPredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectRawPredictRequest instance + */ + public static create(properties?: google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest): google.cloud.aiplatform.v1.StreamDirectRawPredictRequest; + + /** + * Encodes the specified StreamDirectRawPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.verify|verify} messages. + * @param message StreamDirectRawPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectRawPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.verify|verify} messages. + * @param message StreamDirectRawPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1.StreamDirectRawPredictRequest; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1.StreamDirectRawPredictRequest; + + /** + * Verifies a StreamDirectRawPredictRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectRawPredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectRawPredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1.StreamDirectRawPredictRequest; + + /** + * Creates a plain object from a StreamDirectRawPredictRequest message. Also converts values to other types if specified. + * @param message StreamDirectRawPredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1.StreamDirectRawPredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectRawPredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectRawPredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamDirectRawPredictResponse. */ + interface IStreamDirectRawPredictResponse { + + /** StreamDirectRawPredictResponse output */ + output?: (Uint8Array|string|null); + } + + /** Represents a StreamDirectRawPredictResponse. */ + class StreamDirectRawPredictResponse implements IStreamDirectRawPredictResponse { + + /** + * Constructs a new StreamDirectRawPredictResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse); + + /** StreamDirectRawPredictResponse output. */ + public output: (Uint8Array|string); + + /** + * Creates a new StreamDirectRawPredictResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectRawPredictResponse instance + */ + public static create(properties?: google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse): google.cloud.aiplatform.v1.StreamDirectRawPredictResponse; + + /** + * Encodes the specified StreamDirectRawPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictResponse.verify|verify} messages. + * @param message StreamDirectRawPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectRawPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictResponse.verify|verify} messages. + * @param message StreamDirectRawPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1.StreamDirectRawPredictResponse; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1.StreamDirectRawPredictResponse; + + /** + * Verifies a StreamDirectRawPredictResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectRawPredictResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectRawPredictResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1.StreamDirectRawPredictResponse; + + /** + * Creates a plain object from a StreamDirectRawPredictResponse message. Also converts values to other types if specified. + * @param message StreamDirectRawPredictResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1.StreamDirectRawPredictResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectRawPredictResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectRawPredictResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a StreamingPredictRequest. */ interface IStreamingPredictRequest { @@ -148340,6 +148945,34 @@ export namespace google { */ public directRawPredict(request: google.cloud.aiplatform.v1beta1.IDirectRawPredictRequest): Promise; + /** + * Calls StreamDirectPredict. + * @param request StreamDirectPredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and StreamDirectPredictResponse + */ + public streamDirectPredict(request: google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest, callback: google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectPredictCallback): void; + + /** + * Calls StreamDirectPredict. + * @param request StreamDirectPredictRequest message or plain object + * @returns Promise + */ + public streamDirectPredict(request: google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest): Promise; + + /** + * Calls StreamDirectRawPredict. + * @param request StreamDirectRawPredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and StreamDirectRawPredictResponse + */ + public streamDirectRawPredict(request: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest, callback: google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectRawPredictCallback): void; + + /** + * Calls StreamDirectRawPredict. + * @param request StreamDirectRawPredictRequest message or plain object + * @returns Promise + */ + public streamDirectRawPredict(request: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest): Promise; + /** * Calls StreamingPredict. * @param request StreamingPredictRequest message or plain object @@ -148410,6 +149043,20 @@ export namespace google { */ public countTokens(request: google.cloud.aiplatform.v1beta1.ICountTokensRequest): Promise; + /** + * Calls GenerateContent. + * @param request GenerateContentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and GenerateContentResponse + */ + public generateContent(request: google.cloud.aiplatform.v1beta1.IGenerateContentRequest, callback: google.cloud.aiplatform.v1beta1.PredictionService.GenerateContentCallback): void; + + /** + * Calls GenerateContent. + * @param request GenerateContentRequest message or plain object + * @returns Promise + */ + public generateContent(request: google.cloud.aiplatform.v1beta1.IGenerateContentRequest): Promise; + /** * Calls StreamGenerateContent. * @param request GenerateContentRequest message or plain object @@ -148455,6 +149102,20 @@ export namespace google { */ type DirectRawPredictCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1beta1.DirectRawPredictResponse) => void; + /** + * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamDirectPredict}. + * @param error Error, if any + * @param [response] StreamDirectPredictResponse + */ + type StreamDirectPredictCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse) => void; + + /** + * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamDirectRawPredict}. + * @param error Error, if any + * @param [response] StreamDirectRawPredictResponse + */ + type StreamDirectRawPredictCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse) => void; + /** * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamingPredict}. * @param error Error, if any @@ -148490,6 +149151,13 @@ export namespace google { */ type CountTokensCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1beta1.CountTokensResponse) => void; + /** + * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|generateContent}. + * @param error Error, if any + * @param [response] GenerateContentResponse + */ + type GenerateContentCallback = (error: (Error|null), response?: google.cloud.aiplatform.v1beta1.GenerateContentResponse) => void; + /** * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamGenerateContent}. * @param error Error, if any @@ -149255,6 +149923,424 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a StreamDirectPredictRequest. */ + interface IStreamDirectPredictRequest { + + /** StreamDirectPredictRequest endpoint */ + endpoint?: (string|null); + + /** StreamDirectPredictRequest inputs */ + inputs?: (google.cloud.aiplatform.v1beta1.ITensor[]|null); + + /** StreamDirectPredictRequest parameters */ + parameters?: (google.cloud.aiplatform.v1beta1.ITensor|null); + } + + /** Represents a StreamDirectPredictRequest. */ + class StreamDirectPredictRequest implements IStreamDirectPredictRequest { + + /** + * Constructs a new StreamDirectPredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest); + + /** StreamDirectPredictRequest endpoint. */ + public endpoint: string; + + /** StreamDirectPredictRequest inputs. */ + public inputs: google.cloud.aiplatform.v1beta1.ITensor[]; + + /** StreamDirectPredictRequest parameters. */ + public parameters?: (google.cloud.aiplatform.v1beta1.ITensor|null); + + /** + * Creates a new StreamDirectPredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectPredictRequest instance + */ + public static create(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest): google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest; + + /** + * Encodes the specified StreamDirectPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.verify|verify} messages. + * @param message StreamDirectPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.verify|verify} messages. + * @param message StreamDirectPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest; + + /** + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest; + + /** + * Verifies a StreamDirectPredictRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectPredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectPredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest; + + /** + * Creates a plain object from a StreamDirectPredictRequest message. Also converts values to other types if specified. + * @param message StreamDirectPredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectPredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectPredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamDirectPredictResponse. */ + interface IStreamDirectPredictResponse { + + /** StreamDirectPredictResponse outputs */ + outputs?: (google.cloud.aiplatform.v1beta1.ITensor[]|null); + + /** StreamDirectPredictResponse parameters */ + parameters?: (google.cloud.aiplatform.v1beta1.ITensor|null); + } + + /** Represents a StreamDirectPredictResponse. */ + class StreamDirectPredictResponse implements IStreamDirectPredictResponse { + + /** + * Constructs a new StreamDirectPredictResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse); + + /** StreamDirectPredictResponse outputs. */ + public outputs: google.cloud.aiplatform.v1beta1.ITensor[]; + + /** StreamDirectPredictResponse parameters. */ + public parameters?: (google.cloud.aiplatform.v1beta1.ITensor|null); + + /** + * Creates a new StreamDirectPredictResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectPredictResponse instance + */ + public static create(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse): google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse; + + /** + * Encodes the specified StreamDirectPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse.verify|verify} messages. + * @param message StreamDirectPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse.verify|verify} messages. + * @param message StreamDirectPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse; + + /** + * Verifies a StreamDirectPredictResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectPredictResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectPredictResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse; + + /** + * Creates a plain object from a StreamDirectPredictResponse message. Also converts values to other types if specified. + * @param message StreamDirectPredictResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectPredictResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectPredictResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamDirectRawPredictRequest. */ + interface IStreamDirectRawPredictRequest { + + /** StreamDirectRawPredictRequest endpoint */ + endpoint?: (string|null); + + /** StreamDirectRawPredictRequest methodName */ + methodName?: (string|null); + + /** StreamDirectRawPredictRequest input */ + input?: (Uint8Array|string|null); + } + + /** Represents a StreamDirectRawPredictRequest. */ + class StreamDirectRawPredictRequest implements IStreamDirectRawPredictRequest { + + /** + * Constructs a new StreamDirectRawPredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest); + + /** StreamDirectRawPredictRequest endpoint. */ + public endpoint: string; + + /** StreamDirectRawPredictRequest methodName. */ + public methodName: string; + + /** StreamDirectRawPredictRequest input. */ + public input: (Uint8Array|string); + + /** + * Creates a new StreamDirectRawPredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectRawPredictRequest instance + */ + public static create(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest; + + /** + * Encodes the specified StreamDirectRawPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.verify|verify} messages. + * @param message StreamDirectRawPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectRawPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.verify|verify} messages. + * @param message StreamDirectRawPredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest; + + /** + * Verifies a StreamDirectRawPredictRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectRawPredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectRawPredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest; + + /** + * Creates a plain object from a StreamDirectRawPredictRequest message. Also converts values to other types if specified. + * @param message StreamDirectRawPredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectRawPredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectRawPredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamDirectRawPredictResponse. */ + interface IStreamDirectRawPredictResponse { + + /** StreamDirectRawPredictResponse output */ + output?: (Uint8Array|string|null); + } + + /** Represents a StreamDirectRawPredictResponse. */ + class StreamDirectRawPredictResponse implements IStreamDirectRawPredictResponse { + + /** + * Constructs a new StreamDirectRawPredictResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse); + + /** StreamDirectRawPredictResponse output. */ + public output: (Uint8Array|string); + + /** + * Creates a new StreamDirectRawPredictResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamDirectRawPredictResponse instance + */ + public static create(properties?: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse; + + /** + * Encodes the specified StreamDirectRawPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse.verify|verify} messages. + * @param message StreamDirectRawPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamDirectRawPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse.verify|verify} messages. + * @param message StreamDirectRawPredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse; + + /** + * Verifies a StreamDirectRawPredictResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StreamDirectRawPredictResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamDirectRawPredictResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse; + + /** + * Creates a plain object from a StreamDirectRawPredictResponse message. Also converts values to other types if specified. + * @param message StreamDirectRawPredictResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamDirectRawPredictResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamDirectRawPredictResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a StreamingPredictRequest. */ interface IStreamingPredictRequest { diff --git a/packages/google-cloud-aiplatform/protos/protos.js b/packages/google-cloud-aiplatform/protos/protos.js index 194885f610c..afb794ebff5 100644 --- a/packages/google-cloud-aiplatform/protos/protos.js +++ b/packages/google-cloud-aiplatform/protos/protos.js @@ -131714,6 +131714,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamRawPredict}. + * @memberof google.cloud.aiplatform.v1.PredictionService + * @typedef StreamRawPredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.api.HttpBody} [response] HttpBody + */ + + /** + * Calls StreamRawPredict. + * @function streamRawPredict + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IStreamRawPredictRequest} request StreamRawPredictRequest message or plain object + * @param {google.cloud.aiplatform.v1.PredictionService.StreamRawPredictCallback} callback Node-style callback called with the error, if any, and HttpBody + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.streamRawPredict = function streamRawPredict(request, callback) { + return this.rpcCall(streamRawPredict, $root.google.cloud.aiplatform.v1.StreamRawPredictRequest, $root.google.api.HttpBody, request, callback); + }, "name", { value: "StreamRawPredict" }); + + /** + * Calls StreamRawPredict. + * @function streamRawPredict + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IStreamRawPredictRequest} request StreamRawPredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|directPredict}. * @memberof google.cloud.aiplatform.v1.PredictionService @@ -131780,6 +131813,72 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamDirectPredict}. + * @memberof google.cloud.aiplatform.v1.PredictionService + * @typedef StreamDirectPredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.aiplatform.v1.StreamDirectPredictResponse} [response] StreamDirectPredictResponse + */ + + /** + * Calls StreamDirectPredict. + * @function streamDirectPredict + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictRequest} request StreamDirectPredictRequest message or plain object + * @param {google.cloud.aiplatform.v1.PredictionService.StreamDirectPredictCallback} callback Node-style callback called with the error, if any, and StreamDirectPredictResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.streamDirectPredict = function streamDirectPredict(request, callback) { + return this.rpcCall(streamDirectPredict, $root.google.cloud.aiplatform.v1.StreamDirectPredictRequest, $root.google.cloud.aiplatform.v1.StreamDirectPredictResponse, request, callback); + }, "name", { value: "StreamDirectPredict" }); + + /** + * Calls StreamDirectPredict. + * @function streamDirectPredict + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictRequest} request StreamDirectPredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamDirectRawPredict}. + * @memberof google.cloud.aiplatform.v1.PredictionService + * @typedef StreamDirectRawPredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.aiplatform.v1.StreamDirectRawPredictResponse} [response] StreamDirectRawPredictResponse + */ + + /** + * Calls StreamDirectRawPredict. + * @function streamDirectRawPredict + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest} request StreamDirectRawPredictRequest message or plain object + * @param {google.cloud.aiplatform.v1.PredictionService.StreamDirectRawPredictCallback} callback Node-style callback called with the error, if any, and StreamDirectRawPredictResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.streamDirectRawPredict = function streamDirectRawPredict(request, callback) { + return this.rpcCall(streamDirectRawPredict, $root.google.cloud.aiplatform.v1.StreamDirectRawPredictRequest, $root.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse, request, callback); + }, "name", { value: "StreamDirectRawPredict" }); + + /** + * Calls StreamDirectRawPredict. + * @function streamDirectRawPredict + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest} request StreamDirectRawPredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamingPredict}. * @memberof google.cloud.aiplatform.v1.PredictionService @@ -131912,6 +132011,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|generateContent}. + * @memberof google.cloud.aiplatform.v1.PredictionService + * @typedef GenerateContentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.aiplatform.v1.GenerateContentResponse} [response] GenerateContentResponse + */ + + /** + * Calls GenerateContent. + * @function generateContent + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IGenerateContentRequest} request GenerateContentRequest message or plain object + * @param {google.cloud.aiplatform.v1.PredictionService.GenerateContentCallback} callback Node-style callback called with the error, if any, and GenerateContentResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.generateContent = function generateContent(request, callback) { + return this.rpcCall(generateContent, $root.google.cloud.aiplatform.v1.GenerateContentRequest, $root.google.cloud.aiplatform.v1.GenerateContentResponse, request, callback); + }, "name", { value: "GenerateContent" }); + + /** + * Calls GenerateContent. + * @function generateContent + * @memberof google.cloud.aiplatform.v1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1.IGenerateContentRequest} request GenerateContentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.aiplatform.v1.PredictionService|streamGenerateContent}. * @memberof google.cloud.aiplatform.v1.PredictionService @@ -132803,6 +132935,238 @@ return RawPredictRequest; })(); + v1.StreamRawPredictRequest = (function() { + + /** + * Properties of a StreamRawPredictRequest. + * @memberof google.cloud.aiplatform.v1 + * @interface IStreamRawPredictRequest + * @property {string|null} [endpoint] StreamRawPredictRequest endpoint + * @property {google.api.IHttpBody|null} [httpBody] StreamRawPredictRequest httpBody + */ + + /** + * Constructs a new StreamRawPredictRequest. + * @memberof google.cloud.aiplatform.v1 + * @classdesc Represents a StreamRawPredictRequest. + * @implements IStreamRawPredictRequest + * @constructor + * @param {google.cloud.aiplatform.v1.IStreamRawPredictRequest=} [properties] Properties to set + */ + function StreamRawPredictRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamRawPredictRequest endpoint. + * @member {string} endpoint + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @instance + */ + StreamRawPredictRequest.prototype.endpoint = ""; + + /** + * StreamRawPredictRequest httpBody. + * @member {google.api.IHttpBody|null|undefined} httpBody + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @instance + */ + StreamRawPredictRequest.prototype.httpBody = null; + + /** + * Creates a new StreamRawPredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamRawPredictRequest=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1.StreamRawPredictRequest} StreamRawPredictRequest instance + */ + StreamRawPredictRequest.create = function create(properties) { + return new StreamRawPredictRequest(properties); + }; + + /** + * Encodes the specified StreamRawPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamRawPredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamRawPredictRequest} message StreamRawPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamRawPredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.endpoint != null && Object.hasOwnProperty.call(message, "endpoint")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.endpoint); + if (message.httpBody != null && Object.hasOwnProperty.call(message, "httpBody")) + $root.google.api.HttpBody.encode(message.httpBody, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamRawPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamRawPredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamRawPredictRequest} message StreamRawPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamRawPredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamRawPredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1.StreamRawPredictRequest} StreamRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamRawPredictRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1.StreamRawPredictRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.endpoint = reader.string(); + break; + } + case 2: { + message.httpBody = $root.google.api.HttpBody.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamRawPredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1.StreamRawPredictRequest} StreamRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamRawPredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamRawPredictRequest message. + * @function verify + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamRawPredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + if (!$util.isString(message.endpoint)) + return "endpoint: string expected"; + if (message.httpBody != null && message.hasOwnProperty("httpBody")) { + var error = $root.google.api.HttpBody.verify(message.httpBody); + if (error) + return "httpBody." + error; + } + return null; + }; + + /** + * Creates a StreamRawPredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1.StreamRawPredictRequest} StreamRawPredictRequest + */ + StreamRawPredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1.StreamRawPredictRequest) + return object; + var message = new $root.google.cloud.aiplatform.v1.StreamRawPredictRequest(); + if (object.endpoint != null) + message.endpoint = String(object.endpoint); + if (object.httpBody != null) { + if (typeof object.httpBody !== "object") + throw TypeError(".google.cloud.aiplatform.v1.StreamRawPredictRequest.httpBody: object expected"); + message.httpBody = $root.google.api.HttpBody.fromObject(object.httpBody); + } + return message; + }; + + /** + * Creates a plain object from a StreamRawPredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.StreamRawPredictRequest} message StreamRawPredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamRawPredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.endpoint = ""; + object.httpBody = null; + } + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + object.endpoint = message.endpoint; + if (message.httpBody != null && message.hasOwnProperty("httpBody")) + object.httpBody = $root.google.api.HttpBody.toObject(message.httpBody, options); + return object; + }; + + /** + * Converts this StreamRawPredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @instance + * @returns {Object.} JSON object + */ + StreamRawPredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamRawPredictRequest + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1.StreamRawPredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamRawPredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1.StreamRawPredictRequest"; + }; + + return StreamRawPredictRequest; + })(); + v1.DirectPredictRequest = (function() { /** @@ -133804,26 +134168,26 @@ return DirectRawPredictResponse; })(); - v1.StreamingPredictRequest = (function() { + v1.StreamDirectPredictRequest = (function() { /** - * Properties of a StreamingPredictRequest. + * Properties of a StreamDirectPredictRequest. * @memberof google.cloud.aiplatform.v1 - * @interface IStreamingPredictRequest - * @property {string|null} [endpoint] StreamingPredictRequest endpoint - * @property {Array.|null} [inputs] StreamingPredictRequest inputs - * @property {google.cloud.aiplatform.v1.ITensor|null} [parameters] StreamingPredictRequest parameters + * @interface IStreamDirectPredictRequest + * @property {string|null} [endpoint] StreamDirectPredictRequest endpoint + * @property {Array.|null} [inputs] StreamDirectPredictRequest inputs + * @property {google.cloud.aiplatform.v1.ITensor|null} [parameters] StreamDirectPredictRequest parameters */ /** - * Constructs a new StreamingPredictRequest. + * Constructs a new StreamDirectPredictRequest. * @memberof google.cloud.aiplatform.v1 - * @classdesc Represents a StreamingPredictRequest. - * @implements IStreamingPredictRequest + * @classdesc Represents a StreamDirectPredictRequest. + * @implements IStreamDirectPredictRequest * @constructor - * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest=} [properties] Properties to set + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictRequest=} [properties] Properties to set */ - function StreamingPredictRequest(properties) { + function StreamDirectPredictRequest(properties) { this.inputs = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) @@ -133832,51 +134196,51 @@ } /** - * StreamingPredictRequest endpoint. + * StreamDirectPredictRequest endpoint. * @member {string} endpoint - * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest * @instance */ - StreamingPredictRequest.prototype.endpoint = ""; + StreamDirectPredictRequest.prototype.endpoint = ""; /** - * StreamingPredictRequest inputs. + * StreamDirectPredictRequest inputs. * @member {Array.} inputs - * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest * @instance */ - StreamingPredictRequest.prototype.inputs = $util.emptyArray; + StreamDirectPredictRequest.prototype.inputs = $util.emptyArray; /** - * StreamingPredictRequest parameters. + * StreamDirectPredictRequest parameters. * @member {google.cloud.aiplatform.v1.ITensor|null|undefined} parameters - * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest * @instance */ - StreamingPredictRequest.prototype.parameters = null; + StreamDirectPredictRequest.prototype.parameters = null; /** - * Creates a new StreamingPredictRequest instance using the specified properties. + * Creates a new StreamDirectPredictRequest instance using the specified properties. * @function create - * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest * @static - * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest=} [properties] Properties to set - * @returns {google.cloud.aiplatform.v1.StreamingPredictRequest} StreamingPredictRequest instance + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictRequest=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictRequest} StreamDirectPredictRequest instance */ - StreamingPredictRequest.create = function create(properties) { - return new StreamingPredictRequest(properties); + StreamDirectPredictRequest.create = function create(properties) { + return new StreamDirectPredictRequest(properties); }; /** - * Encodes the specified StreamingPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamingPredictRequest.verify|verify} messages. + * Encodes the specified StreamDirectPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictRequest.verify|verify} messages. * @function encode - * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest * @static - * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest} message StreamingPredictRequest message or plain object to encode + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictRequest} message StreamDirectPredictRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - StreamingPredictRequest.encode = function encode(message, writer) { + StreamDirectPredictRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.endpoint != null && Object.hasOwnProperty.call(message, "endpoint")) @@ -133890,33 +134254,1034 @@ }; /** - * Encodes the specified StreamingPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamingPredictRequest.verify|verify} messages. + * Encodes the specified StreamDirectPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest * @static - * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest} message StreamingPredictRequest message or plain object to encode + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictRequest} message StreamDirectPredictRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - StreamingPredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + StreamDirectPredictRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a StreamingPredictRequest message from the specified reader or buffer. + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer. * @function decode - * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.aiplatform.v1.StreamingPredictRequest} StreamingPredictRequest + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictRequest} StreamDirectPredictRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - StreamingPredictRequest.decode = function decode(reader, length) { + StreamDirectPredictRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1.StreamingPredictRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1.StreamDirectPredictRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.endpoint = reader.string(); + break; + } + case 2: { + if (!(message.inputs && message.inputs.length)) + message.inputs = []; + message.inputs.push($root.google.cloud.aiplatform.v1.Tensor.decode(reader, reader.uint32())); + break; + } + case 3: { + message.parameters = $root.google.cloud.aiplatform.v1.Tensor.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictRequest} StreamDirectPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectPredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectPredictRequest message. + * @function verify + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectPredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + if (!$util.isString(message.endpoint)) + return "endpoint: string expected"; + if (message.inputs != null && message.hasOwnProperty("inputs")) { + if (!Array.isArray(message.inputs)) + return "inputs: array expected"; + for (var i = 0; i < message.inputs.length; ++i) { + var error = $root.google.cloud.aiplatform.v1.Tensor.verify(message.inputs[i]); + if (error) + return "inputs." + error; + } + } + if (message.parameters != null && message.hasOwnProperty("parameters")) { + var error = $root.google.cloud.aiplatform.v1.Tensor.verify(message.parameters); + if (error) + return "parameters." + error; + } + return null; + }; + + /** + * Creates a StreamDirectPredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictRequest} StreamDirectPredictRequest + */ + StreamDirectPredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1.StreamDirectPredictRequest) + return object; + var message = new $root.google.cloud.aiplatform.v1.StreamDirectPredictRequest(); + if (object.endpoint != null) + message.endpoint = String(object.endpoint); + if (object.inputs) { + if (!Array.isArray(object.inputs)) + throw TypeError(".google.cloud.aiplatform.v1.StreamDirectPredictRequest.inputs: array expected"); + message.inputs = []; + for (var i = 0; i < object.inputs.length; ++i) { + if (typeof object.inputs[i] !== "object") + throw TypeError(".google.cloud.aiplatform.v1.StreamDirectPredictRequest.inputs: object expected"); + message.inputs[i] = $root.google.cloud.aiplatform.v1.Tensor.fromObject(object.inputs[i]); + } + } + if (object.parameters != null) { + if (typeof object.parameters !== "object") + throw TypeError(".google.cloud.aiplatform.v1.StreamDirectPredictRequest.parameters: object expected"); + message.parameters = $root.google.cloud.aiplatform.v1.Tensor.fromObject(object.parameters); + } + return message; + }; + + /** + * Creates a plain object from a StreamDirectPredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.StreamDirectPredictRequest} message StreamDirectPredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectPredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputs = []; + if (options.defaults) { + object.endpoint = ""; + object.parameters = null; + } + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + object.endpoint = message.endpoint; + if (message.inputs && message.inputs.length) { + object.inputs = []; + for (var j = 0; j < message.inputs.length; ++j) + object.inputs[j] = $root.google.cloud.aiplatform.v1.Tensor.toObject(message.inputs[j], options); + } + if (message.parameters != null && message.hasOwnProperty("parameters")) + object.parameters = $root.google.cloud.aiplatform.v1.Tensor.toObject(message.parameters, options); + return object; + }; + + /** + * Converts this StreamDirectPredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest + * @instance + * @returns {Object.} JSON object + */ + StreamDirectPredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectPredictRequest + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectPredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1.StreamDirectPredictRequest"; + }; + + return StreamDirectPredictRequest; + })(); + + v1.StreamDirectPredictResponse = (function() { + + /** + * Properties of a StreamDirectPredictResponse. + * @memberof google.cloud.aiplatform.v1 + * @interface IStreamDirectPredictResponse + * @property {Array.|null} [outputs] StreamDirectPredictResponse outputs + * @property {google.cloud.aiplatform.v1.ITensor|null} [parameters] StreamDirectPredictResponse parameters + */ + + /** + * Constructs a new StreamDirectPredictResponse. + * @memberof google.cloud.aiplatform.v1 + * @classdesc Represents a StreamDirectPredictResponse. + * @implements IStreamDirectPredictResponse + * @constructor + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictResponse=} [properties] Properties to set + */ + function StreamDirectPredictResponse(properties) { + this.outputs = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamDirectPredictResponse outputs. + * @member {Array.} outputs + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @instance + */ + StreamDirectPredictResponse.prototype.outputs = $util.emptyArray; + + /** + * StreamDirectPredictResponse parameters. + * @member {google.cloud.aiplatform.v1.ITensor|null|undefined} parameters + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @instance + */ + StreamDirectPredictResponse.prototype.parameters = null; + + /** + * Creates a new StreamDirectPredictResponse instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictResponse=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictResponse} StreamDirectPredictResponse instance + */ + StreamDirectPredictResponse.create = function create(properties) { + return new StreamDirectPredictResponse(properties); + }; + + /** + * Encodes the specified StreamDirectPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictResponse} message StreamDirectPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectPredictResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.outputs != null && message.outputs.length) + for (var i = 0; i < message.outputs.length; ++i) + $root.google.cloud.aiplatform.v1.Tensor.encode(message.outputs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.parameters != null && Object.hasOwnProperty.call(message, "parameters")) + $root.google.cloud.aiplatform.v1.Tensor.encode(message.parameters, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamDirectPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectPredictResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectPredictResponse} message StreamDirectPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectPredictResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictResponse} StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectPredictResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1.StreamDirectPredictResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.outputs && message.outputs.length)) + message.outputs = []; + message.outputs.push($root.google.cloud.aiplatform.v1.Tensor.decode(reader, reader.uint32())); + break; + } + case 2: { + message.parameters = $root.google.cloud.aiplatform.v1.Tensor.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictResponse} StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectPredictResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectPredictResponse message. + * @function verify + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectPredictResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.outputs != null && message.hasOwnProperty("outputs")) { + if (!Array.isArray(message.outputs)) + return "outputs: array expected"; + for (var i = 0; i < message.outputs.length; ++i) { + var error = $root.google.cloud.aiplatform.v1.Tensor.verify(message.outputs[i]); + if (error) + return "outputs." + error; + } + } + if (message.parameters != null && message.hasOwnProperty("parameters")) { + var error = $root.google.cloud.aiplatform.v1.Tensor.verify(message.parameters); + if (error) + return "parameters." + error; + } + return null; + }; + + /** + * Creates a StreamDirectPredictResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1.StreamDirectPredictResponse} StreamDirectPredictResponse + */ + StreamDirectPredictResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1.StreamDirectPredictResponse) + return object; + var message = new $root.google.cloud.aiplatform.v1.StreamDirectPredictResponse(); + if (object.outputs) { + if (!Array.isArray(object.outputs)) + throw TypeError(".google.cloud.aiplatform.v1.StreamDirectPredictResponse.outputs: array expected"); + message.outputs = []; + for (var i = 0; i < object.outputs.length; ++i) { + if (typeof object.outputs[i] !== "object") + throw TypeError(".google.cloud.aiplatform.v1.StreamDirectPredictResponse.outputs: object expected"); + message.outputs[i] = $root.google.cloud.aiplatform.v1.Tensor.fromObject(object.outputs[i]); + } + } + if (object.parameters != null) { + if (typeof object.parameters !== "object") + throw TypeError(".google.cloud.aiplatform.v1.StreamDirectPredictResponse.parameters: object expected"); + message.parameters = $root.google.cloud.aiplatform.v1.Tensor.fromObject(object.parameters); + } + return message; + }; + + /** + * Creates a plain object from a StreamDirectPredictResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.StreamDirectPredictResponse} message StreamDirectPredictResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectPredictResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.outputs = []; + if (options.defaults) + object.parameters = null; + if (message.outputs && message.outputs.length) { + object.outputs = []; + for (var j = 0; j < message.outputs.length; ++j) + object.outputs[j] = $root.google.cloud.aiplatform.v1.Tensor.toObject(message.outputs[j], options); + } + if (message.parameters != null && message.hasOwnProperty("parameters")) + object.parameters = $root.google.cloud.aiplatform.v1.Tensor.toObject(message.parameters, options); + return object; + }; + + /** + * Converts this StreamDirectPredictResponse to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @instance + * @returns {Object.} JSON object + */ + StreamDirectPredictResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectPredictResponse + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1.StreamDirectPredictResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectPredictResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1.StreamDirectPredictResponse"; + }; + + return StreamDirectPredictResponse; + })(); + + v1.StreamDirectRawPredictRequest = (function() { + + /** + * Properties of a StreamDirectRawPredictRequest. + * @memberof google.cloud.aiplatform.v1 + * @interface IStreamDirectRawPredictRequest + * @property {string|null} [endpoint] StreamDirectRawPredictRequest endpoint + * @property {string|null} [methodName] StreamDirectRawPredictRequest methodName + * @property {Uint8Array|null} [input] StreamDirectRawPredictRequest input + */ + + /** + * Constructs a new StreamDirectRawPredictRequest. + * @memberof google.cloud.aiplatform.v1 + * @classdesc Represents a StreamDirectRawPredictRequest. + * @implements IStreamDirectRawPredictRequest + * @constructor + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest=} [properties] Properties to set + */ + function StreamDirectRawPredictRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamDirectRawPredictRequest endpoint. + * @member {string} endpoint + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @instance + */ + StreamDirectRawPredictRequest.prototype.endpoint = ""; + + /** + * StreamDirectRawPredictRequest methodName. + * @member {string} methodName + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @instance + */ + StreamDirectRawPredictRequest.prototype.methodName = ""; + + /** + * StreamDirectRawPredictRequest input. + * @member {Uint8Array} input + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @instance + */ + StreamDirectRawPredictRequest.prototype.input = $util.newBuffer([]); + + /** + * Creates a new StreamDirectRawPredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest instance + */ + StreamDirectRawPredictRequest.create = function create(properties) { + return new StreamDirectRawPredictRequest(properties); + }; + + /** + * Encodes the specified StreamDirectRawPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest} message StreamDirectRawPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.endpoint != null && Object.hasOwnProperty.call(message, "endpoint")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.endpoint); + if (message.methodName != null && Object.hasOwnProperty.call(message, "methodName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.methodName); + if (message.input != null && Object.hasOwnProperty.call(message, "input")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.input); + return writer; + }; + + /** + * Encodes the specified StreamDirectRawPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictRequest} message StreamDirectRawPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1.StreamDirectRawPredictRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.endpoint = reader.string(); + break; + } + case 2: { + message.methodName = reader.string(); + break; + } + case 3: { + message.input = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectRawPredictRequest message. + * @function verify + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectRawPredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + if (!$util.isString(message.endpoint)) + return "endpoint: string expected"; + if (message.methodName != null && message.hasOwnProperty("methodName")) + if (!$util.isString(message.methodName)) + return "methodName: string expected"; + if (message.input != null && message.hasOwnProperty("input")) + if (!(message.input && typeof message.input.length === "number" || $util.isString(message.input))) + return "input: buffer expected"; + return null; + }; + + /** + * Creates a StreamDirectRawPredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest + */ + StreamDirectRawPredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1.StreamDirectRawPredictRequest) + return object; + var message = new $root.google.cloud.aiplatform.v1.StreamDirectRawPredictRequest(); + if (object.endpoint != null) + message.endpoint = String(object.endpoint); + if (object.methodName != null) + message.methodName = String(object.methodName); + if (object.input != null) + if (typeof object.input === "string") + $util.base64.decode(object.input, message.input = $util.newBuffer($util.base64.length(object.input)), 0); + else if (object.input.length >= 0) + message.input = object.input; + return message; + }; + + /** + * Creates a plain object from a StreamDirectRawPredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.StreamDirectRawPredictRequest} message StreamDirectRawPredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectRawPredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.endpoint = ""; + object.methodName = ""; + if (options.bytes === String) + object.input = ""; + else { + object.input = []; + if (options.bytes !== Array) + object.input = $util.newBuffer(object.input); + } + } + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + object.endpoint = message.endpoint; + if (message.methodName != null && message.hasOwnProperty("methodName")) + object.methodName = message.methodName; + if (message.input != null && message.hasOwnProperty("input")) + object.input = options.bytes === String ? $util.base64.encode(message.input, 0, message.input.length) : options.bytes === Array ? Array.prototype.slice.call(message.input) : message.input; + return object; + }; + + /** + * Converts this StreamDirectRawPredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @instance + * @returns {Object.} JSON object + */ + StreamDirectRawPredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectRawPredictRequest + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectRawPredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1.StreamDirectRawPredictRequest"; + }; + + return StreamDirectRawPredictRequest; + })(); + + v1.StreamDirectRawPredictResponse = (function() { + + /** + * Properties of a StreamDirectRawPredictResponse. + * @memberof google.cloud.aiplatform.v1 + * @interface IStreamDirectRawPredictResponse + * @property {Uint8Array|null} [output] StreamDirectRawPredictResponse output + */ + + /** + * Constructs a new StreamDirectRawPredictResponse. + * @memberof google.cloud.aiplatform.v1 + * @classdesc Represents a StreamDirectRawPredictResponse. + * @implements IStreamDirectRawPredictResponse + * @constructor + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse=} [properties] Properties to set + */ + function StreamDirectRawPredictResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamDirectRawPredictResponse output. + * @member {Uint8Array} output + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @instance + */ + StreamDirectRawPredictResponse.prototype.output = $util.newBuffer([]); + + /** + * Creates a new StreamDirectRawPredictResponse instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse instance + */ + StreamDirectRawPredictResponse.create = function create(properties) { + return new StreamDirectRawPredictResponse(properties); + }; + + /** + * Encodes the specified StreamDirectRawPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse} message StreamDirectRawPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.output != null && Object.hasOwnProperty.call(message, "output")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.output); + return writer; + }; + + /** + * Encodes the specified StreamDirectRawPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamDirectRawPredictResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.IStreamDirectRawPredictResponse} message StreamDirectRawPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.output = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectRawPredictResponse message. + * @function verify + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectRawPredictResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.output != null && message.hasOwnProperty("output")) + if (!(message.output && typeof message.output.length === "number" || $util.isString(message.output))) + return "output: buffer expected"; + return null; + }; + + /** + * Creates a StreamDirectRawPredictResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse + */ + StreamDirectRawPredictResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse) + return object; + var message = new $root.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse(); + if (object.output != null) + if (typeof object.output === "string") + $util.base64.decode(object.output, message.output = $util.newBuffer($util.base64.length(object.output)), 0); + else if (object.output.length >= 0) + message.output = object.output; + return message; + }; + + /** + * Creates a plain object from a StreamDirectRawPredictResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1.StreamDirectRawPredictResponse} message StreamDirectRawPredictResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectRawPredictResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.output = ""; + else { + object.output = []; + if (options.bytes !== Array) + object.output = $util.newBuffer(object.output); + } + if (message.output != null && message.hasOwnProperty("output")) + object.output = options.bytes === String ? $util.base64.encode(message.output, 0, message.output.length) : options.bytes === Array ? Array.prototype.slice.call(message.output) : message.output; + return object; + }; + + /** + * Converts this StreamDirectRawPredictResponse to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @instance + * @returns {Object.} JSON object + */ + StreamDirectRawPredictResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectRawPredictResponse + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectRawPredictResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1.StreamDirectRawPredictResponse"; + }; + + return StreamDirectRawPredictResponse; + })(); + + v1.StreamingPredictRequest = (function() { + + /** + * Properties of a StreamingPredictRequest. + * @memberof google.cloud.aiplatform.v1 + * @interface IStreamingPredictRequest + * @property {string|null} [endpoint] StreamingPredictRequest endpoint + * @property {Array.|null} [inputs] StreamingPredictRequest inputs + * @property {google.cloud.aiplatform.v1.ITensor|null} [parameters] StreamingPredictRequest parameters + */ + + /** + * Constructs a new StreamingPredictRequest. + * @memberof google.cloud.aiplatform.v1 + * @classdesc Represents a StreamingPredictRequest. + * @implements IStreamingPredictRequest + * @constructor + * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest=} [properties] Properties to set + */ + function StreamingPredictRequest(properties) { + this.inputs = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamingPredictRequest endpoint. + * @member {string} endpoint + * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @instance + */ + StreamingPredictRequest.prototype.endpoint = ""; + + /** + * StreamingPredictRequest inputs. + * @member {Array.} inputs + * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @instance + */ + StreamingPredictRequest.prototype.inputs = $util.emptyArray; + + /** + * StreamingPredictRequest parameters. + * @member {google.cloud.aiplatform.v1.ITensor|null|undefined} parameters + * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @instance + */ + StreamingPredictRequest.prototype.parameters = null; + + /** + * Creates a new StreamingPredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1.StreamingPredictRequest} StreamingPredictRequest instance + */ + StreamingPredictRequest.create = function create(properties) { + return new StreamingPredictRequest(properties); + }; + + /** + * Encodes the specified StreamingPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1.StreamingPredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest} message StreamingPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingPredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.endpoint != null && Object.hasOwnProperty.call(message, "endpoint")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.endpoint); + if (message.inputs != null && message.inputs.length) + for (var i = 0; i < message.inputs.length; ++i) + $root.google.cloud.aiplatform.v1.Tensor.encode(message.inputs[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.parameters != null && Object.hasOwnProperty.call(message, "parameters")) + $root.google.cloud.aiplatform.v1.Tensor.encode(message.parameters, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamingPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1.StreamingPredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @static + * @param {google.cloud.aiplatform.v1.IStreamingPredictRequest} message StreamingPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingPredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamingPredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1.StreamingPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1.StreamingPredictRequest} StreamingPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingPredictRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1.StreamingPredictRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { @@ -360502,6 +361867,72 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamDirectPredict}. + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @typedef StreamDirectPredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse} [response] StreamDirectPredictResponse + */ + + /** + * Calls StreamDirectPredict. + * @function streamDirectPredict + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest} request StreamDirectPredictRequest message or plain object + * @param {google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectPredictCallback} callback Node-style callback called with the error, if any, and StreamDirectPredictResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.streamDirectPredict = function streamDirectPredict(request, callback) { + return this.rpcCall(streamDirectPredict, $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest, $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse, request, callback); + }, "name", { value: "StreamDirectPredict" }); + + /** + * Calls StreamDirectPredict. + * @function streamDirectPredict + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest} request StreamDirectPredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamDirectRawPredict}. + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @typedef StreamDirectRawPredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse} [response] StreamDirectRawPredictResponse + */ + + /** + * Calls StreamDirectRawPredict. + * @function streamDirectRawPredict + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest} request StreamDirectRawPredictRequest message or plain object + * @param {google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectRawPredictCallback} callback Node-style callback called with the error, if any, and StreamDirectRawPredictResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.streamDirectRawPredict = function streamDirectRawPredict(request, callback) { + return this.rpcCall(streamDirectRawPredict, $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest, $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse, request, callback); + }, "name", { value: "StreamDirectRawPredict" }); + + /** + * Calls StreamDirectRawPredict. + * @function streamDirectRawPredict + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest} request StreamDirectRawPredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamingPredict}. * @memberof google.cloud.aiplatform.v1beta1.PredictionService @@ -360667,6 +362098,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|generateContent}. + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @typedef GenerateContentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.aiplatform.v1beta1.GenerateContentResponse} [response] GenerateContentResponse + */ + + /** + * Calls GenerateContent. + * @function generateContent + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1beta1.IGenerateContentRequest} request GenerateContentRequest message or plain object + * @param {google.cloud.aiplatform.v1beta1.PredictionService.GenerateContentCallback} callback Node-style callback called with the error, if any, and GenerateContentResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.generateContent = function generateContent(request, callback) { + return this.rpcCall(generateContent, $root.google.cloud.aiplatform.v1beta1.GenerateContentRequest, $root.google.cloud.aiplatform.v1beta1.GenerateContentResponse, request, callback); + }, "name", { value: "GenerateContent" }); + + /** + * Calls GenerateContent. + * @function generateContent + * @memberof google.cloud.aiplatform.v1beta1.PredictionService + * @instance + * @param {google.cloud.aiplatform.v1beta1.IGenerateContentRequest} request GenerateContentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.aiplatform.v1beta1.PredictionService|streamGenerateContent}. * @memberof google.cloud.aiplatform.v1beta1.PredictionService @@ -362559,6 +364023,1007 @@ return DirectRawPredictResponse; })(); + v1beta1.StreamDirectPredictRequest = (function() { + + /** + * Properties of a StreamDirectPredictRequest. + * @memberof google.cloud.aiplatform.v1beta1 + * @interface IStreamDirectPredictRequest + * @property {string|null} [endpoint] StreamDirectPredictRequest endpoint + * @property {Array.|null} [inputs] StreamDirectPredictRequest inputs + * @property {google.cloud.aiplatform.v1beta1.ITensor|null} [parameters] StreamDirectPredictRequest parameters + */ + + /** + * Constructs a new StreamDirectPredictRequest. + * @memberof google.cloud.aiplatform.v1beta1 + * @classdesc Represents a StreamDirectPredictRequest. + * @implements IStreamDirectPredictRequest + * @constructor + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest=} [properties] Properties to set + */ + function StreamDirectPredictRequest(properties) { + this.inputs = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamDirectPredictRequest endpoint. + * @member {string} endpoint + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @instance + */ + StreamDirectPredictRequest.prototype.endpoint = ""; + + /** + * StreamDirectPredictRequest inputs. + * @member {Array.} inputs + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @instance + */ + StreamDirectPredictRequest.prototype.inputs = $util.emptyArray; + + /** + * StreamDirectPredictRequest parameters. + * @member {google.cloud.aiplatform.v1beta1.ITensor|null|undefined} parameters + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @instance + */ + StreamDirectPredictRequest.prototype.parameters = null; + + /** + * Creates a new StreamDirectPredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest} StreamDirectPredictRequest instance + */ + StreamDirectPredictRequest.create = function create(properties) { + return new StreamDirectPredictRequest(properties); + }; + + /** + * Encodes the specified StreamDirectPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest} message StreamDirectPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectPredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.endpoint != null && Object.hasOwnProperty.call(message, "endpoint")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.endpoint); + if (message.inputs != null && message.inputs.length) + for (var i = 0; i < message.inputs.length; ++i) + $root.google.cloud.aiplatform.v1beta1.Tensor.encode(message.inputs[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.parameters != null && Object.hasOwnProperty.call(message, "parameters")) + $root.google.cloud.aiplatform.v1beta1.Tensor.encode(message.parameters, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamDirectPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictRequest} message StreamDirectPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectPredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest} StreamDirectPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectPredictRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.endpoint = reader.string(); + break; + } + case 2: { + if (!(message.inputs && message.inputs.length)) + message.inputs = []; + message.inputs.push($root.google.cloud.aiplatform.v1beta1.Tensor.decode(reader, reader.uint32())); + break; + } + case 3: { + message.parameters = $root.google.cloud.aiplatform.v1beta1.Tensor.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectPredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest} StreamDirectPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectPredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectPredictRequest message. + * @function verify + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectPredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + if (!$util.isString(message.endpoint)) + return "endpoint: string expected"; + if (message.inputs != null && message.hasOwnProperty("inputs")) { + if (!Array.isArray(message.inputs)) + return "inputs: array expected"; + for (var i = 0; i < message.inputs.length; ++i) { + var error = $root.google.cloud.aiplatform.v1beta1.Tensor.verify(message.inputs[i]); + if (error) + return "inputs." + error; + } + } + if (message.parameters != null && message.hasOwnProperty("parameters")) { + var error = $root.google.cloud.aiplatform.v1beta1.Tensor.verify(message.parameters); + if (error) + return "parameters." + error; + } + return null; + }; + + /** + * Creates a StreamDirectPredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest} StreamDirectPredictRequest + */ + StreamDirectPredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest) + return object; + var message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest(); + if (object.endpoint != null) + message.endpoint = String(object.endpoint); + if (object.inputs) { + if (!Array.isArray(object.inputs)) + throw TypeError(".google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.inputs: array expected"); + message.inputs = []; + for (var i = 0; i < object.inputs.length; ++i) { + if (typeof object.inputs[i] !== "object") + throw TypeError(".google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.inputs: object expected"); + message.inputs[i] = $root.google.cloud.aiplatform.v1beta1.Tensor.fromObject(object.inputs[i]); + } + } + if (object.parameters != null) { + if (typeof object.parameters !== "object") + throw TypeError(".google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest.parameters: object expected"); + message.parameters = $root.google.cloud.aiplatform.v1beta1.Tensor.fromObject(object.parameters); + } + return message; + }; + + /** + * Creates a plain object from a StreamDirectPredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest} message StreamDirectPredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectPredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputs = []; + if (options.defaults) { + object.endpoint = ""; + object.parameters = null; + } + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + object.endpoint = message.endpoint; + if (message.inputs && message.inputs.length) { + object.inputs = []; + for (var j = 0; j < message.inputs.length; ++j) + object.inputs[j] = $root.google.cloud.aiplatform.v1beta1.Tensor.toObject(message.inputs[j], options); + } + if (message.parameters != null && message.hasOwnProperty("parameters")) + object.parameters = $root.google.cloud.aiplatform.v1beta1.Tensor.toObject(message.parameters, options); + return object; + }; + + /** + * Converts this StreamDirectPredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @instance + * @returns {Object.} JSON object + */ + StreamDirectPredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectPredictRequest + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectPredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest"; + }; + + return StreamDirectPredictRequest; + })(); + + v1beta1.StreamDirectPredictResponse = (function() { + + /** + * Properties of a StreamDirectPredictResponse. + * @memberof google.cloud.aiplatform.v1beta1 + * @interface IStreamDirectPredictResponse + * @property {Array.|null} [outputs] StreamDirectPredictResponse outputs + * @property {google.cloud.aiplatform.v1beta1.ITensor|null} [parameters] StreamDirectPredictResponse parameters + */ + + /** + * Constructs a new StreamDirectPredictResponse. + * @memberof google.cloud.aiplatform.v1beta1 + * @classdesc Represents a StreamDirectPredictResponse. + * @implements IStreamDirectPredictResponse + * @constructor + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse=} [properties] Properties to set + */ + function StreamDirectPredictResponse(properties) { + this.outputs = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamDirectPredictResponse outputs. + * @member {Array.} outputs + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @instance + */ + StreamDirectPredictResponse.prototype.outputs = $util.emptyArray; + + /** + * StreamDirectPredictResponse parameters. + * @member {google.cloud.aiplatform.v1beta1.ITensor|null|undefined} parameters + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @instance + */ + StreamDirectPredictResponse.prototype.parameters = null; + + /** + * Creates a new StreamDirectPredictResponse instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse} StreamDirectPredictResponse instance + */ + StreamDirectPredictResponse.create = function create(properties) { + return new StreamDirectPredictResponse(properties); + }; + + /** + * Encodes the specified StreamDirectPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse} message StreamDirectPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectPredictResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.outputs != null && message.outputs.length) + for (var i = 0; i < message.outputs.length; ++i) + $root.google.cloud.aiplatform.v1beta1.Tensor.encode(message.outputs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.parameters != null && Object.hasOwnProperty.call(message, "parameters")) + $root.google.cloud.aiplatform.v1beta1.Tensor.encode(message.parameters, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamDirectPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectPredictResponse} message StreamDirectPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectPredictResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse} StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectPredictResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.outputs && message.outputs.length)) + message.outputs = []; + message.outputs.push($root.google.cloud.aiplatform.v1beta1.Tensor.decode(reader, reader.uint32())); + break; + } + case 2: { + message.parameters = $root.google.cloud.aiplatform.v1beta1.Tensor.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectPredictResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse} StreamDirectPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectPredictResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectPredictResponse message. + * @function verify + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectPredictResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.outputs != null && message.hasOwnProperty("outputs")) { + if (!Array.isArray(message.outputs)) + return "outputs: array expected"; + for (var i = 0; i < message.outputs.length; ++i) { + var error = $root.google.cloud.aiplatform.v1beta1.Tensor.verify(message.outputs[i]); + if (error) + return "outputs." + error; + } + } + if (message.parameters != null && message.hasOwnProperty("parameters")) { + var error = $root.google.cloud.aiplatform.v1beta1.Tensor.verify(message.parameters); + if (error) + return "parameters." + error; + } + return null; + }; + + /** + * Creates a StreamDirectPredictResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse} StreamDirectPredictResponse + */ + StreamDirectPredictResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse) + return object; + var message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse(); + if (object.outputs) { + if (!Array.isArray(object.outputs)) + throw TypeError(".google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse.outputs: array expected"); + message.outputs = []; + for (var i = 0; i < object.outputs.length; ++i) { + if (typeof object.outputs[i] !== "object") + throw TypeError(".google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse.outputs: object expected"); + message.outputs[i] = $root.google.cloud.aiplatform.v1beta1.Tensor.fromObject(object.outputs[i]); + } + } + if (object.parameters != null) { + if (typeof object.parameters !== "object") + throw TypeError(".google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse.parameters: object expected"); + message.parameters = $root.google.cloud.aiplatform.v1beta1.Tensor.fromObject(object.parameters); + } + return message; + }; + + /** + * Creates a plain object from a StreamDirectPredictResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse} message StreamDirectPredictResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectPredictResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.outputs = []; + if (options.defaults) + object.parameters = null; + if (message.outputs && message.outputs.length) { + object.outputs = []; + for (var j = 0; j < message.outputs.length; ++j) + object.outputs[j] = $root.google.cloud.aiplatform.v1beta1.Tensor.toObject(message.outputs[j], options); + } + if (message.parameters != null && message.hasOwnProperty("parameters")) + object.parameters = $root.google.cloud.aiplatform.v1beta1.Tensor.toObject(message.parameters, options); + return object; + }; + + /** + * Converts this StreamDirectPredictResponse to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @instance + * @returns {Object.} JSON object + */ + StreamDirectPredictResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectPredictResponse + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectPredictResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse"; + }; + + return StreamDirectPredictResponse; + })(); + + v1beta1.StreamDirectRawPredictRequest = (function() { + + /** + * Properties of a StreamDirectRawPredictRequest. + * @memberof google.cloud.aiplatform.v1beta1 + * @interface IStreamDirectRawPredictRequest + * @property {string|null} [endpoint] StreamDirectRawPredictRequest endpoint + * @property {string|null} [methodName] StreamDirectRawPredictRequest methodName + * @property {Uint8Array|null} [input] StreamDirectRawPredictRequest input + */ + + /** + * Constructs a new StreamDirectRawPredictRequest. + * @memberof google.cloud.aiplatform.v1beta1 + * @classdesc Represents a StreamDirectRawPredictRequest. + * @implements IStreamDirectRawPredictRequest + * @constructor + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest=} [properties] Properties to set + */ + function StreamDirectRawPredictRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamDirectRawPredictRequest endpoint. + * @member {string} endpoint + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @instance + */ + StreamDirectRawPredictRequest.prototype.endpoint = ""; + + /** + * StreamDirectRawPredictRequest methodName. + * @member {string} methodName + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @instance + */ + StreamDirectRawPredictRequest.prototype.methodName = ""; + + /** + * StreamDirectRawPredictRequest input. + * @member {Uint8Array} input + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @instance + */ + StreamDirectRawPredictRequest.prototype.input = $util.newBuffer([]); + + /** + * Creates a new StreamDirectRawPredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest instance + */ + StreamDirectRawPredictRequest.create = function create(properties) { + return new StreamDirectRawPredictRequest(properties); + }; + + /** + * Encodes the specified StreamDirectRawPredictRequest message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest} message StreamDirectRawPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.endpoint != null && Object.hasOwnProperty.call(message, "endpoint")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.endpoint); + if (message.methodName != null && Object.hasOwnProperty.call(message, "methodName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.methodName); + if (message.input != null && Object.hasOwnProperty.call(message, "input")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.input); + return writer; + }; + + /** + * Encodes the specified StreamDirectRawPredictRequest message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictRequest} message StreamDirectRawPredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.endpoint = reader.string(); + break; + } + case 2: { + message.methodName = reader.string(); + break; + } + case 3: { + message.input = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectRawPredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectRawPredictRequest message. + * @function verify + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectRawPredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + if (!$util.isString(message.endpoint)) + return "endpoint: string expected"; + if (message.methodName != null && message.hasOwnProperty("methodName")) + if (!$util.isString(message.methodName)) + return "methodName: string expected"; + if (message.input != null && message.hasOwnProperty("input")) + if (!(message.input && typeof message.input.length === "number" || $util.isString(message.input))) + return "input: buffer expected"; + return null; + }; + + /** + * Creates a StreamDirectRawPredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest} StreamDirectRawPredictRequest + */ + StreamDirectRawPredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest) + return object; + var message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest(); + if (object.endpoint != null) + message.endpoint = String(object.endpoint); + if (object.methodName != null) + message.methodName = String(object.methodName); + if (object.input != null) + if (typeof object.input === "string") + $util.base64.decode(object.input, message.input = $util.newBuffer($util.base64.length(object.input)), 0); + else if (object.input.length >= 0) + message.input = object.input; + return message; + }; + + /** + * Creates a plain object from a StreamDirectRawPredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest} message StreamDirectRawPredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectRawPredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.endpoint = ""; + object.methodName = ""; + if (options.bytes === String) + object.input = ""; + else { + object.input = []; + if (options.bytes !== Array) + object.input = $util.newBuffer(object.input); + } + } + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + object.endpoint = message.endpoint; + if (message.methodName != null && message.hasOwnProperty("methodName")) + object.methodName = message.methodName; + if (message.input != null && message.hasOwnProperty("input")) + object.input = options.bytes === String ? $util.base64.encode(message.input, 0, message.input.length) : options.bytes === Array ? Array.prototype.slice.call(message.input) : message.input; + return object; + }; + + /** + * Converts this StreamDirectRawPredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @instance + * @returns {Object.} JSON object + */ + StreamDirectRawPredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectRawPredictRequest + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectRawPredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest"; + }; + + return StreamDirectRawPredictRequest; + })(); + + v1beta1.StreamDirectRawPredictResponse = (function() { + + /** + * Properties of a StreamDirectRawPredictResponse. + * @memberof google.cloud.aiplatform.v1beta1 + * @interface IStreamDirectRawPredictResponse + * @property {Uint8Array|null} [output] StreamDirectRawPredictResponse output + */ + + /** + * Constructs a new StreamDirectRawPredictResponse. + * @memberof google.cloud.aiplatform.v1beta1 + * @classdesc Represents a StreamDirectRawPredictResponse. + * @implements IStreamDirectRawPredictResponse + * @constructor + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse=} [properties] Properties to set + */ + function StreamDirectRawPredictResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StreamDirectRawPredictResponse output. + * @member {Uint8Array} output + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @instance + */ + StreamDirectRawPredictResponse.prototype.output = $util.newBuffer([]); + + /** + * Creates a new StreamDirectRawPredictResponse instance using the specified properties. + * @function create + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse=} [properties] Properties to set + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse instance + */ + StreamDirectRawPredictResponse.create = function create(properties) { + return new StreamDirectRawPredictResponse(properties); + }; + + /** + * Encodes the specified StreamDirectRawPredictResponse message. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse} message StreamDirectRawPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.output != null && Object.hasOwnProperty.call(message, "output")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.output); + return writer; + }; + + /** + * Encodes the specified StreamDirectRawPredictResponse message, length delimited. Does not implicitly {@link google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.IStreamDirectRawPredictResponse} message StreamDirectRawPredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamDirectRawPredictResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.output = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamDirectRawPredictResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamDirectRawPredictResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamDirectRawPredictResponse message. + * @function verify + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamDirectRawPredictResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.output != null && message.hasOwnProperty("output")) + if (!(message.output && typeof message.output.length === "number" || $util.isString(message.output))) + return "output: buffer expected"; + return null; + }; + + /** + * Creates a StreamDirectRawPredictResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse} StreamDirectRawPredictResponse + */ + StreamDirectRawPredictResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse) + return object; + var message = new $root.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse(); + if (object.output != null) + if (typeof object.output === "string") + $util.base64.decode(object.output, message.output = $util.newBuffer($util.base64.length(object.output)), 0); + else if (object.output.length >= 0) + message.output = object.output; + return message; + }; + + /** + * Creates a plain object from a StreamDirectRawPredictResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse} message StreamDirectRawPredictResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StreamDirectRawPredictResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.output = ""; + else { + object.output = []; + if (options.bytes !== Array) + object.output = $util.newBuffer(object.output); + } + if (message.output != null && message.hasOwnProperty("output")) + object.output = options.bytes === String ? $util.base64.encode(message.output, 0, message.output.length) : options.bytes === Array ? Array.prototype.slice.call(message.output) : message.output; + return object; + }; + + /** + * Converts this StreamDirectRawPredictResponse to JSON. + * @function toJSON + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @instance + * @returns {Object.} JSON object + */ + StreamDirectRawPredictResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StreamDirectRawPredictResponse + * @function getTypeUrl + * @memberof google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StreamDirectRawPredictResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse"; + }; + + return StreamDirectRawPredictResponse; + })(); + v1beta1.StreamingPredictRequest = (function() { /** diff --git a/packages/google-cloud-aiplatform/protos/protos.json b/packages/google-cloud-aiplatform/protos/protos.json index 5e1073ea1fe..a5d739ff5ae 100644 --- a/packages/google-cloud-aiplatform/protos/protos.json +++ b/packages/google-cloud-aiplatform/protos/protos.json @@ -14367,6 +14367,33 @@ } ] }, + "StreamRawPredict": { + "requestType": "StreamRawPredictRequest", + "responseType": "google.api.HttpBody", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{endpoint=projects/*/locations/*/endpoints/*}:streamRawPredict", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{endpoint=projects/*/locations/*/publishers/*/models/*}:streamRawPredict", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "endpoint,http_body" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{endpoint=projects/*/locations/*/endpoints/*}:streamRawPredict", + "body": "*", + "additional_bindings": { + "post": "/v1/{endpoint=projects/*/locations/*/publishers/*/models/*}:streamRawPredict", + "body": "*" + } + } + }, + { + "(google.api.method_signature)": "endpoint,http_body" + } + ] + }, "DirectPredict": { "requestType": "DirectPredictRequest", "responseType": "DirectPredictResponse", @@ -14399,6 +14426,18 @@ } ] }, + "StreamDirectPredict": { + "requestType": "StreamDirectPredictRequest", + "requestStream": true, + "responseType": "StreamDirectPredictResponse", + "responseStream": true + }, + "StreamDirectRawPredict": { + "requestType": "StreamDirectRawPredictRequest", + "requestStream": true, + "responseType": "StreamDirectRawPredictResponse", + "responseStream": true + }, "StreamingPredict": { "requestType": "StreamingPredictRequest", "requestStream": true, @@ -14454,6 +14493,32 @@ } ] }, + "GenerateContent": { + "requestType": "GenerateContentRequest", + "responseType": "GenerateContentResponse", + "options": { + "(google.api.http).post": "/v1/{model=projects/*/locations/*/endpoints/*}:generateContent", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "model,contents" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{model=projects/*/locations/*/endpoints/*}:generateContent", + "body": "*", + "additional_bindings": { + "post": "/v1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent", + "body": "*" + } + } + }, + { + "(google.api.method_signature)": "model,contents" + } + ] + }, "StreamGenerateContent": { "requestType": "GenerateContentRequest", "responseType": "GenerateContentResponse", @@ -14565,6 +14630,22 @@ } } }, + "StreamRawPredictRequest": { + "fields": { + "endpoint": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "aiplatform.googleapis.com/Endpoint" + } + }, + "httpBody": { + "type": "google.api.HttpBody", + "id": 2 + } + } + }, "DirectPredictRequest": { "fields": { "endpoint": { @@ -14627,6 +14708,80 @@ } } }, + "StreamDirectPredictRequest": { + "fields": { + "endpoint": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "aiplatform.googleapis.com/Endpoint" + } + }, + "inputs": { + "rule": "repeated", + "type": "Tensor", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "parameters": { + "type": "Tensor", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "StreamDirectPredictResponse": { + "fields": { + "outputs": { + "rule": "repeated", + "type": "Tensor", + "id": 1 + }, + "parameters": { + "type": "Tensor", + "id": 2 + } + } + }, + "StreamDirectRawPredictRequest": { + "fields": { + "endpoint": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "aiplatform.googleapis.com/Endpoint" + } + }, + "methodName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "input": { + "type": "bytes", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "StreamDirectRawPredictResponse": { + "fields": { + "output": { + "type": "bytes", + "id": 1 + } + } + }, "StreamingPredictRequest": { "fields": { "endpoint": { @@ -38973,6 +39128,18 @@ } ] }, + "StreamDirectPredict": { + "requestType": "StreamDirectPredictRequest", + "requestStream": true, + "responseType": "StreamDirectPredictResponse", + "responseStream": true + }, + "StreamDirectRawPredict": { + "requestType": "StreamDirectRawPredictRequest", + "requestStream": true, + "responseType": "StreamDirectRawPredictResponse", + "responseStream": true + }, "StreamingPredict": { "requestType": "StreamingPredictRequest", "requestStream": true, @@ -39054,6 +39221,32 @@ } ] }, + "GenerateContent": { + "requestType": "GenerateContentRequest", + "responseType": "GenerateContentResponse", + "options": { + "(google.api.http).post": "/v1beta1/{model=projects/*/locations/*/endpoints/*}:generateContent", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1beta1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "model,contents" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{model=projects/*/locations/*/endpoints/*}:generateContent", + "body": "*", + "additional_bindings": { + "post": "/v1beta1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent", + "body": "*" + } + } + }, + { + "(google.api.method_signature)": "model,contents" + } + ] + }, "StreamGenerateContent": { "requestType": "GenerateContentRequest", "responseType": "GenerateContentResponse", @@ -39227,6 +39420,80 @@ } } }, + "StreamDirectPredictRequest": { + "fields": { + "endpoint": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "aiplatform.googleapis.com/Endpoint" + } + }, + "inputs": { + "rule": "repeated", + "type": "Tensor", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "parameters": { + "type": "Tensor", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "StreamDirectPredictResponse": { + "fields": { + "outputs": { + "rule": "repeated", + "type": "Tensor", + "id": 1 + }, + "parameters": { + "type": "Tensor", + "id": 2 + } + } + }, + "StreamDirectRawPredictRequest": { + "fields": { + "endpoint": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "aiplatform.googleapis.com/Endpoint" + } + }, + "methodName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "input": { + "type": "bytes", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "StreamDirectRawPredictResponse": { + "fields": { + "output": { + "type": "bytes", + "id": 1 + } + } + }, "StreamingPredictRequest": { "fields": { "endpoint": { diff --git a/packages/google-cloud-aiplatform/samples/README.md b/packages/google-cloud-aiplatform/samples/README.md index 5de8df398bd..eb586aa77ff 100644 --- a/packages/google-cloud-aiplatform/samples/README.md +++ b/packages/google-cloud-aiplatform/samples/README.md @@ -211,10 +211,14 @@ * [Prediction_service.direct_predict](#prediction_service.direct_predict) * [Prediction_service.direct_raw_predict](#prediction_service.direct_raw_predict) * [Prediction_service.explain](#prediction_service.explain) + * [Prediction_service.generate_content](#prediction_service.generate_content) * [Prediction_service.predict](#prediction_service.predict) * [Prediction_service.raw_predict](#prediction_service.raw_predict) * [Prediction_service.server_streaming_predict](#prediction_service.server_streaming_predict) + * [Prediction_service.stream_direct_predict](#prediction_service.stream_direct_predict) + * [Prediction_service.stream_direct_raw_predict](#prediction_service.stream_direct_raw_predict) * [Prediction_service.stream_generate_content](#prediction_service.stream_generate_content) + * [Prediction_service.stream_raw_predict](#prediction_service.stream_raw_predict) * [Prediction_service.streaming_predict](#prediction_service.streaming_predict) * [Prediction_service.streaming_raw_predict](#prediction_service.streaming_raw_predict) * [Schedule_service.create_schedule](#schedule_service.create_schedule) @@ -482,9 +486,12 @@ * [Prediction_service.direct_predict](#prediction_service.direct_predict) * [Prediction_service.direct_raw_predict](#prediction_service.direct_raw_predict) * [Prediction_service.explain](#prediction_service.explain) + * [Prediction_service.generate_content](#prediction_service.generate_content) * [Prediction_service.predict](#prediction_service.predict) * [Prediction_service.raw_predict](#prediction_service.raw_predict) * [Prediction_service.server_streaming_predict](#prediction_service.server_streaming_predict) + * [Prediction_service.stream_direct_predict](#prediction_service.stream_direct_predict) + * [Prediction_service.stream_direct_raw_predict](#prediction_service.stream_direct_raw_predict) * [Prediction_service.stream_generate_content](#prediction_service.stream_generate_content) * [Prediction_service.streaming_predict](#prediction_service.streaming_predict) * [Prediction_service.streaming_raw_predict](#prediction_service.streaming_raw_predict) @@ -3945,6 +3952,23 @@ __Usage:__ +### Prediction_service.generate_content + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js` + + +----- + + + + ### Prediction_service.predict View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.predict.js). @@ -3996,6 +4020,40 @@ __Usage:__ +### Prediction_service.stream_direct_predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js` + + +----- + + + + +### Prediction_service.stream_direct_raw_predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js` + + +----- + + + + ### Prediction_service.stream_generate_content View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_generate_content.js). @@ -4013,6 +4071,23 @@ __Usage:__ +### Prediction_service.stream_raw_predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js` + + +----- + + + + ### Prediction_service.streaming_predict View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.streaming_predict.js). @@ -8552,6 +8627,23 @@ __Usage:__ +### Prediction_service.generate_content + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js` + + +----- + + + + ### Prediction_service.predict View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.predict.js). @@ -8603,6 +8695,40 @@ __Usage:__ +### Prediction_service.stream_direct_predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js` + + +----- + + + + +### Prediction_service.stream_direct_raw_predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js` + + +----- + + + + ### Prediction_service.stream_generate_content View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_generate_content.js). diff --git a/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js new file mode 100644 index 00000000000..9256d5e775a --- /dev/null +++ b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.generate_content.js @@ -0,0 +1,89 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(model, contents) { + // [START aiplatform_v1_generated_PredictionService_GenerateContent_async] + /** + * 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. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the publisher model requested to serve the + * prediction. Format: + * `projects/{project}/locations/{location}/publishers/* /models/*` + */ + // const model = 'abc123' + /** + * 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. + */ + // const contents = [1,2,3,4] + /** + * Optional. A list of `Tools` the model may use to generate the next + * response. + * A `Tool` is a piece of code that enables the system to interact with + * external systems to perform an action, or set of actions, outside of + * knowledge and scope of the model. The only supported tool is currently + * `Function` + */ + // const tools = [1,2,3,4] + /** + * Optional. Per request settings for blocking unsafe content. + * Enforced on GenerateContentResponse.candidates. + */ + // const safetySettings = [1,2,3,4] + /** + * Optional. Generation config. + */ + // const generationConfig = {} + + // Imports the Aiplatform library + const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1; + + // Instantiates a client + const aiplatformClient = new PredictionServiceClient(); + + async function callGenerateContent() { + // Construct request + const request = { + model, + contents, + }; + + // Run request + const response = await aiplatformClient.generateContent(request); + console.log(response); + } + + callGenerateContent(); + // [END aiplatform_v1_generated_PredictionService_GenerateContent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js new file mode 100644 index 00000000000..d0b7dbb6713 --- /dev/null +++ b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_predict.js @@ -0,0 +1,75 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(endpoint) { + // [START aiplatform_v1_generated_PredictionService_StreamDirectPredict_async] + /** + * 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. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Endpoint requested to serve the prediction. + * Format: + * `projects/{project}/locations/{location}/endpoints/{endpoint}` + */ + // const endpoint = 'abc123' + /** + * Optional. The prediction input. + */ + // const inputs = [1,2,3,4] + /** + * Optional. The parameters that govern the prediction. + */ + // const parameters = {} + + // Imports the Aiplatform library + const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1; + + // Instantiates a client + const aiplatformClient = new PredictionServiceClient(); + + async function callStreamDirectPredict() { + // Construct request + const request = { + endpoint, + }; + + // Run request + const stream = await aiplatformClient.streamDirectPredict(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamDirectPredict(); + // [END aiplatform_v1_generated_PredictionService_StreamDirectPredict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js new file mode 100644 index 00000000000..0ef25146283 --- /dev/null +++ b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_direct_raw_predict.js @@ -0,0 +1,80 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(endpoint) { + // [START aiplatform_v1_generated_PredictionService_StreamDirectRawPredict_async] + /** + * 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. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Endpoint requested to serve the prediction. + * Format: + * `projects/{project}/locations/{location}/endpoints/{endpoint}` + */ + // const endpoint = 'abc123' + /** + * Optional. Fully qualified name of the API method being invoked to perform + * predictions. + * Format: + * `/namespace.Service/Method/` + * Example: + * `/tensorflow.serving.PredictionService/Predict` + */ + // const methodName = 'abc123' + /** + * Optional. The prediction input. + */ + // const input = Buffer.from('string') + + // Imports the Aiplatform library + const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1; + + // Instantiates a client + const aiplatformClient = new PredictionServiceClient(); + + async function callStreamDirectRawPredict() { + // Construct request + const request = { + endpoint, + }; + + // Run request + const stream = await aiplatformClient.streamDirectRawPredict(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamDirectRawPredict(); + // [END aiplatform_v1_generated_PredictionService_StreamDirectRawPredict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js new file mode 100644 index 00000000000..3dec2a96766 --- /dev/null +++ b/packages/google-cloud-aiplatform/samples/generated/v1/prediction_service.stream_raw_predict.js @@ -0,0 +1,69 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(endpoint) { + // [START aiplatform_v1_generated_PredictionService_StreamRawPredict_async] + /** + * 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. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Endpoint requested to serve the prediction. + * Format: + * `projects/{project}/locations/{location}/endpoints/{endpoint}` + */ + // const endpoint = 'abc123' + /** + * The prediction input. Supports HTTP headers and arbitrary data payload. + */ + // const httpBody = {} + + // Imports the Aiplatform library + const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1; + + // Instantiates a client + const aiplatformClient = new PredictionServiceClient(); + + async function callStreamRawPredict() { + // Construct request + const request = { + endpoint, + }; + + // Run request + const stream = await aiplatformClient.streamRawPredict(request); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + } + + callStreamRawPredict(); + // [END aiplatform_v1_generated_PredictionService_StreamRawPredict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-aiplatform/samples/generated/v1/snippet_metadata_google.cloud.aiplatform.v1.json b/packages/google-cloud-aiplatform/samples/generated/v1/snippet_metadata_google.cloud.aiplatform.v1.json index 672b2ebb4d9..d2f43c1ce07 100644 --- a/packages/google-cloud-aiplatform/samples/generated/v1/snippet_metadata_google.cloud.aiplatform.v1.json +++ b/packages/google-cloud-aiplatform/samples/generated/v1/snippet_metadata_google.cloud.aiplatform.v1.json @@ -9271,11 +9271,55 @@ } } }, + { + "regionTag": "aiplatform_v1_generated_PredictionService_StreamRawPredict_async", + "title": "DatasetService streamRawPredict Sample", + "origin": "API_DEFINITION", + "description": " Perform a streaming online prediction with an arbitrary HTTP payload.", + "canonical": true, + "file": "prediction_service.stream_raw_predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamRawPredict", + "fullName": "google.cloud.aiplatform.v1.PredictionService.StreamRawPredict", + "async": true, + "parameters": [ + { + "name": "endpoint", + "type": "TYPE_STRING" + }, + { + "name": "http_body", + "type": ".google.api.HttpBody" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.aiplatform.v1.PredictionServiceClient" + }, + "method": { + "shortName": "StreamRawPredict", + "fullName": "google.cloud.aiplatform.v1.PredictionService.StreamRawPredict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.aiplatform.v1.PredictionService" + } + } + } + }, { "regionTag": "aiplatform_v1_generated_PredictionService_DirectPredict_async", "title": "DatasetService directPredict Sample", "origin": "API_DEFINITION", - "description": " Perform an unary online prediction request for Vertex first-party products and frameworks.", + "description": " Perform an unary online prediction request to a gRPC model server for Vertex first-party products and frameworks.", "canonical": true, "file": "prediction_service.direct_predict.js", "language": "JAVASCRIPT", @@ -9323,7 +9367,7 @@ "regionTag": "aiplatform_v1_generated_PredictionService_DirectRawPredict_async", "title": "DatasetService directRawPredict Sample", "origin": "API_DEFINITION", - "description": " Perform an online prediction request through gRPC.", + "description": " Perform an unary online prediction request to a gRPC model server for custom containers.", "canonical": true, "file": "prediction_service.direct_raw_predict.js", "language": "JAVASCRIPT", @@ -9367,6 +9411,102 @@ } } }, + { + "regionTag": "aiplatform_v1_generated_PredictionService_StreamDirectPredict_async", + "title": "DatasetService streamDirectPredict Sample", + "origin": "API_DEFINITION", + "description": " Perform a streaming online prediction request to a gRPC model server for Vertex first-party products and frameworks.", + "canonical": true, + "file": "prediction_service.stream_direct_predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamDirectPredict", + "fullName": "google.cloud.aiplatform.v1.PredictionService.StreamDirectPredict", + "async": true, + "parameters": [ + { + "name": "endpoint", + "type": "TYPE_STRING" + }, + { + "name": "inputs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parameters", + "type": ".google.cloud.aiplatform.v1.Tensor" + } + ], + "resultType": ".google.cloud.aiplatform.v1.StreamDirectPredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.aiplatform.v1.PredictionServiceClient" + }, + "method": { + "shortName": "StreamDirectPredict", + "fullName": "google.cloud.aiplatform.v1.PredictionService.StreamDirectPredict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.aiplatform.v1.PredictionService" + } + } + } + }, + { + "regionTag": "aiplatform_v1_generated_PredictionService_StreamDirectRawPredict_async", + "title": "DatasetService streamDirectRawPredict Sample", + "origin": "API_DEFINITION", + "description": " Perform a streaming online prediction request to a gRPC model server for custom containers.", + "canonical": true, + "file": "prediction_service.stream_direct_raw_predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamDirectRawPredict", + "fullName": "google.cloud.aiplatform.v1.PredictionService.StreamDirectRawPredict", + "async": true, + "parameters": [ + { + "name": "endpoint", + "type": "TYPE_STRING" + }, + { + "name": "method_name", + "type": "TYPE_STRING" + }, + { + "name": "input", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.cloud.aiplatform.v1.StreamDirectRawPredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.aiplatform.v1.PredictionServiceClient" + }, + "method": { + "shortName": "StreamDirectRawPredict", + "fullName": "google.cloud.aiplatform.v1.PredictionService.StreamDirectRawPredict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.aiplatform.v1.PredictionService" + } + } + } + }, { "regionTag": "aiplatform_v1_generated_PredictionService_StreamingPredict_async", "title": "DatasetService streamingPredict Sample", @@ -9567,6 +9707,62 @@ } } }, + { + "regionTag": "aiplatform_v1_generated_PredictionService_GenerateContent_async", + "title": "DatasetService generateContent Sample", + "origin": "API_DEFINITION", + "description": " Generate content with multimodal inputs.", + "canonical": true, + "file": "prediction_service.generate_content.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GenerateContent", + "fullName": "google.cloud.aiplatform.v1.PredictionService.GenerateContent", + "async": true, + "parameters": [ + { + "name": "model", + "type": "TYPE_STRING" + }, + { + "name": "contents", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "tools", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "safety_settings", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "generation_config", + "type": ".google.cloud.aiplatform.v1.GenerationConfig" + } + ], + "resultType": ".google.cloud.aiplatform.v1.GenerateContentResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.aiplatform.v1.PredictionServiceClient" + }, + "method": { + "shortName": "GenerateContent", + "fullName": "google.cloud.aiplatform.v1.PredictionService.GenerateContent", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.aiplatform.v1.PredictionService" + } + } + } + }, { "regionTag": "aiplatform_v1_generated_PredictionService_StreamGenerateContent_async", "title": "DatasetService streamGenerateContent Sample", diff --git a/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js b/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js new file mode 100644 index 00000000000..a742a9c1914 --- /dev/null +++ b/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.generate_content.js @@ -0,0 +1,89 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(model, contents) { + // [START aiplatform_v1beta1_generated_PredictionService_GenerateContent_async] + /** + * 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. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the publisher model requested to serve the + * prediction. Format: + * `projects/{project}/locations/{location}/publishers/* /models/*` + */ + // const model = 'abc123' + /** + * 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. + */ + // const contents = [1,2,3,4] + /** + * Optional. A list of `Tools` the model may use to generate the next + * response. + * A `Tool` is a piece of code that enables the system to interact with + * external systems to perform an action, or set of actions, outside of + * knowledge and scope of the model. The only supported tool is currently + * `Function` + */ + // const tools = [1,2,3,4] + /** + * Optional. Per request settings for blocking unsafe content. + * Enforced on GenerateContentResponse.candidates. + */ + // const safetySettings = [1,2,3,4] + /** + * Optional. Generation config. + */ + // const generationConfig = {} + + // Imports the Aiplatform library + const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1beta1; + + // Instantiates a client + const aiplatformClient = new PredictionServiceClient(); + + async function callGenerateContent() { + // Construct request + const request = { + model, + contents, + }; + + // Run request + const response = await aiplatformClient.generateContent(request); + console.log(response); + } + + callGenerateContent(); + // [END aiplatform_v1beta1_generated_PredictionService_GenerateContent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js b/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js new file mode 100644 index 00000000000..c99e7a43ce6 --- /dev/null +++ b/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_predict.js @@ -0,0 +1,75 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(endpoint) { + // [START aiplatform_v1beta1_generated_PredictionService_StreamDirectPredict_async] + /** + * 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. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Endpoint requested to serve the prediction. + * Format: + * `projects/{project}/locations/{location}/endpoints/{endpoint}` + */ + // const endpoint = 'abc123' + /** + * Optional. The prediction input. + */ + // const inputs = [1,2,3,4] + /** + * Optional. The parameters that govern the prediction. + */ + // const parameters = {} + + // Imports the Aiplatform library + const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1beta1; + + // Instantiates a client + const aiplatformClient = new PredictionServiceClient(); + + async function callStreamDirectPredict() { + // Construct request + const request = { + endpoint, + }; + + // Run request + const stream = await aiplatformClient.streamDirectPredict(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamDirectPredict(); + // [END aiplatform_v1beta1_generated_PredictionService_StreamDirectPredict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js b/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js new file mode 100644 index 00000000000..8982bd777c2 --- /dev/null +++ b/packages/google-cloud-aiplatform/samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js @@ -0,0 +1,80 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(endpoint) { + // [START aiplatform_v1beta1_generated_PredictionService_StreamDirectRawPredict_async] + /** + * 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. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Endpoint requested to serve the prediction. + * Format: + * `projects/{project}/locations/{location}/endpoints/{endpoint}` + */ + // const endpoint = 'abc123' + /** + * Optional. Fully qualified name of the API method being invoked to perform + * predictions. + * Format: + * `/namespace.Service/Method/` + * Example: + * `/tensorflow.serving.PredictionService/Predict` + */ + // const methodName = 'abc123' + /** + * Optional. The prediction input. + */ + // const input = Buffer.from('string') + + // Imports the Aiplatform library + const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1beta1; + + // Instantiates a client + const aiplatformClient = new PredictionServiceClient(); + + async function callStreamDirectRawPredict() { + // Construct request + const request = { + endpoint, + }; + + // Run request + const stream = await aiplatformClient.streamDirectRawPredict(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamDirectRawPredict(); + // [END aiplatform_v1beta1_generated_PredictionService_StreamDirectRawPredict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-aiplatform/samples/generated/v1beta1/snippet_metadata_google.cloud.aiplatform.v1beta1.json b/packages/google-cloud-aiplatform/samples/generated/v1beta1/snippet_metadata_google.cloud.aiplatform.v1beta1.json index 7a432109264..608b45612d9 100644 --- a/packages/google-cloud-aiplatform/samples/generated/v1beta1/snippet_metadata_google.cloud.aiplatform.v1beta1.json +++ b/packages/google-cloud-aiplatform/samples/generated/v1beta1/snippet_metadata_google.cloud.aiplatform.v1beta1.json @@ -9651,7 +9651,7 @@ "regionTag": "aiplatform_v1beta1_generated_PredictionService_DirectPredict_async", "title": "DatasetService directPredict Sample", "origin": "API_DEFINITION", - "description": " Perform an unary online prediction request for Vertex first-party products and frameworks.", + "description": " Perform an unary online prediction request to a gRPC model server for Vertex first-party products and frameworks.", "canonical": true, "file": "prediction_service.direct_predict.js", "language": "JAVASCRIPT", @@ -9699,7 +9699,7 @@ "regionTag": "aiplatform_v1beta1_generated_PredictionService_DirectRawPredict_async", "title": "DatasetService directRawPredict Sample", "origin": "API_DEFINITION", - "description": " Perform an online prediction request through gRPC.", + "description": " Perform an unary online prediction request to a gRPC model server for custom containers.", "canonical": true, "file": "prediction_service.direct_raw_predict.js", "language": "JAVASCRIPT", @@ -9743,6 +9743,102 @@ } } }, + { + "regionTag": "aiplatform_v1beta1_generated_PredictionService_StreamDirectPredict_async", + "title": "DatasetService streamDirectPredict Sample", + "origin": "API_DEFINITION", + "description": " Perform a streaming online prediction request to a gRPC model server for Vertex first-party products and frameworks.", + "canonical": true, + "file": "prediction_service.stream_direct_predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamDirectPredict", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectPredict", + "async": true, + "parameters": [ + { + "name": "endpoint", + "type": "TYPE_STRING" + }, + { + "name": "inputs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parameters", + "type": ".google.cloud.aiplatform.v1beta1.Tensor" + } + ], + "resultType": ".google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionServiceClient" + }, + "method": { + "shortName": "StreamDirectPredict", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectPredict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService" + } + } + } + }, + { + "regionTag": "aiplatform_v1beta1_generated_PredictionService_StreamDirectRawPredict_async", + "title": "DatasetService streamDirectRawPredict Sample", + "origin": "API_DEFINITION", + "description": " Perform a streaming online prediction request to a gRPC model server for custom containers.", + "canonical": true, + "file": "prediction_service.stream_direct_raw_predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamDirectRawPredict", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectRawPredict", + "async": true, + "parameters": [ + { + "name": "endpoint", + "type": "TYPE_STRING" + }, + { + "name": "method_name", + "type": "TYPE_STRING" + }, + { + "name": "input", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionServiceClient" + }, + "method": { + "shortName": "StreamDirectRawPredict", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService.StreamDirectRawPredict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService" + } + } + } + }, { "regionTag": "aiplatform_v1beta1_generated_PredictionService_StreamingPredict_async", "title": "DatasetService streamingPredict Sample", @@ -9999,6 +10095,62 @@ } } }, + { + "regionTag": "aiplatform_v1beta1_generated_PredictionService_GenerateContent_async", + "title": "DatasetService generateContent Sample", + "origin": "API_DEFINITION", + "description": " Generate content with multimodal inputs.", + "canonical": true, + "file": "prediction_service.generate_content.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GenerateContent", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService.GenerateContent", + "async": true, + "parameters": [ + { + "name": "model", + "type": "TYPE_STRING" + }, + { + "name": "contents", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "tools", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "safety_settings", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "generation_config", + "type": ".google.cloud.aiplatform.v1beta1.GenerationConfig" + } + ], + "resultType": ".google.cloud.aiplatform.v1beta1.GenerateContentResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionServiceClient" + }, + "method": { + "shortName": "GenerateContent", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService.GenerateContent", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.aiplatform.v1beta1.PredictionService" + } + } + } + }, { "regionTag": "aiplatform_v1beta1_generated_PredictionService_StreamGenerateContent_async", "title": "DatasetService streamGenerateContent Sample", diff --git a/packages/google-cloud-aiplatform/src/v1/gapic_metadata.json b/packages/google-cloud-aiplatform/src/v1/gapic_metadata.json index e671d02bc62..bba1c255960 100644 --- a/packages/google-cloud-aiplatform/src/v1/gapic_metadata.json +++ b/packages/google-cloud-aiplatform/src/v1/gapic_metadata.json @@ -2402,6 +2402,26 @@ "explain" ] }, + "GenerateContent": { + "methods": [ + "generateContent" + ] + }, + "StreamRawPredict": { + "methods": [ + "streamRawPredict" + ] + }, + "StreamDirectPredict": { + "methods": [ + "streamDirectPredict" + ] + }, + "StreamDirectRawPredict": { + "methods": [ + "streamDirectRawPredict" + ] + }, "StreamingPredict": { "methods": [ "streamingPredict" @@ -2451,6 +2471,11 @@ "methods": [ "explain" ] + }, + "GenerateContent": { + "methods": [ + "generateContent" + ] } } } diff --git a/packages/google-cloud-aiplatform/src/v1/prediction_service_client.ts b/packages/google-cloud-aiplatform/src/v1/prediction_service_client.ts index e924f9aa9a6..6b561d12973 100644 --- a/packages/google-cloud-aiplatform/src/v1/prediction_service_client.ts +++ b/packages/google-cloud-aiplatform/src/v1/prediction_service_client.ts @@ -328,6 +328,21 @@ export class PredictionServiceClient { // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this.descriptors.stream = { + streamRawPredict: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.SERVER_STREAMING, + !!opts.fallback, + /* gaxStreamingRetries: */ true + ), + streamDirectPredict: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + /* gaxStreamingRetries: */ true + ), + streamDirectRawPredict: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + /* gaxStreamingRetries: */ true + ), streamingPredict: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, @@ -402,12 +417,16 @@ export class PredictionServiceClient { const predictionServiceStubMethods = [ 'predict', 'rawPredict', + 'streamRawPredict', 'directPredict', 'directRawPredict', + 'streamDirectPredict', + 'streamDirectRawPredict', 'streamingPredict', 'serverStreamingPredict', 'streamingRawPredict', 'explain', + 'generateContent', 'streamGenerateContent', ]; for (const methodName of predictionServiceStubMethods) { @@ -717,8 +736,8 @@ export class PredictionServiceClient { return this.innerApiCalls.rawPredict(request, options, callback); } /** - * 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. * * @param {Object} request * The request object that will be sent. @@ -814,7 +833,8 @@ export class PredictionServiceClient { return this.innerApiCalls.directPredict(request, options, callback); } /** - * Perform an online prediction request through gRPC. + * Perform an unary online prediction request to a gRPC model server for + * custom containers. * * @param {Object} request * The request object that will be sent. @@ -1038,6 +1058,193 @@ export class PredictionServiceClient { this.initialize(); return this.innerApiCalls.explain(request, options, callback); } + /** + * Generate content with multimodal inputs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The name of the publisher model requested to serve the + * prediction. Format: + * `projects/{project}/locations/{location}/publishers/* /models/*` + * @param {number[]} request.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. + * @param {number[]} [request.tools] + * Optional. A list of `Tools` the model may use to generate the next + * response. + * + * A `Tool` is a piece of code that enables the system to interact with + * external systems to perform an action, or set of actions, outside of + * knowledge and scope of the model. The only supported tool is currently + * `Function` + * @param {number[]} [request.safetySettings] + * Optional. Per request settings for blocking unsafe content. + * Enforced on GenerateContentResponse.candidates. + * @param {google.cloud.aiplatform.v1.GenerationConfig} [request.generationConfig] + * Optional. Generation config. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.aiplatform.v1.GenerateContentResponse|GenerateContentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/prediction_service.generate_content.js + * region_tag:aiplatform_v1_generated_PredictionService_GenerateContent_async + */ + generateContent( + request?: protos.google.cloud.aiplatform.v1.IGenerateContentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.aiplatform.v1.IGenerateContentResponse, + protos.google.cloud.aiplatform.v1.IGenerateContentRequest | undefined, + {} | undefined, + ] + >; + generateContent( + request: protos.google.cloud.aiplatform.v1.IGenerateContentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.aiplatform.v1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + generateContent( + request: protos.google.cloud.aiplatform.v1.IGenerateContentRequest, + callback: Callback< + protos.google.cloud.aiplatform.v1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + generateContent( + request?: protos.google.cloud.aiplatform.v1.IGenerateContentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.aiplatform.v1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.aiplatform.v1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.aiplatform.v1.IGenerateContentResponse, + protos.google.cloud.aiplatform.v1.IGenerateContentRequest | undefined, + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + model: request.model ?? '', + }); + this.initialize(); + return this.innerApiCalls.generateContent(request, options, callback); + } + + /** + * Perform a streaming online prediction with an arbitrary HTTP payload. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.endpoint + * Required. The name of the Endpoint requested to serve the prediction. + * Format: + * `projects/{project}/locations/{location}/endpoints/{endpoint}` + * @param {google.api.HttpBody} request.httpBody + * The prediction input. Supports HTTP headers and arbitrary data payload. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits {@link protos.google.api.HttpBody|HttpBody} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1/prediction_service.stream_raw_predict.js + * region_tag:aiplatform_v1_generated_PredictionService_StreamRawPredict_async + */ + streamRawPredict( + request?: protos.google.cloud.aiplatform.v1.IStreamRawPredictRequest, + options?: CallOptions + ): gax.CancellableStream { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + endpoint: request.endpoint ?? '', + }); + this.initialize(); + return this.innerApiCalls.streamRawPredict(request, options); + } + + /** + * Perform a streaming online prediction request to a gRPC model server for + * Vertex first-party products and frameworks. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing {@link protos.google.cloud.aiplatform.v1.StreamDirectPredictRequest|StreamDirectPredictRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.aiplatform.v1.StreamDirectPredictResponse|StreamDirectPredictResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1/prediction_service.stream_direct_predict.js + * region_tag:aiplatform_v1_generated_PredictionService_StreamDirectPredict_async + */ + streamDirectPredict(options?: CallOptions): gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamDirectPredict(null, options); + } + + /** + * Perform a streaming online prediction request to a gRPC model server for + * custom containers. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing {@link protos.google.cloud.aiplatform.v1.StreamDirectRawPredictRequest|StreamDirectRawPredictRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse|StreamDirectRawPredictResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1/prediction_service.stream_direct_raw_predict.js + * region_tag:aiplatform_v1_generated_PredictionService_StreamDirectRawPredict_async + */ + streamDirectRawPredict(options?: CallOptions): gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamDirectRawPredict(null, options); + } /** * Perform a streaming online prediction request for Vertex first-party diff --git a/packages/google-cloud-aiplatform/src/v1/prediction_service_client_config.json b/packages/google-cloud-aiplatform/src/v1/prediction_service_client_config.json index a006537758e..c2996677314 100644 --- a/packages/google-cloud-aiplatform/src/v1/prediction_service_client_config.json +++ b/packages/google-cloud-aiplatform/src/v1/prediction_service_client_config.json @@ -28,6 +28,10 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "StreamRawPredict": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "DirectPredict": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" @@ -36,6 +40,14 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "StreamDirectPredict": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StreamDirectRawPredict": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "StreamingPredict": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" @@ -52,6 +64,10 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "GenerateContent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "StreamGenerateContent": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" diff --git a/packages/google-cloud-aiplatform/src/v1beta1/gapic_metadata.json b/packages/google-cloud-aiplatform/src/v1beta1/gapic_metadata.json index b9dc8c7d113..651733e060c 100644 --- a/packages/google-cloud-aiplatform/src/v1beta1/gapic_metadata.json +++ b/packages/google-cloud-aiplatform/src/v1beta1/gapic_metadata.json @@ -2509,6 +2509,21 @@ "countTokens" ] }, + "GenerateContent": { + "methods": [ + "generateContent" + ] + }, + "StreamDirectPredict": { + "methods": [ + "streamDirectPredict" + ] + }, + "StreamDirectRawPredict": { + "methods": [ + "streamDirectRawPredict" + ] + }, "StreamingPredict": { "methods": [ "streamingPredict" @@ -2563,6 +2578,11 @@ "methods": [ "countTokens" ] + }, + "GenerateContent": { + "methods": [ + "generateContent" + ] } } } diff --git a/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client.ts b/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client.ts index aee84594bb6..8fe73466c4c 100644 --- a/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client.ts +++ b/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client.ts @@ -331,6 +331,16 @@ export class PredictionServiceClient { // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this.descriptors.stream = { + streamDirectPredict: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + /* gaxStreamingRetries: */ true + ), + streamDirectRawPredict: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + /* gaxStreamingRetries: */ true + ), streamingPredict: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, @@ -408,11 +418,14 @@ export class PredictionServiceClient { 'rawPredict', 'directPredict', 'directRawPredict', + 'streamDirectPredict', + 'streamDirectRawPredict', 'streamingPredict', 'serverStreamingPredict', 'streamingRawPredict', 'explain', 'countTokens', + 'generateContent', 'streamGenerateContent', ]; for (const methodName of predictionServiceStubMethods) { @@ -731,8 +744,8 @@ export class PredictionServiceClient { return this.innerApiCalls.rawPredict(request, options, callback); } /** - * 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. * * @param {Object} request * The request object that will be sent. @@ -828,7 +841,8 @@ export class PredictionServiceClient { return this.innerApiCalls.directPredict(request, options, callback); } /** - * Perform an online prediction request through gRPC. + * Perform an unary online prediction request to a gRPC model server for + * custom containers. * * @param {Object} request * The request object that will be sent. @@ -1170,6 +1184,163 @@ export class PredictionServiceClient { this.initialize(); return this.innerApiCalls.countTokens(request, options, callback); } + /** + * Generate content with multimodal inputs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The name of the publisher model requested to serve the + * prediction. Format: + * `projects/{project}/locations/{location}/publishers/* /models/*` + * @param {number[]} request.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. + * @param {number[]} [request.tools] + * Optional. A list of `Tools` the model may use to generate the next + * response. + * + * A `Tool` is a piece of code that enables the system to interact with + * external systems to perform an action, or set of actions, outside of + * knowledge and scope of the model. The only supported tool is currently + * `Function` + * @param {number[]} [request.safetySettings] + * Optional. Per request settings for blocking unsafe content. + * Enforced on GenerateContentResponse.candidates. + * @param {google.cloud.aiplatform.v1beta1.GenerationConfig} [request.generationConfig] + * Optional. Generation config. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.aiplatform.v1beta1.GenerateContentResponse|GenerateContentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/prediction_service.generate_content.js + * region_tag:aiplatform_v1beta1_generated_PredictionService_GenerateContent_async + */ + generateContent( + request?: protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.aiplatform.v1beta1.IGenerateContentResponse, + ( + | protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest + | undefined + ), + {} | undefined, + ] + >; + generateContent( + request: protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.aiplatform.v1beta1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + generateContent( + request: protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest, + callback: Callback< + protos.google.cloud.aiplatform.v1beta1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + generateContent( + request?: protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.aiplatform.v1beta1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.aiplatform.v1beta1.IGenerateContentResponse, + | protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.aiplatform.v1beta1.IGenerateContentResponse, + ( + | protos.google.cloud.aiplatform.v1beta1.IGenerateContentRequest + | undefined + ), + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + model: request.model ?? '', + }); + this.initialize(); + return this.innerApiCalls.generateContent(request, options, callback); + } + + /** + * Perform a streaming online prediction request to a gRPC model server for + * Vertex first-party products and frameworks. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing {@link protos.google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest|StreamDirectPredictRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse|StreamDirectPredictResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/prediction_service.stream_direct_predict.js + * region_tag:aiplatform_v1beta1_generated_PredictionService_StreamDirectPredict_async + */ + streamDirectPredict(options?: CallOptions): gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamDirectPredict(null, options); + } + + /** + * Perform a streaming online prediction request to a gRPC model server for + * custom containers. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing {@link protos.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest|StreamDirectRawPredictRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse|StreamDirectRawPredictResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/prediction_service.stream_direct_raw_predict.js + * region_tag:aiplatform_v1beta1_generated_PredictionService_StreamDirectRawPredict_async + */ + streamDirectRawPredict(options?: CallOptions): gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamDirectRawPredict(null, options); + } /** * Perform a streaming online prediction request for Vertex first-party diff --git a/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client_config.json b/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client_config.json index 6eaf4dedf1d..6f667a6960c 100644 --- a/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client_config.json +++ b/packages/google-cloud-aiplatform/src/v1beta1/prediction_service_client_config.json @@ -37,6 +37,14 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "StreamDirectPredict": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StreamDirectRawPredict": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "StreamingPredict": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" @@ -58,6 +66,10 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "GenerateContent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "StreamGenerateContent": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" diff --git a/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1.ts b/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1.ts index fd3fa200e85..8e2384df7ab 100644 --- a/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1.ts +++ b/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1.ts @@ -865,6 +865,253 @@ describe('v1.PredictionServiceClient', () => { }); }); + describe('generateContent', () => { + it('invokes generateContent without error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.GenerateContentResponse() + ); + client.innerApiCalls.generateContent = stubSimpleCall(expectedResponse); + const [response] = await client.generateContent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateContent without error using callback', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.GenerateContentResponse() + ); + client.innerApiCalls.generateContent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateContent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.aiplatform.v1.IGenerateContentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateContent with error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateContent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.generateContent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateContent with closed client', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.generateContent(request), expectedError); + }); + }); + + describe('streamRawPredict', () => { + it('invokes streamRawPredict without error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamRawPredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1.StreamRawPredictRequest', + ['endpoint'] + ); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.streamRawPredict = + stubServerStreamingCall(expectedResponse); + const stream = client.streamRawPredict(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.api.HttpBody) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.streamRawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamRawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes streamRawPredict with error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamRawPredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1.StreamRawPredictRequest', + ['endpoint'] + ); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.streamRawPredict = stubServerStreamingCall( + undefined, + expectedError + ); + const stream = client.streamRawPredict(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.api.HttpBody) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + const actualRequest = ( + client.innerApiCalls.streamRawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamRawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes streamRawPredict with closed client', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamRawPredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1.StreamRawPredictRequest', + ['endpoint'] + ); + request.endpoint = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.streamRawPredict(request, { + retry: { + shouldRetryFn: () => { + return false; + }, + }, + }); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.api.HttpBody) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); + }); + describe('serverStreamingPredict', () => { it('invokes serverStreamingPredict without error', async () => { const client = new predictionserviceModule.v1.PredictionServiceClient({ @@ -1129,6 +1376,186 @@ describe('v1.PredictionServiceClient', () => { }); }); + describe('streamDirectPredict', () => { + it('invokes streamDirectPredict without error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamDirectPredictRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamDirectPredictResponse() + ); + client.innerApiCalls.streamDirectPredict = + stubBidiStreamingCall(expectedResponse); + const stream = client.streamDirectPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1.StreamDirectPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamDirectPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + + it('invokes streamDirectPredict with error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamDirectPredictRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamDirectPredict = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.streamDirectPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1.StreamDirectPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamDirectPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + }); + + describe('streamDirectRawPredict', () => { + it('invokes streamDirectRawPredict without error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamDirectRawPredictRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse() + ); + client.innerApiCalls.streamDirectRawPredict = + stubBidiStreamingCall(expectedResponse); + const stream = client.streamDirectRawPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamDirectRawPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + + it('invokes streamDirectRawPredict with error', async () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StreamDirectRawPredictRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamDirectRawPredict = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.streamDirectRawPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1.StreamDirectRawPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamDirectRawPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + }); + describe('streamingPredict', () => { it('invokes streamingPredict without error', async () => { const client = new predictionserviceModule.v1.PredictionServiceClient({ diff --git a/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1beta1.ts b/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1beta1.ts index 606a82eeba3..5d225f9e062 100644 --- a/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1beta1.ts +++ b/packages/google-cloud-aiplatform/test/gapic_prediction_service_v1beta1.ts @@ -1026,6 +1026,140 @@ describe('v1beta1.PredictionServiceClient', () => { }); }); + describe('generateContent', () => { + it('invokes generateContent without error', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1beta1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.GenerateContentResponse() + ); + client.innerApiCalls.generateContent = stubSimpleCall(expectedResponse); + const [response] = await client.generateContent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateContent without error using callback', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1beta1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.GenerateContentResponse() + ); + client.innerApiCalls.generateContent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateContent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.aiplatform.v1beta1.IGenerateContentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateContent with error', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1beta1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateContent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.generateContent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateContent with closed client', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.GenerateContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.aiplatform.v1beta1.GenerateContentRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.generateContent(request), expectedError); + }); + }); + describe('serverStreamingPredict', () => { it('invokes serverStreamingPredict without error', async () => { const client = @@ -1296,6 +1430,190 @@ describe('v1beta1.PredictionServiceClient', () => { }); }); + describe('streamDirectPredict', () => { + it('invokes streamDirectPredict without error', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse() + ); + client.innerApiCalls.streamDirectPredict = + stubBidiStreamingCall(expectedResponse); + const stream = client.streamDirectPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamDirectPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + + it('invokes streamDirectPredict with error', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.StreamDirectPredictRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamDirectPredict = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.streamDirectPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1beta1.StreamDirectPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamDirectPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + }); + + describe('streamDirectRawPredict', () => { + it('invokes streamDirectRawPredict without error', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse() + ); + client.innerApiCalls.streamDirectRawPredict = + stubBidiStreamingCall(expectedResponse); + const stream = client.streamDirectRawPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamDirectRawPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + + it('invokes streamDirectRawPredict with error', async () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamDirectRawPredict = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.streamDirectRawPredict(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.aiplatform.v1beta1.StreamDirectRawPredictResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamDirectRawPredict as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + }); + describe('streamingPredict', () => { it('invokes streamingPredict without error', async () => { const client =