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

Commit

Permalink
feat: added speech endpointing setting (#669)
Browse files Browse the repository at this point in the history
* feat: added speech endpointing setting
feat: added Knowledge Search API

PiperOrigin-RevId: 561112943

Source-Link: googleapis/googleapis@6d69526

Source-Link: googleapis/googleapis-gen@5d3ab0d
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWQzYWIwZDlmZmRhMjMyZDM2Y2IxNDhjZTE5MmVhODc3MTUxMDQwMiJ9

* 🦉 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] committed Aug 30, 2023
1 parent f09e34e commit 0bf73ae
Show file tree
Hide file tree
Showing 26 changed files with 1,309 additions and 13 deletions.
6 changes: 6 additions & 0 deletions google/cloud/dialogflow_v2beta1/__init__.py
Expand Up @@ -105,6 +105,9 @@
ListConversationsResponse,
ListMessagesRequest,
ListMessagesResponse,
SearchKnowledgeAnswer,
SearchKnowledgeRequest,
SearchKnowledgeResponse,
SuggestConversationSummaryRequest,
SuggestConversationSummaryResponse,
)
Expand Down Expand Up @@ -467,6 +470,9 @@
"RestoreAgentRequest",
"SearchAgentsRequest",
"SearchAgentsResponse",
"SearchKnowledgeAnswer",
"SearchKnowledgeRequest",
"SearchKnowledgeResponse",
"Sentiment",
"SentimentAnalysisRequestConfig",
"SentimentAnalysisResult",
Expand Down
15 changes: 15 additions & 0 deletions google/cloud/dialogflow_v2beta1/gapic_metadata.json
Expand Up @@ -496,6 +496,11 @@
"list_messages"
]
},
"SearchKnowledge": {
"methods": [
"search_knowledge"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
Expand Down Expand Up @@ -541,6 +546,11 @@
"list_messages"
]
},
"SearchKnowledge": {
"methods": [
"search_knowledge"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
Expand Down Expand Up @@ -586,6 +596,11 @@
"list_messages"
]
},
"SearchKnowledge": {
"methods": [
"search_knowledge"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
Expand Down
Expand Up @@ -1040,7 +1040,7 @@ async def sample_clear_suggestion_feature_config():
request = dialogflow_v2beta1.ClearSuggestionFeatureConfigRequest(
conversation_profile="conversation_profile_value",
participant_role="END_USER",
suggestion_feature_type="CONVERSATION_SUMMARIZATION",
suggestion_feature_type="KNOWLEDGE_SEARCH",
)
# Make the request
Expand Down
Expand Up @@ -1364,7 +1364,7 @@ def sample_clear_suggestion_feature_config():
request = dialogflow_v2beta1.ClearSuggestionFeatureConfigRequest(
conversation_profile="conversation_profile_value",
participant_role="END_USER",
suggestion_feature_type="CONVERSATION_SUMMARIZATION",
suggestion_feature_type="KNOWLEDGE_SEARCH",
)
# Make the request
Expand Down
Expand Up @@ -1165,6 +1165,87 @@ async def sample_generate_stateless_summary():
# Done; return the response.
return response

async def search_knowledge(
self,
request: Optional[Union[conversation.SearchKnowledgeRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> conversation.SearchKnowledgeResponse:
r"""Get answers for the given query based on knowledge
documents.
.. 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_search_knowledge():
# Create a client
client = dialogflow_v2beta1.ConversationsAsyncClient()
# Initialize request argument(s)
request = dialogflow_v2beta1.SearchKnowledgeRequest(
conversation_profile="conversation_profile_value",
)
# Make the request
response = await client.search_knowledge(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.dialogflow_v2beta1.types.SearchKnowledgeRequest, dict]]):
The request object. The request message for
[Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge].
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.SearchKnowledgeResponse:
The response message for
[Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge].
"""
# Create or coerce a protobuf request object.
request = conversation.SearchKnowledgeRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.search_knowledge,
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((("parent", request.parent),)),
)

# 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: Optional[operations_pb2.ListOperationsRequest] = None,
Expand Down
82 changes: 82 additions & 0 deletions google/cloud/dialogflow_v2beta1/services/conversations/client.py
Expand Up @@ -1527,6 +1527,88 @@ def sample_generate_stateless_summary():
# Done; return the response.
return response

def search_knowledge(
self,
request: Optional[Union[conversation.SearchKnowledgeRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> conversation.SearchKnowledgeResponse:
r"""Get answers for the given query based on knowledge
documents.
.. 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_search_knowledge():
# Create a client
client = dialogflow_v2beta1.ConversationsClient()
# Initialize request argument(s)
request = dialogflow_v2beta1.SearchKnowledgeRequest(
conversation_profile="conversation_profile_value",
)
# Make the request
response = client.search_knowledge(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.dialogflow_v2beta1.types.SearchKnowledgeRequest, dict]):
The request object. The request message for
[Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge].
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.SearchKnowledgeResponse:
The response message for
[Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge].
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a conversation.SearchKnowledgeRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, conversation.SearchKnowledgeRequest):
request = conversation.SearchKnowledgeRequest(request)

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

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

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

# Done; return the response.
return response

def __enter__(self) -> "ConversationsClient":
return self

Expand Down
Expand Up @@ -168,6 +168,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.search_knowledge: gapic_v1.method.wrap_method(
self.search_knowledge,
default_timeout=None,
client_info=client_info,
),
}

def close(self):
Expand Down Expand Up @@ -266,6 +271,18 @@ def generate_stateless_summary(
]:
raise NotImplementedError()

@property
def search_knowledge(
self,
) -> Callable[
[conversation.SearchKnowledgeRequest],
Union[
conversation.SearchKnowledgeResponse,
Awaitable[conversation.SearchKnowledgeResponse],
],
]:
raise NotImplementedError()

@property
def list_operations(
self,
Expand Down
Expand Up @@ -489,6 +489,35 @@ def generate_stateless_summary(
)
return self._stubs["generate_stateless_summary"]

@property
def search_knowledge(
self,
) -> Callable[
[conversation.SearchKnowledgeRequest], conversation.SearchKnowledgeResponse
]:
r"""Return a callable for the search knowledge method over gRPC.
Get answers for the given query based on knowledge
documents.
Returns:
Callable[[~.SearchKnowledgeRequest],
~.SearchKnowledgeResponse]:
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 "search_knowledge" not in self._stubs:
self._stubs["search_knowledge"] = self.grpc_channel.unary_unary(
"/google.cloud.dialogflow.v2beta1.Conversations/SearchKnowledge",
request_serializer=conversation.SearchKnowledgeRequest.serialize,
response_deserializer=conversation.SearchKnowledgeResponse.deserialize,
)
return self._stubs["search_knowledge"]

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

Expand Down
Expand Up @@ -496,6 +496,36 @@ def generate_stateless_summary(
)
return self._stubs["generate_stateless_summary"]

@property
def search_knowledge(
self,
) -> Callable[
[conversation.SearchKnowledgeRequest],
Awaitable[conversation.SearchKnowledgeResponse],
]:
r"""Return a callable for the search knowledge method over gRPC.
Get answers for the given query based on knowledge
documents.
Returns:
Callable[[~.SearchKnowledgeRequest],
Awaitable[~.SearchKnowledgeResponse]]:
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 "search_knowledge" not in self._stubs:
self._stubs["search_knowledge"] = self.grpc_channel.unary_unary(
"/google.cloud.dialogflow.v2beta1.Conversations/SearchKnowledge",
request_serializer=conversation.SearchKnowledgeRequest.serialize,
response_deserializer=conversation.SearchKnowledgeResponse.deserialize,
)
return self._stubs["search_knowledge"]

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

Expand Down

0 comments on commit 0bf73ae

Please sign in to comment.