Skip to content

Commit

Permalink
feat(v2beta1): Add Agent Assist Summarization API (https://cloud.goog…
Browse files Browse the repository at this point in the history
…le.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: googleapis/googleapis-gen@b23d242
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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Sep 29, 2022
1 parent 1d1da54 commit d05caf3
Show file tree
Hide file tree
Showing 19 changed files with 1,013 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
from .types.conversation import ListConversationsResponse
from .types.conversation import ListMessagesRequest
from .types.conversation import ListMessagesResponse
from .types.conversation import SuggestConversationSummaryRequest
from .types.conversation import SuggestConversationSummaryResponse
from .types.conversation_event import ConversationEvent
from .types.conversation_profile import AutomatedAgentConfig
from .types.conversation_profile import ClearSuggestionFeatureConfigOperationMetadata
Expand Down Expand Up @@ -451,6 +453,8 @@
"SubAgent",
"SuggestArticlesRequest",
"SuggestArticlesResponse",
"SuggestConversationSummaryRequest",
"SuggestConversationSummaryResponse",
"SuggestFaqAnswersRequest",
"SuggestFaqAnswersResponse",
"SuggestSmartRepliesRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@
"methods": [
"list_messages"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
]
}
}
},
Expand Down Expand Up @@ -380,6 +385,11 @@
"methods": [
"list_messages"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ async def sample_clear_suggestion_feature_config():
request = dialogflow_v2beta1.ClearSuggestionFeatureConfigRequest(
conversation_profile="conversation_profile_value",
participant_role="END_USER",
suggestion_feature_type="SMART_REPLY",
suggestion_feature_type="CONVERSATION_SUMMARIZATION",
)
# Make the request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ def sample_clear_suggestion_feature_config():
request = dialogflow_v2beta1.ClearSuggestionFeatureConfigRequest(
conversation_profile="conversation_profile_value",
participant_role="END_USER",
suggestion_feature_type="SMART_REPLY",
suggestion_feature_type="CONVERSATION_SUMMARIZATION",
)
# Make the request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class ConversationsAsyncClient:
DEFAULT_ENDPOINT = ConversationsClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = ConversationsClient.DEFAULT_MTLS_ENDPOINT

answer_record_path = staticmethod(ConversationsClient.answer_record_path)
parse_answer_record_path = staticmethod(
ConversationsClient.parse_answer_record_path
)
conversation_path = staticmethod(ConversationsClient.conversation_path)
parse_conversation_path = staticmethod(ConversationsClient.parse_conversation_path)
conversation_profile_path = staticmethod(
Expand Down Expand Up @@ -921,6 +925,113 @@ async def sample_list_messages():
# Done; return the response.
return response

async def suggest_conversation_summary(
self,
request: Union[gcd_conversation.SuggestConversationSummaryRequest, dict] = None,
*,
conversation: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_conversation.SuggestConversationSummaryResponse:
r"""Suggest summary for a conversation based on specific
historical messages. The range of the messages to be
used for summary can be specified in the request.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dialogflow_v2beta1
async def sample_suggest_conversation_summary():
# Create a client
client = dialogflow_v2beta1.ConversationsAsyncClient()
# Initialize request argument(s)
request = dialogflow_v2beta1.SuggestConversationSummaryRequest(
conversation="conversation_value",
)
# Make the request
response = await client.suggest_conversation_summary(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryRequest, dict]):
The request object. The request message for
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
conversation (:class:`str`):
Required. The conversation to fetch suggestion for.
Format:
``projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>``.
This corresponds to the ``conversation`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryResponse:
The response message for
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([conversation])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = gcd_conversation.SuggestConversationSummaryRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if conversation is not None:
request.conversation = conversation

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.suggest_conversation_summary,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("conversation", request.conversation),)
),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def list_operations(
self,
request: operations_pb2.ListOperationsRequest = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ def transport(self) -> ConversationsTransport:
"""
return self._transport

@staticmethod
def answer_record_path(
project: str,
answer_record: str,
) -> str:
"""Returns a fully-qualified answer_record string."""
return "projects/{project}/answerRecords/{answer_record}".format(
project=project,
answer_record=answer_record,
)

@staticmethod
def parse_answer_record_path(path: str) -> Dict[str, str]:
"""Parses a answer_record path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/answerRecords/(?P<answer_record>.+?)$", path
)
return m.groupdict() if m else {}

@staticmethod
def conversation_path(
project: str,
Expand Down Expand Up @@ -1177,6 +1196,115 @@ def sample_list_messages():
# Done; return the response.
return response

def suggest_conversation_summary(
self,
request: Union[gcd_conversation.SuggestConversationSummaryRequest, dict] = None,
*,
conversation: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcd_conversation.SuggestConversationSummaryResponse:
r"""Suggest summary for a conversation based on specific
historical messages. The range of the messages to be
used for summary can be specified in the request.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dialogflow_v2beta1
def sample_suggest_conversation_summary():
# Create a client
client = dialogflow_v2beta1.ConversationsClient()
# Initialize request argument(s)
request = dialogflow_v2beta1.SuggestConversationSummaryRequest(
conversation="conversation_value",
)
# Make the request
response = client.suggest_conversation_summary(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryRequest, dict]):
The request object. The request message for
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
conversation (str):
Required. The conversation to fetch suggestion for.
Format:
``projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>``.
This corresponds to the ``conversation`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryResponse:
The response message for
[Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2beta1.Conversations.SuggestConversationSummary].
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([conversation])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a gcd_conversation.SuggestConversationSummaryRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, gcd_conversation.SuggestConversationSummaryRequest):
request = gcd_conversation.SuggestConversationSummaryRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if conversation is not None:
request.conversation = conversation

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[
self._transport.suggest_conversation_summary
]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("conversation", request.conversation),)
),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def __enter__(self):
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.suggest_conversation_summary: gapic_v1.method.wrap_method(
self.suggest_conversation_summary,
default_timeout=None,
client_info=client_info,
),
}

def close(self):
Expand Down Expand Up @@ -237,6 +242,18 @@ def list_messages(
]:
raise NotImplementedError()

@property
def suggest_conversation_summary(
self,
) -> Callable[
[gcd_conversation.SuggestConversationSummaryRequest],
Union[
gcd_conversation.SuggestConversationSummaryResponse,
Awaitable[gcd_conversation.SuggestConversationSummaryResponse],
],
]:
raise NotImplementedError()

@property
def list_operations(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,37 @@ def list_messages(
)
return self._stubs["list_messages"]

@property
def suggest_conversation_summary(
self,
) -> Callable[
[gcd_conversation.SuggestConversationSummaryRequest],
gcd_conversation.SuggestConversationSummaryResponse,
]:
r"""Return a callable for the suggest conversation summary method over gRPC.
Suggest summary for a conversation based on specific
historical messages. The range of the messages to be
used for summary can be specified in the request.
Returns:
Callable[[~.SuggestConversationSummaryRequest],
~.SuggestConversationSummaryResponse]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "suggest_conversation_summary" not in self._stubs:
self._stubs["suggest_conversation_summary"] = self.grpc_channel.unary_unary(
"/google.cloud.dialogflow.v2beta1.Conversations/SuggestConversationSummary",
request_serializer=gcd_conversation.SuggestConversationSummaryRequest.serialize,
response_deserializer=gcd_conversation.SuggestConversationSummaryResponse.deserialize,
)
return self._stubs["suggest_conversation_summary"]

def close(self):
self.grpc_channel.close()

Expand Down
Loading

0 comments on commit d05caf3

Please sign in to comment.