-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deployment_timeout to UploadModel ModelContainerSpec (#6789)
* feat: add ComputeTokens and CountTokens API PiperOrigin-RevId: 582364082 Source-Link: googleapis/googleapis@fdea53f Source-Link: googleapis/googleapis-gen@295f8ea Copy-Tag: eyJwIjoiQWlQbGF0Zm9ybS8uT3dsQm90LnlhbWwiLCJoIjoiMjk1ZjhlYWIyYTg3NzQzZGNjYzY1Yjg4ZTczZDcxZjQ4MDMyMzAyMyJ9 * feat: add deployment_timeout to UploadModel ModelContainerSpec feat: add shared_memory_size_mb to UploadModel ModelContainerSpec feat: add startup_probe, health_probe to UploadModel ModelContainerSpec PiperOrigin-RevId: 582390619 Source-Link: googleapis/googleapis@49c44ef Source-Link: googleapis/googleapis-gen@7a1c0d1 Copy-Tag: eyJwIjoiQWlQbGF0Zm9ybS8uT3dsQm90LnlhbWwiLCJoIjoiN2ExYzBkMTViODJlMDYyNjc4YTUxNmQxODU1MWM2N2MxYjAxNzZhYSJ9
- Loading branch information
1 parent
b161dcf
commit 68c4bc4
Showing
25 changed files
with
5,614 additions
and
54 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
75 changes: 75 additions & 0 deletions
75
AiPlatform/samples/V1/LlmUtilityServiceClient/compute_tokens.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START aiplatform_v1_generated_LlmUtilityService_ComputeTokens_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\AIPlatform\V1\Client\LlmUtilityServiceClient; | ||
use Google\Cloud\AIPlatform\V1\ComputeTokensRequest; | ||
use Google\Cloud\AIPlatform\V1\ComputeTokensResponse; | ||
use Google\Protobuf\Value; | ||
|
||
/** | ||
* Return a list of tokens based on the input text. | ||
* | ||
* @param string $formattedEndpoint The name of the Endpoint requested to get lists of tokens and | ||
* token ids. Please see | ||
* {@see LlmUtilityServiceClient::endpointName()} for help formatting this field. | ||
*/ | ||
function compute_tokens_sample(string $formattedEndpoint): void | ||
{ | ||
// Create a client. | ||
$llmUtilityServiceClient = new LlmUtilityServiceClient(); | ||
|
||
// Prepare the request message. | ||
$instances = [new Value()]; | ||
$request = (new ComputeTokensRequest()) | ||
->setEndpoint($formattedEndpoint) | ||
->setInstances($instances); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var ComputeTokensResponse $response */ | ||
$response = $llmUtilityServiceClient->computeTokens($request); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample 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, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedEndpoint = LlmUtilityServiceClient::endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); | ||
|
||
compute_tokens_sample($formattedEndpoint); | ||
} | ||
// [END aiplatform_v1_generated_LlmUtilityService_ComputeTokens_sync] |
76 changes: 76 additions & 0 deletions
76
AiPlatform/samples/V1/LlmUtilityServiceClient/count_tokens.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START aiplatform_v1_generated_LlmUtilityService_CountTokens_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\AIPlatform\V1\Client\LlmUtilityServiceClient; | ||
use Google\Cloud\AIPlatform\V1\CountTokensRequest; | ||
use Google\Cloud\AIPlatform\V1\CountTokensResponse; | ||
use Google\Protobuf\Value; | ||
|
||
/** | ||
* Perform a token counting. | ||
* | ||
* @param string $formattedEndpoint The name of the Endpoint requested to perform token counting. | ||
* Format: | ||
* `projects/{project}/locations/{location}/endpoints/{endpoint}` | ||
* Please see {@see LlmUtilityServiceClient::endpointName()} for help formatting this field. | ||
*/ | ||
function count_tokens_sample(string $formattedEndpoint): void | ||
{ | ||
// Create a client. | ||
$llmUtilityServiceClient = new LlmUtilityServiceClient(); | ||
|
||
// Prepare the request message. | ||
$instances = [new Value()]; | ||
$request = (new CountTokensRequest()) | ||
->setEndpoint($formattedEndpoint) | ||
->setInstances($instances); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var CountTokensResponse $response */ | ||
$response = $llmUtilityServiceClient->countTokens($request); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample 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, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedEndpoint = LlmUtilityServiceClient::endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]'); | ||
|
||
count_tokens_sample($formattedEndpoint); | ||
} | ||
// [END aiplatform_v1_generated_LlmUtilityService_CountTokens_sync] |
72 changes: 72 additions & 0 deletions
72
AiPlatform/samples/V1/LlmUtilityServiceClient/get_iam_policy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START aiplatform_v1_generated_LlmUtilityService_GetIamPolicy_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\AIPlatform\V1\Client\LlmUtilityServiceClient; | ||
use Google\Cloud\Iam\V1\GetIamPolicyRequest; | ||
use Google\Cloud\Iam\V1\Policy; | ||
|
||
/** | ||
* Gets the access control policy for a resource. Returns an empty policy | ||
if the resource exists and does not have a policy set. | ||
* | ||
* @param string $resource REQUIRED: The resource for which the policy is being requested. | ||
* See the operation documentation for the appropriate value for this field. | ||
*/ | ||
function get_iam_policy_sample(string $resource): void | ||
{ | ||
// Create a client. | ||
$llmUtilityServiceClient = new LlmUtilityServiceClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new GetIamPolicyRequest()) | ||
->setResource($resource); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Policy $response */ | ||
$response = $llmUtilityServiceClient->getIamPolicy($request); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample 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, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$resource = '[RESOURCE]'; | ||
|
||
get_iam_policy_sample($resource); | ||
} | ||
// [END aiplatform_v1_generated_LlmUtilityService_GetIamPolicy_sync] |
57 changes: 57 additions & 0 deletions
57
AiPlatform/samples/V1/LlmUtilityServiceClient/get_location.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START aiplatform_v1_generated_LlmUtilityService_GetLocation_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\AIPlatform\V1\Client\LlmUtilityServiceClient; | ||
use Google\Cloud\Location\GetLocationRequest; | ||
use Google\Cloud\Location\Location; | ||
|
||
/** | ||
* Gets information about a location. | ||
* | ||
* This sample 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, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function get_location_sample(): void | ||
{ | ||
// Create a client. | ||
$llmUtilityServiceClient = new LlmUtilityServiceClient(); | ||
|
||
// Prepare the request message. | ||
$request = new GetLocationRequest(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Location $response */ | ||
$response = $llmUtilityServiceClient->getLocation($request); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
// [END aiplatform_v1_generated_LlmUtilityService_GetLocation_sync] |
62 changes: 62 additions & 0 deletions
62
AiPlatform/samples/V1/LlmUtilityServiceClient/list_locations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START aiplatform_v1_generated_LlmUtilityService_ListLocations_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\PagedListResponse; | ||
use Google\Cloud\AIPlatform\V1\Client\LlmUtilityServiceClient; | ||
use Google\Cloud\Location\ListLocationsRequest; | ||
use Google\Cloud\Location\Location; | ||
|
||
/** | ||
* Lists information about the supported locations for this service. | ||
* | ||
* This sample 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, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function list_locations_sample(): void | ||
{ | ||
// Create a client. | ||
$llmUtilityServiceClient = new LlmUtilityServiceClient(); | ||
|
||
// Prepare the request message. | ||
$request = new ListLocationsRequest(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var PagedListResponse $response */ | ||
$response = $llmUtilityServiceClient->listLocations($request); | ||
|
||
/** @var Location $element */ | ||
foreach ($response as $element) { | ||
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
// [END aiplatform_v1_generated_LlmUtilityService_ListLocations_sync] |
Oops, something went wrong.