From 97cc615d2becaba1518cea8ccceed92d4657c1bc Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 15:39:46 -0700 Subject: [PATCH] feat: extended StreamingListCallCompanionEvents timeout to 600 seconds (#6192) feat: added debug info for StreamingDetectIntent feat: added GenerateStatelessSummary method PiperOrigin-RevId: 530102437 Source-Link: https://github.com/googleapis/googleapis/commit/cea4ed9b7871b1a2eb85b7593ccf0f5269df08b2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/624b26c099fb2c601741d774015502bef99e1bea Copy-Tag: eyJwIjoiRGlhbG9nZmxvdy8uT3dsQm90LnlhbWwiLCJoIjoiNjI0YjI2YzA5OWZiMmM2MDE3NDFkNzc0MDE1NTAyYmVmOTllMWJlYSJ9 --- Dialogflow/metadata/V2/AudioConfig.php | Bin 3565 -> 3603 bytes Dialogflow/metadata/V2/Conversation.php | Bin 5615 -> 6974 bytes Dialogflow/metadata/V2/Participant.php | Bin 11918 -> 12033 bytes Dialogflow/metadata/V2/Session.php | Bin 6680 -> 7687 bytes .../generate_stateless_summary.php | 98 +++ Dialogflow/src/V2/AnswerFeedback.php | 8 + .../src/V2/CloudConversationDebuggingInfo.php | 706 ++++++++++++++++++ .../src/V2/Gapic/ConversationsGapicClient.php | 469 ++++++++++++ .../V2/GenerateStatelessSummaryRequest.php | 222 ++++++ .../MinimalConversation.php | 123 +++ .../V2/GenerateStatelessSummaryResponse.php | 166 ++++ .../Summary.php | 110 +++ Dialogflow/src/V2/InputAudioConfig.php | 54 ++ .../src/V2/StreamingAnalyzeContentRequest.php | 38 + .../V2/StreamingAnalyzeContentResponse.php | 48 ++ .../src/V2/StreamingDetectIntentRequest.php | 34 + .../src/V2/StreamingDetectIntentResponse.php | 48 ++ Dialogflow/src/V2/gapic_metadata.json | 113 +-- .../conversations_client_config.json | 5 + .../conversations_rest_client_config.php | 20 + .../tests/Unit/V2/ConversationsClientTest.php | 81 ++ 21 files changed, 2289 insertions(+), 54 deletions(-) create mode 100644 Dialogflow/samples/V2/ConversationsClient/generate_stateless_summary.php create mode 100644 Dialogflow/src/V2/CloudConversationDebuggingInfo.php create mode 100644 Dialogflow/src/V2/GenerateStatelessSummaryRequest.php create mode 100644 Dialogflow/src/V2/GenerateStatelessSummaryRequest/MinimalConversation.php create mode 100644 Dialogflow/src/V2/GenerateStatelessSummaryResponse.php create mode 100644 Dialogflow/src/V2/GenerateStatelessSummaryResponse/Summary.php diff --git a/Dialogflow/metadata/V2/AudioConfig.php b/Dialogflow/metadata/V2/AudioConfig.php index 2f8a26e8eacf53a19ef221afa86d54788f95aa06..55e0f79adaa37ea13751f357bde46ad795db9962 100644 GIT binary patch delta 67 zcmaDWJy~YMBqo+!VqCfty>&MqW|CuMJh=H0^BhJcAr&r})V#!`oYeTl(vtk##FEV9 W_=3{B&MqW|CuMoW1!G^Bl&_OIY(c0J~ZXB>(^b diff --git a/Dialogflow/metadata/V2/Conversation.php b/Dialogflow/metadata/V2/Conversation.php index e56daf6dcb4adcef10d3be1c70d91d316aaf672a..e5db6c1c3a2637ad69a8e22d239f96ff9f3e718a 100644 GIT binary patch delta 836 zcmaE_z0YjJJ|-dO{JgT%qT2B7qWrYXoXPb}ra9Rt%GhPe!sr zf>D7{gWJe|@HLyzcFmefFu}jEm@*XbJdWe;lTxsDx54GnWExuND{N z=M|?4g>tbML&6XmL@rSCCcj`66~xd!c{fj<(QZaAc4)v0@o=$#yam?GDU{2_3-M%X zGALq;fsSSd274GN*s&Pa#j82_JFgkj7J<$Bd@*eDLU)RYt`x(m!_u!(;CQo sR_Qp>qp}sFR#b{oJU*i*|K*d{A;vJESyC0J93>||WRu*yQpAlB0P74Z(*OVf delta 47 zcmV+~0MP%wHt#F2z5e8MF8q FMggdU5SRb} diff --git a/Dialogflow/metadata/V2/Participant.php b/Dialogflow/metadata/V2/Participant.php index 778b215c7776706da38d94b649a87a6dfb5a1b58..d76f6e52a923374c230784142085c750a89251e7 100644 GIT binary patch delta 164 zcmeB+ZH(Js#=`O?giB|lx6bA?7Jgoq3#?pnll4R-Cl~X2Z@w#N$z&=d%O#qcmzb23 z8lRGyRGOZinU@})nU|I?A*{ft!QsTg#g?3(mzJ6C#LmT}eqlT8#Eliw!=lXwkAv)vIn0+Tfq R6au>hvr7~_0<+r|CKwy#5w8FM diff --git a/Dialogflow/metadata/V2/Session.php b/Dialogflow/metadata/V2/Session.php index 049e1ceb29f835497e6bd1247d6a20a5a5f14858..f39f41eb8fe642395a94ef521360c7743c1ac865 100644 GIT binary patch delta 790 zcmaKqKZ_GV7{-aop1JolCQD2vIrHaoidT4rawwvLAvRiC3&Ujh-OX^DnJ_aOw7SB= zTDGzA1K0^^1V4bC-$Mk&LeN5Rb~ib4cVhki=6#>%ndi;HtNZVNmP(&)!d~*t*MYxg-o6W_a%FDu$+kwj{*f>J!<2VjOE<(yhAW6Aj*eefyZ9sPv$=DxBF-N7D z;Zi(Wk&i9twxGshpG)d9!>Bij#i1qz``U5uLPMdBBSTU6)bJ@%83Y;)IcMivw_3?} zx81q}^?)mF=yFZ0vMZ#Rd~y3j0#$8AS%I-JsF?7OIH@*w1bsb2^d@x1l;JF*`7wQb zO_Pm&G5P9tuMMHQWCJe#NuJNiBWq`E-AoFNIt#;bZ@^W%gdL)y+_y)y=5wSGGbp?l zbgEb8HZ$`*XpWf*kqe4*6owkb!w?nv1Ty^=SZZ1`xSu=R%7_Qh_RTan<1bB8lMA`x z-aQ~0b<$bRTwMB3vpSXHaY`%Ml{D|h0n~(~OJV5}85?rRj&^TzZL2YhtrL81NHvrA z5ISDOQ+pE@1=NeA#uGnXOSkSnfoIpxa@r_l)3kEy-Ei%To-=q?gpMt0Cz0jG;zM<( fP/locations/`. Please see + * {@see ConversationsClient::locationName()} for help formatting this field. + * @param string $conversationProfileDisplayName Human readable name for this profile. Max length 1024 bytes. + */ +function generate_stateless_summary_sample( + string $statelessConversationMessagesContent, + string $formattedStatelessConversationParent, + string $conversationProfileDisplayName +): void { + // Create a client. + $conversationsClient = new ConversationsClient(); + + // Prepare any non-scalar elements to be passed along with the request. + $message = (new Message()) + ->setContent($statelessConversationMessagesContent); + $statelessConversationMessages = [$message,]; + $statelessConversation = (new MinimalConversation()) + ->setMessages($statelessConversationMessages) + ->setParent($formattedStatelessConversationParent); + $conversationProfile = (new ConversationProfile()) + ->setDisplayName($conversationProfileDisplayName); + + // Call the API and handle any network failures. + try { + /** @var GenerateStatelessSummaryResponse $response */ + $response = $conversationsClient->generateStatelessSummary( + $statelessConversation, + $conversationProfile + ); + 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 +{ + $statelessConversationMessagesContent = '[CONTENT]'; + $formattedStatelessConversationParent = ConversationsClient::locationName( + '[PROJECT]', + '[LOCATION]' + ); + $conversationProfileDisplayName = '[DISPLAY_NAME]'; + + generate_stateless_summary_sample( + $statelessConversationMessagesContent, + $formattedStatelessConversationParent, + $conversationProfileDisplayName + ); +} +// [END dialogflow_v2_generated_Conversations_GenerateStatelessSummary_sync] diff --git a/Dialogflow/src/V2/AnswerFeedback.php b/Dialogflow/src/V2/AnswerFeedback.php index 8898d63a820c..9dcad46b8a73 100644 --- a/Dialogflow/src/V2/AnswerFeedback.php +++ b/Dialogflow/src/V2/AnswerFeedback.php @@ -25,6 +25,8 @@ class AnswerFeedback extends \Google\Protobuf\Internal\Message /** * Indicates whether the answer/item was clicked by the human agent * or not. Default to false. + * For knowledge search, the answer record is considered to be clicked if the + * answer was copied or any URI was clicked. * * Generated from protobuf field bool clicked = 3; */ @@ -63,6 +65,8 @@ class AnswerFeedback extends \Google\Protobuf\Internal\Message * @type bool $clicked * Indicates whether the answer/item was clicked by the human agent * or not. Default to false. + * For knowledge search, the answer record is considered to be clicked if the + * answer was copied or any URI was clicked. * @type \Google\Protobuf\Timestamp $click_time * Time when the answer/item was clicked. * @type bool $displayed @@ -137,6 +141,8 @@ public function setAgentAssistantDetailFeedback($var) /** * Indicates whether the answer/item was clicked by the human agent * or not. Default to false. + * For knowledge search, the answer record is considered to be clicked if the + * answer was copied or any URI was clicked. * * Generated from protobuf field bool clicked = 3; * @return bool @@ -149,6 +155,8 @@ public function getClicked() /** * Indicates whether the answer/item was clicked by the human agent * or not. Default to false. + * For knowledge search, the answer record is considered to be clicked if the + * answer was copied or any URI was clicked. * * Generated from protobuf field bool clicked = 3; * @param bool $var diff --git a/Dialogflow/src/V2/CloudConversationDebuggingInfo.php b/Dialogflow/src/V2/CloudConversationDebuggingInfo.php new file mode 100644 index 000000000000..0f005b014ab0 --- /dev/null +++ b/Dialogflow/src/V2/CloudConversationDebuggingInfo.php @@ -0,0 +1,706 @@ +google.cloud.dialogflow.v2.CloudConversationDebuggingInfo + */ +class CloudConversationDebuggingInfo extends \Google\Protobuf\Internal\Message +{ + /** + * Number of input audio data chunks in streaming requests. + * + * Generated from protobuf field int32 audio_data_chunks = 1; + */ + private $audio_data_chunks = 0; + /** + * Time offset of the end of speech utterance relative to the + * beginning of the first audio chunk. + * + * Generated from protobuf field .google.protobuf.Duration result_end_time_offset = 2; + */ + private $result_end_time_offset = null; + /** + * Duration of first audio chunk. + * + * Generated from protobuf field .google.protobuf.Duration first_audio_duration = 3; + */ + private $first_audio_duration = null; + /** + * Whether client used single utterance mode. + * + * Generated from protobuf field bool single_utterance = 5; + */ + private $single_utterance = false; + /** + * Time offsets of the speech partial results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration speech_partial_results_end_times = 6; + */ + private $speech_partial_results_end_times; + /** + * Time offsets of the speech final results (is_final=true) relative to the + * beginning of the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration speech_final_results_end_times = 7; + */ + private $speech_final_results_end_times; + /** + * Total number of partial responses. + * + * Generated from protobuf field int32 partial_responses = 8; + */ + private $partial_responses = 0; + /** + * Time offset of Speaker ID stream close time relative to the Speech stream + * close time in milliseconds. Only meaningful for conversations involving + * passive verification. + * + * Generated from protobuf field int32 speaker_id_passive_latency_ms_offset = 9; + */ + private $speaker_id_passive_latency_ms_offset = 0; + /** + * Whether a barge-in event is triggered in this request. + * + * Generated from protobuf field bool bargein_event_triggered = 10; + */ + private $bargein_event_triggered = false; + /** + * Whether speech uses single utterance mode. + * + * Generated from protobuf field bool speech_single_utterance = 11; + */ + private $speech_single_utterance = false; + /** + * Time offsets of the DTMF partial results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration dtmf_partial_results_times = 12; + */ + private $dtmf_partial_results_times; + /** + * Time offsets of the DTMF final results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration dtmf_final_results_times = 13; + */ + private $dtmf_final_results_times; + /** + * Time offset of the end-of-single-utterance signal relative to the + * beginning of the stream. + * + * Generated from protobuf field .google.protobuf.Duration single_utterance_end_time_offset = 14; + */ + private $single_utterance_end_time_offset = null; + /** + * No speech timeout settings observed at runtime. + * + * Generated from protobuf field .google.protobuf.Duration no_speech_timeout = 15; + */ + private $no_speech_timeout = null; + /** + * Whether the streaming terminates with an injected text query. + * + * Generated from protobuf field bool is_input_text = 16; + */ + private $is_input_text = false; + /** + * Client half close time in terms of input audio duration. + * + * Generated from protobuf field .google.protobuf.Duration client_half_close_time_offset = 17; + */ + private $client_half_close_time_offset = null; + /** + * Client half close time in terms of API streaming duration. + * + * Generated from protobuf field .google.protobuf.Duration client_half_close_streaming_time_offset = 18; + */ + private $client_half_close_streaming_time_offset = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $audio_data_chunks + * Number of input audio data chunks in streaming requests. + * @type \Google\Protobuf\Duration $result_end_time_offset + * Time offset of the end of speech utterance relative to the + * beginning of the first audio chunk. + * @type \Google\Protobuf\Duration $first_audio_duration + * Duration of first audio chunk. + * @type bool $single_utterance + * Whether client used single utterance mode. + * @type array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $speech_partial_results_end_times + * Time offsets of the speech partial results relative to the beginning of + * the stream. + * @type array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $speech_final_results_end_times + * Time offsets of the speech final results (is_final=true) relative to the + * beginning of the stream. + * @type int $partial_responses + * Total number of partial responses. + * @type int $speaker_id_passive_latency_ms_offset + * Time offset of Speaker ID stream close time relative to the Speech stream + * close time in milliseconds. Only meaningful for conversations involving + * passive verification. + * @type bool $bargein_event_triggered + * Whether a barge-in event is triggered in this request. + * @type bool $speech_single_utterance + * Whether speech uses single utterance mode. + * @type array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $dtmf_partial_results_times + * Time offsets of the DTMF partial results relative to the beginning of + * the stream. + * @type array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $dtmf_final_results_times + * Time offsets of the DTMF final results relative to the beginning of + * the stream. + * @type \Google\Protobuf\Duration $single_utterance_end_time_offset + * Time offset of the end-of-single-utterance signal relative to the + * beginning of the stream. + * @type \Google\Protobuf\Duration $no_speech_timeout + * No speech timeout settings observed at runtime. + * @type bool $is_input_text + * Whether the streaming terminates with an injected text query. + * @type \Google\Protobuf\Duration $client_half_close_time_offset + * Client half close time in terms of input audio duration. + * @type \Google\Protobuf\Duration $client_half_close_streaming_time_offset + * Client half close time in terms of API streaming duration. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\V2\Session::initOnce(); + parent::__construct($data); + } + + /** + * Number of input audio data chunks in streaming requests. + * + * Generated from protobuf field int32 audio_data_chunks = 1; + * @return int + */ + public function getAudioDataChunks() + { + return $this->audio_data_chunks; + } + + /** + * Number of input audio data chunks in streaming requests. + * + * Generated from protobuf field int32 audio_data_chunks = 1; + * @param int $var + * @return $this + */ + public function setAudioDataChunks($var) + { + GPBUtil::checkInt32($var); + $this->audio_data_chunks = $var; + + return $this; + } + + /** + * Time offset of the end of speech utterance relative to the + * beginning of the first audio chunk. + * + * Generated from protobuf field .google.protobuf.Duration result_end_time_offset = 2; + * @return \Google\Protobuf\Duration|null + */ + public function getResultEndTimeOffset() + { + return $this->result_end_time_offset; + } + + public function hasResultEndTimeOffset() + { + return isset($this->result_end_time_offset); + } + + public function clearResultEndTimeOffset() + { + unset($this->result_end_time_offset); + } + + /** + * Time offset of the end of speech utterance relative to the + * beginning of the first audio chunk. + * + * Generated from protobuf field .google.protobuf.Duration result_end_time_offset = 2; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setResultEndTimeOffset($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->result_end_time_offset = $var; + + return $this; + } + + /** + * Duration of first audio chunk. + * + * Generated from protobuf field .google.protobuf.Duration first_audio_duration = 3; + * @return \Google\Protobuf\Duration|null + */ + public function getFirstAudioDuration() + { + return $this->first_audio_duration; + } + + public function hasFirstAudioDuration() + { + return isset($this->first_audio_duration); + } + + public function clearFirstAudioDuration() + { + unset($this->first_audio_duration); + } + + /** + * Duration of first audio chunk. + * + * Generated from protobuf field .google.protobuf.Duration first_audio_duration = 3; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setFirstAudioDuration($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->first_audio_duration = $var; + + return $this; + } + + /** + * Whether client used single utterance mode. + * + * Generated from protobuf field bool single_utterance = 5; + * @return bool + */ + public function getSingleUtterance() + { + return $this->single_utterance; + } + + /** + * Whether client used single utterance mode. + * + * Generated from protobuf field bool single_utterance = 5; + * @param bool $var + * @return $this + */ + public function setSingleUtterance($var) + { + GPBUtil::checkBool($var); + $this->single_utterance = $var; + + return $this; + } + + /** + * Time offsets of the speech partial results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration speech_partial_results_end_times = 6; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSpeechPartialResultsEndTimes() + { + return $this->speech_partial_results_end_times; + } + + /** + * Time offsets of the speech partial results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration speech_partial_results_end_times = 6; + * @param array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSpeechPartialResultsEndTimes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Duration::class); + $this->speech_partial_results_end_times = $arr; + + return $this; + } + + /** + * Time offsets of the speech final results (is_final=true) relative to the + * beginning of the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration speech_final_results_end_times = 7; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSpeechFinalResultsEndTimes() + { + return $this->speech_final_results_end_times; + } + + /** + * Time offsets of the speech final results (is_final=true) relative to the + * beginning of the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration speech_final_results_end_times = 7; + * @param array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSpeechFinalResultsEndTimes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Duration::class); + $this->speech_final_results_end_times = $arr; + + return $this; + } + + /** + * Total number of partial responses. + * + * Generated from protobuf field int32 partial_responses = 8; + * @return int + */ + public function getPartialResponses() + { + return $this->partial_responses; + } + + /** + * Total number of partial responses. + * + * Generated from protobuf field int32 partial_responses = 8; + * @param int $var + * @return $this + */ + public function setPartialResponses($var) + { + GPBUtil::checkInt32($var); + $this->partial_responses = $var; + + return $this; + } + + /** + * Time offset of Speaker ID stream close time relative to the Speech stream + * close time in milliseconds. Only meaningful for conversations involving + * passive verification. + * + * Generated from protobuf field int32 speaker_id_passive_latency_ms_offset = 9; + * @return int + */ + public function getSpeakerIdPassiveLatencyMsOffset() + { + return $this->speaker_id_passive_latency_ms_offset; + } + + /** + * Time offset of Speaker ID stream close time relative to the Speech stream + * close time in milliseconds. Only meaningful for conversations involving + * passive verification. + * + * Generated from protobuf field int32 speaker_id_passive_latency_ms_offset = 9; + * @param int $var + * @return $this + */ + public function setSpeakerIdPassiveLatencyMsOffset($var) + { + GPBUtil::checkInt32($var); + $this->speaker_id_passive_latency_ms_offset = $var; + + return $this; + } + + /** + * Whether a barge-in event is triggered in this request. + * + * Generated from protobuf field bool bargein_event_triggered = 10; + * @return bool + */ + public function getBargeinEventTriggered() + { + return $this->bargein_event_triggered; + } + + /** + * Whether a barge-in event is triggered in this request. + * + * Generated from protobuf field bool bargein_event_triggered = 10; + * @param bool $var + * @return $this + */ + public function setBargeinEventTriggered($var) + { + GPBUtil::checkBool($var); + $this->bargein_event_triggered = $var; + + return $this; + } + + /** + * Whether speech uses single utterance mode. + * + * Generated from protobuf field bool speech_single_utterance = 11; + * @return bool + */ + public function getSpeechSingleUtterance() + { + return $this->speech_single_utterance; + } + + /** + * Whether speech uses single utterance mode. + * + * Generated from protobuf field bool speech_single_utterance = 11; + * @param bool $var + * @return $this + */ + public function setSpeechSingleUtterance($var) + { + GPBUtil::checkBool($var); + $this->speech_single_utterance = $var; + + return $this; + } + + /** + * Time offsets of the DTMF partial results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration dtmf_partial_results_times = 12; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDtmfPartialResultsTimes() + { + return $this->dtmf_partial_results_times; + } + + /** + * Time offsets of the DTMF partial results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration dtmf_partial_results_times = 12; + * @param array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDtmfPartialResultsTimes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Duration::class); + $this->dtmf_partial_results_times = $arr; + + return $this; + } + + /** + * Time offsets of the DTMF final results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration dtmf_final_results_times = 13; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDtmfFinalResultsTimes() + { + return $this->dtmf_final_results_times; + } + + /** + * Time offsets of the DTMF final results relative to the beginning of + * the stream. + * + * Generated from protobuf field repeated .google.protobuf.Duration dtmf_final_results_times = 13; + * @param array<\Google\Protobuf\Duration>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDtmfFinalResultsTimes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Duration::class); + $this->dtmf_final_results_times = $arr; + + return $this; + } + + /** + * Time offset of the end-of-single-utterance signal relative to the + * beginning of the stream. + * + * Generated from protobuf field .google.protobuf.Duration single_utterance_end_time_offset = 14; + * @return \Google\Protobuf\Duration|null + */ + public function getSingleUtteranceEndTimeOffset() + { + return $this->single_utterance_end_time_offset; + } + + public function hasSingleUtteranceEndTimeOffset() + { + return isset($this->single_utterance_end_time_offset); + } + + public function clearSingleUtteranceEndTimeOffset() + { + unset($this->single_utterance_end_time_offset); + } + + /** + * Time offset of the end-of-single-utterance signal relative to the + * beginning of the stream. + * + * Generated from protobuf field .google.protobuf.Duration single_utterance_end_time_offset = 14; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setSingleUtteranceEndTimeOffset($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->single_utterance_end_time_offset = $var; + + return $this; + } + + /** + * No speech timeout settings observed at runtime. + * + * Generated from protobuf field .google.protobuf.Duration no_speech_timeout = 15; + * @return \Google\Protobuf\Duration|null + */ + public function getNoSpeechTimeout() + { + return $this->no_speech_timeout; + } + + public function hasNoSpeechTimeout() + { + return isset($this->no_speech_timeout); + } + + public function clearNoSpeechTimeout() + { + unset($this->no_speech_timeout); + } + + /** + * No speech timeout settings observed at runtime. + * + * Generated from protobuf field .google.protobuf.Duration no_speech_timeout = 15; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setNoSpeechTimeout($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->no_speech_timeout = $var; + + return $this; + } + + /** + * Whether the streaming terminates with an injected text query. + * + * Generated from protobuf field bool is_input_text = 16; + * @return bool + */ + public function getIsInputText() + { + return $this->is_input_text; + } + + /** + * Whether the streaming terminates with an injected text query. + * + * Generated from protobuf field bool is_input_text = 16; + * @param bool $var + * @return $this + */ + public function setIsInputText($var) + { + GPBUtil::checkBool($var); + $this->is_input_text = $var; + + return $this; + } + + /** + * Client half close time in terms of input audio duration. + * + * Generated from protobuf field .google.protobuf.Duration client_half_close_time_offset = 17; + * @return \Google\Protobuf\Duration|null + */ + public function getClientHalfCloseTimeOffset() + { + return $this->client_half_close_time_offset; + } + + public function hasClientHalfCloseTimeOffset() + { + return isset($this->client_half_close_time_offset); + } + + public function clearClientHalfCloseTimeOffset() + { + unset($this->client_half_close_time_offset); + } + + /** + * Client half close time in terms of input audio duration. + * + * Generated from protobuf field .google.protobuf.Duration client_half_close_time_offset = 17; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setClientHalfCloseTimeOffset($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->client_half_close_time_offset = $var; + + return $this; + } + + /** + * Client half close time in terms of API streaming duration. + * + * Generated from protobuf field .google.protobuf.Duration client_half_close_streaming_time_offset = 18; + * @return \Google\Protobuf\Duration|null + */ + public function getClientHalfCloseStreamingTimeOffset() + { + return $this->client_half_close_streaming_time_offset; + } + + public function hasClientHalfCloseStreamingTimeOffset() + { + return isset($this->client_half_close_streaming_time_offset); + } + + public function clearClientHalfCloseStreamingTimeOffset() + { + unset($this->client_half_close_streaming_time_offset); + } + + /** + * Client half close time in terms of API streaming duration. + * + * Generated from protobuf field .google.protobuf.Duration client_half_close_streaming_time_offset = 18; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setClientHalfCloseStreamingTimeOffset($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->client_half_close_streaming_time_offset = $var; + + return $this; + } + +} + diff --git a/Dialogflow/src/V2/Gapic/ConversationsGapicClient.php b/Dialogflow/src/V2/Gapic/ConversationsGapicClient.php index 6c25d62db038..e8ef8925a233 100644 --- a/Dialogflow/src/V2/Gapic/ConversationsGapicClient.php +++ b/Dialogflow/src/V2/Gapic/ConversationsGapicClient.php @@ -37,7 +37,11 @@ use Google\Cloud\Dialogflow\V2\AssistQueryParameters; use Google\Cloud\Dialogflow\V2\CompleteConversationRequest; use Google\Cloud\Dialogflow\V2\Conversation; +use Google\Cloud\Dialogflow\V2\ConversationProfile; use Google\Cloud\Dialogflow\V2\CreateConversationRequest; +use Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest; +use Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest\MinimalConversation; +use Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse; use Google\Cloud\Dialogflow\V2\GetConversationRequest; use Google\Cloud\Dialogflow\V2\ListConversationsRequest; use Google\Cloud\Dialogflow\V2\ListConversationsResponse; @@ -94,28 +98,54 @@ class ConversationsGapicClient 'https://www.googleapis.com/auth/dialogflow', ]; + private static $agentNameTemplate; + + private static $cXSecuritySettingsNameTemplate; + private static $conversationNameTemplate; + private static $conversationModelNameTemplate; + private static $conversationProfileNameTemplate; + private static $documentNameTemplate; + + private static $knowledgeBaseNameTemplate; + private static $locationNameTemplate; private static $messageNameTemplate; private static $projectNameTemplate; + private static $projectAgentNameTemplate; + private static $projectConversationNameTemplate; private static $projectConversationMessageNameTemplate; + private static $projectConversationModelNameTemplate; + private static $projectConversationProfileNameTemplate; + private static $projectKnowledgeBaseNameTemplate; + + private static $projectKnowledgeBaseDocumentNameTemplate; + + private static $projectLocationAgentNameTemplate; + private static $projectLocationConversationNameTemplate; private static $projectLocationConversationMessageNameTemplate; + private static $projectLocationConversationModelNameTemplate; + private static $projectLocationConversationProfileNameTemplate; + private static $projectLocationKnowledgeBaseNameTemplate; + + private static $projectLocationKnowledgeBaseDocumentNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() @@ -137,6 +167,24 @@ private static function getClientDefaults() ]; } + private static function getAgentNameTemplate() + { + if (self::$agentNameTemplate == null) { + self::$agentNameTemplate = new PathTemplate('projects/{project}/agent'); + } + + return self::$agentNameTemplate; + } + + private static function getCXSecuritySettingsNameTemplate() + { + if (self::$cXSecuritySettingsNameTemplate == null) { + self::$cXSecuritySettingsNameTemplate = new PathTemplate('projects/{project}/locations/{location}/securitySettings/{security_settings}'); + } + + return self::$cXSecuritySettingsNameTemplate; + } + private static function getConversationNameTemplate() { if (self::$conversationNameTemplate == null) { @@ -146,6 +194,15 @@ private static function getConversationNameTemplate() return self::$conversationNameTemplate; } + private static function getConversationModelNameTemplate() + { + if (self::$conversationModelNameTemplate == null) { + self::$conversationModelNameTemplate = new PathTemplate('projects/{project}/locations/{location}/conversationModels/{conversation_model}'); + } + + return self::$conversationModelNameTemplate; + } + private static function getConversationProfileNameTemplate() { if (self::$conversationProfileNameTemplate == null) { @@ -155,6 +212,24 @@ private static function getConversationProfileNameTemplate() return self::$conversationProfileNameTemplate; } + private static function getDocumentNameTemplate() + { + if (self::$documentNameTemplate == null) { + self::$documentNameTemplate = new PathTemplate('projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}'); + } + + return self::$documentNameTemplate; + } + + private static function getKnowledgeBaseNameTemplate() + { + if (self::$knowledgeBaseNameTemplate == null) { + self::$knowledgeBaseNameTemplate = new PathTemplate('projects/{project}/knowledgeBases/{knowledge_base}'); + } + + return self::$knowledgeBaseNameTemplate; + } + private static function getLocationNameTemplate() { if (self::$locationNameTemplate == null) { @@ -182,6 +257,15 @@ private static function getProjectNameTemplate() return self::$projectNameTemplate; } + private static function getProjectAgentNameTemplate() + { + if (self::$projectAgentNameTemplate == null) { + self::$projectAgentNameTemplate = new PathTemplate('projects/{project}/agent'); + } + + return self::$projectAgentNameTemplate; + } + private static function getProjectConversationNameTemplate() { if (self::$projectConversationNameTemplate == null) { @@ -200,6 +284,15 @@ private static function getProjectConversationMessageNameTemplate() return self::$projectConversationMessageNameTemplate; } + private static function getProjectConversationModelNameTemplate() + { + if (self::$projectConversationModelNameTemplate == null) { + self::$projectConversationModelNameTemplate = new PathTemplate('projects/{project}/conversationModels/{conversation_model}'); + } + + return self::$projectConversationModelNameTemplate; + } + private static function getProjectConversationProfileNameTemplate() { if (self::$projectConversationProfileNameTemplate == null) { @@ -209,6 +302,33 @@ private static function getProjectConversationProfileNameTemplate() return self::$projectConversationProfileNameTemplate; } + private static function getProjectKnowledgeBaseNameTemplate() + { + if (self::$projectKnowledgeBaseNameTemplate == null) { + self::$projectKnowledgeBaseNameTemplate = new PathTemplate('projects/{project}/knowledgeBases/{knowledge_base}'); + } + + return self::$projectKnowledgeBaseNameTemplate; + } + + private static function getProjectKnowledgeBaseDocumentNameTemplate() + { + if (self::$projectKnowledgeBaseDocumentNameTemplate == null) { + self::$projectKnowledgeBaseDocumentNameTemplate = new PathTemplate('projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}'); + } + + return self::$projectKnowledgeBaseDocumentNameTemplate; + } + + private static function getProjectLocationAgentNameTemplate() + { + if (self::$projectLocationAgentNameTemplate == null) { + self::$projectLocationAgentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agent'); + } + + return self::$projectLocationAgentNameTemplate; + } + private static function getProjectLocationConversationNameTemplate() { if (self::$projectLocationConversationNameTemplate == null) { @@ -227,6 +347,15 @@ private static function getProjectLocationConversationMessageNameTemplate() return self::$projectLocationConversationMessageNameTemplate; } + private static function getProjectLocationConversationModelNameTemplate() + { + if (self::$projectLocationConversationModelNameTemplate == null) { + self::$projectLocationConversationModelNameTemplate = new PathTemplate('projects/{project}/locations/{location}/conversationModels/{conversation_model}'); + } + + return self::$projectLocationConversationModelNameTemplate; + } + private static function getProjectLocationConversationProfileNameTemplate() { if (self::$projectLocationConversationProfileNameTemplate == null) { @@ -236,27 +365,92 @@ private static function getProjectLocationConversationProfileNameTemplate() return self::$projectLocationConversationProfileNameTemplate; } + private static function getProjectLocationKnowledgeBaseNameTemplate() + { + if (self::$projectLocationKnowledgeBaseNameTemplate == null) { + self::$projectLocationKnowledgeBaseNameTemplate = new PathTemplate('projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}'); + } + + return self::$projectLocationKnowledgeBaseNameTemplate; + } + + private static function getProjectLocationKnowledgeBaseDocumentNameTemplate() + { + if (self::$projectLocationKnowledgeBaseDocumentNameTemplate == null) { + self::$projectLocationKnowledgeBaseDocumentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document}'); + } + + return self::$projectLocationKnowledgeBaseDocumentNameTemplate; + } + private static function getPathTemplateMap() { if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ + 'agent' => self::getAgentNameTemplate(), + 'cXSecuritySettings' => self::getCXSecuritySettingsNameTemplate(), 'conversation' => self::getConversationNameTemplate(), + 'conversationModel' => self::getConversationModelNameTemplate(), 'conversationProfile' => self::getConversationProfileNameTemplate(), + 'document' => self::getDocumentNameTemplate(), + 'knowledgeBase' => self::getKnowledgeBaseNameTemplate(), 'location' => self::getLocationNameTemplate(), 'message' => self::getMessageNameTemplate(), 'project' => self::getProjectNameTemplate(), + 'projectAgent' => self::getProjectAgentNameTemplate(), 'projectConversation' => self::getProjectConversationNameTemplate(), 'projectConversationMessage' => self::getProjectConversationMessageNameTemplate(), + 'projectConversationModel' => self::getProjectConversationModelNameTemplate(), 'projectConversationProfile' => self::getProjectConversationProfileNameTemplate(), + 'projectKnowledgeBase' => self::getProjectKnowledgeBaseNameTemplate(), + 'projectKnowledgeBaseDocument' => self::getProjectKnowledgeBaseDocumentNameTemplate(), + 'projectLocationAgent' => self::getProjectLocationAgentNameTemplate(), 'projectLocationConversation' => self::getProjectLocationConversationNameTemplate(), 'projectLocationConversationMessage' => self::getProjectLocationConversationMessageNameTemplate(), + 'projectLocationConversationModel' => self::getProjectLocationConversationModelNameTemplate(), 'projectLocationConversationProfile' => self::getProjectLocationConversationProfileNameTemplate(), + 'projectLocationKnowledgeBase' => self::getProjectLocationKnowledgeBaseNameTemplate(), + 'projectLocationKnowledgeBaseDocument' => self::getProjectLocationKnowledgeBaseDocumentNameTemplate(), ]; } return self::$pathTemplateMap; } + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName($project) + { + return self::getAgentNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cx_security_settings resource. + * + * @param string $project + * @param string $location + * @param string $securitySettings + * + * @return string The formatted cx_security_settings resource. + */ + public static function cXSecuritySettingsName($project, $location, $securitySettings) + { + return self::getCXSecuritySettingsNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'security_settings' => $securitySettings, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a conversation * resource. @@ -274,6 +468,25 @@ public static function conversationName($project, $conversation) ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted conversation_model resource. + */ + public static function conversationModelName($project, $location, $conversationModel) + { + return self::getConversationModelNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * conversation_profile resource. @@ -291,6 +504,42 @@ public static function conversationProfileName($project, $conversationProfile) ]); } + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted document resource. + */ + public static function documentName($project, $knowledgeBase, $document) + { + return self::getDocumentNameTemplate()->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted knowledge_base resource. + */ + public static function knowledgeBaseName($project, $knowledgeBase) + { + return self::getKnowledgeBaseNameTemplate()->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a location * resource. @@ -342,6 +591,21 @@ public static function projectName($project) ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName($project) + { + return self::getProjectAgentNameTemplate()->render([ + 'project' => $project, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * project_conversation resource. @@ -378,6 +642,23 @@ public static function projectConversationMessageName($project, $conversation, $ ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_model resource. + * + * @param string $project + * @param string $conversationModel + * + * @return string The formatted project_conversation_model resource. + */ + public static function projectConversationModelName($project, $conversationModel) + { + return self::getProjectConversationModelNameTemplate()->render([ + 'project' => $project, + 'conversation_model' => $conversationModel, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * project_conversation_profile resource. @@ -395,6 +676,59 @@ public static function projectConversationProfileName($project, $conversationPro ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted project_knowledge_base resource. + */ + public static function projectKnowledgeBaseName($project, $knowledgeBase) + { + return self::getProjectKnowledgeBaseNameTemplate()->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base_document resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_knowledge_base_document resource. + */ + public static function projectKnowledgeBaseDocumentName($project, $knowledgeBase, $document) + { + return self::getProjectKnowledgeBaseDocumentNameTemplate()->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName($project, $location) + { + return self::getProjectLocationAgentNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * project_location_conversation resource. @@ -435,6 +769,25 @@ public static function projectLocationConversationMessageName($project, $locatio ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted project_location_conversation_model resource. + */ + public static function projectLocationConversationModelName($project, $location, $conversationModel) + { + return self::getProjectLocationConversationModelNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * project_location_conversation_profile resource. @@ -454,21 +807,74 @@ public static function projectLocationConversationProfileName($project, $locatio ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * + * @return string The formatted project_location_knowledge_base resource. + */ + public static function projectLocationKnowledgeBaseName($project, $location, $knowledgeBase) + { + return self::getProjectLocationKnowledgeBaseNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base_document resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_location_knowledge_base_document resource. + */ + public static function projectLocationKnowledgeBaseDocumentName($project, $location, $knowledgeBase, $document) + { + return self::getProjectLocationKnowledgeBaseDocumentNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + /** * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: * Template: Pattern + * - agent: projects/{project}/agent + * - cXSecuritySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} * - conversation: projects/{project}/conversations/{conversation} + * - conversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} * - conversationProfile: projects/{project}/conversationProfiles/{conversation_profile} + * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} * - location: projects/{project}/locations/{location} * - message: projects/{project}/conversations/{conversation}/messages/{message} * - project: projects/{project} + * - projectAgent: projects/{project}/agent * - projectConversation: projects/{project}/conversations/{conversation} * - projectConversationMessage: projects/{project}/conversations/{conversation}/messages/{message} + * - projectConversationModel: projects/{project}/conversationModels/{conversation_model} * - projectConversationProfile: projects/{project}/conversationProfiles/{conversation_profile} + * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - projectLocationAgent: projects/{project}/locations/{location}/agent * - projectLocationConversation: projects/{project}/locations/{location}/conversations/{conversation} * - projectLocationConversationMessage: projects/{project}/locations/{location}/conversations/{conversation}/messages/{message} + * - projectLocationConversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} * - projectLocationConversationProfile: projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} + * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} + * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} * * The optional $template argument can be supplied to specify a particular pattern, * and must match one of the templates listed above. If no $template argument is @@ -685,6 +1091,69 @@ public function createConversation($parent, $conversation, array $optionalArgs = return $this->startCall('CreateConversation', Conversation::class, $optionalArgs, $request)->wait(); } + /** + * Generates and returns a summary for a conversation that does not have a + * resource created for it. + * + * Sample code: + * ``` + * $conversationsClient = new ConversationsClient(); + * try { + * $statelessConversation = new MinimalConversation(); + * $conversationProfile = new ConversationProfile(); + * $response = $conversationsClient->generateStatelessSummary($statelessConversation, $conversationProfile); + * } finally { + * $conversationsClient->close(); + * } + * ``` + * + * @param MinimalConversation $statelessConversation Required. The conversation to suggest a summary for. + * @param ConversationProfile $conversationProfile Required. A ConversationProfile containing information required for Summary + * generation. + * Required fields: {language_code, security_settings} + * Optional fields: {agent_assistant_config} + * @param array $optionalArgs { + * Optional. + * + * @type string $latestMessage + * The name of the latest conversation message used as context for + * generating a Summary. If empty, the latest message of the conversation will + * be used. The format is specific to the user and the names of the messages + * provided. + * @type int $maxContextSize + * Max number of messages prior to and including + * [latest_message] to use as context when compiling the + * suggestion. By default 500 and at most 1000. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse + * + * @throws ApiException if the remote call fails + */ + public function generateStatelessSummary($statelessConversation, $conversationProfile, array $optionalArgs = []) + { + $request = new GenerateStatelessSummaryRequest(); + $requestParamHeaders = []; + $request->setStatelessConversation($statelessConversation); + $request->setConversationProfile($conversationProfile); + $requestParamHeaders['stateless_conversation.parent'] = $statelessConversation->getParent(); + if (isset($optionalArgs['latestMessage'])) { + $request->setLatestMessage($optionalArgs['latestMessage']); + } + + if (isset($optionalArgs['maxContextSize'])) { + $request->setMaxContextSize($optionalArgs['maxContextSize']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GenerateStatelessSummary', GenerateStatelessSummaryResponse::class, $optionalArgs, $request)->wait(); + } + /** * Retrieves the specific conversation. * diff --git a/Dialogflow/src/V2/GenerateStatelessSummaryRequest.php b/Dialogflow/src/V2/GenerateStatelessSummaryRequest.php new file mode 100644 index 000000000000..4f6f3e3e2206 --- /dev/null +++ b/Dialogflow/src/V2/GenerateStatelessSummaryRequest.php @@ -0,0 +1,222 @@ +google.cloud.dialogflow.v2.GenerateStatelessSummaryRequest + */ +class GenerateStatelessSummaryRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The conversation to suggest a summary for. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.GenerateStatelessSummaryRequest.MinimalConversation stateless_conversation = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $stateless_conversation = null; + /** + * Required. A ConversationProfile containing information required for Summary + * generation. + * Required fields: {language_code, security_settings} + * Optional fields: {agent_assistant_config} + * + * Generated from protobuf field .google.cloud.dialogflow.v2.ConversationProfile conversation_profile = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $conversation_profile = null; + /** + * The name of the latest conversation message used as context for + * generating a Summary. If empty, the latest message of the conversation will + * be used. The format is specific to the user and the names of the messages + * provided. + * + * Generated from protobuf field string latest_message = 3 [(.google.api.resource_reference) = { + */ + private $latest_message = ''; + /** + * Max number of messages prior to and including + * [latest_message] to use as context when compiling the + * suggestion. By default 500 and at most 1000. + * + * Generated from protobuf field int32 max_context_size = 4; + */ + private $max_context_size = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest\MinimalConversation $stateless_conversation + * Required. The conversation to suggest a summary for. + * @type \Google\Cloud\Dialogflow\V2\ConversationProfile $conversation_profile + * Required. A ConversationProfile containing information required for Summary + * generation. + * Required fields: {language_code, security_settings} + * Optional fields: {agent_assistant_config} + * @type string $latest_message + * The name of the latest conversation message used as context for + * generating a Summary. If empty, the latest message of the conversation will + * be used. The format is specific to the user and the names of the messages + * provided. + * @type int $max_context_size + * Max number of messages prior to and including + * [latest_message] to use as context when compiling the + * suggestion. By default 500 and at most 1000. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\V2\Conversation::initOnce(); + parent::__construct($data); + } + + /** + * Required. The conversation to suggest a summary for. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.GenerateStatelessSummaryRequest.MinimalConversation stateless_conversation = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest\MinimalConversation|null + */ + public function getStatelessConversation() + { + return $this->stateless_conversation; + } + + public function hasStatelessConversation() + { + return isset($this->stateless_conversation); + } + + public function clearStatelessConversation() + { + unset($this->stateless_conversation); + } + + /** + * Required. The conversation to suggest a summary for. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.GenerateStatelessSummaryRequest.MinimalConversation stateless_conversation = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest\MinimalConversation $var + * @return $this + */ + public function setStatelessConversation($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest\MinimalConversation::class); + $this->stateless_conversation = $var; + + return $this; + } + + /** + * Required. A ConversationProfile containing information required for Summary + * generation. + * Required fields: {language_code, security_settings} + * Optional fields: {agent_assistant_config} + * + * Generated from protobuf field .google.cloud.dialogflow.v2.ConversationProfile conversation_profile = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dialogflow\V2\ConversationProfile|null + */ + public function getConversationProfile() + { + return $this->conversation_profile; + } + + public function hasConversationProfile() + { + return isset($this->conversation_profile); + } + + public function clearConversationProfile() + { + unset($this->conversation_profile); + } + + /** + * Required. A ConversationProfile containing information required for Summary + * generation. + * Required fields: {language_code, security_settings} + * Optional fields: {agent_assistant_config} + * + * Generated from protobuf field .google.cloud.dialogflow.v2.ConversationProfile conversation_profile = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dialogflow\V2\ConversationProfile $var + * @return $this + */ + public function setConversationProfile($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\ConversationProfile::class); + $this->conversation_profile = $var; + + return $this; + } + + /** + * The name of the latest conversation message used as context for + * generating a Summary. If empty, the latest message of the conversation will + * be used. The format is specific to the user and the names of the messages + * provided. + * + * Generated from protobuf field string latest_message = 3 [(.google.api.resource_reference) = { + * @return string + */ + public function getLatestMessage() + { + return $this->latest_message; + } + + /** + * The name of the latest conversation message used as context for + * generating a Summary. If empty, the latest message of the conversation will + * be used. The format is specific to the user and the names of the messages + * provided. + * + * Generated from protobuf field string latest_message = 3 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setLatestMessage($var) + { + GPBUtil::checkString($var, True); + $this->latest_message = $var; + + return $this; + } + + /** + * Max number of messages prior to and including + * [latest_message] to use as context when compiling the + * suggestion. By default 500 and at most 1000. + * + * Generated from protobuf field int32 max_context_size = 4; + * @return int + */ + public function getMaxContextSize() + { + return $this->max_context_size; + } + + /** + * Max number of messages prior to and including + * [latest_message] to use as context when compiling the + * suggestion. By default 500 and at most 1000. + * + * Generated from protobuf field int32 max_context_size = 4; + * @param int $var + * @return $this + */ + public function setMaxContextSize($var) + { + GPBUtil::checkInt32($var); + $this->max_context_size = $var; + + return $this; + } + +} + diff --git a/Dialogflow/src/V2/GenerateStatelessSummaryRequest/MinimalConversation.php b/Dialogflow/src/V2/GenerateStatelessSummaryRequest/MinimalConversation.php new file mode 100644 index 000000000000..59e8f8e47bfd --- /dev/null +++ b/Dialogflow/src/V2/GenerateStatelessSummaryRequest/MinimalConversation.php @@ -0,0 +1,123 @@ +google.cloud.dialogflow.v2.GenerateStatelessSummaryRequest.MinimalConversation + */ +class MinimalConversation extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The messages that the Summary will be generated from. It is + * expected that this message content is already redacted and does not + * contain any PII. Required fields: {content, language_code, participant, + * participant_role} Optional fields: {send_time} If send_time is not + * provided, then the messages must be provided in chronological order. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.v2.Message messages = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $messages; + /** + * Required. The parent resource to charge for the Summary's generation. + * Format: `projects//locations/`. + * + * Generated from protobuf field string parent = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Dialogflow\V2\Message>|\Google\Protobuf\Internal\RepeatedField $messages + * Required. The messages that the Summary will be generated from. It is + * expected that this message content is already redacted and does not + * contain any PII. Required fields: {content, language_code, participant, + * participant_role} Optional fields: {send_time} If send_time is not + * provided, then the messages must be provided in chronological order. + * @type string $parent + * Required. The parent resource to charge for the Summary's generation. + * Format: `projects//locations/`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\V2\Conversation::initOnce(); + parent::__construct($data); + } + + /** + * Required. The messages that the Summary will be generated from. It is + * expected that this message content is already redacted and does not + * contain any PII. Required fields: {content, language_code, participant, + * participant_role} Optional fields: {send_time} If send_time is not + * provided, then the messages must be provided in chronological order. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.v2.Message messages = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMessages() + { + return $this->messages; + } + + /** + * Required. The messages that the Summary will be generated from. It is + * expected that this message content is already redacted and does not + * contain any PII. Required fields: {content, language_code, participant, + * participant_role} Optional fields: {send_time} If send_time is not + * provided, then the messages must be provided in chronological order. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.v2.Message messages = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param array<\Google\Cloud\Dialogflow\V2\Message>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMessages($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Message::class); + $this->messages = $arr; + + return $this; + } + + /** + * Required. The parent resource to charge for the Summary's generation. + * Format: `projects//locations/`. + * + * Generated from protobuf field string parent = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent resource to charge for the Summary's generation. + * Format: `projects//locations/`. + * + * Generated from protobuf field string parent = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + +} + + diff --git a/Dialogflow/src/V2/GenerateStatelessSummaryResponse.php b/Dialogflow/src/V2/GenerateStatelessSummaryResponse.php new file mode 100644 index 000000000000..d6b50164ed5e --- /dev/null +++ b/Dialogflow/src/V2/GenerateStatelessSummaryResponse.php @@ -0,0 +1,166 @@ +google.cloud.dialogflow.v2.GenerateStatelessSummaryResponse + */ +class GenerateStatelessSummaryResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated summary. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.GenerateStatelessSummaryResponse.Summary summary = 1; + */ + private $summary = null; + /** + * The name of the latest conversation message used as context for + * compiling suggestion. The format is specific to the user and the names of + * the messages provided. + * + * Generated from protobuf field string latest_message = 2 [(.google.api.resource_reference) = { + */ + private $latest_message = ''; + /** + * Number of messages prior to and including + * [last_conversation_message][] used to compile the suggestion. It may be + * smaller than the [GenerateStatelessSummaryRequest.context_size][] field in + * the request if there weren't that many messages in the conversation. + * + * Generated from protobuf field int32 context_size = 3; + */ + private $context_size = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse\Summary $summary + * Generated summary. + * @type string $latest_message + * The name of the latest conversation message used as context for + * compiling suggestion. The format is specific to the user and the names of + * the messages provided. + * @type int $context_size + * Number of messages prior to and including + * [last_conversation_message][] used to compile the suggestion. It may be + * smaller than the [GenerateStatelessSummaryRequest.context_size][] field in + * the request if there weren't that many messages in the conversation. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\V2\Conversation::initOnce(); + parent::__construct($data); + } + + /** + * Generated summary. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.GenerateStatelessSummaryResponse.Summary summary = 1; + * @return \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse\Summary|null + */ + public function getSummary() + { + return $this->summary; + } + + public function hasSummary() + { + return isset($this->summary); + } + + public function clearSummary() + { + unset($this->summary); + } + + /** + * Generated summary. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.GenerateStatelessSummaryResponse.Summary summary = 1; + * @param \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse\Summary $var + * @return $this + */ + public function setSummary($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse\Summary::class); + $this->summary = $var; + + return $this; + } + + /** + * The name of the latest conversation message used as context for + * compiling suggestion. The format is specific to the user and the names of + * the messages provided. + * + * Generated from protobuf field string latest_message = 2 [(.google.api.resource_reference) = { + * @return string + */ + public function getLatestMessage() + { + return $this->latest_message; + } + + /** + * The name of the latest conversation message used as context for + * compiling suggestion. The format is specific to the user and the names of + * the messages provided. + * + * Generated from protobuf field string latest_message = 2 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setLatestMessage($var) + { + GPBUtil::checkString($var, True); + $this->latest_message = $var; + + return $this; + } + + /** + * Number of messages prior to and including + * [last_conversation_message][] used to compile the suggestion. It may be + * smaller than the [GenerateStatelessSummaryRequest.context_size][] field in + * the request if there weren't that many messages in the conversation. + * + * Generated from protobuf field int32 context_size = 3; + * @return int + */ + public function getContextSize() + { + return $this->context_size; + } + + /** + * Number of messages prior to and including + * [last_conversation_message][] used to compile the suggestion. It may be + * smaller than the [GenerateStatelessSummaryRequest.context_size][] field in + * the request if there weren't that many messages in the conversation. + * + * Generated from protobuf field int32 context_size = 3; + * @param int $var + * @return $this + */ + public function setContextSize($var) + { + GPBUtil::checkInt32($var); + $this->context_size = $var; + + return $this; + } + +} + diff --git a/Dialogflow/src/V2/GenerateStatelessSummaryResponse/Summary.php b/Dialogflow/src/V2/GenerateStatelessSummaryResponse/Summary.php new file mode 100644 index 000000000000..d926922356d3 --- /dev/null +++ b/Dialogflow/src/V2/GenerateStatelessSummaryResponse/Summary.php @@ -0,0 +1,110 @@ +google.cloud.dialogflow.v2.GenerateStatelessSummaryResponse.Summary + */ +class Summary extends \Google\Protobuf\Internal\Message +{ + /** + * The summary content that is concatenated into one string. + * + * Generated from protobuf field string text = 1; + */ + private $text = ''; + /** + * The summary content that is divided into sections. The key is the + * section's name and the value is the section's content. There is no + * specific format for the key or value. + * + * Generated from protobuf field map text_sections = 2; + */ + private $text_sections; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $text + * The summary content that is concatenated into one string. + * @type array|\Google\Protobuf\Internal\MapField $text_sections + * The summary content that is divided into sections. The key is the + * section's name and the value is the section's content. There is no + * specific format for the key or value. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\V2\Conversation::initOnce(); + parent::__construct($data); + } + + /** + * The summary content that is concatenated into one string. + * + * Generated from protobuf field string text = 1; + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * The summary content that is concatenated into one string. + * + * Generated from protobuf field string text = 1; + * @param string $var + * @return $this + */ + public function setText($var) + { + GPBUtil::checkString($var, True); + $this->text = $var; + + return $this; + } + + /** + * The summary content that is divided into sections. The key is the + * section's name and the value is the section's content. There is no + * specific format for the key or value. + * + * Generated from protobuf field map text_sections = 2; + * @return \Google\Protobuf\Internal\MapField + */ + public function getTextSections() + { + return $this->text_sections; + } + + /** + * The summary content that is divided into sections. The key is the + * section's name and the value is the section's content. There is no + * specific format for the key or value. + * + * Generated from protobuf field map text_sections = 2; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setTextSections($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->text_sections = $arr; + + return $this; + } + +} + + diff --git a/Dialogflow/src/V2/InputAudioConfig.php b/Dialogflow/src/V2/InputAudioConfig.php index b7e34b11675b..8cc6ee745a09 100644 --- a/Dialogflow/src/V2/InputAudioConfig.php +++ b/Dialogflow/src/V2/InputAudioConfig.php @@ -87,6 +87,11 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * [Cloud Speech API * documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model) * for more details. + * If you specify a model, the following models typically have the best + * performance: + * - phone_call (best for Agent Assist and telephony) + * - latest_short (best for Dialogflow non-telephony) + * - command_and_search (best for very short utterances and commands) * * Generated from protobuf field string model = 7; */ @@ -124,6 +129,12 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool disable_no_speech_recognized_event = 14; */ private $disable_no_speech_recognized_event = false; + /** + * Enable automatic punctuation option at the speech backend. + * + * Generated from protobuf field bool enable_automatic_punctuation = 17; + */ + private $enable_automatic_punctuation = false; /** * Constructor. @@ -178,6 +189,11 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * [Cloud Speech API * documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model) * for more details. + * If you specify a model, the following models typically have the best + * performance: + * - phone_call (best for Agent Assist and telephony) + * - latest_short (best for Dialogflow non-telephony) + * - command_and_search (best for very short utterances and commands) * @type int $model_variant * Which variant of the [Speech * model][google.cloud.dialogflow.v2.InputAudioConfig.model] to use. @@ -199,6 +215,8 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * [Participants.StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent]. * If `false` and recognition doesn't return any result, trigger * `NO_SPEECH_RECOGNIZED` event to Dialogflow agent. + * @type bool $enable_automatic_punctuation + * Enable automatic punctuation option at the speech backend. * } */ public function __construct($data = NULL) { @@ -424,6 +442,11 @@ public function setSpeechContexts($var) * [Cloud Speech API * documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model) * for more details. + * If you specify a model, the following models typically have the best + * performance: + * - phone_call (best for Agent Assist and telephony) + * - latest_short (best for Dialogflow non-telephony) + * - command_and_search (best for very short utterances and commands) * * Generated from protobuf field string model = 7; * @return string @@ -445,6 +468,11 @@ public function getModel() * [Cloud Speech API * documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model) * for more details. + * If you specify a model, the following models typically have the best + * performance: + * - phone_call (best for Agent Assist and telephony) + * - latest_short (best for Dialogflow non-telephony) + * - command_and_search (best for very short utterances and commands) * * Generated from protobuf field string model = 7; * @param string $var @@ -566,5 +594,31 @@ public function setDisableNoSpeechRecognizedEvent($var) return $this; } + /** + * Enable automatic punctuation option at the speech backend. + * + * Generated from protobuf field bool enable_automatic_punctuation = 17; + * @return bool + */ + public function getEnableAutomaticPunctuation() + { + return $this->enable_automatic_punctuation; + } + + /** + * Enable automatic punctuation option at the speech backend. + * + * Generated from protobuf field bool enable_automatic_punctuation = 17; + * @param bool $var + * @return $this + */ + public function setEnableAutomaticPunctuation($var) + { + GPBUtil::checkBool($var); + $this->enable_automatic_punctuation = $var; + + return $this; + } + } diff --git a/Dialogflow/src/V2/StreamingAnalyzeContentRequest.php b/Dialogflow/src/V2/StreamingAnalyzeContentRequest.php index f8a3666ad06b..081f68b30dd2 100644 --- a/Dialogflow/src/V2/StreamingAnalyzeContentRequest.php +++ b/Dialogflow/src/V2/StreamingAnalyzeContentRequest.php @@ -96,6 +96,13 @@ class StreamingAnalyzeContentRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool enable_partial_automated_agent_reply = 12; */ private $enable_partial_automated_agent_reply = false; + /** + * If true, `StreamingAnalyzeContentResponse.debugging_info` will get + * populated. + * + * Generated from protobuf field bool enable_debugging_info = 19; + */ + private $enable_debugging_info = false; protected $config; protected $input; @@ -147,6 +154,9 @@ class StreamingAnalyzeContentRequest extends \Google\Protobuf\Internal\Message * response stream still contains only one final response even if some * `Fulfillment`s in Dialogflow virtual agent have been configured to return * partial responses. + * @type bool $enable_debugging_info + * If true, `StreamingAnalyzeContentResponse.debugging_info` will get + * populated. * } */ public function __construct($data = NULL) { @@ -545,6 +555,34 @@ public function setEnablePartialAutomatedAgentReply($var) return $this; } + /** + * If true, `StreamingAnalyzeContentResponse.debugging_info` will get + * populated. + * + * Generated from protobuf field bool enable_debugging_info = 19; + * @return bool + */ + public function getEnableDebuggingInfo() + { + return $this->enable_debugging_info; + } + + /** + * If true, `StreamingAnalyzeContentResponse.debugging_info` will get + * populated. + * + * Generated from protobuf field bool enable_debugging_info = 19; + * @param bool $var + * @return $this + */ + public function setEnableDebuggingInfo($var) + { + GPBUtil::checkBool($var); + $this->enable_debugging_info = $var; + + return $this; + } + /** * @return string */ diff --git a/Dialogflow/src/V2/StreamingAnalyzeContentResponse.php b/Dialogflow/src/V2/StreamingAnalyzeContentResponse.php index a25d3eed8edb..642d742454aa 100644 --- a/Dialogflow/src/V2/StreamingAnalyzeContentResponse.php +++ b/Dialogflow/src/V2/StreamingAnalyzeContentResponse.php @@ -100,6 +100,13 @@ class StreamingAnalyzeContentResponse extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.dialogflow.v2.DtmfParameters dtmf_parameters = 10; */ private $dtmf_parameters = null; + /** + * Debugging info that would get populated when + * `StreamingAnalyzeContentRequest.enable_debugging_info` is set to true. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.CloudConversationDebuggingInfo debugging_info = 11; + */ + private $debugging_info = null; /** * Constructor. @@ -143,6 +150,9 @@ class StreamingAnalyzeContentResponse extends \Google\Protobuf\Internal\Message * [HumanAgentAssistantConfig.end_user_suggestion_config][google.cloud.dialogflow.v2.HumanAgentAssistantConfig.end_user_suggestion_config]. * @type \Google\Cloud\Dialogflow\V2\DtmfParameters $dtmf_parameters * Indicates the parameters of DTMF. + * @type \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo $debugging_info + * Debugging info that would get populated when + * `StreamingAnalyzeContentRequest.enable_debugging_info` is set to true. * } */ public function __construct($data = NULL) { @@ -448,5 +458,43 @@ public function setDtmfParameters($var) return $this; } + /** + * Debugging info that would get populated when + * `StreamingAnalyzeContentRequest.enable_debugging_info` is set to true. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.CloudConversationDebuggingInfo debugging_info = 11; + * @return \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo|null + */ + public function getDebuggingInfo() + { + return $this->debugging_info; + } + + public function hasDebuggingInfo() + { + return isset($this->debugging_info); + } + + public function clearDebuggingInfo() + { + unset($this->debugging_info); + } + + /** + * Debugging info that would get populated when + * `StreamingAnalyzeContentRequest.enable_debugging_info` is set to true. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.CloudConversationDebuggingInfo debugging_info = 11; + * @param \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo $var + * @return $this + */ + public function setDebuggingInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo::class); + $this->debugging_info = $var; + + return $this; + } + } diff --git a/Dialogflow/src/V2/StreamingDetectIntentRequest.php b/Dialogflow/src/V2/StreamingDetectIntentRequest.php index 5b8d1276fb6d..d882c7248258 100644 --- a/Dialogflow/src/V2/StreamingDetectIntentRequest.php +++ b/Dialogflow/src/V2/StreamingDetectIntentRequest.php @@ -122,6 +122,12 @@ class StreamingDetectIntentRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field bytes input_audio = 6; */ private $input_audio = ''; + /** + * if true, `StreamingDetectIntentResponse.debugging_info` will get populated. + * + * Generated from protobuf field bool enable_debugging_info = 8; + */ + private $enable_debugging_info = false; /** * Constructor. @@ -179,6 +185,8 @@ class StreamingDetectIntentRequest extends \Google\Protobuf\Internal\Message * The input audio content to be recognized. Must be sent if * `query_input` was set to a streaming input audio config. The complete audio * over all streaming messages must not exceed 1 minute. + * @type bool $enable_debugging_info + * if true, `StreamingDetectIntentResponse.debugging_info` will get populated. * } */ public function __construct($data = NULL) { @@ -484,5 +492,31 @@ public function setInputAudio($var) return $this; } + /** + * if true, `StreamingDetectIntentResponse.debugging_info` will get populated. + * + * Generated from protobuf field bool enable_debugging_info = 8; + * @return bool + */ + public function getEnableDebuggingInfo() + { + return $this->enable_debugging_info; + } + + /** + * if true, `StreamingDetectIntentResponse.debugging_info` will get populated. + * + * Generated from protobuf field bool enable_debugging_info = 8; + * @param bool $var + * @return $this + */ + public function setEnableDebuggingInfo($var) + { + GPBUtil::checkBool($var); + $this->enable_debugging_info = $var; + + return $this; + } + } diff --git a/Dialogflow/src/V2/StreamingDetectIntentResponse.php b/Dialogflow/src/V2/StreamingDetectIntentResponse.php index 920c1aa30ac3..36dcc7747853 100644 --- a/Dialogflow/src/V2/StreamingDetectIntentResponse.php +++ b/Dialogflow/src/V2/StreamingDetectIntentResponse.php @@ -70,6 +70,13 @@ class StreamingDetectIntentResponse extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.dialogflow.v2.OutputAudioConfig output_audio_config = 6; */ private $output_audio_config = null; + /** + * Debugging info that would get populated when + * `StreamingDetectIntentRequest.enable_debugging_info` is set to true. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.CloudConversationDebuggingInfo debugging_info = 8; + */ + private $debugging_info = null; /** * Constructor. @@ -98,6 +105,9 @@ class StreamingDetectIntentResponse extends \Google\Protobuf\Internal\Message * has content. * @type \Google\Cloud\Dialogflow\V2\OutputAudioConfig $output_audio_config * The config used by the speech synthesizer to generate the output audio. + * @type \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo $debugging_info + * Debugging info that would get populated when + * `StreamingDetectIntentRequest.enable_debugging_info` is set to true. * } */ public function __construct($data = NULL) { @@ -319,5 +329,43 @@ public function setOutputAudioConfig($var) return $this; } + /** + * Debugging info that would get populated when + * `StreamingDetectIntentRequest.enable_debugging_info` is set to true. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.CloudConversationDebuggingInfo debugging_info = 8; + * @return \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo|null + */ + public function getDebuggingInfo() + { + return $this->debugging_info; + } + + public function hasDebuggingInfo() + { + return isset($this->debugging_info); + } + + public function clearDebuggingInfo() + { + unset($this->debugging_info); + } + + /** + * Debugging info that would get populated when + * `StreamingDetectIntentRequest.enable_debugging_info` is set to true. + * + * Generated from protobuf field .google.cloud.dialogflow.v2.CloudConversationDebuggingInfo debugging_info = 8; + * @param \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo $var + * @return $this + */ + public function setDebuggingInfo($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\CloudConversationDebuggingInfo::class); + $this->debugging_info = $var; + + return $this; + } + } diff --git a/Dialogflow/src/V2/gapic_metadata.json b/Dialogflow/src/V2/gapic_metadata.json index 3856eb92dc9e..414aa7a6e3e0 100644 --- a/Dialogflow/src/V2/gapic_metadata.json +++ b/Dialogflow/src/V2/gapic_metadata.json @@ -407,6 +407,60 @@ } } }, + "ConversationProfiles": { + "clients": { + "grpc": { + "libraryClient": "ConversationProfilesGapicClient", + "rpcs": { + "ClearSuggestionFeatureConfig": { + "methods": [ + "clearSuggestionFeatureConfig" + ] + }, + "CreateConversationProfile": { + "methods": [ + "createConversationProfile" + ] + }, + "DeleteConversationProfile": { + "methods": [ + "deleteConversationProfile" + ] + }, + "GetConversationProfile": { + "methods": [ + "getConversationProfile" + ] + }, + "ListConversationProfiles": { + "methods": [ + "listConversationProfiles" + ] + }, + "SetSuggestionFeatureConfig": { + "methods": [ + "setSuggestionFeatureConfig" + ] + }, + "UpdateConversationProfile": { + "methods": [ + "updateConversationProfile" + ] + }, + "GetLocation": { + "methods": [ + "getLocation" + ] + }, + "ListLocations": { + "methods": [ + "listLocations" + ] + } + } + } + } + }, "Conversations": { "clients": { "grpc": { @@ -422,6 +476,11 @@ "createConversation" ] }, + "GenerateStatelessSummary": { + "methods": [ + "generateStatelessSummary" + ] + }, "GetConversation": { "methods": [ "getConversation" @@ -564,60 +623,6 @@ } } }, - "ConversationProfiles": { - "clients": { - "grpc": { - "libraryClient": "ConversationProfilesGapicClient", - "rpcs": { - "ClearSuggestionFeatureConfig": { - "methods": [ - "clearSuggestionFeatureConfig" - ] - }, - "CreateConversationProfile": { - "methods": [ - "createConversationProfile" - ] - }, - "DeleteConversationProfile": { - "methods": [ - "deleteConversationProfile" - ] - }, - "GetConversationProfile": { - "methods": [ - "getConversationProfile" - ] - }, - "ListConversationProfiles": { - "methods": [ - "listConversationProfiles" - ] - }, - "SetSuggestionFeatureConfig": { - "methods": [ - "setSuggestionFeatureConfig" - ] - }, - "UpdateConversationProfile": { - "methods": [ - "updateConversationProfile" - ] - }, - "GetLocation": { - "methods": [ - "getLocation" - ] - }, - "ListLocations": { - "methods": [ - "listLocations" - ] - } - } - } - } - }, "Documents": { "clients": { "grpc": { diff --git a/Dialogflow/src/V2/resources/conversations_client_config.json b/Dialogflow/src/V2/resources/conversations_client_config.json index 47e5785bc38a..4b4cc56a8955 100644 --- a/Dialogflow/src/V2/resources/conversations_client_config.json +++ b/Dialogflow/src/V2/resources/conversations_client_config.json @@ -38,6 +38,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "GenerateStatelessSummary": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, "GetConversation": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", diff --git a/Dialogflow/src/V2/resources/conversations_rest_client_config.php b/Dialogflow/src/V2/resources/conversations_rest_client_config.php index 4aab11384239..e2874160aaec 100644 --- a/Dialogflow/src/V2/resources/conversations_rest_client_config.php +++ b/Dialogflow/src/V2/resources/conversations_rest_client_config.php @@ -41,6 +41,26 @@ ], ], ], + 'GenerateStatelessSummary' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{stateless_conversation.parent=projects/*}/suggestions:generateStatelessSummary', + 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v2/{stateless_conversation.parent=projects/*/locations/*}/suggestions:generateStatelessSummary', + 'body' => '*', + ], + ], + 'placeholders' => [ + 'stateless_conversation.parent' => [ + 'getters' => [ + 'getStatelessConversation', + 'getParent', + ], + ], + ], + ], 'GetConversation' => [ 'method' => 'get', 'uriTemplate' => '/v2/{name=projects/*/conversations/*}', diff --git a/Dialogflow/tests/Unit/V2/ConversationsClientTest.php b/Dialogflow/tests/Unit/V2/ConversationsClientTest.php index 349e379e9fc5..354ed3684be6 100644 --- a/Dialogflow/tests/Unit/V2/ConversationsClientTest.php +++ b/Dialogflow/tests/Unit/V2/ConversationsClientTest.php @@ -27,7 +27,10 @@ use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; use Google\Cloud\Dialogflow\V2\Conversation; +use Google\Cloud\Dialogflow\V2\ConversationProfile; use Google\Cloud\Dialogflow\V2\ConversationsClient; +use Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest\MinimalConversation; +use Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse; use Google\Cloud\Dialogflow\V2\ListConversationsResponse; use Google\Cloud\Dialogflow\V2\ListMessagesResponse; use Google\Cloud\Dialogflow\V2\Message; @@ -197,6 +200,84 @@ public function createConversationExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function generateStatelessSummaryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $latestMessage2 = 'latestMessage2-440913086'; + $contextSize = 1116903569; + $expectedResponse = new GenerateStatelessSummaryResponse(); + $expectedResponse->setLatestMessage($latestMessage2); + $expectedResponse->setContextSize($contextSize); + $transport->addResponse($expectedResponse); + // Mock request + $statelessConversation = new MinimalConversation(); + $statelessConversationMessages = []; + $statelessConversation->setMessages($statelessConversationMessages); + $statelessConversationParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $statelessConversation->setParent($statelessConversationParent); + $conversationProfile = new ConversationProfile(); + $conversationProfileDisplayName = 'conversationProfileDisplayName-203415833'; + $conversationProfile->setDisplayName($conversationProfileDisplayName); + $response = $gapicClient->generateStatelessSummary($statelessConversation, $conversationProfile); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.v2.Conversations/GenerateStatelessSummary', $actualFuncCall); + $actualValue = $actualRequestObject->getStatelessConversation(); + $this->assertProtobufEquals($statelessConversation, $actualValue); + $actualValue = $actualRequestObject->getConversationProfile(); + $this->assertProtobufEquals($conversationProfile, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function generateStatelessSummaryExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $statelessConversation = new MinimalConversation(); + $statelessConversationMessages = []; + $statelessConversation->setMessages($statelessConversationMessages); + $statelessConversationParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $statelessConversation->setParent($statelessConversationParent); + $conversationProfile = new ConversationProfile(); + $conversationProfileDisplayName = 'conversationProfileDisplayName-203415833'; + $conversationProfile->setDisplayName($conversationProfileDisplayName); + try { + $gapicClient->generateStatelessSummary($statelessConversation, $conversationProfile); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function getConversationTest() {