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 (#668)
Browse files Browse the repository at this point in the history
* feat: added speech endpointing setting
feat: added Knowledge Search API

PiperOrigin-RevId: 560215389

Source-Link: googleapis/googleapis@b1666e6

Source-Link: googleapis/googleapis-gen@07e82b4
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDdlODJiNGQ0OTE3NDk0ZDg1MDM5NzIyZjY3M2Q0MDljNGM3MzA1ZiJ9

* 🦉 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 28, 2023
1 parent 6ac5a4f commit f09e34e
Show file tree
Hide file tree
Showing 29 changed files with 2,046 additions and 31 deletions.
12 changes: 12 additions & 0 deletions google/cloud/dialogflow/__init__.py
Expand Up @@ -154,6 +154,9 @@
ListConversationsResponse,
ListMessagesRequest,
ListMessagesResponse,
SearchKnowledgeAnswer,
SearchKnowledgeRequest,
SearchKnowledgeResponse,
SuggestConversationSummaryRequest,
SuggestConversationSummaryResponse,
)
Expand Down Expand Up @@ -301,10 +304,12 @@
AssistQueryParameters,
AutomatedAgentReply,
CreateParticipantRequest,
DialogflowAssistAnswer,
DtmfParameters,
FaqAnswer,
GetParticipantRequest,
InputTextConfig,
IntentSuggestion,
ListParticipantsRequest,
ListParticipantsResponse,
Message,
Expand All @@ -318,6 +323,7 @@
SuggestArticlesResponse,
SuggestFaqAnswersRequest,
SuggestFaqAnswersResponse,
SuggestionInput,
SuggestionResult,
SuggestSmartRepliesRequest,
SuggestSmartRepliesResponse,
Expand Down Expand Up @@ -453,6 +459,9 @@
"ListConversationsResponse",
"ListMessagesRequest",
"ListMessagesResponse",
"SearchKnowledgeAnswer",
"SearchKnowledgeRequest",
"SearchKnowledgeResponse",
"SuggestConversationSummaryRequest",
"SuggestConversationSummaryResponse",
"ConversationDataset",
Expand Down Expand Up @@ -579,10 +588,12 @@
"AssistQueryParameters",
"AutomatedAgentReply",
"CreateParticipantRequest",
"DialogflowAssistAnswer",
"DtmfParameters",
"FaqAnswer",
"GetParticipantRequest",
"InputTextConfig",
"IntentSuggestion",
"ListParticipantsRequest",
"ListParticipantsResponse",
"Message",
Expand All @@ -596,6 +607,7 @@
"SuggestArticlesResponse",
"SuggestFaqAnswersRequest",
"SuggestFaqAnswersResponse",
"SuggestionInput",
"SuggestionResult",
"SuggestSmartRepliesRequest",
"SuggestSmartRepliesResponse",
Expand Down
12 changes: 12 additions & 0 deletions google/cloud/dialogflow_v2/__init__.py
Expand Up @@ -107,6 +107,9 @@
ListConversationsResponse,
ListMessagesRequest,
ListMessagesResponse,
SearchKnowledgeAnswer,
SearchKnowledgeRequest,
SearchKnowledgeResponse,
SuggestConversationSummaryRequest,
SuggestConversationSummaryResponse,
)
Expand Down Expand Up @@ -252,10 +255,12 @@
AssistQueryParameters,
AutomatedAgentReply,
CreateParticipantRequest,
DialogflowAssistAnswer,
DtmfParameters,
FaqAnswer,
GetParticipantRequest,
InputTextConfig,
IntentSuggestion,
ListParticipantsRequest,
ListParticipantsResponse,
Message,
Expand All @@ -269,6 +274,7 @@
SuggestArticlesResponse,
SuggestFaqAnswersRequest,
SuggestFaqAnswersResponse,
SuggestionInput,
SuggestionResult,
SuggestSmartRepliesRequest,
SuggestSmartRepliesResponse,
Expand Down Expand Up @@ -408,6 +414,7 @@
"DeployConversationModelRequest",
"DetectIntentRequest",
"DetectIntentResponse",
"DialogflowAssistAnswer",
"Document",
"DocumentsClient",
"DtmfParameters",
Expand Down Expand Up @@ -464,6 +471,7 @@
"InputTextConfig",
"Intent",
"IntentBatch",
"IntentSuggestion",
"IntentView",
"IntentsClient",
"KnowledgeBase",
Expand Down Expand Up @@ -518,6 +526,9 @@
"RestoreAgentRequest",
"SearchAgentsRequest",
"SearchAgentsResponse",
"SearchKnowledgeAnswer",
"SearchKnowledgeRequest",
"SearchKnowledgeResponse",
"Sentiment",
"SentimentAnalysisRequestConfig",
"SentimentAnalysisResult",
Expand Down Expand Up @@ -549,6 +560,7 @@
"SuggestSmartRepliesRequest",
"SuggestSmartRepliesResponse",
"SuggestionFeature",
"SuggestionInput",
"SuggestionResult",
"SynthesizeSpeechConfig",
"TelephonyDtmf",
Expand Down
15 changes: 15 additions & 0 deletions google/cloud/dialogflow_v2/gapic_metadata.json
Expand Up @@ -724,6 +724,11 @@
"list_messages"
]
},
"SearchKnowledge": {
"methods": [
"search_knowledge"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
Expand Down Expand Up @@ -764,6 +769,11 @@
"list_messages"
]
},
"SearchKnowledge": {
"methods": [
"search_knowledge"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
Expand Down Expand Up @@ -804,6 +814,11 @@
"list_messages"
]
},
"SearchKnowledge": {
"methods": [
"search_knowledge"
]
},
"SuggestConversationSummary": {
"methods": [
"suggest_conversation_summary"
Expand Down
Expand Up @@ -69,6 +69,10 @@ class AnswerRecordsAsyncClient:
parse_answer_record_path = staticmethod(
AnswerRecordsClient.parse_answer_record_path
)
context_path = staticmethod(AnswerRecordsClient.context_path)
parse_context_path = staticmethod(AnswerRecordsClient.parse_context_path)
intent_path = staticmethod(AnswerRecordsClient.intent_path)
parse_intent_path = staticmethod(AnswerRecordsClient.parse_intent_path)
common_billing_account_path = staticmethod(
AnswerRecordsClient.common_billing_account_path
)
Expand Down
39 changes: 39 additions & 0 deletions google/cloud/dialogflow_v2/services/answer_records/client.py
Expand Up @@ -201,6 +201,45 @@ def parse_answer_record_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}

@staticmethod
def context_path(
project: str,
session: str,
context: str,
) -> str:
"""Returns a fully-qualified context string."""
return "projects/{project}/agent/sessions/{session}/contexts/{context}".format(
project=project,
session=session,
context=context,
)

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

@staticmethod
def intent_path(
project: str,
intent: str,
) -> str:
"""Returns a fully-qualified intent string."""
return "projects/{project}/agent/intents/{intent}".format(
project=project,
intent=intent,
)

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

@staticmethod
def common_billing_account_path(
billing_account: str,
Expand Down
Expand Up @@ -1042,7 +1042,7 @@ async def sample_clear_suggestion_feature_config():
request = dialogflow_v2.ClearSuggestionFeatureConfigRequest(
conversation_profile="conversation_profile_value",
participant_role="END_USER",
suggestion_feature_type="SMART_REPLY",
suggestion_feature_type="KNOWLEDGE_SEARCH",
)
# Make the request
Expand Down
Expand Up @@ -1366,7 +1366,7 @@ def sample_clear_suggestion_feature_config():
request = dialogflow_v2.ClearSuggestionFeatureConfigRequest(
conversation_profile="conversation_profile_value",
participant_role="END_USER",
suggestion_feature_type="SMART_REPLY",
suggestion_feature_type="KNOWLEDGE_SEARCH",
)
# Make the request
Expand Down
86 changes: 86 additions & 0 deletions google/cloud/dialogflow_v2/services/conversations/async_client.py
Expand Up @@ -1055,6 +1055,92 @@ 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_v2
async def sample_search_knowledge():
# Create a client
client = dialogflow_v2.ConversationsAsyncClient()
# Initialize request argument(s)
query = dialogflow_v2.TextInput()
query.text = "text_value"
query.language_code = "language_code_value"
request = dialogflow_v2.SearchKnowledgeRequest(
query=query,
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_v2.types.SearchKnowledgeRequest, dict]]):
The request object. The request message for
[Conversations.SearchKnowledge][google.cloud.dialogflow.v2.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_v2.types.SearchKnowledgeResponse:
The response message for
[Conversations.SearchKnowledge][google.cloud.dialogflow.v2.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

0 comments on commit f09e34e

Please sign in to comment.