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

Commit 1648b27

Browse files
feat(v2beta1): Add Agent Assist Summarization API (https://cloud.google.com/agent-assist/docs/summarization) (#580)
* feat: Add Agent Assist Summarization API (https://cloud.google.com/agent-assist/docs/summarization) docs: clarify SuggestionFeature enums which are specific to chat agents PiperOrigin-RevId: 477479918 Source-Link: googleapis/googleapis@6deca98 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b23d242c5c5deb7ce6f4a7f71862a311555069bd Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjIzZDI0MmM1YzVkZWI3Y2U2ZjRhN2Y3MTg2MmEzMTE1NTUwNjliZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 11cb701 commit 1648b27

19 files changed

+1013
-30
lines changed

google/cloud/dialogflow_v2beta1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
from .types.conversation import ListConversationsResponse
100100
from .types.conversation import ListMessagesRequest
101101
from .types.conversation import ListMessagesResponse
102+
from .types.conversation import SuggestConversationSummaryRequest
103+
from .types.conversation import SuggestConversationSummaryResponse
102104
from .types.conversation_event import ConversationEvent
103105
from .types.conversation_profile import AutomatedAgentConfig
104106
from .types.conversation_profile import ClearSuggestionFeatureConfigOperationMetadata
@@ -451,6 +453,8 @@
451453
"SubAgent",
452454
"SuggestArticlesRequest",
453455
"SuggestArticlesResponse",
456+
"SuggestConversationSummaryRequest",
457+
"SuggestConversationSummaryResponse",
454458
"SuggestFaqAnswersRequest",
455459
"SuggestFaqAnswersResponse",
456460
"SuggestSmartRepliesRequest",

google/cloud/dialogflow_v2beta1/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@
345345
"methods": [
346346
"list_messages"
347347
]
348+
},
349+
"SuggestConversationSummary": {
350+
"methods": [
351+
"suggest_conversation_summary"
352+
]
348353
}
349354
}
350355
},
@@ -380,6 +385,11 @@
380385
"methods": [
381386
"list_messages"
382387
]
388+
},
389+
"SuggestConversationSummary": {
390+
"methods": [
391+
"suggest_conversation_summary"
392+
]
383393
}
384394
}
385395
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ async def sample_clear_suggestion_feature_config():
992992
request = dialogflow_v2beta1.ClearSuggestionFeatureConfigRequest(
993993
conversation_profile="conversation_profile_value",
994994
participant_role="END_USER",
995-
suggestion_feature_type="SMART_REPLY",
995+
suggestion_feature_type="CONVERSATION_SUMMARIZATION",
996996
)
997997
998998
# Make the request

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ def sample_clear_suggestion_feature_config():
13121312
request = dialogflow_v2beta1.ClearSuggestionFeatureConfigRequest(
13131313
conversation_profile="conversation_profile_value",
13141314
participant_role="END_USER",
1315-
suggestion_feature_type="SMART_REPLY",
1315+
suggestion_feature_type="CONVERSATION_SUMMARIZATION",
13161316
)
13171317
13181318
# Make the request

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

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class ConversationsAsyncClient:
5353
DEFAULT_ENDPOINT = ConversationsClient.DEFAULT_ENDPOINT
5454
DEFAULT_MTLS_ENDPOINT = ConversationsClient.DEFAULT_MTLS_ENDPOINT
5555

56+
answer_record_path = staticmethod(ConversationsClient.answer_record_path)
57+
parse_answer_record_path = staticmethod(
58+
ConversationsClient.parse_answer_record_path
59+
)
5660
conversation_path = staticmethod(ConversationsClient.conversation_path)
5761
parse_conversation_path = staticmethod(ConversationsClient.parse_conversation_path)
5862
conversation_profile_path = staticmethod(
@@ -921,6 +925,113 @@ async def sample_list_messages():
921925
# Done; return the response.
922926
return response
923927

928+
async def suggest_conversation_summary(
929+
self,
930+
request: Union[gcd_conversation.SuggestConversationSummaryRequest, dict] = None,
931+
*,
932+
conversation: str = None,
933+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
934+
timeout: float = None,
935+
metadata: Sequence[Tuple[str, str]] = (),
936+
) -> gcd_conversation.SuggestConversationSummaryResponse:
937+
r"""Suggest summary for a conversation based on specific
938+
historical messages. The range of the messages to be
939+
used for summary can be specified in the request.
940+
941+
.. code-block:: python
942+
943+
# This snippet has been automatically generated and should be regarded as a
944+
# code template only.
945+
# It will require modifications to work:
946+
# - It may require correct/in-range values for request initialization.
947+
# - It may require specifying regional endpoints when creating the service
948+
# client as shown in:
949+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
950+
from google.cloud import dialogflow_v2beta1
951+
952+
async def sample_suggest_conversation_summary():
953+
# Create a client
954+
client = dialogflow_v2beta1.ConversationsAsyncClient()
955+
956+
# Initialize request argument(s)
957+
request = dialogflow_v2beta1.SuggestConversationSummaryRequest(
958+
conversation="conversation_value",
959+
)
960+
961+
# Make the request
962+
response = await client.suggest_conversation_summary(request=request)
963+
964+
# Handle the response
965+
print(response)
966+
967+
Args:
968+
request (Union[google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryRequest, dict]):
969+
The request object. The request message for
970+
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
971+
conversation (:class:`str`):
972+
Required. The conversation to fetch suggestion for.
973+
Format:
974+
``projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>``.
975+
976+
This corresponds to the ``conversation`` field
977+
on the ``request`` instance; if ``request`` is provided, this
978+
should not be set.
979+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
980+
should be retried.
981+
timeout (float): The timeout for this request.
982+
metadata (Sequence[Tuple[str, str]]): Strings which should be
983+
sent along with the request as metadata.
984+
985+
Returns:
986+
google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryResponse:
987+
The response message for
988+
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
989+
990+
"""
991+
# Create or coerce a protobuf request object.
992+
# Quick check: If we got a request object, we should *not* have
993+
# gotten any keyword arguments that map to the request.
994+
has_flattened_params = any([conversation])
995+
if request is not None and has_flattened_params:
996+
raise ValueError(
997+
"If the `request` argument is set, then none of "
998+
"the individual field arguments should be set."
999+
)
1000+
1001+
request = gcd_conversation.SuggestConversationSummaryRequest(request)
1002+
1003+
# If we have keyword arguments corresponding to fields on the
1004+
# request, apply these.
1005+
if conversation is not None:
1006+
request.conversation = conversation
1007+
1008+
# Wrap the RPC method; this adds retry and timeout information,
1009+
# and friendly error handling.
1010+
rpc = gapic_v1.method_async.wrap_method(
1011+
self._client._transport.suggest_conversation_summary,
1012+
default_timeout=None,
1013+
client_info=DEFAULT_CLIENT_INFO,
1014+
)
1015+
1016+
# Certain fields should be provided within the metadata header;
1017+
# add these here.
1018+
metadata = tuple(metadata) + (
1019+
gapic_v1.routing_header.to_grpc_metadata(
1020+
(("conversation", request.conversation),)
1021+
),
1022+
)
1023+
1024+
# Send the request.
1025+
response = await rpc(
1026+
request,
1027+
retry=retry,
1028+
timeout=timeout,
1029+
metadata=metadata,
1030+
)
1031+
1032+
# Done; return the response.
1033+
return response
1034+
9241035
async def list_operations(
9251036
self,
9261037
request: operations_pb2.ListOperationsRequest = None,

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

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ def transport(self) -> ConversationsTransport:
167167
"""
168168
return self._transport
169169

170+
@staticmethod
171+
def answer_record_path(
172+
project: str,
173+
answer_record: str,
174+
) -> str:
175+
"""Returns a fully-qualified answer_record string."""
176+
return "projects/{project}/answerRecords/{answer_record}".format(
177+
project=project,
178+
answer_record=answer_record,
179+
)
180+
181+
@staticmethod
182+
def parse_answer_record_path(path: str) -> Dict[str, str]:
183+
"""Parses a answer_record path into its component segments."""
184+
m = re.match(
185+
r"^projects/(?P<project>.+?)/answerRecords/(?P<answer_record>.+?)$", path
186+
)
187+
return m.groupdict() if m else {}
188+
170189
@staticmethod
171190
def conversation_path(
172191
project: str,
@@ -1177,6 +1196,115 @@ def sample_list_messages():
11771196
# Done; return the response.
11781197
return response
11791198

1199+
def suggest_conversation_summary(
1200+
self,
1201+
request: Union[gcd_conversation.SuggestConversationSummaryRequest, dict] = None,
1202+
*,
1203+
conversation: str = None,
1204+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1205+
timeout: float = None,
1206+
metadata: Sequence[Tuple[str, str]] = (),
1207+
) -> gcd_conversation.SuggestConversationSummaryResponse:
1208+
r"""Suggest summary for a conversation based on specific
1209+
historical messages. The range of the messages to be
1210+
used for summary can be specified in the request.
1211+
1212+
.. code-block:: python
1213+
1214+
# This snippet has been automatically generated and should be regarded as a
1215+
# code template only.
1216+
# It will require modifications to work:
1217+
# - It may require correct/in-range values for request initialization.
1218+
# - It may require specifying regional endpoints when creating the service
1219+
# client as shown in:
1220+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
1221+
from google.cloud import dialogflow_v2beta1
1222+
1223+
def sample_suggest_conversation_summary():
1224+
# Create a client
1225+
client = dialogflow_v2beta1.ConversationsClient()
1226+
1227+
# Initialize request argument(s)
1228+
request = dialogflow_v2beta1.SuggestConversationSummaryRequest(
1229+
conversation="conversation_value",
1230+
)
1231+
1232+
# Make the request
1233+
response = client.suggest_conversation_summary(request=request)
1234+
1235+
# Handle the response
1236+
print(response)
1237+
1238+
Args:
1239+
request (Union[google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryRequest, dict]):
1240+
The request object. The request message for
1241+
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
1242+
conversation (str):
1243+
Required. The conversation to fetch suggestion for.
1244+
Format:
1245+
``projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>``.
1246+
1247+
This corresponds to the ``conversation`` field
1248+
on the ``request`` instance; if ``request`` is provided, this
1249+
should not be set.
1250+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1251+
should be retried.
1252+
timeout (float): The timeout for this request.
1253+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1254+
sent along with the request as metadata.
1255+
1256+
Returns:
1257+
google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryResponse:
1258+
The response message for
1259+
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
1260+
1261+
"""
1262+
# Create or coerce a protobuf request object.
1263+
# Quick check: If we got a request object, we should *not* have
1264+
# gotten any keyword arguments that map to the request.
1265+
has_flattened_params = any([conversation])
1266+
if request is not None and has_flattened_params:
1267+
raise ValueError(
1268+
"If the `request` argument is set, then none of "
1269+
"the individual field arguments should be set."
1270+
)
1271+
1272+
# Minor optimization to avoid making a copy if the user passes
1273+
# in a gcd_conversation.SuggestConversationSummaryRequest.
1274+
# There's no risk of modifying the input as we've already verified
1275+
# there are no flattened fields.
1276+
if not isinstance(request, gcd_conversation.SuggestConversationSummaryRequest):
1277+
request = gcd_conversation.SuggestConversationSummaryRequest(request)
1278+
# If we have keyword arguments corresponding to fields on the
1279+
# request, apply these.
1280+
if conversation is not None:
1281+
request.conversation = conversation
1282+
1283+
# Wrap the RPC method; this adds retry and timeout information,
1284+
# and friendly error handling.
1285+
rpc = self._transport._wrapped_methods[
1286+
self._transport.suggest_conversation_summary
1287+
]
1288+
1289+
# Certain fields should be provided within the metadata header;
1290+
# add these here.
1291+
metadata = tuple(metadata) + (
1292+
gapic_v1.routing_header.to_grpc_metadata(
1293+
(("conversation", request.conversation),)
1294+
),
1295+
)
1296+
1297+
# Send the request.
1298+
response = rpc(
1299+
request,
1300+
retry=retry,
1301+
timeout=timeout,
1302+
metadata=metadata,
1303+
)
1304+
1305+
# Done; return the response.
1306+
return response
1307+
11801308
def __enter__(self):
11811309
return self
11821310

google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ def _prep_wrapped_messages(self, client_info):
163163
default_timeout=None,
164164
client_info=client_info,
165165
),
166+
self.suggest_conversation_summary: gapic_v1.method.wrap_method(
167+
self.suggest_conversation_summary,
168+
default_timeout=None,
169+
client_info=client_info,
170+
),
166171
}
167172

168173
def close(self):
@@ -237,6 +242,18 @@ def list_messages(
237242
]:
238243
raise NotImplementedError()
239244

245+
@property
246+
def suggest_conversation_summary(
247+
self,
248+
) -> Callable[
249+
[gcd_conversation.SuggestConversationSummaryRequest],
250+
Union[
251+
gcd_conversation.SuggestConversationSummaryResponse,
252+
Awaitable[gcd_conversation.SuggestConversationSummaryResponse],
253+
],
254+
]:
255+
raise NotImplementedError()
256+
240257
@property
241258
def list_operations(
242259
self,

google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,37 @@ def list_messages(
429429
)
430430
return self._stubs["list_messages"]
431431

432+
@property
433+
def suggest_conversation_summary(
434+
self,
435+
) -> Callable[
436+
[gcd_conversation.SuggestConversationSummaryRequest],
437+
gcd_conversation.SuggestConversationSummaryResponse,
438+
]:
439+
r"""Return a callable for the suggest conversation summary method over gRPC.
440+
441+
Suggest summary for a conversation based on specific
442+
historical messages. The range of the messages to be
443+
used for summary can be specified in the request.
444+
445+
Returns:
446+
Callable[[~.SuggestConversationSummaryRequest],
447+
~.SuggestConversationSummaryResponse]:
448+
A function that, when called, will call the underlying RPC
449+
on the server.
450+
"""
451+
# Generate a "stub function" on-the-fly which will actually make
452+
# the request.
453+
# gRPC handles serialization and deserialization, so we just need
454+
# to pass in the functions for each.
455+
if "suggest_conversation_summary" not in self._stubs:
456+
self._stubs["suggest_conversation_summary"] = self.grpc_channel.unary_unary(
457+
"/google.cloud.dialogflow.v2beta1.Conversations/SuggestConversationSummary",
458+
request_serializer=gcd_conversation.SuggestConversationSummaryRequest.serialize,
459+
response_deserializer=gcd_conversation.SuggestConversationSummaryResponse.deserialize,
460+
)
461+
return self._stubs["suggest_conversation_summary"]
462+
432463
def close(self):
433464
self.grpc_channel.close()
434465

0 commit comments

Comments
 (0)