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

Commit 6f615f9

Browse files
feat: support document metadata filter in article suggestion (#442)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 410295622 Source-Link: googleapis/googleapis@dfa9d62 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0096968b1fe0d67ca878187436e406b016e27a0d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDA5Njk2OGIxZmUwZDY3Y2E4NzgxODc0MzZlNDA2YjAxNmUyN2EwZCJ9
1 parent 0cec256 commit 6f615f9

File tree

6 files changed

+90
-17
lines changed

6 files changed

+90
-17
lines changed

google/cloud/dialogflow_v2beta1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
from .types.participant import AnalyzeContentResponse
178178
from .types.participant import AnnotatedMessagePart
179179
from .types.participant import ArticleAnswer
180+
from .types.participant import AssistQueryParameters
180181
from .types.participant import AutomatedAgentReply
181182
from .types.participant import CompileSuggestionRequest
182183
from .types.participant import CompileSuggestionResponse
@@ -265,6 +266,7 @@
265266
"AnswerRecord",
266267
"AnswerRecordsClient",
267268
"ArticleAnswer",
269+
"AssistQueryParameters",
268270
"AudioEncoding",
269271
"AutomatedAgentConfig",
270272
"AutomatedAgentReply",

google/cloud/dialogflow_v2beta1/services/participants/async_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ async def list_participants(
364364
Returns:
365365
google.cloud.dialogflow_v2beta1.services.participants.pagers.ListParticipantsAsyncPager:
366366
The response message for
367-
[Participants.ListParticipants][google.cloud.dialogflow.v2beta1.Participants.ListParticipants].
367+
[Participants.ListParticipants][google.cloud.dialogflow.v2beta1.Participants.ListParticipants].
368368
369369
Iterating over this object will yield results and
370370
resolve additional pages automatically.
@@ -545,7 +545,7 @@ async def analyze_content(
545545
Returns:
546546
google.cloud.dialogflow_v2beta1.types.AnalyzeContentResponse:
547547
The response message for
548-
[Participants.AnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.AnalyzeContent].
548+
[Participants.AnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.AnalyzeContent].
549549
550550
"""
551551
# Create or coerce a protobuf request object.
@@ -640,7 +640,7 @@ async def suggest_articles(
640640
Returns:
641641
google.cloud.dialogflow_v2beta1.types.SuggestArticlesResponse:
642642
The response message for
643-
[Participants.SuggestArticles][google.cloud.dialogflow.v2beta1.Participants.SuggestArticles].
643+
[Participants.SuggestArticles][google.cloud.dialogflow.v2beta1.Participants.SuggestArticles].
644644
645645
"""
646646
# Create or coerce a protobuf request object.
@@ -713,7 +713,7 @@ async def suggest_faq_answers(
713713
Returns:
714714
google.cloud.dialogflow_v2beta1.types.SuggestFaqAnswersResponse:
715715
The request message for
716-
[Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2beta1.Participants.SuggestFaqAnswers].
716+
[Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2beta1.Participants.SuggestFaqAnswers].
717717
718718
"""
719719
# Create or coerce a protobuf request object.
@@ -786,7 +786,7 @@ async def suggest_smart_replies(
786786
Returns:
787787
google.cloud.dialogflow_v2beta1.types.SuggestSmartRepliesResponse:
788788
The response message for
789-
[Participants.SuggestSmartReplies][google.cloud.dialogflow.v2beta1.Participants.SuggestSmartReplies].
789+
[Participants.SuggestSmartReplies][google.cloud.dialogflow.v2beta1.Participants.SuggestSmartReplies].
790790
791791
"""
792792
# Create or coerce a protobuf request object.
@@ -868,7 +868,7 @@ async def list_suggestions(
868868
Returns:
869869
google.cloud.dialogflow_v2beta1.services.participants.pagers.ListSuggestionsAsyncPager:
870870
The response message for
871-
[Participants.ListSuggestions][google.cloud.dialogflow.v2beta1.Participants.ListSuggestions].
871+
[Participants.ListSuggestions][google.cloud.dialogflow.v2beta1.Participants.ListSuggestions].
872872
873873
Iterating over this object will yield results and
874874
resolve additional pages automatically.
@@ -944,7 +944,7 @@ async def compile_suggestion(
944944
Returns:
945945
google.cloud.dialogflow_v2beta1.types.CompileSuggestionResponse:
946946
The response message for
947-
[Participants.CompileSuggestion][google.cloud.dialogflow.v2beta1.Participants.CompileSuggestion].
947+
[Participants.CompileSuggestion][google.cloud.dialogflow.v2beta1.Participants.CompileSuggestion].
948948
949949
"""
950950
warnings.warn(

google/cloud/dialogflow_v2beta1/services/participants/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def list_participants(
623623
Returns:
624624
google.cloud.dialogflow_v2beta1.services.participants.pagers.ListParticipantsPager:
625625
The response message for
626-
[Participants.ListParticipants][google.cloud.dialogflow.v2beta1.Participants.ListParticipants].
626+
[Participants.ListParticipants][google.cloud.dialogflow.v2beta1.Participants.ListParticipants].
627627
628628
Iterating over this object will yield results and
629629
resolve additional pages automatically.
@@ -804,7 +804,7 @@ def analyze_content(
804804
Returns:
805805
google.cloud.dialogflow_v2beta1.types.AnalyzeContentResponse:
806806
The response message for
807-
[Participants.AnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.AnalyzeContent].
807+
[Participants.AnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.AnalyzeContent].
808808
809809
"""
810810
# Create or coerce a protobuf request object.
@@ -890,7 +890,7 @@ def suggest_articles(
890890
Returns:
891891
google.cloud.dialogflow_v2beta1.types.SuggestArticlesResponse:
892892
The response message for
893-
[Participants.SuggestArticles][google.cloud.dialogflow.v2beta1.Participants.SuggestArticles].
893+
[Participants.SuggestArticles][google.cloud.dialogflow.v2beta1.Participants.SuggestArticles].
894894
895895
"""
896896
# Create or coerce a protobuf request object.
@@ -963,7 +963,7 @@ def suggest_faq_answers(
963963
Returns:
964964
google.cloud.dialogflow_v2beta1.types.SuggestFaqAnswersResponse:
965965
The request message for
966-
[Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2beta1.Participants.SuggestFaqAnswers].
966+
[Participants.SuggestFaqAnswers][google.cloud.dialogflow.v2beta1.Participants.SuggestFaqAnswers].
967967
968968
"""
969969
# Create or coerce a protobuf request object.
@@ -1036,7 +1036,7 @@ def suggest_smart_replies(
10361036
Returns:
10371037
google.cloud.dialogflow_v2beta1.types.SuggestSmartRepliesResponse:
10381038
The response message for
1039-
[Participants.SuggestSmartReplies][google.cloud.dialogflow.v2beta1.Participants.SuggestSmartReplies].
1039+
[Participants.SuggestSmartReplies][google.cloud.dialogflow.v2beta1.Participants.SuggestSmartReplies].
10401040
10411041
"""
10421042
# Create or coerce a protobuf request object.
@@ -1118,7 +1118,7 @@ def list_suggestions(
11181118
Returns:
11191119
google.cloud.dialogflow_v2beta1.services.participants.pagers.ListSuggestionsPager:
11201120
The response message for
1121-
[Participants.ListSuggestions][google.cloud.dialogflow.v2beta1.Participants.ListSuggestions].
1121+
[Participants.ListSuggestions][google.cloud.dialogflow.v2beta1.Participants.ListSuggestions].
11221122
11231123
Iterating over this object will yield results and
11241124
resolve additional pages automatically.
@@ -1195,7 +1195,7 @@ def compile_suggestion(
11951195
Returns:
11961196
google.cloud.dialogflow_v2beta1.types.CompileSuggestionResponse:
11971197
The response message for
1198-
[Participants.CompileSuggestion][google.cloud.dialogflow.v2beta1.Participants.CompileSuggestion].
1198+
[Participants.CompileSuggestion][google.cloud.dialogflow.v2beta1.Participants.CompileSuggestion].
11991199
12001200
"""
12011201
warnings.warn(

google/cloud/dialogflow_v2beta1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
AnalyzeContentResponse,
173173
AnnotatedMessagePart,
174174
ArticleAnswer,
175+
AssistQueryParameters,
175176
AutomatedAgentReply,
176177
CompileSuggestionRequest,
177178
CompileSuggestionResponse,
@@ -377,6 +378,7 @@
377378
"AnalyzeContentResponse",
378379
"AnnotatedMessagePart",
379380
"ArticleAnswer",
381+
"AssistQueryParameters",
380382
"AutomatedAgentReply",
381383
"CompileSuggestionRequest",
382384
"CompileSuggestionResponse",

google/cloud/dialogflow_v2beta1/types/participant.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"OutputAudio",
3737
"AutomatedAgentReply",
3838
"SuggestionFeature",
39+
"AssistQueryParameters",
3940
"AnalyzeContentRequest",
4041
"DtmfParameters",
4142
"AnalyzeContentResponse",
@@ -109,6 +110,27 @@ class Participant(proto.Message):
109110
- Dialogflow only accepts a UTF-8 encoded string, e.g., a
110111
hex digest of a hash function like SHA-512.
111112
- The length of the user id must be <= 256 characters.
113+
documents_metadata_filters (Sequence[google.cloud.dialogflow_v2beta1.types.Participant.DocumentsMetadataFiltersEntry]):
114+
Optional. Key-value filters on the metadata of documents
115+
returned by article suggestion. If specified, article
116+
suggestion only returns suggested documents that match all
117+
filters in their
118+
[Document.metadata][google.cloud.dialogflow.v2beta1.Document.metadata].
119+
Multiple values for a metadata key should be concatenated by
120+
comma. For example, filters to match all documents that have
121+
'US' or 'CA' in their market metadata values and 'agent' in
122+
their user metadata values will be
123+
124+
::
125+
126+
documents_metadata_filters {
127+
key: "market"
128+
value: "US,CA"
129+
}
130+
documents_metadata_filters {
131+
key: "user"
132+
value: "agent"
133+
}
112134
"""
113135

114136
class Role(proto.Enum):
@@ -123,6 +145,7 @@ class Role(proto.Enum):
123145
name = proto.Field(proto.STRING, number=1,)
124146
role = proto.Field(proto.ENUM, number=2, enum=Role,)
125147
obfuscated_external_user_id = proto.Field(proto.STRING, number=7,)
148+
documents_metadata_filters = proto.MapField(proto.STRING, proto.STRING, number=8,)
126149

127150

128151
class Message(proto.Message):
@@ -385,6 +408,35 @@ class Type(proto.Enum):
385408
type_ = proto.Field(proto.ENUM, number=1, enum=Type,)
386409

387410

411+
class AssistQueryParameters(proto.Message):
412+
r"""Represents the parameters of human assist query.
413+
414+
Attributes:
415+
documents_metadata_filters (Sequence[google.cloud.dialogflow_v2beta1.types.AssistQueryParameters.DocumentsMetadataFiltersEntry]):
416+
Key-value filters on the metadata of documents returned by
417+
article suggestion. If specified, article suggestion only
418+
returns suggested documents that match all filters in their
419+
[Document.metadata][google.cloud.dialogflow.v2beta1.Document.metadata].
420+
Multiple values for a metadata key should be concatenated by
421+
comma. For example, filters to match all documents that have
422+
'US' or 'CA' in their market metadata values and 'agent' in
423+
their user metadata values will be
424+
425+
::
426+
427+
documents_metadata_filters {
428+
key: "market"
429+
value: "US,CA"
430+
}
431+
documents_metadata_filters {
432+
key: "user"
433+
value: "agent"
434+
}
435+
"""
436+
437+
documents_metadata_filters = proto.MapField(proto.STRING, proto.STRING, number=1,)
438+
439+
388440
class AnalyzeContentRequest(proto.Message):
389441
r"""The request message for
390442
[Participants.AnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.AnalyzeContent].
@@ -419,6 +471,8 @@ class AnalyzeContentRequest(proto.Message):
419471
query_params (google.cloud.dialogflow_v2beta1.types.QueryParameters):
420472
Parameters for a Dialogflow virtual-agent
421473
query.
474+
assist_query_params (google.cloud.dialogflow_v2beta1.types.AssistQueryParameters):
475+
Parameters for a human assist query.
422476
message_send_time (google.protobuf.timestamp_pb2.Timestamp):
423477
Optional. The send time of the message from
424478
end user or human agent's perspective. It is
@@ -456,6 +510,9 @@ class AnalyzeContentRequest(proto.Message):
456510
query_params = proto.Field(
457511
proto.MESSAGE, number=9, message=session.QueryParameters,
458512
)
513+
assist_query_params = proto.Field(
514+
proto.MESSAGE, number=14, message="AssistQueryParameters",
515+
)
459516
message_send_time = proto.Field(
460517
proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp,
461518
)
@@ -756,11 +813,17 @@ class SuggestArticlesRequest(proto.Message):
756813
[latest_message][google.cloud.dialogflow.v2beta1.SuggestArticlesRequest.latest_message]
757814
to use as context when compiling the suggestion. By default
758815
20 and at most 50.
816+
assist_query_params (google.cloud.dialogflow_v2beta1.types.AssistQueryParameters):
817+
Optional. Parameters for a human assist
818+
query.
759819
"""
760820

761821
parent = proto.Field(proto.STRING, number=1,)
762822
latest_message = proto.Field(proto.STRING, number=2,)
763823
context_size = proto.Field(proto.INT32, number=3,)
824+
assist_query_params = proto.Field(
825+
proto.MESSAGE, number=4, message="AssistQueryParameters",
826+
)
764827

765828

766829
class SuggestArticlesResponse(proto.Message):
@@ -813,11 +876,17 @@ class SuggestFaqAnswersRequest(proto.Message):
813876
Optional. Max number of messages prior to and including
814877
[latest_message] to use as context when compiling the
815878
suggestion. By default 20 and at most 50.
879+
assist_query_params (google.cloud.dialogflow_v2beta1.types.AssistQueryParameters):
880+
Optional. Parameters for a human assist
881+
query.
816882
"""
817883

818884
parent = proto.Field(proto.STRING, number=1,)
819885
latest_message = proto.Field(proto.STRING, number=2,)
820886
context_size = proto.Field(proto.INT32, number=3,)
887+
assist_query_params = proto.Field(
888+
proto.MESSAGE, number=4, message="AssistQueryParameters",
889+
)
821890

822891

823892
class SuggestFaqAnswersResponse(proto.Message):

scripts/fixup_dialogflow_v2beta1_keywords.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def partition(
3939
class dialogflowCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'analyze_content': ('participant', 'text_input', 'event_input', 'reply_audio_config', 'query_params', 'message_send_time', 'request_id', ),
42+
'analyze_content': ('participant', 'text_input', 'event_input', 'reply_audio_config', 'query_params', 'assist_query_params', 'message_send_time', 'request_id', ),
4343
'batch_create_entities': ('parent', 'entities', 'language_code', ),
4444
'batch_create_messages': ('parent', 'requests', ),
4545
'batch_delete_entities': ('parent', 'entity_values', 'language_code', ),
@@ -111,8 +111,8 @@ class dialogflowCallTransformer(cst.CSTTransformer):
111111
'search_agents': ('parent', 'page_size', 'page_token', ),
112112
'set_agent': ('agent', 'update_mask', ),
113113
'streaming_detect_intent': ('session', 'query_input', 'query_params', 'single_utterance', 'output_audio_config', 'output_audio_config_mask', 'input_audio', ),
114-
'suggest_articles': ('parent', 'latest_message', 'context_size', ),
115-
'suggest_faq_answers': ('parent', 'latest_message', 'context_size', ),
114+
'suggest_articles': ('parent', 'latest_message', 'context_size', 'assist_query_params', ),
115+
'suggest_faq_answers': ('parent', 'latest_message', 'context_size', 'assist_query_params', ),
116116
'suggest_smart_replies': ('parent', 'current_text_input', 'latest_message', 'context_size', ),
117117
'train_agent': ('parent', ),
118118
'update_answer_record': ('answer_record', 'update_mask', ),

0 commit comments

Comments
 (0)