Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
feat: add document metadata filter in article suggestion (#437)
Browse files Browse the repository at this point in the history
- [x] Regenerate this pull request now.

PiperOrigin-RevId: 409190373

Source-Link: googleapis/googleapis@29bb98c

Source-Link: googleapis/googleapis-gen@e90c22e
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTkwYzIyZTkyNzViOTFhYWJjNmM4MjBhNzY3YWYyZmQ2OTU0ZjYyNCJ9

feat: add smart reply model in human agent assistant
  • Loading branch information
gcf-owl-bot[bot] committed Nov 12, 2021
1 parent 5b1d8bb commit 56a6e11
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 11 deletions.
2 changes: 2 additions & 0 deletions google/cloud/dialogflow/__init__.py
Expand Up @@ -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
Expand Down Expand Up @@ -432,6 +433,7 @@
"AnalyzeContentResponse",
"AnnotatedMessagePart",
"ArticleAnswer",
"AssistQueryParameters",
"AutomatedAgentReply",
"CreateParticipantRequest",
"DtmfParameters",
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/dialogflow_v2/__init__.py
Expand Up @@ -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
Expand Down Expand Up @@ -243,6 +244,7 @@
"AnswerRecord",
"AnswerRecordsClient",
"ArticleAnswer",
"AssistQueryParameters",
"AudioEncoding",
"AutomatedAgentConfig",
"AutomatedAgentReply",
Expand Down
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions google/cloud/dialogflow_v2/services/participants/client.py
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/dialogflow_v2/types/__init__.py
Expand Up @@ -159,6 +159,7 @@
AnalyzeContentResponse,
AnnotatedMessagePart,
ArticleAnswer,
AssistQueryParameters,
AutomatedAgentReply,
CreateParticipantRequest,
DtmfParameters,
Expand Down Expand Up @@ -342,6 +343,7 @@
"AnalyzeContentResponse",
"AnnotatedMessagePart",
"ArticleAnswer",
"AssistQueryParameters",
"AutomatedAgentReply",
"CreateParticipantRequest",
"DtmfParameters",
Expand Down
1 change: 1 addition & 0 deletions google/cloud/dialogflow_v2/types/conversation_profile.py
Expand Up @@ -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,)

Expand Down
58 changes: 58 additions & 0 deletions google/cloud/dialogflow_v2/types/participant.py
Expand Up @@ -47,6 +47,7 @@
"SuggestionResult",
"AnnotatedMessagePart",
"MessageAnnotation",
"AssistQueryParameters",
},
)

Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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,)


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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))
6 changes: 3 additions & 3 deletions scripts/fixup_dialogflow_v2_keywords.py
Expand Up @@ -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', ),
Expand Down Expand Up @@ -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', ),
Expand Down

0 comments on commit 56a6e11

Please sign in to comment.