Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [aiplatform] Add Grounding feature to PredictionService.GenerateContent #10358

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java-aiplatform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-aiplatform.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-aiplatform/3.35.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-aiplatform/3.36.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ public final ListFeatureOnlineStoresPagedResponse listFeatureOnlineStores(
* mask. If the user does not provide a mask then only the non-empty fields present in the
* request will be overwritten. Set the update_mask to `*` to override all fields.
* <p>Updatable fields:
* <p>&#42; `big_query_source` &#42; `labels` &#42; `sync_config`
* <p>&#42; `big_query_source` &#42; `bigtable` &#42; `labels` &#42; `sync_config`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<FeatureOnlineStore, UpdateFeatureOnlineStoreOperationMetadata>
Expand Down Expand Up @@ -1894,7 +1894,7 @@ public final ListFeatureViewsPagedResponse listFeatureViews(ListFeatureViewsRequ
* user does not provide a mask then only the non-empty fields present in the request will be
* overwritten. Set the update_mask to `&#42;` to override all fields.
* <p>Updatable fields:
* <p>&#42; `labels`
* <p>&#42; `labels` &#42; `serviceAgentType`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<FeatureView, UpdateFeatureViewOperationMetadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ public final UnaryCallable<DeleteIndexRequest, Operation> deleteIndexCallable()
* UpsertDatapointsRequest.newBuilder()
* .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
* .addAllDatapoints(new ArrayList<IndexDatapoint>())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* UpsertDatapointsResponse response = indexServiceClient.upsertDatapoints(request);
* }
Expand Down Expand Up @@ -1118,6 +1119,7 @@ public final UpsertDatapointsResponse upsertDatapoints(UpsertDatapointsRequest r
* UpsertDatapointsRequest.newBuilder()
* .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
* .addAllDatapoints(new ArrayList<IndexDatapoint>())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture<UpsertDatapointsResponse> future =
* indexServiceClient.upsertDatapointsCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ public final ListFeatureOnlineStoresPagedResponse listFeatureOnlineStores(
* mask. If the user does not provide a mask then only the non-empty fields present in the
* request will be overwritten. Set the update_mask to `&#42;` to override all fields.
* <p>Updatable fields:
* <p>&#42; `big_query_source` &#42; `labels` &#42; `sync_config`
* <p>&#42; `big_query_source` &#42; `bigtable` &#42; `labels` &#42; `sync_config`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<FeatureOnlineStore, UpdateFeatureOnlineStoreOperationMetadata>
Expand Down Expand Up @@ -1896,7 +1896,7 @@ public final ListFeatureViewsPagedResponse listFeatureViews(ListFeatureViewsRequ
* user does not provide a mask then only the non-empty fields present in the request will be
* overwritten. Set the update_mask to `&#42;` to override all fields.
* <p>Updatable fields:
* <p>&#42; `labels`
* <p>&#42; `labels` &#42; `serviceAgentType`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<FeatureView, UpdateFeatureViewOperationMetadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ public final UnaryCallable<DeleteIndexRequest, Operation> deleteIndexCallable()
* UpsertDatapointsRequest.newBuilder()
* .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
* .addAllDatapoints(new ArrayList<IndexDatapoint>())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* UpsertDatapointsResponse response = indexServiceClient.upsertDatapoints(request);
* }
Expand Down Expand Up @@ -1120,6 +1121,7 @@ public final UpsertDatapointsResponse upsertDatapoints(UpsertDatapointsRequest r
* UpsertDatapointsRequest.newBuilder()
* .setIndex(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
* .addAllDatapoints(new ArrayList<IndexDatapoint>())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture<UpsertDatapointsResponse> future =
* indexServiceClient.upsertDatapointsCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* EndpointName endpoint =
* EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
* List<Value> instances = new ArrayList<>();
* CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
* ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances);
* }
* }</pre>
*
Expand All @@ -76,25 +76,6 @@
* <th>Method Variants</th>
* </tr>
* <tr>
* <td><p> CountTokens</td>
* <td><p> Perform a token counting.</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> countTokens(CountTokensRequest 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> countTokens(EndpointName endpoint, List&lt;Value&gt; instances)
* <li><p> countTokens(String endpoint, List&lt;Value&gt; instances)
* </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> countTokensCallable()
* </ul>
* </td>
* </tr>
* <tr>
* <td><p> ComputeTokens</td>
* <td><p> Return a list of tokens based on the input text.</td>
* <td>
Expand Down Expand Up @@ -280,142 +261,6 @@ public LlmUtilityServiceStub getStub() {
return stub;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* EndpointName endpoint =
* EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
* List<Value> instances = new ArrayList<>();
* CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
* }
* }</pre>
*
* @param endpoint Required. The name of the Endpoint requested to perform token counting. Format:
* `projects/{project}/locations/{location}/endpoints/{endpoint}`
* @param instances Required. The instances that are the input to token counting call. Schema is
* identical to the prediction schema of the underlying model.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CountTokensResponse countTokens(EndpointName endpoint, List<Value> instances) {
CountTokensRequest request =
CountTokensRequest.newBuilder()
.setEndpoint(endpoint == null ? null : endpoint.toString())
.addAllInstances(instances)
.build();
return countTokens(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* String endpoint =
* EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString();
* List<Value> instances = new ArrayList<>();
* CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
* }
* }</pre>
*
* @param endpoint Required. The name of the Endpoint requested to perform token counting. Format:
* `projects/{project}/locations/{location}/endpoints/{endpoint}`
* @param instances Required. The instances that are the input to token counting call. Schema is
* identical to the prediction schema of the underlying model.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CountTokensResponse countTokens(String endpoint, List<Value> instances) {
CountTokensRequest request =
CountTokensRequest.newBuilder().setEndpoint(endpoint).addAllInstances(instances).build();
return countTokens(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* CountTokensRequest request =
* CountTokensRequest.newBuilder()
* .setEndpoint(
* EndpointName.ofProjectLocationEndpointName(
* "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString())
* .setModel("model104069929")
* .addAllInstances(new ArrayList<Value>())
* .addAllContents(new ArrayList<Content>())
* .build();
* CountTokensResponse response = llmUtilityServiceClient.countTokens(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 CountTokensResponse countTokens(CountTokensRequest request) {
return countTokensCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform a token counting.
*
* <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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
* CountTokensRequest request =
* CountTokensRequest.newBuilder()
* .setEndpoint(
* EndpointName.ofProjectLocationEndpointName(
* "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
* .toString())
* .setModel("model104069929")
* .addAllInstances(new ArrayList<Value>())
* .addAllContents(new ArrayList<Content>())
* .build();
* ApiFuture<CountTokensResponse> future =
* llmUtilityServiceClient.countTokensCallable().futureCall(request);
* // Do something.
* CountTokensResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<CountTokensRequest, CountTokensResponse> countTokensCallable() {
return stub.countTokensCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Return a list of tokens based on the input text.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of countTokens to 30 seconds:
* <p>For example, to set the total timeout of computeTokens to 30 seconds:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -69,10 +69,10 @@
* LlmUtilityServiceSettings.Builder llmUtilityServiceSettingsBuilder =
* LlmUtilityServiceSettings.newBuilder();
* llmUtilityServiceSettingsBuilder
* .countTokensSettings()
* .computeTokensSettings()
* .setRetrySettings(
* llmUtilityServiceSettingsBuilder
* .countTokensSettings()
* .computeTokensSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
Expand All @@ -84,11 +84,6 @@
@Generated("by gapic-generator-java")
public class LlmUtilityServiceSettings extends ClientSettings<LlmUtilityServiceSettings> {

/** Returns the object with the settings used for calls to countTokens. */
public UnaryCallSettings<CountTokensRequest, CountTokensResponse> countTokensSettings() {
return ((LlmUtilityServiceStubSettings) getStubSettings()).countTokensSettings();
}

/** Returns the object with the settings used for calls to computeTokens. */
public UnaryCallSettings<ComputeTokensRequest, ComputeTokensResponse> computeTokensSettings() {
return ((LlmUtilityServiceStubSettings) getStubSettings()).computeTokensSettings();
Expand Down Expand Up @@ -218,12 +213,6 @@ public Builder applyToAllUnaryMethods(
return this;
}

/** Returns the builder for the settings used for calls to countTokens. */
public UnaryCallSettings.Builder<CountTokensRequest, CountTokensResponse>
countTokensSettings() {
return getStubSettingsBuilder().countTokensSettings();
}

/** Returns the builder for the settings used for calls to computeTokens. */
public UnaryCallSettings.Builder<ComputeTokensRequest, ComputeTokensResponse>
computeTokensSettings() {
Expand Down
Loading
Loading