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] A new field score is added to message .google.cloud.aiplatform.v1.Candidate #7557

Merged
merged 2 commits into from
Jul 30, 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
Binary file modified AiPlatform/metadata/V1/AcceleratorType.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/Content.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/CustomJob.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/Dataset.php
Binary file not shown.
8 changes: 4 additions & 4 deletions AiPlatform/metadata/V1/DatasetVersion.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified AiPlatform/metadata/V1/Endpoint.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/FeatureOnlineStoreService.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/ModelGardenService.php
Binary file not shown.
Binary file added AiPlatform/metadata/V1/NotebookExecutionJob.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/NotebookService.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/PersistentResource.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/PredictionService.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/Tool.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/TuningJob.php
Binary file not shown.
21 changes: 3 additions & 18 deletions AiPlatform/samples/V1/LlmUtilityServiceClient/count_tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
// [START aiplatform_v1_generated_LlmUtilityService_CountTokens_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\LlmUtilityServiceClient;
use Google\Cloud\AIPlatform\V1\Content;
use Google\Cloud\AIPlatform\V1\CountTokensRequest;
use Google\Cloud\AIPlatform\V1\CountTokensResponse;
use Google\Cloud\AIPlatform\V1\Part;
use Google\Protobuf\Value;

/**
* Perform a token counting.
Expand All @@ -38,26 +35,15 @@
* Format:
* `projects/{project}/locations/{location}/endpoints/{endpoint}`
* Please see {@see LlmUtilityServiceClient::endpointName()} for help formatting this field.
* @param string $model The name of the publisher model requested to serve the
* prediction. Format:
* `projects/{project}/locations/{location}/publishers/*/models/*`
*/
function count_tokens_sample(string $formattedEndpoint, string $model): void
function count_tokens_sample(string $formattedEndpoint): void
{
// Create a client.
$llmUtilityServiceClient = new LlmUtilityServiceClient();

// Prepare the request message.
$instances = [new Value()];
$contentsParts = [new Part()];
$content = (new Content())
->setParts($contentsParts);
$contents = [$content,];
$request = (new CountTokensRequest())
->setEndpoint($formattedEndpoint)
->setModel($model)
->setInstances($instances)
->setContents($contents);
->setEndpoint($formattedEndpoint);

// Call the API and handle any network failures.
try {
Expand All @@ -81,8 +67,7 @@ function count_tokens_sample(string $formattedEndpoint, string $model): void
function callSample(): void
{
$formattedEndpoint = LlmUtilityServiceClient::endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
$model = '[MODEL]';

count_tokens_sample($formattedEndpoint, $model);
count_tokens_sample($formattedEndpoint);
}
// [END aiplatform_v1_generated_LlmUtilityService_CountTokens_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/*
* 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.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_NotebookService_CreateNotebookExecutionJob_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AIPlatform\V1\Client\NotebookServiceClient;
use Google\Cloud\AIPlatform\V1\CreateNotebookExecutionJobRequest;
use Google\Cloud\AIPlatform\V1\NotebookExecutionJob;
use Google\Rpc\Status;

/**
* Creates a NotebookExecutionJob.
*
* @param string $formattedParent The resource name of the Location to create the
* NotebookExecutionJob. Format: `projects/{project}/locations/{location}`
* Please see {@see NotebookServiceClient::locationName()} for help formatting this field.
*/
function create_notebook_execution_job_sample(string $formattedParent): void
{
// Create a client.
$notebookServiceClient = new NotebookServiceClient();

// Prepare the request message.
$notebookExecutionJob = new NotebookExecutionJob();
$request = (new CreateNotebookExecutionJobRequest())
->setParent($formattedParent)
->setNotebookExecutionJob($notebookExecutionJob);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $notebookServiceClient->createNotebookExecutionJob($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var NotebookExecutionJob $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->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
{
$formattedParent = NotebookServiceClient::locationName('[PROJECT]', '[LOCATION]');

create_notebook_execution_job_sample($formattedParent);
}
// [END aiplatform_v1_generated_NotebookService_CreateNotebookExecutionJob_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php
/*
* 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.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_NotebookService_DeleteNotebookExecutionJob_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AIPlatform\V1\Client\NotebookServiceClient;
use Google\Cloud\AIPlatform\V1\DeleteNotebookExecutionJobRequest;
use Google\Rpc\Status;

/**
* Deletes a NotebookExecutionJob.
*
* @param string $formattedName The name of the NotebookExecutionJob resource to be deleted. Please see
* {@see NotebookServiceClient::notebookExecutionJobName()} for help formatting this field.
*/
function delete_notebook_execution_job_sample(string $formattedName): void
{
// Create a client.
$notebookServiceClient = new NotebookServiceClient();

// Prepare the request message.
$request = (new DeleteNotebookExecutionJobRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $notebookServiceClient->deleteNotebookExecutionJob($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->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
{
$formattedName = NotebookServiceClient::notebookExecutionJobName(
'[PROJECT]',
'[LOCATION]',
'[NOTEBOOK_EXECUTION_JOB]'
);

delete_notebook_execution_job_sample($formattedName);
}
// [END aiplatform_v1_generated_NotebookService_DeleteNotebookExecutionJob_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/*
* 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.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_NotebookService_GetNotebookExecutionJob_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\NotebookServiceClient;
use Google\Cloud\AIPlatform\V1\GetNotebookExecutionJobRequest;
use Google\Cloud\AIPlatform\V1\NotebookExecutionJob;

/**
* Gets a NotebookExecutionJob.
*
* @param string $formattedName The name of the NotebookExecutionJob resource. Please see
* {@see NotebookServiceClient::notebookExecutionJobName()} for help formatting this field.
*/
function get_notebook_execution_job_sample(string $formattedName): void
{
// Create a client.
$notebookServiceClient = new NotebookServiceClient();

// Prepare the request message.
$request = (new GetNotebookExecutionJobRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var NotebookExecutionJob $response */
$response = $notebookServiceClient->getNotebookExecutionJob($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
{
$formattedName = NotebookServiceClient::notebookExecutionJobName(
'[PROJECT]',
'[LOCATION]',
'[NOTEBOOK_EXECUTION_JOB]'
);

get_notebook_execution_job_sample($formattedName);
}
// [END aiplatform_v1_generated_NotebookService_GetNotebookExecutionJob_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/*
* 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.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_NotebookService_ListNotebookExecutionJobs_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AIPlatform\V1\Client\NotebookServiceClient;
use Google\Cloud\AIPlatform\V1\ListNotebookExecutionJobsRequest;
use Google\Cloud\AIPlatform\V1\NotebookExecutionJob;

/**
* Lists NotebookExecutionJobs in a Location.
*
* @param string $formattedParent The resource name of the Location from which to list the
* NotebookExecutionJobs.
* Format: `projects/{project}/locations/{location}`
* Please see {@see NotebookServiceClient::locationName()} for help formatting this field.
*/
function list_notebook_execution_jobs_sample(string $formattedParent): void
{
// Create a client.
$notebookServiceClient = new NotebookServiceClient();

// Prepare the request message.
$request = (new ListNotebookExecutionJobsRequest())
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $notebookServiceClient->listNotebookExecutionJobs($request);

/** @var NotebookExecutionJob $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());
}
}

/**
* 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
{
$formattedParent = NotebookServiceClient::locationName('[PROJECT]', '[LOCATION]');

list_notebook_execution_jobs_sample($formattedParent);
}
// [END aiplatform_v1_generated_NotebookService_ListNotebookExecutionJobs_sync]
Loading
Loading