|
60 | 60 | * EndpointName endpoint =
|
61 | 61 | * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
|
62 | 62 | * List<Value> instances = new ArrayList<>();
|
63 |
| - * ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances); |
| 63 | + * CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances); |
64 | 64 | * }
|
65 | 65 | * }</pre>
|
66 | 66 | *
|
|
74 | 74 | * <th>Description</th>
|
75 | 75 | * <th>Method Variants</th>
|
76 | 76 | * <tr>
|
| 77 | + * <td>CountTokens</td> |
| 78 | + * <td><p> Perform a token counting.</td> |
| 79 | + * <td> |
| 80 | + * <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p> |
| 81 | + * <ul> |
| 82 | + * <li>countTokens(CountTokensRequest request) |
| 83 | + * </ul> |
| 84 | + * <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> |
| 85 | + * <ul> |
| 86 | + * <li>countTokens(EndpointName endpoint, List<Value> instances) |
| 87 | + * <li>countTokens(String endpoint, List<Value> instances) |
| 88 | + * </ul> |
| 89 | + * <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> |
| 90 | + * <ul> |
| 91 | + * <li>countTokensCallable() |
| 92 | + * </ul> |
| 93 | + * </td> |
| 94 | + * </tr> |
| 95 | + * <tr> |
77 | 96 | * <td>ComputeTokens</td>
|
78 | 97 | * <td><p> Return a list of tokens based on the input text.</td>
|
79 | 98 | * <td>
|
@@ -260,6 +279,142 @@ public LlmUtilityServiceStub getStub() {
|
260 | 279 | return stub;
|
261 | 280 | }
|
262 | 281 |
|
| 282 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 283 | + /** |
| 284 | + * Perform a token counting. |
| 285 | + * |
| 286 | + * <p>Sample code: |
| 287 | + * |
| 288 | + * <pre>{@code |
| 289 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 290 | + * // It will require modifications to work: |
| 291 | + * // - It may require correct/in-range values for request initialization. |
| 292 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 293 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 294 | + * try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) { |
| 295 | + * EndpointName endpoint = |
| 296 | + * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); |
| 297 | + * List<Value> instances = new ArrayList<>(); |
| 298 | + * CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances); |
| 299 | + * } |
| 300 | + * }</pre> |
| 301 | + * |
| 302 | + * @param endpoint Required. The name of the Endpoint requested to perform token counting. Format: |
| 303 | + * `projects/{project}/locations/{location}/endpoints/{endpoint}` |
| 304 | + * @param instances Required. The instances that are the input to token counting call. Schema is |
| 305 | + * identical to the prediction schema of the underlying model. |
| 306 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 307 | + */ |
| 308 | + public final CountTokensResponse countTokens(EndpointName endpoint, List<Value> instances) { |
| 309 | + CountTokensRequest request = |
| 310 | + CountTokensRequest.newBuilder() |
| 311 | + .setEndpoint(endpoint == null ? null : endpoint.toString()) |
| 312 | + .addAllInstances(instances) |
| 313 | + .build(); |
| 314 | + return countTokens(request); |
| 315 | + } |
| 316 | + |
| 317 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 318 | + /** |
| 319 | + * Perform a token counting. |
| 320 | + * |
| 321 | + * <p>Sample code: |
| 322 | + * |
| 323 | + * <pre>{@code |
| 324 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 325 | + * // It will require modifications to work: |
| 326 | + * // - It may require correct/in-range values for request initialization. |
| 327 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 328 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 329 | + * try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) { |
| 330 | + * String endpoint = |
| 331 | + * EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]") |
| 332 | + * .toString(); |
| 333 | + * List<Value> instances = new ArrayList<>(); |
| 334 | + * CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances); |
| 335 | + * } |
| 336 | + * }</pre> |
| 337 | + * |
| 338 | + * @param endpoint Required. The name of the Endpoint requested to perform token counting. Format: |
| 339 | + * `projects/{project}/locations/{location}/endpoints/{endpoint}` |
| 340 | + * @param instances Required. The instances that are the input to token counting call. Schema is |
| 341 | + * identical to the prediction schema of the underlying model. |
| 342 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 343 | + */ |
| 344 | + public final CountTokensResponse countTokens(String endpoint, List<Value> instances) { |
| 345 | + CountTokensRequest request = |
| 346 | + CountTokensRequest.newBuilder().setEndpoint(endpoint).addAllInstances(instances).build(); |
| 347 | + return countTokens(request); |
| 348 | + } |
| 349 | + |
| 350 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 351 | + /** |
| 352 | + * Perform a token counting. |
| 353 | + * |
| 354 | + * <p>Sample code: |
| 355 | + * |
| 356 | + * <pre>{@code |
| 357 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 358 | + * // It will require modifications to work: |
| 359 | + * // - It may require correct/in-range values for request initialization. |
| 360 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 361 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 362 | + * try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) { |
| 363 | + * CountTokensRequest request = |
| 364 | + * CountTokensRequest.newBuilder() |
| 365 | + * .setEndpoint( |
| 366 | + * EndpointName.ofProjectLocationEndpointName( |
| 367 | + * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") |
| 368 | + * .toString()) |
| 369 | + * .setModel("model104069929") |
| 370 | + * .addAllInstances(new ArrayList<Value>()) |
| 371 | + * .addAllContents(new ArrayList<Content>()) |
| 372 | + * .build(); |
| 373 | + * CountTokensResponse response = llmUtilityServiceClient.countTokens(request); |
| 374 | + * } |
| 375 | + * }</pre> |
| 376 | + * |
| 377 | + * @param request The request object containing all of the parameters for the API call. |
| 378 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 379 | + */ |
| 380 | + public final CountTokensResponse countTokens(CountTokensRequest request) { |
| 381 | + return countTokensCallable().call(request); |
| 382 | + } |
| 383 | + |
| 384 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 385 | + /** |
| 386 | + * Perform a token counting. |
| 387 | + * |
| 388 | + * <p>Sample code: |
| 389 | + * |
| 390 | + * <pre>{@code |
| 391 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 392 | + * // It will require modifications to work: |
| 393 | + * // - It may require correct/in-range values for request initialization. |
| 394 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 395 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 396 | + * try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) { |
| 397 | + * CountTokensRequest request = |
| 398 | + * CountTokensRequest.newBuilder() |
| 399 | + * .setEndpoint( |
| 400 | + * EndpointName.ofProjectLocationEndpointName( |
| 401 | + * "[PROJECT]", "[LOCATION]", "[ENDPOINT]") |
| 402 | + * .toString()) |
| 403 | + * .setModel("model104069929") |
| 404 | + * .addAllInstances(new ArrayList<Value>()) |
| 405 | + * .addAllContents(new ArrayList<Content>()) |
| 406 | + * .build(); |
| 407 | + * ApiFuture<CountTokensResponse> future = |
| 408 | + * llmUtilityServiceClient.countTokensCallable().futureCall(request); |
| 409 | + * // Do something. |
| 410 | + * CountTokensResponse response = future.get(); |
| 411 | + * } |
| 412 | + * }</pre> |
| 413 | + */ |
| 414 | + public final UnaryCallable<CountTokensRequest, CountTokensResponse> countTokensCallable() { |
| 415 | + return stub.countTokensCallable(); |
| 416 | + } |
| 417 | + |
263 | 418 | // AUTO-GENERATED DOCUMENTATION AND METHOD.
|
264 | 419 | /**
|
265 | 420 | * Return a list of tokens based on the input text.
|
|
0 commit comments