From 56a6e11622f73c6d302a5f43142ceb289b334fd1 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 12 Nov 2021 03:40:13 +0000 Subject: [PATCH] feat: add document metadata filter in article suggestion (#437) - [x] Regenerate this pull request now. PiperOrigin-RevId: 409190373 Source-Link: https://github.com/googleapis/googleapis/commit/29bb98c1167ffc41e9771570e2e2d10a930baa4a Source-Link: https://github.com/googleapis/googleapis-gen/commit/e90c22e9275b91aabc6c820a767af2fd6954f624 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTkwYzIyZTkyNzViOTFhYWJjNmM4MjBhNzY3YWYyZmQ2OTU0ZjYyNCJ9 feat: add smart reply model in human agent assistant --- google/cloud/dialogflow/__init__.py | 2 + google/cloud/dialogflow_v2/__init__.py | 2 + .../services/participants/async_client.py | 8 +-- .../services/participants/client.py | 8 +-- google/cloud/dialogflow_v2/types/__init__.py | 2 + .../types/conversation_profile.py | 1 + .../cloud/dialogflow_v2/types/participant.py | 58 +++++++++++++++++++ scripts/fixup_dialogflow_v2_keywords.py | 6 +- 8 files changed, 76 insertions(+), 11 deletions(-) diff --git a/google/cloud/dialogflow/__init__.py b/google/cloud/dialogflow/__init__.py index 2e7f45779..cfb1e351a 100644 --- a/google/cloud/dialogflow/__init__.py +++ b/google/cloud/dialogflow/__init__.py @@ -218,6 +218,7 @@ from google.cloud.dialogflow_v2.types.participant import AnalyzeContentResponse from google.cloud.dialogflow_v2.types.participant import AnnotatedMessagePart from google.cloud.dialogflow_v2.types.participant import ArticleAnswer +from google.cloud.dialogflow_v2.types.participant import AssistQueryParameters from google.cloud.dialogflow_v2.types.participant import AutomatedAgentReply from google.cloud.dialogflow_v2.types.participant import CreateParticipantRequest from google.cloud.dialogflow_v2.types.participant import DtmfParameters @@ -432,6 +433,7 @@ "AnalyzeContentResponse", "AnnotatedMessagePart", "ArticleAnswer", + "AssistQueryParameters", "AutomatedAgentReply", "CreateParticipantRequest", "DtmfParameters", diff --git a/google/cloud/dialogflow_v2/__init__.py b/google/cloud/dialogflow_v2/__init__.py index 8d44eb9dd..5f07b5ef4 100644 --- a/google/cloud/dialogflow_v2/__init__.py +++ b/google/cloud/dialogflow_v2/__init__.py @@ -166,6 +166,7 @@ from .types.participant import AnalyzeContentResponse from .types.participant import AnnotatedMessagePart from .types.participant import ArticleAnswer +from .types.participant import AssistQueryParameters from .types.participant import AutomatedAgentReply from .types.participant import CreateParticipantRequest from .types.participant import DtmfParameters @@ -243,6 +244,7 @@ "AnswerRecord", "AnswerRecordsClient", "ArticleAnswer", + "AssistQueryParameters", "AudioEncoding", "AutomatedAgentConfig", "AutomatedAgentReply", diff --git a/google/cloud/dialogflow_v2/services/participants/async_client.py b/google/cloud/dialogflow_v2/services/participants/async_client.py index fd6c31e7b..0b1f43a3b 100644 --- a/google/cloud/dialogflow_v2/services/participants/async_client.py +++ b/google/cloud/dialogflow_v2/services/participants/async_client.py @@ -361,7 +361,7 @@ async def list_participants( Returns: google.cloud.dialogflow_v2.services.participants.pagers.ListParticipantsAsyncPager: The response message for - [Participants.ListParticipants][google.cloud.dialogflow.v2.Participants.ListParticipants]. + [Participants.ListParticipants][google.cloud.dialogflow.v2.Participants.ListParticipants]. Iterating over this object will yield results and resolve additional pages automatically. @@ -542,7 +542,7 @@ async def analyze_content( Returns: google.cloud.dialogflow_v2.types.AnalyzeContentResponse: The response message for - [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]. + [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]. """ # Create or coerce a protobuf request object. @@ -630,7 +630,7 @@ async def suggest_articles( Returns: google.cloud.dialogflow_v2.types.SuggestArticlesResponse: The response message for - [Participants.SuggestArticles][google.cloud.dialogflow.v2.Participants.SuggestArticles]. + [Participants.SuggestArticles][google.cloud.dialogflow.v2.Participants.SuggestArticles]. """ # Create or coerce a protobuf request object. @@ -703,7 +703,7 @@ async def suggest_faq_answers( Returns: google.cloud.dialogflow_v2.types.SuggestFaqAnswersResponse: The request message for - [Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2.Participants.SuggestFaqAnswers]. + [Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2.Participants.SuggestFaqAnswers]. """ # Create or coerce a protobuf request object. diff --git a/google/cloud/dialogflow_v2/services/participants/client.py b/google/cloud/dialogflow_v2/services/participants/client.py index 9b273011a..cf3ab93ed 100644 --- a/google/cloud/dialogflow_v2/services/participants/client.py +++ b/google/cloud/dialogflow_v2/services/participants/client.py @@ -606,7 +606,7 @@ def list_participants( Returns: google.cloud.dialogflow_v2.services.participants.pagers.ListParticipantsPager: The response message for - [Participants.ListParticipants][google.cloud.dialogflow.v2.Participants.ListParticipants]. + [Participants.ListParticipants][google.cloud.dialogflow.v2.Participants.ListParticipants]. Iterating over this object will yield results and resolve additional pages automatically. @@ -787,7 +787,7 @@ def analyze_content( Returns: google.cloud.dialogflow_v2.types.AnalyzeContentResponse: The response message for - [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]. + [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]. """ # Create or coerce a protobuf request object. @@ -866,7 +866,7 @@ def suggest_articles( Returns: google.cloud.dialogflow_v2.types.SuggestArticlesResponse: The response message for - [Participants.SuggestArticles][google.cloud.dialogflow.v2.Participants.SuggestArticles]. + [Participants.SuggestArticles][google.cloud.dialogflow.v2.Participants.SuggestArticles]. """ # Create or coerce a protobuf request object. @@ -939,7 +939,7 @@ def suggest_faq_answers( Returns: google.cloud.dialogflow_v2.types.SuggestFaqAnswersResponse: The request message for - [Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2.Participants.SuggestFaqAnswers]. + [Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2.Participants.SuggestFaqAnswers]. """ # Create or coerce a protobuf request object. diff --git a/google/cloud/dialogflow_v2/types/__init__.py b/google/cloud/dialogflow_v2/types/__init__.py index 7426db72a..b8a99fdb8 100644 --- a/google/cloud/dialogflow_v2/types/__init__.py +++ b/google/cloud/dialogflow_v2/types/__init__.py @@ -159,6 +159,7 @@ AnalyzeContentResponse, AnnotatedMessagePart, ArticleAnswer, + AssistQueryParameters, AutomatedAgentReply, CreateParticipantRequest, DtmfParameters, @@ -342,6 +343,7 @@ "AnalyzeContentResponse", "AnnotatedMessagePart", "ArticleAnswer", + "AssistQueryParameters", "AutomatedAgentReply", "CreateParticipantRequest", "DtmfParameters", diff --git a/google/cloud/dialogflow_v2/types/conversation_profile.py b/google/cloud/dialogflow_v2/types/conversation_profile.py index c04d95c84..dc029305c 100644 --- a/google/cloud/dialogflow_v2/types/conversation_profile.py +++ b/google/cloud/dialogflow_v2/types/conversation_profile.py @@ -732,6 +732,7 @@ class Type(proto.Enum): TYPE_UNSPECIFIED = 0 ARTICLE_SUGGESTION = 1 FAQ = 2 + SMART_REPLY = 3 type_ = proto.Field(proto.ENUM, number=1, enum=Type,) diff --git a/google/cloud/dialogflow_v2/types/participant.py b/google/cloud/dialogflow_v2/types/participant.py index 6a1e75bbb..5b29ba6b2 100644 --- a/google/cloud/dialogflow_v2/types/participant.py +++ b/google/cloud/dialogflow_v2/types/participant.py @@ -47,6 +47,7 @@ "SuggestionResult", "AnnotatedMessagePart", "MessageAnnotation", + "AssistQueryParameters", }, ) @@ -69,6 +70,27 @@ class Participant(proto.Message): metadata and SDP. This is used to assign transcriptions from that media stream to this participant. This field can be updated. + documents_metadata_filters (Sequence[google.cloud.dialogflow_v2.types.Participant.DocumentsMetadataFiltersEntry]): + Optional. Key-value filters on the metadata of documents + returned by article suggestion. If specified, article + suggestion only returns suggested documents that match all + filters in their + [Document.metadata][google.cloud.dialogflow.v2.Document.metadata]. + Multiple values for a metadata key should be concatenated by + comma. For example, filters to match all documents that have + 'US' or 'CA' in their market metadata values and 'agent' in + their user metadata values will be + + :: + + documents_metadata_filters { + key: "market" + value: "US,CA" + } + documents_metadata_filters { + key: "user" + value: "agent" + } """ class Role(proto.Enum): @@ -83,6 +105,7 @@ class Role(proto.Enum): name = proto.Field(proto.STRING, number=1,) role = proto.Field(proto.ENUM, number=2, enum=Role,) sip_recording_media_label = proto.Field(proto.STRING, number=6,) + documents_metadata_filters = proto.MapField(proto.STRING, proto.STRING, number=8,) class Message(proto.Message): @@ -247,6 +270,8 @@ class AnalyzeContentRequest(proto.Message): query_params (google.cloud.dialogflow_v2.types.QueryParameters): Parameters for a Dialogflow virtual-agent query. + assist_query_params (google.cloud.dialogflow_v2.types.AssistQueryParameters): + Parameters for a human assist query. request_id (str): A unique identifier for this request. Restricted to 36 ASCII characters. A random UUID is recommended. This request is @@ -266,6 +291,9 @@ class AnalyzeContentRequest(proto.Message): query_params = proto.Field( proto.MESSAGE, number=9, message=session.QueryParameters, ) + assist_query_params = proto.Field( + proto.MESSAGE, number=14, message="AssistQueryParameters", + ) request_id = proto.Field(proto.STRING, number=11,) @@ -365,11 +393,16 @@ class SuggestArticlesRequest(proto.Message): [latest_message][google.cloud.dialogflow.v2.SuggestArticlesRequest.latest_message] to use as context when compiling the suggestion. By default 20 and at most 50. + assist_query_params (google.cloud.dialogflow_v2.types.AssistQueryParameters): + Parameters for a human assist query. """ parent = proto.Field(proto.STRING, number=1,) latest_message = proto.Field(proto.STRING, number=2,) context_size = proto.Field(proto.INT32, number=3,) + assist_query_params = proto.Field( + proto.MESSAGE, number=4, message="AssistQueryParameters", + ) class SuggestArticlesResponse(proto.Message): @@ -422,11 +455,16 @@ class SuggestFaqAnswersRequest(proto.Message): Max number of messages prior to and including [latest_message] to use as context when compiling the suggestion. By default 20 and at most 50. + assist_query_params (google.cloud.dialogflow_v2.types.AssistQueryParameters): + Parameters for a human assist query. """ parent = proto.Field(proto.STRING, number=1,) latest_message = proto.Field(proto.STRING, number=2,) context_size = proto.Field(proto.INT32, number=3,) + assist_query_params = proto.Field( + proto.MESSAGE, number=4, message="AssistQueryParameters", + ) class SuggestFaqAnswersResponse(proto.Message): @@ -678,4 +716,24 @@ class MessageAnnotation(proto.Message): contain_entities = proto.Field(proto.BOOL, number=2,) +class AssistQueryParameters(proto.Message): + r"""Represents the parameters of human assist query. + + Attributes: + documents_metadata_filters (Sequence[google.cloud.dialogflow_v2.types.AssistQueryParameters.DocumentsMetadataFiltersEntry]): + Key-value filters on the metadata of documents returned by + article suggestion. If specified, article suggestion only + returns suggested documents that match all filters in their + [Document.metadata][google.cloud.dialogflow.v2.Document.metadata]. + Multiple values for a metadata key should be concatenated by + comma. For example, filters to match all documents that have + 'US' or 'CA' in their market metadata values and 'agent' in + their user metadata values will be + documents_metadata_filters { key: "market" value: "US,CA" } + documents_metadata_filters { key: "user" value: "agent" } + """ + + documents_metadata_filters = proto.MapField(proto.STRING, proto.STRING, number=1,) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/scripts/fixup_dialogflow_v2_keywords.py b/scripts/fixup_dialogflow_v2_keywords.py index 499bd93a7..6af3adf69 100644 --- a/scripts/fixup_dialogflow_v2_keywords.py +++ b/scripts/fixup_dialogflow_v2_keywords.py @@ -39,7 +39,7 @@ def partition( class dialogflowCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'analyze_content': ('participant', 'text_input', 'event_input', 'reply_audio_config', 'query_params', 'request_id', ), + 'analyze_content': ('participant', 'text_input', 'event_input', 'reply_audio_config', 'query_params', 'assist_query_params', 'request_id', ), 'batch_create_entities': ('parent', 'entities', 'language_code', ), 'batch_delete_entities': ('parent', 'entity_values', 'language_code', ), 'batch_delete_entity_types': ('parent', 'entity_type_names', ), @@ -106,8 +106,8 @@ class dialogflowCallTransformer(cst.CSTTransformer): 'search_agents': ('parent', 'page_size', 'page_token', ), 'set_agent': ('agent', 'update_mask', ), 'streaming_detect_intent': ('session', 'query_input', 'query_params', 'single_utterance', 'output_audio_config', 'output_audio_config_mask', 'input_audio', ), - 'suggest_articles': ('parent', 'latest_message', 'context_size', ), - 'suggest_faq_answers': ('parent', 'latest_message', 'context_size', ), + 'suggest_articles': ('parent', 'latest_message', 'context_size', 'assist_query_params', ), + 'suggest_faq_answers': ('parent', 'latest_message', 'context_size', 'assist_query_params', ), 'train_agent': ('parent', ), 'update_answer_record': ('answer_record', 'update_mask', ), 'update_context': ('context', 'update_mask', ),