Skip to content

Commit

Permalink
feat: added Generator API (#6832)
Browse files Browse the repository at this point in the history
docs: updated doc for speech mode
PiperOrigin-RevId: 586469693
Source-Link: googleapis/googleapis@e8148d6
Source-Link: googleapis/googleapis-gen@85136bd
Copy-Tag: eyJwIjoiRGlhbG9nZmxvd0N4Ly5Pd2xCb3QueWFtbCIsImgiOiI4NTEzNmJkMDQzODNlZDcxNzJiYjE4YjdiOGQyMjBkZDdmZjZiM2EwIn0=
  • Loading branch information
gcf-owl-bot[bot] authored Dec 1, 2023
1 parent b43313e commit 8a35600
Show file tree
Hide file tree
Showing 48 changed files with 5,299 additions and 12 deletions.
Binary file modified DialogflowCx/metadata/V3/Agent.php
Binary file not shown.
Binary file modified DialogflowCx/metadata/V3/AudioConfig.php
Binary file not shown.
Binary file modified DialogflowCx/metadata/V3/EntityType.php
Binary file not shown.
78 changes: 78 additions & 0 deletions DialogflowCx/metadata/V3/Generator.php

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

Binary file modified DialogflowCx/metadata/V3/Session.php
Binary file not shown.
85 changes: 85 additions & 0 deletions DialogflowCx/samples/V3/GeneratorsClient/create_generator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?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 dialogflow_v3_generated_Generators_CreateGenerator_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Generator;
use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient;
use Google\Cloud\Dialogflow\Cx\V3\Phrase;

/**
* Creates a generator in the specified agent.
*
* @param string $formattedParent The agent to create a generator for.
* Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
* {@see GeneratorsClient::agentName()} for help formatting this field.
* @param string $generatorDisplayName The human-readable name of the generator, unique within the
* agent. The prompt contains pre-defined parameters such as $conversation,
* $last-user-utterance, etc. populated by Dialogflow. It can also contain
* custom placeholders which will be resolved during fulfillment.
* @param string $generatorPromptTextText Text input which can be used for prompt or banned phrases.
*/
function create_generator_sample(
string $formattedParent,
string $generatorDisplayName,
string $generatorPromptTextText
): void {
// Create a client.
$generatorsClient = new GeneratorsClient();

// Prepare any non-scalar elements to be passed along with the request.
$generatorPromptText = (new Phrase())
->setText($generatorPromptTextText);
$generator = (new Generator())
->setDisplayName($generatorDisplayName)
->setPromptText($generatorPromptText);

// Call the API and handle any network failures.
try {
/** @var Generator $response */
$response = $generatorsClient->createGenerator($formattedParent, $generator);
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
{
$formattedParent = GeneratorsClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
$generatorDisplayName = '[DISPLAY_NAME]';
$generatorPromptTextText = '[TEXT]';

create_generator_sample($formattedParent, $generatorDisplayName, $generatorPromptTextText);
}
// [END dialogflow_v3_generated_Generators_CreateGenerator_sync]
71 changes: 71 additions & 0 deletions DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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 dialogflow_v3_generated_Generators_DeleteGenerator_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient;

/**
* Deletes the specified generators.
*
* @param string $formattedName The name of the generator to delete.
* Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
* ID>/generators/<Generator ID>`. Please see
* {@see GeneratorsClient::generatorName()} for help formatting this field.
*/
function delete_generator_sample(string $formattedName): void
{
// Create a client.
$generatorsClient = new GeneratorsClient();

// Call the API and handle any network failures.
try {
$generatorsClient->deleteGenerator($formattedName);
printf('Call completed successfully.' . PHP_EOL);
} 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 = GeneratorsClient::generatorName(
'[PROJECT]',
'[LOCATION]',
'[AGENT]',
'[GENERATOR]'
);

delete_generator_sample($formattedName);
}
// [END dialogflow_v3_generated_Generators_DeleteGenerator_sync]
73 changes: 73 additions & 0 deletions DialogflowCx/samples/V3/GeneratorsClient/get_generator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?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 dialogflow_v3_generated_Generators_GetGenerator_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Generator;
use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient;

/**
* Retrieves the specified generator.
*
* @param string $formattedName The name of the generator.
* Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
* ID>/generators/<Generator ID>`. Please see
* {@see GeneratorsClient::generatorName()} for help formatting this field.
*/
function get_generator_sample(string $formattedName): void
{
// Create a client.
$generatorsClient = new GeneratorsClient();

// Call the API and handle any network failures.
try {
/** @var Generator $response */
$response = $generatorsClient->getGenerator($formattedName);
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 = GeneratorsClient::generatorName(
'[PROJECT]',
'[LOCATION]',
'[AGENT]',
'[GENERATOR]'
);

get_generator_sample($formattedName);
}
// [END dialogflow_v3_generated_Generators_GetGenerator_sync]
53 changes: 53 additions & 0 deletions DialogflowCx/samples/V3/GeneratorsClient/get_location.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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 dialogflow_v3_generated_Generators_GetLocation_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient;
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.
$generatorsClient = new GeneratorsClient();

// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $generatorsClient->getLocation();
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END dialogflow_v3_generated_Generators_GetLocation_sync]
Loading

0 comments on commit 8a35600

Please sign in to comment.