Skip to content

Commit

Permalink
feat: [aiplatform] Add generateContent Unary API for aiplatform_v1 (#…
Browse files Browse the repository at this point in the history
…10319)

* feat: Add generateContent Unary API for aiplatform_v1beta1
docs: Update comment for DirectPredict and DirectRawPredict

PiperOrigin-RevId: 603497761

Source-Link: googleapis/googleapis@4f5f442

Source-Link: https://github.com/googleapis/googleapis-gen/commit/f1d6d8b375f1dbf6d5df26bcae3bf0c8b8cfddf7
Copy-Tag: eyJwIjoiamF2YS1haXBsYXRmb3JtLy5Pd2xCb3QueWFtbCIsImgiOiJmMWQ2ZDhiMzc1ZjFkYmY2ZDVkZjI2YmNhZTNiZjBjOGI4Y2ZkZGY3In0=

* 🦉 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

* feat: Add generateContent Unary API for aiplatform_v1
docs: Update comment for DirectPredict and DirectRawPredict

PiperOrigin-RevId: 603498510

Source-Link: googleapis/googleapis@49815f4

Source-Link: https://github.com/googleapis/googleapis-gen/commit/893e2e072e7aa54f3fb0425a3c2da9a2668c701b
Copy-Tag: eyJwIjoiamF2YS1haXBsYXRmb3JtLy5Pd2xCb3QueWFtbCIsImgiOiI4OTNlMmUwNzJlN2FhNTRmM2ZiMDQyNWEzYzJkYTlhMjY2OGM3MDFiIn0=

* 🦉 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 <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Feb 2, 2024
1 parent f14c131 commit 08700f2
Show file tree
Hide file tree
Showing 53 changed files with 14,338 additions and 347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,18 @@
* </td>
* </tr>
* <tr>
* <td><p> StreamRawPredict</td>
* <td><p> Perform a streaming online prediction with an arbitrary HTTP payload.</td>
* <td>
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
* <ul>
* <li><p> streamRawPredictCallable()
* </ul>
* </td>
* </tr>
* <tr>
* <td><p> DirectPredict</td>
* <td><p> Perform an unary online prediction request for Vertex first-party products and frameworks.</td>
* <td><p> Perform an unary online prediction request to a gRPC model server for Vertex first-party products and frameworks.</td>
* <td>
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
* <ul>
Expand All @@ -139,7 +149,7 @@
* </tr>
* <tr>
* <td><p> DirectRawPredict</td>
* <td><p> Perform an online prediction request through gRPC.</td>
* <td><p> Perform an unary online prediction request to a gRPC model server for custom containers.</td>
* <td>
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
* <ul>
Expand All @@ -152,6 +162,26 @@
* </td>
* </tr>
* <tr>
* <td><p> StreamDirectPredict</td>
* <td><p> Perform a streaming online prediction request to a gRPC model server for Vertex first-party products and frameworks.</td>
* <td>
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
* <ul>
* <li><p> streamDirectPredictCallable()
* </ul>
* </td>
* </tr>
* <tr>
* <td><p> StreamDirectRawPredict</td>
* <td><p> Perform a streaming online prediction request to a gRPC model server for custom containers.</td>
* <td>
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
* <ul>
* <li><p> streamDirectRawPredictCallable()
* </ul>
* </td>
* </tr>
* <tr>
* <td><p> StreamingPredict</td>
* <td><p> Perform a streaming online prediction request for Vertex first-party products and frameworks.</td>
* <td>
Expand Down Expand Up @@ -202,6 +232,24 @@
* </td>
* </tr>
* <tr>
* <td><p> GenerateContent</td>
* <td><p> Generate content with multimodal inputs.</td>
* <td>
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
* <ul>
* <li><p> generateContent(GenerateContentRequest request)
* </ul>
* <p>"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.</p>
* <ul>
* <li><p> generateContent(String model, List&lt;Content&gt; contents)
* </ul>
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
* <ul>
* <li><p> generateContentCallable()
* </ul>
* </td>
* </tr>
* <tr>
* <td><p> StreamGenerateContent</td>
* <td><p> Generate content with multimodal inputs with streaming support.</td>
* <td>
Expand Down Expand Up @@ -740,7 +788,42 @@ public final UnaryCallable<RawPredictRequest, HttpBody> rawPredictCallable() {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform an unary online prediction request for Vertex first-party products and frameworks.
* Perform a streaming online prediction with an arbitrary HTTP payload.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
* StreamRawPredictRequest request =
* StreamRawPredictRequest.newBuilder()
* .setEndpoint(
* EndpointName.ofProjectLocationEndpointName(
* "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString())
* .setHttpBody(HttpBody.newBuilder().build())
* .build();
* ServerStream<HttpBody> stream =
* predictionServiceClient.streamRawPredictCallable().call(request);
* for (HttpBody response : stream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*/
public final ServerStreamingCallable<StreamRawPredictRequest, HttpBody>
streamRawPredictCallable() {
return stub.streamRawPredictCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform an unary online prediction request to a gRPC model server for Vertex first-party
* products and frameworks.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -773,7 +856,8 @@ public final DirectPredictResponse directPredict(DirectPredictRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform an unary online prediction request for Vertex first-party products and frameworks.
* Perform an unary online prediction request to a gRPC model server for Vertex first-party
* products and frameworks.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -806,7 +890,7 @@ public final UnaryCallable<DirectPredictRequest, DirectPredictResponse> directPr

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform an online prediction request through gRPC.
* Perform an unary online prediction request to a gRPC model server for custom containers.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -839,7 +923,7 @@ public final DirectRawPredictResponse directRawPredict(DirectRawPredictRequest r

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform an online prediction request through gRPC.
* Perform an unary online prediction request to a gRPC model server for custom containers.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -871,6 +955,79 @@ public final DirectRawPredictResponse directRawPredict(DirectRawPredictRequest r
return stub.directRawPredictCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a streaming online prediction request to a gRPC model server for Vertex first-party
* products and frameworks.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
* BidiStream<StreamDirectPredictRequest, StreamDirectPredictResponse> bidiStream =
* predictionServiceClient.streamDirectPredictCallable().call();
* StreamDirectPredictRequest request =
* StreamDirectPredictRequest.newBuilder()
* .setEndpoint(
* EndpointName.ofProjectLocationEndpointName(
* "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString())
* .addAllInputs(new ArrayList<Tensor>())
* .setParameters(Tensor.newBuilder().build())
* .build();
* bidiStream.send(request);
* for (StreamDirectPredictResponse response : bidiStream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*/
public final BidiStreamingCallable<StreamDirectPredictRequest, StreamDirectPredictResponse>
streamDirectPredictCallable() {
return stub.streamDirectPredictCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a streaming online prediction request to a gRPC model server for custom containers.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
* BidiStream<StreamDirectRawPredictRequest, StreamDirectRawPredictResponse> bidiStream =
* predictionServiceClient.streamDirectRawPredictCallable().call();
* StreamDirectRawPredictRequest request =
* StreamDirectRawPredictRequest.newBuilder()
* .setEndpoint(
* EndpointName.ofProjectLocationEndpointName(
* "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString())
* .setMethodName("methodName-723163380")
* .setInput(ByteString.EMPTY)
* .build();
* bidiStream.send(request);
* for (StreamDirectRawPredictResponse response : bidiStream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*/
public final BidiStreamingCallable<StreamDirectRawPredictRequest, StreamDirectRawPredictResponse>
streamDirectRawPredictCallable() {
return stub.streamDirectRawPredictCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a streaming online prediction request for Vertex first-party products and frameworks.
Expand Down Expand Up @@ -1187,6 +1344,103 @@ public final UnaryCallable<ExplainRequest, ExplainResponse> explainCallable() {
return stub.explainCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Generate content with multimodal inputs.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
* String model = "model104069929";
* List<Content> contents = new ArrayList<>();
* GenerateContentResponse response = predictionServiceClient.generateContent(model, contents);
* }
* }</pre>
*
* @param model Required. The name of the publisher model requested to serve the prediction.
* Format: `projects/{project}/locations/{location}/publishers/&#42;/models/&#42;`
* @param contents Required. The content of the current conversation with the model.
* <p>For single-turn queries, this is a single instance. For multi-turn queries, this is a
* repeated field that contains conversation history + latest request.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final GenerateContentResponse generateContent(String model, List<Content> contents) {
GenerateContentRequest request =
GenerateContentRequest.newBuilder().setModel(model).addAllContents(contents).build();
return generateContent(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Generate content with multimodal inputs.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
* GenerateContentRequest request =
* GenerateContentRequest.newBuilder()
* .setModel("model104069929")
* .addAllContents(new ArrayList<Content>())
* .addAllTools(new ArrayList<Tool>())
* .addAllSafetySettings(new ArrayList<SafetySetting>())
* .setGenerationConfig(GenerationConfig.newBuilder().build())
* .build();
* GenerateContentResponse response = predictionServiceClient.generateContent(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final GenerateContentResponse generateContent(GenerateContentRequest request) {
return generateContentCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Generate content with multimodal inputs.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
* GenerateContentRequest request =
* GenerateContentRequest.newBuilder()
* .setModel("model104069929")
* .addAllContents(new ArrayList<Content>())
* .addAllTools(new ArrayList<Tool>())
* .addAllSafetySettings(new ArrayList<SafetySetting>())
* .setGenerationConfig(GenerationConfig.newBuilder().build())
* .build();
* ApiFuture<GenerateContentResponse> future =
* predictionServiceClient.generateContentCallable().futureCall(request);
* // Do something.
* GenerateContentResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GenerateContentRequest, GenerateContentResponse>
generateContentCallable() {
return stub.generateContentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Generate content with multimodal inputs with streaming support.
Expand Down
Loading

0 comments on commit 08700f2

Please sign in to comment.