From a481c80e541b9a21495fa507fc7ba895c5780869 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:14:38 -0500 Subject: [PATCH] feat: [google-cloud-dialogflow] add sections field to HumanAgentAssistantConfig.SuggestionQueryConfig (#12128) - [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: Add sections field to HumanAgentAssistantConfig.SuggestionQueryConfig feat: Add enable_conversation_augmented_query field to HumanAgentAssistantConfig.SuggestionFeatureConfig message feat: Add INTENT enum in SearchKnowledgeAnswer.AnswerType message feat: Add rewritten_query in field in SearchKnowledgeResponse message docs: Improved comments on audio_config proto END_COMMIT_OVERRIDE PiperOrigin-RevId: 591042460 Source-Link: https://github.com/googleapis/googleapis/commit/8e2e40355a53afac199776c01e23e1343117351f Source-Link: https://github.com/googleapis/googleapis-gen/commit/c8cdc4d386352c860fce2b6efc5c02e680403a3d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRpYWxvZ2Zsb3cvLk93bEJvdC55YW1sIiwiaCI6ImM4Y2RjNGQzODYzNTJjODYwZmNlMmI2ZWZjNWMwMmU2ODA0MDNhM2QifQ== --------- Co-authored-by: Owl Bot --- .../google/cloud/dialogflow/gapic_version.py | 2 +- .../cloud/dialogflow_v2/gapic_version.py | 2 +- .../cloud/dialogflow_v2beta1/gapic_version.py | 2 +- .../dialogflow_v2beta1/types/audio_config.py | 40 ++++---- .../dialogflow_v2beta1/types/conversation.py | 11 ++- .../types/conversation_profile.py | 96 +++++++++++++++++-- ...t_metadata_google.cloud.dialogflow.v2.json | 2 +- ...adata_google.cloud.dialogflow.v2beta1.json | 2 +- .../test_conversation_profiles.py | 4 + .../dialogflow_v2beta1/test_conversations.py | 15 ++- 10 files changed, 141 insertions(+), 35 deletions(-) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py index 6a37b1b764dd..360a0d13ebdd 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.26.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py index 6a37b1b764dd..360a0d13ebdd 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.26.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py index 6a37b1b764dd..360a0d13ebdd 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.26.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/audio_config.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/audio_config.py index c614d994356b..fa77b5bdf451 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/audio_config.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/audio_config.py @@ -471,23 +471,9 @@ class InputAudioConfig(proto.Message): documentation `__ for more details. model (str): - Which Speech model to select for the given request. Select - the model best suited to your domain to get best results. If - a model is not explicitly specified, then we auto-select a - model based on the parameters in the InputAudioConfig. If - enhanced speech model is enabled for the agent and an - enhanced version of the specified model for the language - does not exist, then the speech is recognized using the - standard version of the specified model. Refer to `Cloud - Speech API - documentation `__ - 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) + Optional. Which Speech model to select for the given + request. For more information, see `Speech + models `__. model_variant (google.cloud.dialogflow_v2beta1.types.SpeechModelVariant): Which variant of the [Speech model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model] @@ -739,10 +725,24 @@ class SpeechToTextConfig(proto.Message): model (str): Which Speech model to select. Select the model best suited to your domain to get best results. If a model is not - explicitly specified, then a default model is used. Refer to - `Cloud Speech API + explicitly specified, then Dialogflow auto-selects a model + based on other parameters in the SpeechToTextConfig and + Agent settings. If enhanced speech model is enabled for the + agent and an enhanced version of the specified model for the + language does not exist, then the speech is recognized using + the standard version of the specified model. Refer to `Cloud + Speech API documentation `__ - for more details. + 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 + + Leave this field unspecified to use `Agent Speech + settings `__ + for model selection. use_timeout_based_endpointing (bool): Use timeout based endpointing, interpreting endpointer sensitivy as seconds of timeout diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation.py index 5981f4aada06..f50508c523c8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation.py @@ -826,6 +826,8 @@ class SearchKnowledgeResponse(proto.Message): Most relevant snippets extracted from articles in the given knowledge base, ordered by confidence. + rewritten_query (str): + The rewritten query used to search knowledge. """ answers: MutableSequence["SearchKnowledgeAnswer"] = proto.RepeatedField( @@ -833,6 +835,10 @@ class SearchKnowledgeResponse(proto.Message): number=2, message="SearchKnowledgeAnswer", ) + rewritten_query: str = proto.Field( + proto.STRING, + number=3, + ) class SearchKnowledgeAnswer(proto.Message): @@ -858,13 +864,16 @@ class AnswerType(proto.Enum): ANSWER_TYPE_UNSPECIFIED (0): The answer has a unspecified type. FAQ (1): - The answer is from FAQ doucments. + The answer is from FAQ documents. GENERATIVE (2): The answer is from generative model. + INTENT (3): + The answer is from intent matching. """ ANSWER_TYPE_UNSPECIFIED = 0 FAQ = 1 GENERATIVE = 2 + INTENT = 3 class AnswerSource(proto.Message): r"""The sources of the answers. diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation_profile.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation_profile.py index 7bf0257f6778..012b3a4e8042 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation_profile.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/types/conversation_profile.py @@ -208,12 +208,12 @@ class AutomatedAgentConfig(proto.Message): If environment is not specified, the default ``draft`` environment is used. session_ttl (google.protobuf.duration_pb2.Duration): - Optional. Sets Dialogflow CX session life - time. By default, a Dialogflow CX session - remains active and its data is stored for 30 - minutes after the last request is sent for the - session. This value should be no longer than 1 - day. + Optional. Configure lifetime of the + Dialogflow session. By default, a Dialogflow CX + session remains active and its data is stored + for 30 minutes after the last request is sent + for the session. This value should be no longer + than 1 day. """ agent: str = proto.Field( @@ -286,6 +286,9 @@ class SuggestionFeatureConfig(proto.Message): at answer records. Supported features: KNOWLEDGE_SEARCH. + enable_conversation_augmented_query (bool): + Optional. Enable including conversation context during query + answer generation. Supported features: KNOWLEDGE_SEARCH. suggestion_trigger_settings (google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionTriggerSettings): Settings of suggestion trigger. @@ -312,6 +315,10 @@ class SuggestionFeatureConfig(proto.Message): proto.BOOL, number=14, ) + enable_conversation_augmented_query: bool = proto.Field( + proto.BOOL, + number=16, + ) suggestion_trigger_settings: "HumanAgentAssistantConfig.SuggestionTriggerSettings" = proto.Field( proto.MESSAGE, number=10, @@ -424,6 +431,10 @@ class SuggestionQueryConfig(proto.Message): Determines how recent conversation context is filtered when generating suggestions. If unspecified, no messages will be dropped. + sections (google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionQueryConfig.Sections): + Optional. The customized sections chosen to + return when requesting a summary of a + conversation. """ class KnowledgeBaseQuerySource(proto.Message): @@ -534,6 +545,72 @@ class ContextFilterSettings(proto.Message): number=3, ) + class Sections(proto.Message): + r"""Custom sections to return when requesting a summary of a + conversation. This is only supported when ``baseline_model_version`` + == '2.0'. + + Supported features: CONVERSATION_SUMMARIZATION, + CONVERSATION_SUMMARIZATION_VOICE. + + Attributes: + section_types (MutableSequence[google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionQueryConfig.Sections.SectionType]): + The selected sections chosen to return when + requesting a summary of a conversation. A + duplicate selected section will be treated as a + single selected section. If section types are + not provided, the default will be {SITUATION, + ACTION, RESULT}. + """ + + class SectionType(proto.Enum): + r"""Selectable sections to return when requesting a summary of a + conversation. + + Values: + SECTION_TYPE_UNSPECIFIED (0): + Undefined section type, does not return + anything. + SITUATION (1): + What the customer needs help with or has + question about. Section name: "situation". + ACTION (2): + What the agent does to help the customer. + Section name: "action". + RESOLUTION (3): + Result of the customer service. A single word + describing the result of the conversation. + Section name: "resolution". + REASON_FOR_CANCELLATION (4): + Reason for cancellation if the customer requests for a + cancellation. "N/A" otherwise. Section name: + "reason_for_cancellation". + CUSTOMER_SATISFACTION (5): + "Unsatisfied" or "Satisfied" depending on the customer's + feelings at the end of the conversation. Section name: + "customer_satisfaction". + ENTITIES (6): + Key entities extracted from the conversation, + such as ticket number, order number, dollar + amount, etc. Section names are prefixed by + "entities/". + """ + SECTION_TYPE_UNSPECIFIED = 0 + SITUATION = 1 + ACTION = 2 + RESOLUTION = 3 + REASON_FOR_CANCELLATION = 4 + CUSTOMER_SATISFACTION = 5 + ENTITIES = 6 + + section_types: MutableSequence[ + "HumanAgentAssistantConfig.SuggestionQueryConfig.Sections.SectionType" + ] = proto.RepeatedField( + proto.ENUM, + number=1, + enum="HumanAgentAssistantConfig.SuggestionQueryConfig.Sections.SectionType", + ) + knowledge_base_query_source: "HumanAgentAssistantConfig.SuggestionQueryConfig.KnowledgeBaseQuerySource" = proto.Field( proto.MESSAGE, number=1, @@ -565,6 +642,13 @@ class ContextFilterSettings(proto.Message): number=7, message="HumanAgentAssistantConfig.SuggestionQueryConfig.ContextFilterSettings", ) + sections: "HumanAgentAssistantConfig.SuggestionQueryConfig.Sections" = ( + proto.Field( + proto.MESSAGE, + number=8, + message="HumanAgentAssistantConfig.SuggestionQueryConfig.Sections", + ) + ) class ConversationModelConfig(proto.Message): r"""Custom conversation models used in agent assist feature. diff --git a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json index e6da51f4c809..15f4b2c8fa69 100644 --- a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json +++ b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-dialogflow", - "version": "2.26.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json index 98a12de42d61..11feb40f02d8 100644 --- a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json +++ b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-dialogflow", - "version": "2.26.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py index c6faaefe20a7..0620079e72b2 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py @@ -3497,6 +3497,7 @@ def test_create_conversation_profile_rest(request_type): "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, "disable_agent_query_logging": True, + "enable_conversation_augmented_query": True, "suggestion_trigger_settings": { "no_small_talk": True, "only_end_user": True, @@ -3522,6 +3523,7 @@ def test_create_conversation_profile_rest(request_type): "drop_virtual_agent_messages": True, "drop_ivr_messages": True, }, + "sections": {"section_types": [1]}, }, "conversation_model_config": { "model": "model_value", @@ -3960,6 +3962,7 @@ def test_update_conversation_profile_rest(request_type): "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, "disable_agent_query_logging": True, + "enable_conversation_augmented_query": True, "suggestion_trigger_settings": { "no_small_talk": True, "only_end_user": True, @@ -3985,6 +3988,7 @@ def test_update_conversation_profile_rest(request_type): "drop_virtual_agent_messages": True, "drop_ivr_messages": True, }, + "sections": {"section_types": [1]}, }, "conversation_model_config": { "model": "model_value", diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py index a7cf73aef164..137af1af088f 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py @@ -3064,7 +3064,9 @@ def test_search_knowledge(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = conversation.SearchKnowledgeResponse() + call.return_value = conversation.SearchKnowledgeResponse( + rewritten_query="rewritten_query_value", + ) response = client.search_knowledge(request) # Establish that the underlying gRPC stub method was called. @@ -3074,6 +3076,7 @@ def test_search_knowledge(request_type, transport: str = "grpc"): # Establish that the response is the type that we expect. assert isinstance(response, conversation.SearchKnowledgeResponse) + assert response.rewritten_query == "rewritten_query_value" def test_search_knowledge_empty_call(): @@ -3109,7 +3112,9 @@ async def test_search_knowledge_async( with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - conversation.SearchKnowledgeResponse() + conversation.SearchKnowledgeResponse( + rewritten_query="rewritten_query_value", + ) ) response = await client.search_knowledge(request) @@ -3120,6 +3125,7 @@ async def test_search_knowledge_async( # Establish that the response is the type that we expect. assert isinstance(response, conversation.SearchKnowledgeResponse) + assert response.rewritten_query == "rewritten_query_value" @pytest.mark.asyncio @@ -5614,7 +5620,9 @@ def test_search_knowledge_rest(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = conversation.SearchKnowledgeResponse() + return_value = conversation.SearchKnowledgeResponse( + rewritten_query="rewritten_query_value", + ) # Wrap the value into a proper Response obj response_value = Response() @@ -5629,6 +5637,7 @@ def test_search_knowledge_rest(request_type): # Establish that the response is the type that we expect. assert isinstance(response, conversation.SearchKnowledgeResponse) + assert response.rewritten_query == "rewritten_query_value" def test_search_knowledge_rest_required_fields(