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

feat: added speech endpointing setting #668

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions google/cloud/dialogflow/__init__.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading