diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d8103e6d..50b9d4d8 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.23.3" + ".": "2.24.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 171cf0d6..a40c53f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,25 @@ [1]: https://pypi.org/project/dialogflow/#history +## [2.24.0](https://github.com/googleapis/python-dialogflow/compare/v2.23.3...v2.24.0) (2023-09-13) + + +### Features + +* Added baseline model version used to generate the summary ([6ac5a4f](https://github.com/googleapis/python-dialogflow/commit/6ac5a4f3e892ab3530117b0cab5038409e26c901)) +* Added baseline model version used to generate the summary ([64b674a](https://github.com/googleapis/python-dialogflow/commit/64b674a080b2d93da9c251ba56a811d671798583)) +* Added Knowledge Search API ([0bf73ae](https://github.com/googleapis/python-dialogflow/commit/0bf73ae45a6f66d45fa5478d62a6391138b73ab7)) +* Added Knowledge Search API ([f09e34e](https://github.com/googleapis/python-dialogflow/commit/f09e34e11748f3bbf449dcc9f0b6c23323f25a10)) +* Added speech endpointing setting ([0bf73ae](https://github.com/googleapis/python-dialogflow/commit/0bf73ae45a6f66d45fa5478d62a6391138b73ab7)) +* Added speech endpointing setting ([f09e34e](https://github.com/googleapis/python-dialogflow/commit/f09e34e11748f3bbf449dcc9f0b6c23323f25a10)) +* Added the platform of the virtual agent response messages ([6ac5a4f](https://github.com/googleapis/python-dialogflow/commit/6ac5a4f3e892ab3530117b0cab5038409e26c901)) +* Added the platform of the virtual agent response messages ([64b674a](https://github.com/googleapis/python-dialogflow/commit/64b674a080b2d93da9c251ba56a811d671798583)) + + +### Documentation + +* Minor formatting ([de86202](https://github.com/googleapis/python-dialogflow/commit/de862024df7f364a0612d09f01ae5ca5134a5fde)) + ## [2.23.3](https://github.com/googleapis/python-dialogflow/compare/v2.23.2...v2.23.3) (2023-08-03) diff --git a/google/cloud/dialogflow/__init__.py b/google/cloud/dialogflow/__init__.py index fa6f2f92..4950bc3c 100644 --- a/google/cloud/dialogflow/__init__.py +++ b/google/cloud/dialogflow/__init__.py @@ -154,6 +154,9 @@ ListConversationsResponse, ListMessagesRequest, ListMessagesResponse, + SearchKnowledgeAnswer, + SearchKnowledgeRequest, + SearchKnowledgeResponse, SuggestConversationSummaryRequest, SuggestConversationSummaryResponse, ) @@ -301,10 +304,12 @@ AssistQueryParameters, AutomatedAgentReply, CreateParticipantRequest, + DialogflowAssistAnswer, DtmfParameters, FaqAnswer, GetParticipantRequest, InputTextConfig, + IntentSuggestion, ListParticipantsRequest, ListParticipantsResponse, Message, @@ -318,6 +323,7 @@ SuggestArticlesResponse, SuggestFaqAnswersRequest, SuggestFaqAnswersResponse, + SuggestionInput, SuggestionResult, SuggestSmartRepliesRequest, SuggestSmartRepliesResponse, @@ -453,6 +459,9 @@ "ListConversationsResponse", "ListMessagesRequest", "ListMessagesResponse", + "SearchKnowledgeAnswer", + "SearchKnowledgeRequest", + "SearchKnowledgeResponse", "SuggestConversationSummaryRequest", "SuggestConversationSummaryResponse", "ConversationDataset", @@ -579,10 +588,12 @@ "AssistQueryParameters", "AutomatedAgentReply", "CreateParticipantRequest", + "DialogflowAssistAnswer", "DtmfParameters", "FaqAnswer", "GetParticipantRequest", "InputTextConfig", + "IntentSuggestion", "ListParticipantsRequest", "ListParticipantsResponse", "Message", @@ -596,6 +607,7 @@ "SuggestArticlesResponse", "SuggestFaqAnswersRequest", "SuggestFaqAnswersResponse", + "SuggestionInput", "SuggestionResult", "SuggestSmartRepliesRequest", "SuggestSmartRepliesResponse", diff --git a/google/cloud/dialogflow/gapic_version.py b/google/cloud/dialogflow/gapic_version.py index 26ba4efa..07de09d5 100644 --- a/google/cloud/dialogflow/gapic_version.py +++ b/google/cloud/dialogflow/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.23.3" # {x-release-please-version} +__version__ = "2.24.0" # {x-release-please-version} diff --git a/google/cloud/dialogflow_v2/__init__.py b/google/cloud/dialogflow_v2/__init__.py index 7e0f5044..740b5e41 100644 --- a/google/cloud/dialogflow_v2/__init__.py +++ b/google/cloud/dialogflow_v2/__init__.py @@ -107,6 +107,9 @@ ListConversationsResponse, ListMessagesRequest, ListMessagesResponse, + SearchKnowledgeAnswer, + SearchKnowledgeRequest, + SearchKnowledgeResponse, SuggestConversationSummaryRequest, SuggestConversationSummaryResponse, ) @@ -252,10 +255,12 @@ AssistQueryParameters, AutomatedAgentReply, CreateParticipantRequest, + DialogflowAssistAnswer, DtmfParameters, FaqAnswer, GetParticipantRequest, InputTextConfig, + IntentSuggestion, ListParticipantsRequest, ListParticipantsResponse, Message, @@ -269,6 +274,7 @@ SuggestArticlesResponse, SuggestFaqAnswersRequest, SuggestFaqAnswersResponse, + SuggestionInput, SuggestionResult, SuggestSmartRepliesRequest, SuggestSmartRepliesResponse, @@ -408,6 +414,7 @@ "DeployConversationModelRequest", "DetectIntentRequest", "DetectIntentResponse", + "DialogflowAssistAnswer", "Document", "DocumentsClient", "DtmfParameters", @@ -464,6 +471,7 @@ "InputTextConfig", "Intent", "IntentBatch", + "IntentSuggestion", "IntentView", "IntentsClient", "KnowledgeBase", @@ -518,6 +526,9 @@ "RestoreAgentRequest", "SearchAgentsRequest", "SearchAgentsResponse", + "SearchKnowledgeAnswer", + "SearchKnowledgeRequest", + "SearchKnowledgeResponse", "Sentiment", "SentimentAnalysisRequestConfig", "SentimentAnalysisResult", @@ -549,6 +560,7 @@ "SuggestSmartRepliesRequest", "SuggestSmartRepliesResponse", "SuggestionFeature", + "SuggestionInput", "SuggestionResult", "SynthesizeSpeechConfig", "TelephonyDtmf", diff --git a/google/cloud/dialogflow_v2/gapic_metadata.json b/google/cloud/dialogflow_v2/gapic_metadata.json index 7df043d2..7faa9bfb 100644 --- a/google/cloud/dialogflow_v2/gapic_metadata.json +++ b/google/cloud/dialogflow_v2/gapic_metadata.json @@ -724,6 +724,11 @@ "list_messages" ] }, + "SearchKnowledge": { + "methods": [ + "search_knowledge" + ] + }, "SuggestConversationSummary": { "methods": [ "suggest_conversation_summary" @@ -764,6 +769,11 @@ "list_messages" ] }, + "SearchKnowledge": { + "methods": [ + "search_knowledge" + ] + }, "SuggestConversationSummary": { "methods": [ "suggest_conversation_summary" @@ -804,6 +814,11 @@ "list_messages" ] }, + "SearchKnowledge": { + "methods": [ + "search_knowledge" + ] + }, "SuggestConversationSummary": { "methods": [ "suggest_conversation_summary" diff --git a/google/cloud/dialogflow_v2/gapic_version.py b/google/cloud/dialogflow_v2/gapic_version.py index 26ba4efa..07de09d5 100644 --- a/google/cloud/dialogflow_v2/gapic_version.py +++ b/google/cloud/dialogflow_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.23.3" # {x-release-please-version} +__version__ = "2.24.0" # {x-release-please-version} diff --git a/google/cloud/dialogflow_v2/services/agents/async_client.py b/google/cloud/dialogflow_v2/services/agents/async_client.py index 224b1e75..ca077d9d 100644 --- a/google/cloud/dialogflow_v2/services/agents/async_client.py +++ b/google/cloud/dialogflow_v2/services/agents/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/agents/client.py b/google/cloud/dialogflow_v2/services/agents/client.py index 8194406c..bdab0f9e 100644 --- a/google/cloud/dialogflow_v2/services/agents/client.py +++ b/google/cloud/dialogflow_v2/services/agents/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/agents/transports/rest.py b/google/cloud/dialogflow_v2/services/agents/transports/rest.py index a5623467..b9727361 100644 --- a/google/cloud/dialogflow_v2/services/agents/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/agents/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2/services/answer_records/async_client.py b/google/cloud/dialogflow_v2/services/answer_records/async_client.py index 88e4b0b2..0dcd5936 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/async_client.py +++ b/google/cloud/dialogflow_v2/services/answer_records/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.answer_records import pagers @@ -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 ) diff --git a/google/cloud/dialogflow_v2/services/answer_records/client.py b/google/cloud/dialogflow_v2/services/answer_records/client.py index cd4356e0..8adeab5d 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/client.py +++ b/google/cloud/dialogflow_v2/services/answer_records/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.answer_records import pagers @@ -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.+?)/agent/sessions/(?P.+?)/contexts/(?P.+?)$", + 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.+?)/agent/intents/(?P.+?)$", path) + return m.groupdict() if m else {} + @staticmethod def common_billing_account_path( billing_account: str, diff --git a/google/cloud/dialogflow_v2/services/answer_records/transports/base.py b/google/cloud/dialogflow_v2/services/answer_records/transports/base.py index ca13d20c..567375ca 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/base.py +++ b/google/cloud/dialogflow_v2/services/answer_records/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py index 0c31f444..8bce13e2 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2.types import answer_record diff --git a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py index 12861338..c856bb7b 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2/services/answer_records/transports/rest.py b/google/cloud/dialogflow_v2/services/answer_records/transports/rest.py index 63a52041..31835b3b 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/answer_records/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2.types import answer_record from google.cloud.dialogflow_v2.types import answer_record as gcd_answer_record diff --git a/google/cloud/dialogflow_v2/services/contexts/async_client.py b/google/cloud/dialogflow_v2/services/contexts/async_client.py index 1aac92f9..93e47de4 100644 --- a/google/cloud/dialogflow_v2/services/contexts/async_client.py +++ b/google/cloud/dialogflow_v2/services/contexts/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -467,6 +467,7 @@ async def create_context( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_context.Context: r"""Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2/services/contexts/client.py b/google/cloud/dialogflow_v2/services/contexts/client.py index a7ae54e7..9bf96391 100644 --- a/google/cloud/dialogflow_v2/services/contexts/client.py +++ b/google/cloud/dialogflow_v2/services/contexts/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -702,6 +702,7 @@ def create_context( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_context.Context: r"""Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2/services/contexts/transports/base.py b/google/cloud/dialogflow_v2/services/contexts/transports/base.py index 22802925..eb271db4 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/base.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py b/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py index 04a1bef6..0eafc427 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -290,6 +290,7 @@ def create_context( r"""Return a callable for the create context method over gRPC. Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py index e30aa6d2..66076a7b 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -297,6 +297,7 @@ def create_context( r"""Return a callable for the create context method over gRPC. Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2/services/contexts/transports/rest.py b/google/cloud/dialogflow_v2/services/contexts/transports/rest.py index 994cee6d..67cc53c7 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2.types import context diff --git a/google/cloud/dialogflow_v2/services/conversation_datasets/async_client.py b/google/cloud/dialogflow_v2/services/conversation_datasets/async_client.py index 29dbd203..0c81b77e 100644 --- a/google/cloud/dialogflow_v2/services/conversation_datasets/async_client.py +++ b/google/cloud/dialogflow_v2/services/conversation_datasets/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -62,6 +62,7 @@ class ConversationDatasetsAsyncClient: """Conversation datasets. + Conversation datasets contain raw conversation files and their customizable metadata that can be used for model training. """ diff --git a/google/cloud/dialogflow_v2/services/conversation_datasets/client.py b/google/cloud/dialogflow_v2/services/conversation_datasets/client.py index 07ba6d2c..b2ff04e8 100644 --- a/google/cloud/dialogflow_v2/services/conversation_datasets/client.py +++ b/google/cloud/dialogflow_v2/services/conversation_datasets/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -104,6 +104,7 @@ def get_transport_class( class ConversationDatasetsClient(metaclass=ConversationDatasetsClientMeta): """Conversation datasets. + Conversation datasets contain raw conversation files and their customizable metadata that can be used for model training. """ diff --git a/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc.py b/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc.py index fe26c320..176c0c79 100644 --- a/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc.py @@ -36,6 +36,7 @@ class ConversationDatasetsGrpcTransport(ConversationDatasetsTransport): """gRPC backend transport for ConversationDatasets. Conversation datasets. + Conversation datasets contain raw conversation files and their customizable metadata that can be used for model training. diff --git a/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc_asyncio.py index 81112739..6999104a 100644 --- a/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc_asyncio.py @@ -37,6 +37,7 @@ class ConversationDatasetsGrpcAsyncIOTransport(ConversationDatasetsTransport): """gRPC AsyncIO backend transport for ConversationDatasets. Conversation datasets. + Conversation datasets contain raw conversation files and their customizable metadata that can be used for model training. diff --git a/google/cloud/dialogflow_v2/services/conversation_datasets/transports/rest.py b/google/cloud/dialogflow_v2/services/conversation_datasets/transports/rest.py index b2f4acb1..c3207b7f 100644 --- a/google/cloud/dialogflow_v2/services/conversation_datasets/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/conversation_datasets/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -373,6 +372,7 @@ class ConversationDatasetsRestTransport(ConversationDatasetsTransport): """REST backend transport for ConversationDatasets. Conversation datasets. + Conversation datasets contain raw conversation files and their customizable metadata that can be used for model training. diff --git a/google/cloud/dialogflow_v2/services/conversation_models/async_client.py b/google/cloud/dialogflow_v2/services/conversation_models/async_client.py index ebf441f4..6296f282 100644 --- a/google/cloud/dialogflow_v2/services/conversation_models/async_client.py +++ b/google/cloud/dialogflow_v2/services/conversation_models/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/conversation_models/client.py b/google/cloud/dialogflow_v2/services/conversation_models/client.py index 95886670..7fbdffb4 100644 --- a/google/cloud/dialogflow_v2/services/conversation_models/client.py +++ b/google/cloud/dialogflow_v2/services/conversation_models/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/conversation_models/transports/rest.py b/google/cloud/dialogflow_v2/services/conversation_models/transports/rest.py index 88f6bac4..3fe16d1a 100644 --- a/google/cloud/dialogflow_v2/services/conversation_models/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/conversation_models/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py b/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py index f0b891d8..e2d32117 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -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 diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/client.py b/google/cloud/dialogflow_v2/services/conversation_profiles/client.py index d1b04fa3..dd07bd0e 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/client.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -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 diff --git a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/rest.py b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/rest.py index a3c69c4f..e8576cc5 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2/services/conversations/async_client.py b/google/cloud/dialogflow_v2/services/conversations/async_client.py index b2e30127..505c6010 100644 --- a/google/cloud/dialogflow_v2/services/conversations/async_client.py +++ b/google/cloud/dialogflow_v2/services/conversations/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2.services.conversations import pagers @@ -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, diff --git a/google/cloud/dialogflow_v2/services/conversations/client.py b/google/cloud/dialogflow_v2/services/conversations/client.py index bf940389..9129a02a 100644 --- a/google/cloud/dialogflow_v2/services/conversations/client.py +++ b/google/cloud/dialogflow_v2/services/conversations/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2.services.conversations import pagers @@ -1417,6 +1417,93 @@ 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_v2 + + def sample_search_knowledge(): + # Create a client + client = dialogflow_v2.ConversationsClient() + + # 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 = client.search_knowledge(request=request) + + # Handle the response + print(response) + + Args: + request (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. + # 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 diff --git a/google/cloud/dialogflow_v2/services/conversations/transports/base.py b/google/cloud/dialogflow_v2/services/conversations/transports/base.py index c31f33a5..d56dfa38 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/base.py +++ b/google/cloud/dialogflow_v2/services/conversations/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2 import gapic_version as package_version @@ -163,6 +163,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): @@ -249,6 +254,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, diff --git a/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py b/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py index 090f6002..55e3d76b 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2.types import conversation @@ -458,6 +458,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.v2.Conversations/SearchKnowledge", + request_serializer=conversation.SearchKnowledgeRequest.serialize, + response_deserializer=conversation.SearchKnowledgeResponse.deserialize, + ) + return self._stubs["search_knowledge"] + def close(self): self.grpc_channel.close() diff --git a/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py index ee1bc6a2..a6be82fd 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -465,6 +465,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.v2.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() diff --git a/google/cloud/dialogflow_v2/services/conversations/transports/rest.py b/google/cloud/dialogflow_v2/services/conversations/transports/rest.py index ebaf354b..1c8b96e3 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/conversations/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2.types import conversation from google.cloud.dialogflow_v2.types import conversation as gcd_conversation @@ -114,6 +115,14 @@ def post_list_messages(self, response): logging.log(f"Received response: {response}") return response + def pre_search_knowledge(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_search_knowledge(self, response): + logging.log(f"Received response: {response}") + return response + def pre_suggest_conversation_summary(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -266,6 +275,29 @@ def post_list_messages( """ return response + def pre_search_knowledge( + self, + request: conversation.SearchKnowledgeRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[conversation.SearchKnowledgeRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for search_knowledge + + Override in a subclass to manipulate the request or metadata + before they are sent to the Conversations server. + """ + return request, metadata + + def post_search_knowledge( + self, response: conversation.SearchKnowledgeResponse + ) -> conversation.SearchKnowledgeResponse: + """Post-rpc interceptor for search_knowledge + + Override in a subclass to manipulate the response + after it is returned by the Conversations server but before + it is returned to user code. + """ + return response + def pre_suggest_conversation_summary( self, request: gcd_conversation.SuggestConversationSummaryRequest, @@ -1116,6 +1148,121 @@ def __call__( resp = self._interceptor.post_list_messages(resp) return resp + class _SearchKnowledge(ConversationsRestStub): + def __hash__(self): + return hash("SearchKnowledge") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: conversation.SearchKnowledgeRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> conversation.SearchKnowledgeResponse: + r"""Call the search knowledge method over HTTP. + + Args: + request (~.conversation.SearchKnowledgeRequest): + 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: + ~.conversation.SearchKnowledgeResponse: + The response message for + [Conversations.SearchKnowledge][google.cloud.dialogflow.v2.Conversations.SearchKnowledge]. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v2/{parent=projects/*}/suggestions:searchKnowledge", + "body": "*", + }, + { + "method": "post", + "uri": "/v2/{parent=projects/*/locations/*}/suggestions:searchKnowledge", + "body": "*", + }, + { + "method": "post", + "uri": "/v2/{conversation=projects/*/conversations/*}/suggestions:searchKnowledge", + "body": "*", + }, + { + "method": "post", + "uri": "/v2/{conversation=projects/*/locations/*/conversations/*}/suggestions:searchKnowledge", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_search_knowledge( + request, metadata + ) + pb_request = conversation.SearchKnowledgeRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = conversation.SearchKnowledgeResponse() + pb_resp = conversation.SearchKnowledgeResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_knowledge(resp) + return resp + class _SuggestConversationSummary(ConversationsRestStub): def __hash__(self): return hash("SuggestConversationSummary") @@ -1281,6 +1428,16 @@ def list_messages( # In C++ this would require a dynamic_cast return self._ListMessages(self._session, self._host, self._interceptor) # type: ignore + @property + def search_knowledge( + self, + ) -> Callable[ + [conversation.SearchKnowledgeRequest], conversation.SearchKnowledgeResponse + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._SearchKnowledge(self._session, self._host, self._interceptor) # type: ignore + @property def suggest_conversation_summary( self, diff --git a/google/cloud/dialogflow_v2/services/documents/async_client.py b/google/cloud/dialogflow_v2/services/documents/async_client.py index 0a90c07c..eacf9125 100644 --- a/google/cloud/dialogflow_v2/services/documents/async_client.py +++ b/google/cloud/dialogflow_v2/services/documents/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/documents/client.py b/google/cloud/dialogflow_v2/services/documents/client.py index e0db97a4..032dc42a 100644 --- a/google/cloud/dialogflow_v2/services/documents/client.py +++ b/google/cloud/dialogflow_v2/services/documents/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/documents/transports/rest.py b/google/cloud/dialogflow_v2/services/documents/transports/rest.py index 4a7ed956..1c34b9ee 100644 --- a/google/cloud/dialogflow_v2/services/documents/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/documents/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2/services/entity_types/async_client.py b/google/cloud/dialogflow_v2/services/entity_types/async_client.py index 70767d8a..40905bc3 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/async_client.py +++ b/google/cloud/dialogflow_v2/services/entity_types/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/entity_types/client.py b/google/cloud/dialogflow_v2/services/entity_types/client.py index d5078836..95cdd9bd 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/client.py +++ b/google/cloud/dialogflow_v2/services/entity_types/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/entity_types/transports/rest.py b/google/cloud/dialogflow_v2/services/entity_types/transports/rest.py index a750dccc..5be9c82e 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/entity_types/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2/services/environments/async_client.py b/google/cloud/dialogflow_v2/services/environments/async_client.py index a7785158..e12192c1 100644 --- a/google/cloud/dialogflow_v2/services/environments/async_client.py +++ b/google/cloud/dialogflow_v2/services/environments/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2.services.environments import pagers diff --git a/google/cloud/dialogflow_v2/services/environments/client.py b/google/cloud/dialogflow_v2/services/environments/client.py index c956d0bd..839546cc 100644 --- a/google/cloud/dialogflow_v2/services/environments/client.py +++ b/google/cloud/dialogflow_v2/services/environments/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2.services.environments import pagers diff --git a/google/cloud/dialogflow_v2/services/environments/transports/base.py b/google/cloud/dialogflow_v2/services/environments/transports/base.py index 1c324c03..a7b6c46b 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/base.py +++ b/google/cloud/dialogflow_v2/services/environments/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/environments/transports/grpc.py b/google/cloud/dialogflow_v2/services/environments/transports/grpc.py index 7917fd31..867439da 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/environments/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore diff --git a/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py index 153ed836..12544a4e 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2/services/environments/transports/rest.py b/google/cloud/dialogflow_v2/services/environments/transports/rest.py index c779491a..a0cb2653 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/environments/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2.types import environment diff --git a/google/cloud/dialogflow_v2/services/fulfillments/async_client.py b/google/cloud/dialogflow_v2/services/fulfillments/async_client.py index 78d8e0b2..8c139e51 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/async_client.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.types import fulfillment diff --git a/google/cloud/dialogflow_v2/services/fulfillments/client.py b/google/cloud/dialogflow_v2/services/fulfillments/client.py index c22e2c0c..1fdfe824 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/client.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.types import fulfillment diff --git a/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py index df9f8ca0..782a4941 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py index e9e621f2..0fa0b191 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2.types import fulfillment diff --git a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py index 830dcee7..d529b171 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2/services/fulfillments/transports/rest.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/rest.py index 85438b03..e15cfe8a 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2.types import fulfillment from google.cloud.dialogflow_v2.types import fulfillment as gcd_fulfillment diff --git a/google/cloud/dialogflow_v2/services/intents/async_client.py b/google/cloud/dialogflow_v2/services/intents/async_client.py index c8b31022..c9b57f88 100644 --- a/google/cloud/dialogflow_v2/services/intents/async_client.py +++ b/google/cloud/dialogflow_v2/services/intents/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/intents/client.py b/google/cloud/dialogflow_v2/services/intents/client.py index 794d662f..907719f2 100644 --- a/google/cloud/dialogflow_v2/services/intents/client.py +++ b/google/cloud/dialogflow_v2/services/intents/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/intents/transports/rest.py b/google/cloud/dialogflow_v2/services/intents/transports/rest.py index 9d7f7b5f..8ace19f8 100644 --- a/google/cloud/dialogflow_v2/services/intents/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/intents/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py b/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py index fffe44d6..0dc93ae3 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.knowledge_bases import pagers diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/client.py b/google/cloud/dialogflow_v2/services/knowledge_bases/client.py index 60686b90..93f68010 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/client.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.knowledge_bases import pagers diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py index ae391ffe..ddd6eb0e 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py index 5acb77ce..f451bfea 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py index 60451278..e62ec2e9 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/rest.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/rest.py index 7e3042eb..870b60d0 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2.types import knowledge_base as gcd_knowledge_base diff --git a/google/cloud/dialogflow_v2/services/participants/async_client.py b/google/cloud/dialogflow_v2/services/participants/async_client.py index 9165fb90..c3411940 100644 --- a/google/cloud/dialogflow_v2/services/participants/async_client.py +++ b/google/cloud/dialogflow_v2/services/participants/async_client.py @@ -46,7 +46,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.participants import pagers diff --git a/google/cloud/dialogflow_v2/services/participants/client.py b/google/cloud/dialogflow_v2/services/participants/client.py index 306b9096..3f0a2c3d 100644 --- a/google/cloud/dialogflow_v2/services/participants/client.py +++ b/google/cloud/dialogflow_v2/services/participants/client.py @@ -49,7 +49,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.participants import pagers diff --git a/google/cloud/dialogflow_v2/services/participants/transports/base.py b/google/cloud/dialogflow_v2/services/participants/transports/base.py index 8d782785..a6b89d35 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/base.py +++ b/google/cloud/dialogflow_v2/services/participants/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2/services/participants/transports/grpc.py b/google/cloud/dialogflow_v2/services/participants/transports/grpc.py index 131e7a81..fa0cc34d 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/participants/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2.types import participant diff --git a/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py index 0fe4b28f..db4b3f19 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2/services/participants/transports/rest.py b/google/cloud/dialogflow_v2/services/participants/transports/rest.py index e4fe02ec..8fa8f493 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/participants/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2.types import participant from google.cloud.dialogflow_v2.types import participant as gcd_participant diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py b/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py index e33275fd..2c4c031f 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.session_entity_types import pagers @@ -367,6 +367,7 @@ async def get_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -488,6 +489,7 @@ async def create_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -628,6 +630,7 @@ async def update_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -760,6 +763,7 @@ async def delete_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/client.py b/google/cloud/dialogflow_v2/services/session_entity_types/client.py index 1fd4dd62..4ebe16f7 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/client.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2.services.session_entity_types import pagers @@ -593,6 +593,7 @@ def get_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -714,6 +715,7 @@ def create_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -858,6 +860,7 @@ def update_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -994,6 +997,7 @@ def delete_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py index 8e8bbb5e..e760b0a2 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py index 176efae5..f1135db5 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -278,6 +278,7 @@ def get_session_entity_type( r"""Return a callable for the get session entity type method over gRPC. Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -310,6 +311,7 @@ def create_session_entity_type( r"""Return a callable for the create session entity type method over gRPC. Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -345,6 +347,7 @@ def update_session_entity_type( r"""Return a callable for the update session entity type method over gRPC. Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -376,6 +379,7 @@ def delete_session_entity_type( r"""Return a callable for the delete session entity type method over gRPC. Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py index b3a21f47..1721f543 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -281,6 +281,7 @@ def get_session_entity_type( r"""Return a callable for the get session entity type method over gRPC. Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -313,6 +314,7 @@ def create_session_entity_type( r"""Return a callable for the create session entity type method over gRPC. Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -348,6 +350,7 @@ def update_session_entity_type( r"""Return a callable for the update session entity type method over gRPC. Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -379,6 +382,7 @@ def delete_session_entity_type( r"""Return a callable for the delete session entity type method over gRPC. Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2/services/session_entity_types/transports/rest.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/rest.py index 5919ba7e..a05529a9 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2.types import ( diff --git a/google/cloud/dialogflow_v2/services/sessions/async_client.py b/google/cloud/dialogflow_v2/services/sessions/async_client.py index 527dcd91..e2f64351 100644 --- a/google/cloud/dialogflow_v2/services/sessions/async_client.py +++ b/google/cloud/dialogflow_v2/services/sessions/async_client.py @@ -46,7 +46,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.cloud.dialogflow_v2.types import audio_config @@ -318,13 +318,14 @@ async def sample_detect_intent(): can be set to: 1. an audio config which instructs the - speech recognizer how to process the - speech audio, + speech recognizer how to process the + speech audio, 2. a conversational query in the form of - text, or + text, or + 3. an event that specifies which intent - to trigger. + to trigger. This corresponds to the ``query_input`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/dialogflow_v2/services/sessions/client.py b/google/cloud/dialogflow_v2/services/sessions/client.py index 18172f16..e41e30dc 100644 --- a/google/cloud/dialogflow_v2/services/sessions/client.py +++ b/google/cloud/dialogflow_v2/services/sessions/client.py @@ -49,7 +49,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.cloud.dialogflow_v2.types import audio_config @@ -602,13 +602,14 @@ def sample_detect_intent(): can be set to: 1. an audio config which instructs the - speech recognizer how to process the - speech audio, + speech recognizer how to process the + speech audio, 2. a conversational query in the form of - text, or + text, or + 3. an event that specifies which intent - to trigger. + to trigger. This corresponds to the ``query_input`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/dialogflow_v2/services/sessions/transports/base.py b/google/cloud/dialogflow_v2/services/sessions/transports/base.py index e9079bb6..c6e2886a 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/base.py +++ b/google/cloud/dialogflow_v2/services/sessions/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py b/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py index 12237ea4..e4ef6e01 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2.types import session diff --git a/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py index 08c54d95..fff30c83 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2/services/sessions/transports/rest.py b/google/cloud/dialogflow_v2/services/sessions/transports/rest.py index cd7a8811..ee128d60 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/sessions/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2.types import session from google.cloud.dialogflow_v2.types import session as gcd_session diff --git a/google/cloud/dialogflow_v2/services/versions/async_client.py b/google/cloud/dialogflow_v2/services/versions/async_client.py index a4d62281..807ab4d0 100644 --- a/google/cloud/dialogflow_v2/services/versions/async_client.py +++ b/google/cloud/dialogflow_v2/services/versions/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -465,6 +465,7 @@ async def create_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -599,6 +600,7 @@ async def update_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2/services/versions/client.py b/google/cloud/dialogflow_v2/services/versions/client.py index ec080223..205f90a3 100644 --- a/google/cloud/dialogflow_v2/services/versions/client.py +++ b/google/cloud/dialogflow_v2/services/versions/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -697,6 +697,7 @@ def create_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -831,6 +832,7 @@ def update_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2/services/versions/transports/base.py b/google/cloud/dialogflow_v2/services/versions/transports/base.py index d844d760..8bd950bd 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/base.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2/services/versions/transports/grpc.py b/google/cloud/dialogflow_v2/services/versions/transports/grpc.py index 7e6f2ef5..b246e4b7 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/grpc.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -290,6 +290,7 @@ def create_version( r"""Return a callable for the create version method over gRPC. Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -318,6 +319,7 @@ def update_version( r"""Return a callable for the update version method over gRPC. Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py index 6fb252b7..e61f7a33 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -297,6 +297,7 @@ def create_version( r"""Return a callable for the create version method over gRPC. Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -325,6 +326,7 @@ def update_version( r"""Return a callable for the update version method over gRPC. Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2/services/versions/transports/rest.py b/google/cloud/dialogflow_v2/services/versions/transports/rest.py index 0f2ba90b..9de5b4f8 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/rest.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2.types import version diff --git a/google/cloud/dialogflow_v2/types/__init__.py b/google/cloud/dialogflow_v2/types/__init__.py index 04636925..7256f274 100644 --- a/google/cloud/dialogflow_v2/types/__init__.py +++ b/google/cloud/dialogflow_v2/types/__init__.py @@ -73,6 +73,9 @@ ListConversationsResponse, ListMessagesRequest, ListMessagesResponse, + SearchKnowledgeAnswer, + SearchKnowledgeRequest, + SearchKnowledgeResponse, SuggestConversationSummaryRequest, SuggestConversationSummaryResponse, ) @@ -214,10 +217,12 @@ AssistQueryParameters, AutomatedAgentReply, CreateParticipantRequest, + DialogflowAssistAnswer, DtmfParameters, FaqAnswer, GetParticipantRequest, InputTextConfig, + IntentSuggestion, ListParticipantsRequest, ListParticipantsResponse, Message, @@ -231,6 +236,7 @@ SuggestArticlesResponse, SuggestFaqAnswersRequest, SuggestFaqAnswersResponse, + SuggestionInput, SuggestionResult, SuggestSmartRepliesRequest, SuggestSmartRepliesResponse, @@ -325,6 +331,9 @@ "ListConversationsResponse", "ListMessagesRequest", "ListMessagesResponse", + "SearchKnowledgeAnswer", + "SearchKnowledgeRequest", + "SearchKnowledgeResponse", "SuggestConversationSummaryRequest", "SuggestConversationSummaryResponse", "ConversationDataset", @@ -451,10 +460,12 @@ "AssistQueryParameters", "AutomatedAgentReply", "CreateParticipantRequest", + "DialogflowAssistAnswer", "DtmfParameters", "FaqAnswer", "GetParticipantRequest", "InputTextConfig", + "IntentSuggestion", "ListParticipantsRequest", "ListParticipantsResponse", "Message", @@ -468,6 +479,7 @@ "SuggestArticlesResponse", "SuggestFaqAnswersRequest", "SuggestFaqAnswersResponse", + "SuggestionInput", "SuggestionResult", "SuggestSmartRepliesRequest", "SuggestSmartRepliesResponse", diff --git a/google/cloud/dialogflow_v2/types/answer_record.py b/google/cloud/dialogflow_v2/types/answer_record.py index 2c9fa334..240661db 100644 --- a/google/cloud/dialogflow_v2/types/answer_record.py +++ b/google/cloud/dialogflow_v2/types/answer_record.py @@ -321,6 +321,8 @@ class AgentAssistantFeedback(proto.Message): summarization_feedback (google.cloud.dialogflow_v2.types.AgentAssistantFeedback.SummarizationFeedback): Optional. Feedback for conversation summarization. + knowledge_search_feedback (google.cloud.dialogflow_v2.types.AgentAssistantFeedback.KnowledgeSearchFeedback): + Optional. Feedback for knowledge search. """ class AnswerRelevance(proto.Enum): @@ -396,6 +398,33 @@ class SummarizationFeedback(proto.Message): number=3, ) + class KnowledgeSearchFeedback(proto.Message): + r"""Feedback for knowledge search. + + Attributes: + answer_copied (bool): + Whether the answer was copied by the human agent or not. If + the value is set to be true, + [AnswerFeedback.clicked][google.cloud.dialogflow.v2.AnswerFeedback.clicked] + will be updated to be true. + clicked_uris (MutableSequence[str]): + The URIs clicked by the human agent. The value is appended + for each + [UpdateAnswerRecordRequest][google.cloud.dialogflow.v2.UpdateAnswerRecordRequest]. + If the value is not empty, + [AnswerFeedback.clicked][google.cloud.dialogflow.v2.AnswerFeedback.clicked] + will be updated to be true. + """ + + answer_copied: bool = proto.Field( + proto.BOOL, + number=1, + ) + clicked_uris: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=2, + ) + answer_relevance: AnswerRelevance = proto.Field( proto.ENUM, number=1, @@ -416,6 +445,11 @@ class SummarizationFeedback(proto.Message): number=4, message=SummarizationFeedback, ) + knowledge_search_feedback: KnowledgeSearchFeedback = proto.Field( + proto.MESSAGE, + number=5, + message=KnowledgeSearchFeedback, + ) class AgentAssistantRecord(proto.Message): @@ -436,6 +470,10 @@ class AgentAssistantRecord(proto.Message): faq_answer (google.cloud.dialogflow_v2.types.FaqAnswer): Output only. The FAQ answer. + This field is a member of `oneof`_ ``answer``. + dialogflow_assist_answer (google.cloud.dialogflow_v2.types.DialogflowAssistAnswer): + Output only. Dialogflow assist answer. + This field is a member of `oneof`_ ``answer``. """ @@ -451,6 +489,12 @@ class AgentAssistantRecord(proto.Message): oneof="answer", message=participant.FaqAnswer, ) + dialogflow_assist_answer: participant.DialogflowAssistAnswer = proto.Field( + proto.MESSAGE, + number=7, + oneof="answer", + message=participant.DialogflowAssistAnswer, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dialogflow_v2/types/audio_config.py b/google/cloud/dialogflow_v2/types/audio_config.py index 6bac4cb3..511d833c 100644 --- a/google/cloud/dialogflow_v2/types/audio_config.py +++ b/google/cloud/dialogflow_v2/types/audio_config.py @@ -669,6 +669,10 @@ class SpeechToTextConfig(proto.Message): `Cloud Speech API documentation `__ for more details. + use_timeout_based_endpointing (bool): + Use timeout based endpointing, interpreting + endpointer sensitivy as seconds of timeout + value. """ speech_model_variant: "SpeechModelVariant" = proto.Field( @@ -680,6 +684,10 @@ class SpeechToTextConfig(proto.Message): proto.STRING, number=2, ) + use_timeout_based_endpointing: bool = proto.Field( + proto.BOOL, + number=11, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dialogflow_v2/types/conversation.py b/google/cloud/dialogflow_v2/types/conversation.py index 14d56c36..246e7816 100644 --- a/google/cloud/dialogflow_v2/types/conversation.py +++ b/google/cloud/dialogflow_v2/types/conversation.py @@ -23,7 +23,7 @@ from google.cloud.dialogflow_v2.types import ( conversation_profile as gcd_conversation_profile, ) -from google.cloud.dialogflow_v2.types import participant +from google.cloud.dialogflow_v2.types import participant, session __protobuf__ = proto.module( package="google.cloud.dialogflow.v2", @@ -41,6 +41,9 @@ "SuggestConversationSummaryResponse", "GenerateStatelessSummaryRequest", "GenerateStatelessSummaryResponse", + "SearchKnowledgeRequest", + "SearchKnowledgeResponse", + "SearchKnowledgeAnswer", }, ) @@ -500,6 +503,10 @@ class Summary(proto.Message): "projects//answerRecords/". + baseline_model_version (str): + The baseline model version used to generate + this summary. It is empty if a baseline model + was not used to generate this summary. """ text: str = proto.Field( @@ -515,6 +522,10 @@ class Summary(proto.Message): proto.STRING, number=3, ) + baseline_model_version: str = proto.Field( + proto.STRING, + number=5, + ) summary: Summary = proto.Field( proto.MESSAGE, @@ -637,6 +648,10 @@ class Summary(proto.Message): sections. The key is the section's name and the value is the section's content. There is no specific format for the key or value. + baseline_model_version (str): + The baseline model version used to generate + this summary. It is empty if a baseline model + was not used to generate this summary. """ text: str = proto.Field( @@ -648,6 +663,10 @@ class Summary(proto.Message): proto.STRING, number=2, ) + baseline_model_version: str = proto.Field( + proto.STRING, + number=4, + ) summary: Summary = proto.Field( proto.MESSAGE, @@ -664,4 +683,160 @@ class Summary(proto.Message): ) +class SearchKnowledgeRequest(proto.Message): + r"""The request message for + [Conversations.SearchKnowledge][google.cloud.dialogflow.v2.Conversations.SearchKnowledge]. + + Attributes: + parent (str): + The parent resource contains the conversation profile + Format: 'projects/' or + ``projects//locations/``. + query (google.cloud.dialogflow_v2.types.TextInput): + Required. The natural language text query for + knowledge search. + conversation_profile (str): + Required. The conversation profile used to configure the + search. Format: + ``projects//locations//conversationProfiles/``. + session_id (str): + The ID of the search session. The session_id can be combined + with Dialogflow V3 Agent ID retrieved from conversation + profile or on its own to identify a search session. The + search history of the same session will impact the search + result. It's up to the API caller to choose an appropriate + ``Session ID``. It can be a random number or some type of + session identifiers (preferably hashed). The length must not + exceed 36 characters. + conversation (str): + The conversation (between human agent and end user) where + the search request is triggered. Format: + ``projects//locations//conversations/``. + latest_message (str): + The name of the latest conversation message when the request + is triggered. Format: + ``projects//locations//conversations//messages/``. + """ + + parent: str = proto.Field( + proto.STRING, + number=6, + ) + query: session.TextInput = proto.Field( + proto.MESSAGE, + number=1, + message=session.TextInput, + ) + conversation_profile: str = proto.Field( + proto.STRING, + number=2, + ) + session_id: str = proto.Field( + proto.STRING, + number=3, + ) + conversation: str = proto.Field( + proto.STRING, + number=4, + ) + latest_message: str = proto.Field( + proto.STRING, + number=5, + ) + + +class SearchKnowledgeResponse(proto.Message): + r"""The response message for + [Conversations.SearchKnowledge][google.cloud.dialogflow.v2.Conversations.SearchKnowledge]. + + Attributes: + answers (MutableSequence[google.cloud.dialogflow_v2.types.SearchKnowledgeAnswer]): + Most relevant snippets extracted from + articles in the given knowledge base, ordered by + confidence. + """ + + answers: MutableSequence["SearchKnowledgeAnswer"] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="SearchKnowledgeAnswer", + ) + + +class SearchKnowledgeAnswer(proto.Message): + r"""Represents a SearchKnowledge answer. + + Attributes: + answer (str): + The piece of text from the knowledge base + documents that answers the search query + answer_type (google.cloud.dialogflow_v2.types.SearchKnowledgeAnswer.AnswerType): + The type of the answer. + answer_sources (MutableSequence[google.cloud.dialogflow_v2.types.SearchKnowledgeAnswer.AnswerSource]): + All sources used to generate the answer. + answer_record (str): + The name of the answer record. Format: + ``projects//locations//answer Records/`` + """ + + class AnswerType(proto.Enum): + r"""The type of the answer. + + Values: + ANSWER_TYPE_UNSPECIFIED (0): + The answer has a unspecified type. + FAQ (1): + The answer is from FAQ doucments. + GENERATIVE (2): + The answer is from generative model. + """ + ANSWER_TYPE_UNSPECIFIED = 0 + FAQ = 1 + GENERATIVE = 2 + + class AnswerSource(proto.Message): + r"""The sources of the answers. + + Attributes: + title (str): + The title of the article. + uri (str): + The URI of the article. + snippet (str): + The relevant snippet of the article. + """ + + title: str = proto.Field( + proto.STRING, + number=1, + ) + uri: str = proto.Field( + proto.STRING, + number=2, + ) + snippet: str = proto.Field( + proto.STRING, + number=3, + ) + + answer: str = proto.Field( + proto.STRING, + number=1, + ) + answer_type: AnswerType = proto.Field( + proto.ENUM, + number=2, + enum=AnswerType, + ) + answer_sources: MutableSequence[AnswerSource] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=AnswerSource, + ) + answer_record: str = proto.Field( + proto.STRING, + number=5, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dialogflow_v2/types/conversation_profile.py b/google/cloud/dialogflow_v2/types/conversation_profile.py index ace08026..0116df54 100644 --- a/google/cloud/dialogflow_v2/types/conversation_profile.py +++ b/google/cloud/dialogflow_v2/types/conversation_profile.py @@ -73,6 +73,7 @@ class ConversationProfile(proto.Message): with this profile. human_agent_handoff_config (google.cloud.dialogflow_v2.types.HumanAgentHandoffConfig): Configuration for connecting to a live agent. + Currently, this feature is not general available, please contact Google to get access. notification_config (google.cloud.dialogflow_v2.types.NotificationConfig): @@ -423,7 +424,13 @@ class SuggestionFeatureConfig(proto.Message): suggestions. Supported features: ARTICLE_SUGGESTION, FAQ, - DIALOGFLOW_ASSIST. + DIALOGFLOW_ASSIST, KNOWLEDGE_ASSIST. + disable_agent_query_logging (bool): + Optional. Disable the logging of search queries sent by + human agents. It can prevent those queries from being stored + at answer records. + + Supported features: KNOWLEDGE_SEARCH. suggestion_trigger_settings (google.cloud.dialogflow_v2.types.HumanAgentAssistantConfig.SuggestionTriggerSettings): Settings of suggestion trigger. @@ -446,6 +453,10 @@ class SuggestionFeatureConfig(proto.Message): proto.BOOL, number=3, ) + disable_agent_query_logging: bool = proto.Field( + proto.BOOL, + number=14, + ) suggestion_trigger_settings: "HumanAgentAssistantConfig.SuggestionTriggerSettings" = proto.Field( proto.MESSAGE, number=10, @@ -606,12 +617,37 @@ class DialogflowQuerySource(proto.Message): ``projects//locations//agent``. When multiple agents are allowed in the same Dialogflow project. + human_agent_side_config (google.cloud.dialogflow_v2.types.HumanAgentAssistantConfig.SuggestionQueryConfig.DialogflowQuerySource.HumanAgentSideConfig): + Optional. The Dialogflow assist configuration + for human agent. """ + class HumanAgentSideConfig(proto.Message): + r"""The configuration used for human agent side Dialogflow assist + suggestion. + + Attributes: + agent (str): + Optional. The name of a dialogflow virtual agent used for + intent detection and suggestion triggered by human agent. + Format: + ``projects//locations//agent``. + """ + + agent: str = proto.Field( + proto.STRING, + number=1, + ) + agent: str = proto.Field( proto.STRING, number=1, ) + human_agent_side_config: "HumanAgentAssistantConfig.SuggestionQueryConfig.DialogflowQuerySource.HumanAgentSideConfig" = proto.Field( + proto.MESSAGE, + number=3, + message="HumanAgentAssistantConfig.SuggestionQueryConfig.DialogflowQuerySource.HumanAgentSideConfig", + ) class ContextFilterSettings(proto.Message): r"""Settings that determine how to filter recent conversation @@ -788,6 +824,7 @@ class MessageAnalysisConfig(proto.Message): class HumanAgentHandoffConfig(proto.Message): r"""Defines the hand off to a live agent, typically on which external agent service provider to connect to a conversation. + Currently, this feature is not general available, please contact Google to get access. @@ -970,11 +1007,15 @@ class Type(proto.Enum): Run FAQ model for chat. SMART_REPLY (3): Run smart reply model for chat. + KNOWLEDGE_SEARCH (14): + Run knowledge search with text input from + agent or text generated query. """ TYPE_UNSPECIFIED = 0 ARTICLE_SUGGESTION = 1 FAQ = 2 SMART_REPLY = 3 + KNOWLEDGE_SEARCH = 14 type_: Type = proto.Field( proto.ENUM, diff --git a/google/cloud/dialogflow_v2/types/fulfillment.py b/google/cloud/dialogflow_v2/types/fulfillment.py index 3344f575..e46457ab 100644 --- a/google/cloud/dialogflow_v2/types/fulfillment.py +++ b/google/cloud/dialogflow_v2/types/fulfillment.py @@ -77,6 +77,7 @@ class GenericWebService(proto.Message): - Basic authentication with username and password. - Authentication with additional authentication headers. + More information could be found at: https://cloud.google.com/dialogflow/docs/fulfillment-configure. diff --git a/google/cloud/dialogflow_v2/types/participant.py b/google/cloud/dialogflow_v2/types/participant.py index b085f33e..619f4359 100644 --- a/google/cloud/dialogflow_v2/types/participant.py +++ b/google/cloud/dialogflow_v2/types/participant.py @@ -52,10 +52,13 @@ "ArticleAnswer", "FaqAnswer", "SmartReplyAnswer", + "IntentSuggestion", + "DialogflowAssistAnswer", "SuggestionResult", "InputTextConfig", "AnnotatedMessagePart", "MessageAnnotation", + "SuggestionInput", "AssistQueryParameters", }, ) @@ -403,6 +406,11 @@ class AnalyzeContentRequest(proto.Message): event_input (google.cloud.dialogflow_v2.types.EventInput): An input event to send to Dialogflow. + This field is a member of `oneof`_ ``input``. + suggestion_input (google.cloud.dialogflow_v2.types.SuggestionInput): + An input representing the selection of a + suggestion. + This field is a member of `oneof`_ ``input``. reply_audio_config (google.cloud.dialogflow_v2.types.OutputAudioConfig): Speech synthesis configuration. @@ -446,6 +454,12 @@ class AnalyzeContentRequest(proto.Message): oneof="input", message=session.EventInput, ) + suggestion_input: "SuggestionInput" = proto.Field( + proto.MESSAGE, + number=12, + oneof="input", + message="SuggestionInput", + ) reply_audio_config: gcd_audio_config.OutputAudioConfig = proto.Field( proto.MESSAGE, number=5, @@ -665,7 +679,8 @@ class StreamingAnalyzeContentRequest(proto.Message): Must be sent if ``text_config`` is set in the first message. Text length must not exceed 256 bytes for virtual agent interactions. The ``input_text`` field can be only sent - once. + once, and would cancel the speech recognition if any + ongoing. This field is a member of `oneof`_ ``input``. input_dtmf (google.cloud.dialogflow_v2.types.TelephonyDtmfEvents): @@ -1360,6 +1375,86 @@ class SmartReplyAnswer(proto.Message): ) +class IntentSuggestion(proto.Message): + r"""Represents an intent suggestion. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + display_name (str): + The display name of the intent. + intent_v2 (str): + The unique identifier of this + [intent][google.cloud.dialogflow.v2.Intent]. Format: + ``projects//locations//agent/intents/``. + + This field is a member of `oneof`_ ``intent``. + description (str): + Human readable description for better + understanding an intent like its scope, content, + result etc. Maximum character limit: 140 + characters. + """ + + display_name: str = proto.Field( + proto.STRING, + number=1, + ) + intent_v2: str = proto.Field( + proto.STRING, + number=2, + oneof="intent", + ) + description: str = proto.Field( + proto.STRING, + number=5, + ) + + +class DialogflowAssistAnswer(proto.Message): + r"""Represents a Dialogflow assist answer. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + query_result (google.cloud.dialogflow_v2.types.QueryResult): + Result from v2 agent. + + This field is a member of `oneof`_ ``result``. + intent_suggestion (google.cloud.dialogflow_v2.types.IntentSuggestion): + An intent suggestion generated from + conversation. + + This field is a member of `oneof`_ ``result``. + answer_record (str): + The name of answer record, in the format of + "projects//locations//answerRecords/". + """ + + query_result: session.QueryResult = proto.Field( + proto.MESSAGE, + number=1, + oneof="result", + message=session.QueryResult, + ) + intent_suggestion: "IntentSuggestion" = proto.Field( + proto.MESSAGE, + number=5, + oneof="result", + message="IntentSuggestion", + ) + answer_record: str = proto.Field( + proto.STRING, + number=2, + ) + + class SuggestionResult(proto.Message): r"""One response of different type of suggestion response which is used in the response of @@ -1508,6 +1603,24 @@ class MessageAnnotation(proto.Message): ) +class SuggestionInput(proto.Message): + r"""Represents the selection of a suggestion. + + Attributes: + answer_record (str): + Required. The ID of a suggestion selected by the human + agent. The suggestion(s) were generated in a previous call + to request Dialogflow assist. The format is: + ``projects//locations//answerRecords/`` + where is an alphanumeric string. + """ + + answer_record: str = proto.Field( + proto.STRING, + number=1, + ) + + class AssistQueryParameters(proto.Message): r"""Represents the parameters of human assist query. diff --git a/google/cloud/dialogflow_v2/types/session.py b/google/cloud/dialogflow_v2/types/session.py index a137d5e1..48f663fd 100644 --- a/google/cloud/dialogflow_v2/types/session.py +++ b/google/cloud/dialogflow_v2/types/session.py @@ -82,12 +82,13 @@ class DetectIntentRequest(proto.Message): set to: 1. an audio config which instructs the speech - recognizer how to process the speech audio, + recognizer how to process the speech audio, 2. a conversational query in the form of text, - or + or + 3. an event that specifies which intent to - trigger. + trigger. output_audio_config (google.cloud.dialogflow_v2.types.OutputAudioConfig): Instructs the speech synthesizer how to generate the output audio. If this field is not @@ -245,6 +246,12 @@ class QueryParameters(proto.Message): "User-Agent", "Accept-Encoding", "If-Modified-Since", "If-None-Match", "X-Forwarded-For", etc. + platform (str): + The platform of the virtual agent response messages. + + If not empty, only emits messages from this platform in the + response. Valid values are the enum names of + [platform][google.cloud.dialogflow.v2.Intent.Message.platform]. """ time_zone: str = proto.Field( @@ -287,13 +294,17 @@ class QueryParameters(proto.Message): proto.STRING, number=14, ) + platform: str = proto.Field( + proto.STRING, + number=18, + ) class QueryInput(proto.Message): r"""Represents the query input. It can contain either: 1. An audio config which instructs the speech recognizer how to - process the speech audio. + process the speech audio. 2. A conversational query in the form of text. @@ -604,12 +615,13 @@ class StreamingDetectIntentRequest(proto.Message): set to: 1. an audio config which instructs the speech - recognizer how to process the speech audio, + recognizer how to process the speech audio, 2. a conversational query in the form of text, - or + or + 3. an event that specifies which intent to - trigger. + trigger. single_utterance (bool): Please use [InputAudioConfig.single_utterance][google.cloud.dialogflow.v2.InputAudioConfig.single_utterance] @@ -730,8 +742,10 @@ class CloudConversationDebuggingInfo(proto.Message): Time offset of the end-of-single-utterance signal relative to the beginning of the stream. no_speech_timeout (google.protobuf.duration_pb2.Duration): - No speech timeout settings observed at - runtime. + No speech timeout settings for the stream. + endpointing_timeout (google.protobuf.duration_pb2.Duration): + Speech endpointing timeout settings for the + stream. is_input_text (bool): Whether the streaming terminates with an injected text query. @@ -815,6 +829,11 @@ class CloudConversationDebuggingInfo(proto.Message): number=15, message=duration_pb2.Duration, ) + endpointing_timeout: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=19, + message=duration_pb2.Duration, + ) is_input_text: bool = proto.Field( proto.BOOL, number=16, @@ -1053,6 +1072,7 @@ class MessageType(proto.Enum): class TextInput(proto.Message): r"""Auxiliary proto messages. + Represents the natural language text to be processed. Attributes: diff --git a/google/cloud/dialogflow_v2beta1/__init__.py b/google/cloud/dialogflow_v2beta1/__init__.py index e67e8454..1adabe7b 100644 --- a/google/cloud/dialogflow_v2beta1/__init__.py +++ b/google/cloud/dialogflow_v2beta1/__init__.py @@ -105,6 +105,9 @@ ListConversationsResponse, ListMessagesRequest, ListMessagesResponse, + SearchKnowledgeAnswer, + SearchKnowledgeRequest, + SearchKnowledgeResponse, SuggestConversationSummaryRequest, SuggestConversationSummaryResponse, ) @@ -467,6 +470,9 @@ "RestoreAgentRequest", "SearchAgentsRequest", "SearchAgentsResponse", + "SearchKnowledgeAnswer", + "SearchKnowledgeRequest", + "SearchKnowledgeResponse", "Sentiment", "SentimentAnalysisRequestConfig", "SentimentAnalysisResult", diff --git a/google/cloud/dialogflow_v2beta1/gapic_metadata.json b/google/cloud/dialogflow_v2beta1/gapic_metadata.json index 43a0d4c9..3cd78643 100644 --- a/google/cloud/dialogflow_v2beta1/gapic_metadata.json +++ b/google/cloud/dialogflow_v2beta1/gapic_metadata.json @@ -496,6 +496,11 @@ "list_messages" ] }, + "SearchKnowledge": { + "methods": [ + "search_knowledge" + ] + }, "SuggestConversationSummary": { "methods": [ "suggest_conversation_summary" @@ -541,6 +546,11 @@ "list_messages" ] }, + "SearchKnowledge": { + "methods": [ + "search_knowledge" + ] + }, "SuggestConversationSummary": { "methods": [ "suggest_conversation_summary" @@ -586,6 +596,11 @@ "list_messages" ] }, + "SearchKnowledge": { + "methods": [ + "search_knowledge" + ] + }, "SuggestConversationSummary": { "methods": [ "suggest_conversation_summary" diff --git a/google/cloud/dialogflow_v2beta1/gapic_version.py b/google/cloud/dialogflow_v2beta1/gapic_version.py index 26ba4efa..07de09d5 100644 --- a/google/cloud/dialogflow_v2beta1/gapic_version.py +++ b/google/cloud/dialogflow_v2beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.23.3" # {x-release-please-version} +__version__ = "2.24.0" # {x-release-please-version} diff --git a/google/cloud/dialogflow_v2beta1/services/agents/async_client.py b/google/cloud/dialogflow_v2beta1/services/agents/async_client.py index 5ce996a8..9fda2027 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/agents/client.py b/google/cloud/dialogflow_v2beta1/services/agents/client.py index 2ea3ac6f..b4aa6831 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/client.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/agents/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/agents/transports/rest.py index 99729d8c..681610e2 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py b/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py index 2b5cf822..d443eea3 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py @@ -44,7 +44,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.answer_records import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/client.py b/google/cloud/dialogflow_v2beta1/services/answer_records/client.py index 3954a0b3..beba4a1e 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/client.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/client.py @@ -48,7 +48,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.answer_records import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py index c42970cb..d87df5f6 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2beta1 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py index 6a531c6e..e2b2c2a1 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2beta1.types import answer_record as gcd_answer_record diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py index 1186fd48..6140f23b 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/rest.py index 8431fd65..2428fed6 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2beta1.types import answer_record as gcd_answer_record from google.cloud.dialogflow_v2beta1.types import answer_record diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py b/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py index e01d0db9..dcefaf17 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -479,6 +479,7 @@ async def create_context( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_context.Context: r"""Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/client.py b/google/cloud/dialogflow_v2beta1/services/contexts/client.py index 2a46dbd5..843e667d 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/client.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -714,6 +714,7 @@ def create_context( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_context.Context: r"""Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py index 02a4229d..d95fec9e 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py index ac9eba05..a0cd3698 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -291,6 +291,7 @@ def create_context( r"""Return a callable for the create context method over gRPC. Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py index 0390e8e8..ccf5cae6 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -298,6 +298,7 @@ def create_context( r"""Return a callable for the create context method over gRPC. Creates a context. + If the specified context already exists, overrides the context. diff --git a/google/cloud/dialogflow_v2beta1/services/contexts/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/rest.py index 30e0eec7..3a05bddc 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import context diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py index ca11dd6f..83e358fb 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -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 diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py index 958915fb..b4c62439 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -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 diff --git a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/rest.py index ce6ed26a..29122026 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py b/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py index fb293994..a535cd3a 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.conversations import pagers @@ -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, diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/client.py b/google/cloud/dialogflow_v2beta1/services/conversations/client.py index 6b1e20fd..73287f59 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/client.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.conversations import pagers @@ -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 diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py index e5857c93..82318589 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2beta1 import gapic_version as package_version @@ -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): @@ -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, diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py index 4016b7df..39a9b0c1 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2beta1.types import conversation as gcd_conversation @@ -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() diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py index ca23a671..01697088 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -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() diff --git a/google/cloud/dialogflow_v2beta1/services/conversations/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/rest.py index e5691a5f..2d7290e1 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2beta1.types import conversation as gcd_conversation from google.cloud.dialogflow_v2beta1.types import conversation @@ -122,6 +123,14 @@ def post_list_messages(self, response): logging.log(f"Received response: {response}") return response + def pre_search_knowledge(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_search_knowledge(self, response): + logging.log(f"Received response: {response}") + return response + def pre_suggest_conversation_summary(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -297,6 +306,29 @@ def post_list_messages( """ return response + def pre_search_knowledge( + self, + request: conversation.SearchKnowledgeRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[conversation.SearchKnowledgeRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for search_knowledge + + Override in a subclass to manipulate the request or metadata + before they are sent to the Conversations server. + """ + return request, metadata + + def post_search_knowledge( + self, response: conversation.SearchKnowledgeResponse + ) -> conversation.SearchKnowledgeResponse: + """Post-rpc interceptor for search_knowledge + + Override in a subclass to manipulate the response + after it is returned by the Conversations server but before + it is returned to user code. + """ + return response + def pre_suggest_conversation_summary( self, request: gcd_conversation.SuggestConversationSummaryRequest, @@ -1252,6 +1284,121 @@ def __call__( resp = self._interceptor.post_list_messages(resp) return resp + class _SearchKnowledge(ConversationsRestStub): + def __hash__(self): + return hash("SearchKnowledge") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: conversation.SearchKnowledgeRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> conversation.SearchKnowledgeResponse: + r"""Call the search knowledge method over HTTP. + + Args: + request (~.conversation.SearchKnowledgeRequest): + 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: + ~.conversation.SearchKnowledgeResponse: + The response message for + [Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge]. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v2beta1/{parent=projects/*}/suggestions:searchKnowledge", + "body": "*", + }, + { + "method": "post", + "uri": "/v2beta1/{parent=projects/*/locations/*}/suggestions:searchKnowledge", + "body": "*", + }, + { + "method": "post", + "uri": "/v2beta1/{conversation=projects/*/conversations/*}/suggestions:searchKnowledge", + "body": "*", + }, + { + "method": "post", + "uri": "/v2beta1/{conversation=projects/*/locations/*/conversations/*}/suggestions:searchKnowledge", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_search_knowledge( + request, metadata + ) + pb_request = conversation.SearchKnowledgeRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=True, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = conversation.SearchKnowledgeResponse() + pb_resp = conversation.SearchKnowledgeResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_knowledge(resp) + return resp + class _SuggestConversationSummary(ConversationsRestStub): def __hash__(self): return hash("SuggestConversationSummary") @@ -1428,6 +1575,16 @@ def list_messages( # In C++ this would require a dynamic_cast return self._ListMessages(self._session, self._host, self._interceptor) # type: ignore + @property + def search_knowledge( + self, + ) -> Callable[ + [conversation.SearchKnowledgeRequest], conversation.SearchKnowledgeResponse + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._SearchKnowledge(self._session, self._host, self._interceptor) # type: ignore + @property def suggest_conversation_summary( self, diff --git a/google/cloud/dialogflow_v2beta1/services/documents/async_client.py b/google/cloud/dialogflow_v2beta1/services/documents/async_client.py index 1d40405f..8efccead 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/documents/client.py b/google/cloud/dialogflow_v2beta1/services/documents/client.py index ea5c34f5..0f4730d5 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/client.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/documents/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/documents/transports/rest.py index d1ba909c..7f5c443e 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py b/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py index 65187a4b..0eb0ea12 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/client.py b/google/cloud/dialogflow_v2beta1/services/entity_types/client.py index 8c9840fd..c70994c9 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/client.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/rest.py index 6c209bbb..786f24ac 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2beta1/services/environments/async_client.py b/google/cloud/dialogflow_v2beta1/services/environments/async_client.py index 8d133e68..b5febaa7 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.environments import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/environments/client.py b/google/cloud/dialogflow_v2beta1/services/environments/client.py index f2641b34..847f6f28 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/client.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.environments import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py index 8650cf46..f76af789 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py index 40671275..581c437c 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py index cc6aed3c..c967461f 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/environments/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/rest.py index 3c78aa77..5a90614f 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import environment diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py index a3d27ee7..c0bbc663 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import fulfillment as gcd_fulfillment diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py index 564120e5..decc84b2 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import fulfillment as gcd_fulfillment diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py index 2f1ac08e..917f3115 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2beta1 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py index a1aa8d5e..71d2b74b 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2beta1.types import fulfillment as gcd_fulfillment diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py index 54b20dc2..228d4e68 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/rest.py index 996481f2..97709618 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2beta1.types import fulfillment as gcd_fulfillment from google.cloud.dialogflow_v2beta1.types import fulfillment diff --git a/google/cloud/dialogflow_v2beta1/services/intents/async_client.py b/google/cloud/dialogflow_v2beta1/services/intents/async_client.py index 70d7483a..20620ac3 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/async_client.py @@ -45,7 +45,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/intents/client.py b/google/cloud/dialogflow_v2beta1/services/intents/client.py index 02d4f377..c60dee78 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/client.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/client.py @@ -49,7 +49,7 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/intents/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/intents/transports/rest.py index cfb8f6e6..a8a247c6 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/transports/rest.py @@ -33,7 +33,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py index 3cf112fc..a99e9961 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.knowledge_bases import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py index 1e6c90f2..ac93e5a9 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.knowledge_bases import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py index 7af423cc..27ce97cf 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py index 40b59d16..0eeec181 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py index 5403efc8..ea8ab372 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/rest.py index 5c16185b..8d72bb8e 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import knowledge_base as gcd_knowledge_base diff --git a/google/cloud/dialogflow_v2beta1/services/participants/async_client.py b/google/cloud/dialogflow_v2beta1/services/participants/async_client.py index 8cac31b6..5862a2ae 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/async_client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.participants import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/participants/client.py b/google/cloud/dialogflow_v2beta1/services/participants/client.py index 1d5dfd13..407bd05b 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/client.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/client.py @@ -50,7 +50,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.participants import pagers diff --git a/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py index 33739fe0..0a98515a 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2beta1 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py index 32c5fc7c..0d35faa6 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2beta1.types import participant as gcd_participant diff --git a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py index f53c0b4d..ad7accf6 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/participants/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/rest.py index 4457ca86..8b1d6731 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2beta1.types import participant as gcd_participant from google.cloud.dialogflow_v2beta1.types import participant diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py index 611114c5..f32d15bf 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.session_entity_types import pagers @@ -372,6 +372,7 @@ async def get_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -498,6 +499,7 @@ async def create_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -636,6 +638,7 @@ async def update_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -761,6 +764,7 @@ async def delete_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py index 038ef478..215ed126 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.services.session_entity_types import pagers @@ -598,6 +598,7 @@ def get_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -724,6 +725,7 @@ def create_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -866,6 +868,7 @@ def update_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -995,6 +998,7 @@ def delete_session_entity_type( metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py index 135df180..dfbe771f 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py index 08a1f436..6dd5641b 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -278,6 +278,7 @@ def get_session_entity_type( r"""Return a callable for the get session entity type method over gRPC. Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -310,6 +311,7 @@ def create_session_entity_type( r"""Return a callable for the create session entity type method over gRPC. Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -345,6 +347,7 @@ def update_session_entity_type( r"""Return a callable for the update session entity type method over gRPC. Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -376,6 +379,7 @@ def delete_session_entity_type( r"""Return a callable for the delete session entity type method over gRPC. Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py index 070e5651..4870811d 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -281,6 +281,7 @@ def get_session_entity_type( r"""Return a callable for the get session entity type method over gRPC. Retrieves the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -313,6 +314,7 @@ def create_session_entity_type( r"""Return a callable for the create session entity type method over gRPC. Creates a session entity type. + If the specified session entity type already exists, overrides the session entity type. @@ -348,6 +350,7 @@ def update_session_entity_type( r"""Return a callable for the update session entity type method over gRPC. Updates the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. @@ -379,6 +382,7 @@ def delete_session_entity_type( r"""Return a callable for the delete session entity type method over gRPC. Deletes the specified session entity type. + This method doesn't work with Google Assistant integration. Contact Dialogflow support if you need to use session entities with Google Assistant integration. diff --git a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/rest.py index 06a7de32..f9ee1855 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import ( diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py b/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py index bf96fec6..86d0a32f 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py @@ -46,7 +46,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import audio_config @@ -324,13 +324,14 @@ async def sample_detect_intent(): can be set to: 1. an audio config which instructs the - speech recognizer how to process the - speech audio, + speech recognizer how to process the + speech audio, 2. a conversational query in the form of - text, or + text, or + 3. an event that specifies which intent - to trigger. + to trigger. This corresponds to the ``query_input`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/client.py b/google/cloud/dialogflow_v2beta1/services/sessions/client.py index 4f5d876c..a484b903 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/client.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/client.py @@ -49,7 +49,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import audio_config @@ -628,13 +628,14 @@ def sample_detect_intent(): can be set to: 1. an audio config which instructs the - speech recognizer how to process the - speech audio, + speech recognizer how to process the + speech audio, 2. a conversational query in the form of - text, or + text, or + 3. an event that specifies which intent - to trigger. + to trigger. This corresponds to the ``query_input`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py index 7df269b2..2044e456 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.dialogflow_v2beta1 import gapic_version as package_version diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py index 06517c99..98e3f27a 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.dialogflow_v2beta1.types import session diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py index 158f0367..572529c2 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/sessions/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/rest.py index e558c17a..5951d86d 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,8 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore + from google.cloud.dialogflow_v2beta1.types import session from google.cloud.dialogflow_v2beta1.types import session as gcd_session diff --git a/google/cloud/dialogflow_v2beta1/services/versions/async_client.py b/google/cloud/dialogflow_v2beta1/services/versions/async_client.py index c0a411ea..1c142b6f 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/async_client.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/async_client.py @@ -43,7 +43,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -467,6 +467,7 @@ async def create_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -601,6 +602,7 @@ async def update_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2beta1/services/versions/client.py b/google/cloud/dialogflow_v2beta1/services/versions/client.py index c771f810..298b8296 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/client.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/client.py @@ -47,7 +47,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -699,6 +699,7 @@ def create_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -833,6 +834,7 @@ def update_version( metadata: Sequence[Tuple[str, str]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py index e95469c5..49c40fb0 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py @@ -23,7 +23,7 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py index badb66b0..80410e39 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py @@ -21,7 +21,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore @@ -291,6 +291,7 @@ def create_version( r"""Return a callable for the create version method over gRPC. Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -319,6 +320,7 @@ def update_version( r"""Return a callable for the update version method over gRPC. Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py index 7c628aa8..e79ef315 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py @@ -20,7 +20,7 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -298,6 +298,7 @@ def create_version( r"""Return a callable for the create version method over gRPC. Creates an agent version. + The new version points to the agent instance in the "default" environment. @@ -326,6 +327,7 @@ def update_version( r"""Return a callable for the update version method over gRPC. Updates the specified agent version. + Note that this method does not allow you to update the state of the agent the given version points to. It allows you to update only mutable properties of the diff --git a/google/cloud/dialogflow_v2beta1/services/versions/transports/rest.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/rest.py index 732cf06c..a1f5fab7 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/rest.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/rest.py @@ -27,7 +27,6 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 from google.protobuf import json_format import grpc # type: ignore from requests import __version__ as requests_version @@ -38,6 +37,7 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.cloud.dialogflow_v2beta1.types import version diff --git a/google/cloud/dialogflow_v2beta1/types/__init__.py b/google/cloud/dialogflow_v2beta1/types/__init__.py index b1ff178b..6e842d15 100644 --- a/google/cloud/dialogflow_v2beta1/types/__init__.py +++ b/google/cloud/dialogflow_v2beta1/types/__init__.py @@ -79,6 +79,9 @@ ListConversationsResponse, ListMessagesRequest, ListMessagesResponse, + SearchKnowledgeAnswer, + SearchKnowledgeRequest, + SearchKnowledgeResponse, SuggestConversationSummaryRequest, SuggestConversationSummaryResponse, ) @@ -309,6 +312,9 @@ "ListConversationsResponse", "ListMessagesRequest", "ListMessagesResponse", + "SearchKnowledgeAnswer", + "SearchKnowledgeRequest", + "SearchKnowledgeResponse", "SuggestConversationSummaryRequest", "SuggestConversationSummaryResponse", "ConversationEvent", diff --git a/google/cloud/dialogflow_v2beta1/types/answer_record.py b/google/cloud/dialogflow_v2beta1/types/answer_record.py index d8569060..8c1a0ba2 100644 --- a/google/cloud/dialogflow_v2beta1/types/answer_record.py +++ b/google/cloud/dialogflow_v2beta1/types/answer_record.py @@ -267,6 +267,8 @@ class AgentAssistantFeedback(proto.Message): [DocumentEfficiency.INEFFICIENT][google.cloud.dialogflow.v2beta1.AgentAssistantFeedback.DocumentEfficiency.INEFFICIENT]. summarization_feedback (google.cloud.dialogflow_v2beta1.types.AgentAssistantFeedback.SummarizationFeedback): Feedback for conversation summarization. + knowledge_search_feedback (google.cloud.dialogflow_v2beta1.types.AgentAssistantFeedback.KnowledgeSearchFeedback): + Optional. Feedback for knowledge search. """ class AnswerRelevance(proto.Enum): @@ -342,6 +344,32 @@ class SummarizationFeedback(proto.Message): number=3, ) + class KnowledgeSearchFeedback(proto.Message): + r"""Feedback for knowledge search. + + Attributes: + answer_copied (bool): + Whether the answer was copied by the human agent or not. If + the value is set to be true, + [AnswerFeedback.clicked][google.cloud.dialogflow.v2beta1.AnswerFeedback.clicked] + will be updated to be true. + clicked_uris (MutableSequence[str]): + The URIs clicked by the human agent. The value is appended + for each UpdateAnswerRecordRequest. If the value is not + empty, + [AnswerFeedback.clicked][google.cloud.dialogflow.v2beta1.AnswerFeedback.clicked] + will be updated to be true. + """ + + answer_copied: bool = proto.Field( + proto.BOOL, + number=1, + ) + clicked_uris: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=2, + ) + answer_relevance: AnswerRelevance = proto.Field( proto.ENUM, number=1, @@ -362,6 +390,11 @@ class SummarizationFeedback(proto.Message): number=4, message=SummarizationFeedback, ) + knowledge_search_feedback: KnowledgeSearchFeedback = proto.Field( + proto.MESSAGE, + number=5, + message=KnowledgeSearchFeedback, + ) class GetAnswerRecordRequest(proto.Message): diff --git a/google/cloud/dialogflow_v2beta1/types/audio_config.py b/google/cloud/dialogflow_v2beta1/types/audio_config.py index 400b411f..c614d994 100644 --- a/google/cloud/dialogflow_v2beta1/types/audio_config.py +++ b/google/cloud/dialogflow_v2beta1/types/audio_config.py @@ -743,6 +743,10 @@ class SpeechToTextConfig(proto.Message): `Cloud Speech API documentation `__ for more details. + use_timeout_based_endpointing (bool): + Use timeout based endpointing, interpreting + endpointer sensitivy as seconds of timeout + value. """ speech_model_variant: "SpeechModelVariant" = proto.Field( @@ -754,6 +758,10 @@ class SpeechToTextConfig(proto.Message): proto.STRING, number=2, ) + use_timeout_based_endpointing: bool = proto.Field( + proto.BOOL, + number=11, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dialogflow_v2beta1/types/conversation.py b/google/cloud/dialogflow_v2beta1/types/conversation.py index 74dd8530..5981f4aa 100644 --- a/google/cloud/dialogflow_v2beta1/types/conversation.py +++ b/google/cloud/dialogflow_v2beta1/types/conversation.py @@ -23,7 +23,7 @@ from google.cloud.dialogflow_v2beta1.types import ( conversation_profile as gcd_conversation_profile, ) -from google.cloud.dialogflow_v2beta1.types import participant +from google.cloud.dialogflow_v2beta1.types import participant, session __protobuf__ = proto.module( package="google.cloud.dialogflow.v2beta1", @@ -44,6 +44,9 @@ "SuggestConversationSummaryResponse", "GenerateStatelessSummaryRequest", "GenerateStatelessSummaryResponse", + "SearchKnowledgeRequest", + "SearchKnowledgeResponse", + "SearchKnowledgeAnswer", }, ) @@ -572,6 +575,10 @@ class Summary(proto.Message): "projects//answerRecords/". + baseline_model_version (str): + The baseline model version used to generate + this summary. It is empty if a baseline model + was not used to generate this summary. """ text: str = proto.Field( @@ -587,6 +594,10 @@ class Summary(proto.Message): proto.STRING, number=3, ) + baseline_model_version: str = proto.Field( + proto.STRING, + number=5, + ) summary: Summary = proto.Field( proto.MESSAGE, @@ -709,6 +720,10 @@ class Summary(proto.Message): sections. The key is the section's name and the value is the section's content. There is no specific format for the key or value. + baseline_model_version (str): + The baseline model version used to generate + this summary. It is empty if a baseline model + was not used to generate this summary. """ text: str = proto.Field( @@ -720,6 +735,10 @@ class Summary(proto.Message): proto.STRING, number=2, ) + baseline_model_version: str = proto.Field( + proto.STRING, + number=4, + ) summary: Summary = proto.Field( proto.MESSAGE, @@ -736,4 +755,160 @@ class Summary(proto.Message): ) +class SearchKnowledgeRequest(proto.Message): + r"""The request message for + [Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge]. + + Attributes: + parent (str): + The parent resource contains the conversation profile + Format: 'projects/' or + ``projects//locations/``. + query (google.cloud.dialogflow_v2beta1.types.TextInput): + Required. The natural language text query for + knowledge search. + conversation_profile (str): + Required. The conversation profile used to configure the + search. Format: + ``projects//locations//conversationProfiles/``. + session_id (str): + The ID of the search session. The session_id can be combined + with Dialogflow V3 Agent ID retrieved from conversation + profile or on its own to identify a search session. The + search history of the same session will impact the search + result. It's up to the API caller to choose an appropriate + ``Session ID``. It can be a random number or some type of + session identifiers (preferably hashed). The length must not + exceed 36 characters. + conversation (str): + The conversation (between human agent and end user) where + the search request is triggered. Format: + ``projects//locations//conversations/``. + latest_message (str): + The name of the latest conversation message when the request + is triggered. Format: + ``projects//locations//conversations//messages/``. + """ + + parent: str = proto.Field( + proto.STRING, + number=6, + ) + query: session.TextInput = proto.Field( + proto.MESSAGE, + number=1, + message=session.TextInput, + ) + conversation_profile: str = proto.Field( + proto.STRING, + number=2, + ) + session_id: str = proto.Field( + proto.STRING, + number=3, + ) + conversation: str = proto.Field( + proto.STRING, + number=4, + ) + latest_message: str = proto.Field( + proto.STRING, + number=5, + ) + + +class SearchKnowledgeResponse(proto.Message): + r"""The response message for + [Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge]. + + Attributes: + answers (MutableSequence[google.cloud.dialogflow_v2beta1.types.SearchKnowledgeAnswer]): + Most relevant snippets extracted from + articles in the given knowledge base, ordered by + confidence. + """ + + answers: MutableSequence["SearchKnowledgeAnswer"] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="SearchKnowledgeAnswer", + ) + + +class SearchKnowledgeAnswer(proto.Message): + r"""Represents a SearchKnowledge answer. + + Attributes: + answer (str): + The piece of text from the knowledge base + documents that answers the search query + answer_type (google.cloud.dialogflow_v2beta1.types.SearchKnowledgeAnswer.AnswerType): + The type of the answer. + answer_sources (MutableSequence[google.cloud.dialogflow_v2beta1.types.SearchKnowledgeAnswer.AnswerSource]): + All sources used to generate the answer. + answer_record (str): + The name of the answer record. Format: + ``projects//locations//answer Records/`` + """ + + class AnswerType(proto.Enum): + r"""The type of the answer. + + Values: + ANSWER_TYPE_UNSPECIFIED (0): + The answer has a unspecified type. + FAQ (1): + The answer is from FAQ doucments. + GENERATIVE (2): + The answer is from generative model. + """ + ANSWER_TYPE_UNSPECIFIED = 0 + FAQ = 1 + GENERATIVE = 2 + + class AnswerSource(proto.Message): + r"""The sources of the answers. + + Attributes: + title (str): + The title of the article. + uri (str): + The URI of the article. + snippet (str): + The relevant snippet of the article. + """ + + title: str = proto.Field( + proto.STRING, + number=1, + ) + uri: str = proto.Field( + proto.STRING, + number=2, + ) + snippet: str = proto.Field( + proto.STRING, + number=3, + ) + + answer: str = proto.Field( + proto.STRING, + number=1, + ) + answer_type: AnswerType = proto.Field( + proto.ENUM, + number=2, + enum=AnswerType, + ) + answer_sources: MutableSequence[AnswerSource] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=AnswerSource, + ) + answer_record: str = proto.Field( + proto.STRING, + number=5, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dialogflow_v2beta1/types/conversation_profile.py b/google/cloud/dialogflow_v2beta1/types/conversation_profile.py index ce596ba0..7bf0257f 100644 --- a/google/cloud/dialogflow_v2beta1/types/conversation_profile.py +++ b/google/cloud/dialogflow_v2beta1/types/conversation_profile.py @@ -72,6 +72,7 @@ class ConversationProfile(proto.Message): with this profile. human_agent_handoff_config (google.cloud.dialogflow_v2beta1.types.HumanAgentHandoffConfig): Configuration for connecting to a live agent. + Currently, this feature is not general available, please contact Google to get access. notification_config (google.cloud.dialogflow_v2beta1.types.NotificationConfig): @@ -278,7 +279,13 @@ class SuggestionFeatureConfig(proto.Message): suggestions. Supported features: ARTICLE_SUGGESTION, FAQ, - DIALOGFLOW_ASSIST, ENTITY_EXTRACTION. + DIALOGFLOW_ASSIST, ENTITY_EXTRACTION, KNOWLEDGE_ASSIST. + disable_agent_query_logging (bool): + Optional. Disable the logging of search queries sent by + human agents. It can prevent those queries from being stored + at answer records. + + Supported features: KNOWLEDGE_SEARCH. suggestion_trigger_settings (google.cloud.dialogflow_v2beta1.types.HumanAgentAssistantConfig.SuggestionTriggerSettings): Settings of suggestion trigger. @@ -301,6 +308,10 @@ class SuggestionFeatureConfig(proto.Message): proto.BOOL, number=3, ) + disable_agent_query_logging: bool = proto.Field( + proto.BOOL, + number=14, + ) suggestion_trigger_settings: "HumanAgentAssistantConfig.SuggestionTriggerSettings" = proto.Field( proto.MESSAGE, number=10, @@ -668,6 +679,7 @@ class MessageAnalysisConfig(proto.Message): class HumanAgentHandoffConfig(proto.Message): r"""Defines the hand off to a live agent, typically on which external agent service provider to connect to a conversation. + Currently, this feature is not general available, please contact Google to get access. diff --git a/google/cloud/dialogflow_v2beta1/types/fulfillment.py b/google/cloud/dialogflow_v2beta1/types/fulfillment.py index aaaf7d0b..b0d05547 100644 --- a/google/cloud/dialogflow_v2beta1/types/fulfillment.py +++ b/google/cloud/dialogflow_v2beta1/types/fulfillment.py @@ -76,6 +76,7 @@ class GenericWebService(proto.Message): - Basic authentication with username and password. - Authentication with additional authentication headers. + More information could be found at: https://cloud.google.com/dialogflow/docs/fulfillment-configure. diff --git a/google/cloud/dialogflow_v2beta1/types/intent.py b/google/cloud/dialogflow_v2beta1/types/intent.py index d1050546..92be047c 100644 --- a/google/cloud/dialogflow_v2beta1/types/intent.py +++ b/google/cloud/dialogflow_v2beta1/types/intent.py @@ -484,6 +484,7 @@ class Message(proto.Message): This field is a member of `oneof`_ ``message``. rbm_text (google.cloud.dialogflow_v2beta1.types.Intent.Message.RbmText): Rich Business Messaging (RBM) text response. + RBM allows businesses to send enriched and branded versions of SMS. See https://jibe.google.com/business-messaging. diff --git a/google/cloud/dialogflow_v2beta1/types/participant.py b/google/cloud/dialogflow_v2beta1/types/participant.py index 80487163..7a5ad173 100644 --- a/google/cloud/dialogflow_v2beta1/types/participant.py +++ b/google/cloud/dialogflow_v2beta1/types/participant.py @@ -688,6 +688,9 @@ class Type(proto.Enum): CONVERSATION_SUMMARIZATION (8): Run conversation summarization model for chat. + KNOWLEDGE_SEARCH (14): + Run knowledge search with text input from + agent or text generated query. """ TYPE_UNSPECIFIED = 0 ARTICLE_SUGGESTION = 1 @@ -695,6 +698,7 @@ class Type(proto.Enum): SMART_REPLY = 3 DIALOGFLOW_ASSIST = 4 CONVERSATION_SUMMARIZATION = 8 + KNOWLEDGE_SEARCH = 14 type_: Type = proto.Field( proto.ENUM, @@ -1106,7 +1110,8 @@ class StreamingAnalyzeContentRequest(proto.Message): Must be sent if ``text_config`` is set in the first message. Text length must not exceed 256 bytes for virtual agent interactions. The ``input_text`` field can be only sent - once. + once, and would cancel the speech recognition if any + ongoing. This field is a member of `oneof`_ ``input``. input_dtmf (google.cloud.dialogflow_v2beta1.types.TelephonyDtmfEvents): diff --git a/google/cloud/dialogflow_v2beta1/types/session.py b/google/cloud/dialogflow_v2beta1/types/session.py index d8631d56..9d7c62d3 100644 --- a/google/cloud/dialogflow_v2beta1/types/session.py +++ b/google/cloud/dialogflow_v2beta1/types/session.py @@ -87,12 +87,13 @@ class DetectIntentRequest(proto.Message): set to: 1. an audio config which instructs the speech - recognizer how to process the speech audio, + recognizer how to process the speech audio, 2. a conversational query in the form of text, - or + or + 3. an event that specifies which intent to - trigger. + trigger. output_audio_config (google.cloud.dialogflow_v2beta1.types.OutputAudioConfig): Instructs the speech synthesizer how to generate the output audio. If this field is not @@ -278,6 +279,12 @@ class QueryParameters(proto.Message): "User-Agent", "Accept-Encoding", "If-Modified-Since", "If-None-Match", "X-Forwarded-For", etc. + platform (str): + The platform of the virtual agent response messages. + + If not empty, only emits messages from this platform in the + response. Valid values are the enum names of + [platform][google.cloud.dialogflow.v2beta1.Intent.Message.platform]. """ time_zone: str = proto.Field( @@ -329,13 +336,17 @@ class QueryParameters(proto.Message): proto.STRING, number=14, ) + platform: str = proto.Field( + proto.STRING, + number=18, + ) class QueryInput(proto.Message): r"""Represents the query input. It can contain either: 1. An audio config which instructs the speech recognizer how to - process the speech audio. + process the speech audio. 2. A conversational query in the form of text. @@ -761,12 +772,13 @@ class StreamingDetectIntentRequest(proto.Message): set to: 1. an audio config which instructs the speech - recognizer how to process the speech audio, + recognizer how to process the speech audio, 2. a conversational query in the form of text, - or + or + 3. an event that specifies which intent to - trigger. + trigger. single_utterance (bool): DEPRECATED. Please use [InputAudioConfig.single_utterance][google.cloud.dialogflow.v2beta1.InputAudioConfig.single_utterance] @@ -887,8 +899,10 @@ class CloudConversationDebuggingInfo(proto.Message): Time offset of the end-of-single-utterance signal relative to the beginning of the stream. no_speech_timeout (google.protobuf.duration_pb2.Duration): - No speech timeout settings observed at - runtime. + No speech timeout settings for the stream. + endpointing_timeout (google.protobuf.duration_pb2.Duration): + Speech endpointing timeout settings for the + stream. is_input_text (bool): Whether the streaming terminates with an injected text query. @@ -972,6 +986,11 @@ class CloudConversationDebuggingInfo(proto.Message): number=15, message=duration_pb2.Duration, ) + endpointing_timeout: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=19, + message=duration_pb2.Duration, + ) is_input_text: bool = proto.Field( proto.BOOL, number=16, diff --git a/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_async.py b/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_async.py index 0614ab5e..8a08b66a 100644 --- a/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_async.py +++ b/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_async.py @@ -42,7 +42,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 diff --git a/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_sync.py b/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_sync.py index 799888a8..6a80a30f 100644 --- a/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_sync.py +++ b/samples/generated_samples/dialogflow_v2_generated_conversation_profiles_clear_suggestion_feature_config_sync.py @@ -42,7 +42,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 diff --git a/samples/generated_samples/dialogflow_v2_generated_conversations_search_knowledge_async.py b/samples/generated_samples/dialogflow_v2_generated_conversations_search_knowledge_async.py new file mode 100644 index 00000000..3b65b455 --- /dev/null +++ b/samples/generated_samples/dialogflow_v2_generated_conversations_search_knowledge_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SearchKnowledge +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflow + + +# [START dialogflow_v2_generated_Conversations_SearchKnowledge_async] +# 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) + +# [END dialogflow_v2_generated_Conversations_SearchKnowledge_async] diff --git a/samples/generated_samples/dialogflow_v2_generated_conversations_search_knowledge_sync.py b/samples/generated_samples/dialogflow_v2_generated_conversations_search_knowledge_sync.py new file mode 100644 index 00000000..1a43367f --- /dev/null +++ b/samples/generated_samples/dialogflow_v2_generated_conversations_search_knowledge_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SearchKnowledge +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflow + + +# [START dialogflow_v2_generated_Conversations_SearchKnowledge_sync] +# 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 + + +def sample_search_knowledge(): + # Create a client + client = dialogflow_v2.ConversationsClient() + + # 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 = client.search_knowledge(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v2_generated_Conversations_SearchKnowledge_sync] diff --git a/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_async.py b/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_async.py index 6f67a5bf..fad4a040 100644 --- a/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_async.py +++ b/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_async.py @@ -42,7 +42,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 diff --git a/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_sync.py b/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_sync.py index 547e5fc2..a59c725d 100644 --- a/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_sync.py +++ b/samples/generated_samples/dialogflow_v2beta1_generated_conversation_profiles_clear_suggestion_feature_config_sync.py @@ -42,7 +42,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 diff --git a/samples/generated_samples/dialogflow_v2beta1_generated_conversations_search_knowledge_async.py b/samples/generated_samples/dialogflow_v2beta1_generated_conversations_search_knowledge_async.py new file mode 100644 index 00000000..33534cc1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v2beta1_generated_conversations_search_knowledge_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SearchKnowledge +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflow + + +# [START dialogflow_v2beta1_generated_Conversations_SearchKnowledge_async] +# 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) + +# [END dialogflow_v2beta1_generated_Conversations_SearchKnowledge_async] diff --git a/samples/generated_samples/dialogflow_v2beta1_generated_conversations_search_knowledge_sync.py b/samples/generated_samples/dialogflow_v2beta1_generated_conversations_search_knowledge_sync.py new file mode 100644 index 00000000..9608390a --- /dev/null +++ b/samples/generated_samples/dialogflow_v2beta1_generated_conversations_search_knowledge_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SearchKnowledge +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflow + + +# [START dialogflow_v2beta1_generated_Conversations_SearchKnowledge_sync] +# 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) + +# [END dialogflow_v2beta1_generated_Conversations_SearchKnowledge_sync] diff --git a/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json b/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json index 7bd83b77..3f1fae71 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-dialogflow", - "version": "2.23.3" + "version": "2.24.0" }, "snippets": [ { @@ -7119,6 +7119,159 @@ ], "title": "dialogflow_v2_generated_conversations_list_messages_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.dialogflow_v2.ConversationsAsyncClient", + "shortName": "ConversationsAsyncClient" + }, + "fullName": "google.cloud.dialogflow_v2.ConversationsAsyncClient.search_knowledge", + "method": { + "fullName": "google.cloud.dialogflow.v2.Conversations.SearchKnowledge", + "service": { + "fullName": "google.cloud.dialogflow.v2.Conversations", + "shortName": "Conversations" + }, + "shortName": "SearchKnowledge" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.dialogflow_v2.types.SearchKnowledgeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.dialogflow_v2.types.SearchKnowledgeResponse", + "shortName": "search_knowledge" + }, + "description": "Sample for SearchKnowledge", + "file": "dialogflow_v2_generated_conversations_search_knowledge_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "dialogflow_v2_generated_Conversations_SearchKnowledge_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "dialogflow_v2_generated_conversations_search_knowledge_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.dialogflow_v2.ConversationsClient", + "shortName": "ConversationsClient" + }, + "fullName": "google.cloud.dialogflow_v2.ConversationsClient.search_knowledge", + "method": { + "fullName": "google.cloud.dialogflow.v2.Conversations.SearchKnowledge", + "service": { + "fullName": "google.cloud.dialogflow.v2.Conversations", + "shortName": "Conversations" + }, + "shortName": "SearchKnowledge" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.dialogflow_v2.types.SearchKnowledgeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.dialogflow_v2.types.SearchKnowledgeResponse", + "shortName": "search_knowledge" + }, + "description": "Sample for SearchKnowledge", + "file": "dialogflow_v2_generated_conversations_search_knowledge_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "dialogflow_v2_generated_Conversations_SearchKnowledge_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "dialogflow_v2_generated_conversations_search_knowledge_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json b/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json index 2bfe03dc..7d682d15 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-dialogflow", - "version": "2.23.3" + "version": "2.24.0" }, "snippets": [ { @@ -5179,6 +5179,159 @@ ], "title": "dialogflow_v2beta1_generated_conversations_list_messages_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.dialogflow_v2beta1.ConversationsAsyncClient", + "shortName": "ConversationsAsyncClient" + }, + "fullName": "google.cloud.dialogflow_v2beta1.ConversationsAsyncClient.search_knowledge", + "method": { + "fullName": "google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge", + "service": { + "fullName": "google.cloud.dialogflow.v2beta1.Conversations", + "shortName": "Conversations" + }, + "shortName": "SearchKnowledge" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.dialogflow_v2beta1.types.SearchKnowledgeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.dialogflow_v2beta1.types.SearchKnowledgeResponse", + "shortName": "search_knowledge" + }, + "description": "Sample for SearchKnowledge", + "file": "dialogflow_v2beta1_generated_conversations_search_knowledge_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "dialogflow_v2beta1_generated_Conversations_SearchKnowledge_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "dialogflow_v2beta1_generated_conversations_search_knowledge_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.dialogflow_v2beta1.ConversationsClient", + "shortName": "ConversationsClient" + }, + "fullName": "google.cloud.dialogflow_v2beta1.ConversationsClient.search_knowledge", + "method": { + "fullName": "google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge", + "service": { + "fullName": "google.cloud.dialogflow.v2beta1.Conversations", + "shortName": "Conversations" + }, + "shortName": "SearchKnowledge" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.dialogflow_v2beta1.types.SearchKnowledgeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.dialogflow_v2beta1.types.SearchKnowledgeResponse", + "shortName": "search_knowledge" + }, + "description": "Sample for SearchKnowledge", + "file": "dialogflow_v2beta1_generated_conversations_search_knowledge_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "dialogflow_v2beta1_generated_Conversations_SearchKnowledge_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "dialogflow_v2beta1_generated_conversations_search_knowledge_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/scripts/fixup_dialogflow_v2_keywords.py b/scripts/fixup_dialogflow_v2_keywords.py index 1dd94f02..584f1e81 100644 --- a/scripts/fixup_dialogflow_v2_keywords.py +++ b/scripts/fixup_dialogflow_v2_keywords.py @@ -39,7 +39,7 @@ def partition( class dialogflowCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'analyze_content': ('participant', 'text_input', 'event_input', 'reply_audio_config', 'query_params', 'assist_query_params', 'cx_parameters', 'request_id', ), + 'analyze_content': ('participant', 'text_input', 'event_input', 'suggestion_input', 'reply_audio_config', 'query_params', 'assist_query_params', 'cx_parameters', 'request_id', ), 'batch_create_entities': ('parent', 'entities', 'language_code', ), 'batch_delete_entities': ('parent', 'entity_values', 'language_code', ), 'batch_delete_entity_types': ('parent', 'entity_type_names', ), @@ -121,6 +121,7 @@ class dialogflowCallTransformer(cst.CSTTransformer): 'reload_document': ('name', 'content_uri', 'import_gcs_custom_metadata', 'smart_messaging_partial_update', ), 'restore_agent': ('parent', 'agent_uri', 'agent_content', ), 'search_agents': ('parent', 'page_size', 'page_token', ), + 'search_knowledge': ('query', 'conversation_profile', 'parent', 'session_id', 'conversation', 'latest_message', ), 'set_agent': ('agent', 'update_mask', ), 'set_suggestion_feature_config': ('conversation_profile', 'participant_role', 'suggestion_feature_config', ), 'streaming_analyze_content': ('participant', 'audio_config', 'text_config', 'reply_audio_config', 'input_audio', 'input_text', 'input_dtmf', 'query_params', 'assist_query_params', 'cx_parameters', 'enable_partial_automated_agent_reply', 'enable_debugging_info', ), diff --git a/scripts/fixup_dialogflow_v2beta1_keywords.py b/scripts/fixup_dialogflow_v2beta1_keywords.py index 5f46862c..26a9e1d9 100644 --- a/scripts/fixup_dialogflow_v2beta1_keywords.py +++ b/scripts/fixup_dialogflow_v2beta1_keywords.py @@ -111,6 +111,7 @@ class dialogflowCallTransformer(cst.CSTTransformer): 'reload_document': ('name', 'gcs_source', 'import_gcs_custom_metadata', ), 'restore_agent': ('parent', 'agent_uri', 'agent_content', ), 'search_agents': ('parent', 'page_size', 'page_token', ), + 'search_knowledge': ('query', 'conversation_profile', 'parent', 'session_id', 'conversation', 'latest_message', ), 'set_agent': ('agent', 'update_mask', ), 'set_suggestion_feature_config': ('conversation_profile', 'participant_role', 'suggestion_feature_config', ), 'streaming_analyze_content': ('participant', 'audio_config', 'text_config', 'reply_audio_config', 'input_audio', 'input_text', 'input_dtmf', 'query_params', 'assist_query_params', 'cx_parameters', 'cx_current_page', 'enable_partial_automated_agent_reply', 'enable_debugging_info', ), diff --git a/tests/unit/gapic/dialogflow_v2/test_agents.py b/tests/unit/gapic/dialogflow_v2/test_agents.py index 5d20706c..71ead343 100644 --- a/tests/unit/gapic/dialogflow_v2/test_agents.py +++ b/tests/unit/gapic/dialogflow_v2/test_agents.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2/test_answer_records.py b/tests/unit/gapic/dialogflow_v2/test_answer_records.py index 58f00dd1..b879bdcf 100644 --- a/tests/unit/gapic/dialogflow_v2/test_answer_records.py +++ b/tests/unit/gapic/dialogflow_v2/test_answer_records.py @@ -33,10 +33,11 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format +from google.protobuf import struct_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore import grpc from grpc.experimental import aio @@ -52,9 +53,9 @@ pagers, transports, ) +from google.cloud.dialogflow_v2.types import context, intent, participant, session from google.cloud.dialogflow_v2.types import answer_record from google.cloud.dialogflow_v2.types import answer_record as gcd_answer_record -from google.cloud.dialogflow_v2.types import participant def client_cert_source_callback(): @@ -1780,6 +1781,10 @@ def test_update_answer_record_rest(request_type): "submit_time": {}, "summary_text": "summary_text_value", }, + "knowledge_search_feedback": { + "answer_copied": True, + "clicked_uris": ["clicked_uris_value1", "clicked_uris_value2"], + }, }, "clicked": True, "click_time": {}, @@ -1803,6 +1808,217 @@ def test_update_answer_record_rest(request_type): "metadata": {}, "answer_record": "answer_record_value", }, + "dialogflow_assist_answer": { + "query_result": { + "query_text": "query_text_value", + "language_code": "language_code_value", + "speech_recognition_confidence": 0.3045, + "action": "action_value", + "parameters": {"fields": {}}, + "all_required_params_present": True, + "cancels_slot_filling": True, + "fulfillment_text": "fulfillment_text_value", + "fulfillment_messages": [ + { + "text": {"text": ["text_value1", "text_value2"]}, + "image": { + "image_uri": "image_uri_value", + "accessibility_text": "accessibility_text_value", + }, + "quick_replies": { + "title": "title_value", + "quick_replies": [ + "quick_replies_value1", + "quick_replies_value2", + ], + }, + "card": { + "title": "title_value", + "subtitle": "subtitle_value", + "image_uri": "image_uri_value", + "buttons": [ + {"text": "text_value", "postback": "postback_value"} + ], + }, + "payload": {}, + "simple_responses": { + "simple_responses": [ + { + "text_to_speech": "text_to_speech_value", + "ssml": "ssml_value", + "display_text": "display_text_value", + } + ] + }, + "basic_card": { + "title": "title_value", + "subtitle": "subtitle_value", + "formatted_text": "formatted_text_value", + "image": {}, + "buttons": [ + { + "title": "title_value", + "open_uri_action": {"uri": "uri_value"}, + } + ], + }, + "suggestions": {"suggestions": [{"title": "title_value"}]}, + "link_out_suggestion": { + "destination_name": "destination_name_value", + "uri": "uri_value", + }, + "list_select": { + "title": "title_value", + "items": [ + { + "info": { + "key": "key_value", + "synonyms": [ + "synonyms_value1", + "synonyms_value2", + ], + }, + "title": "title_value", + "description": "description_value", + "image": {}, + } + ], + "subtitle": "subtitle_value", + }, + "carousel_select": { + "items": [ + { + "info": {}, + "title": "title_value", + "description": "description_value", + "image": {}, + } + ] + }, + "browse_carousel_card": { + "items": [ + { + "open_uri_action": { + "url": "url_value", + "url_type_hint": 1, + }, + "title": "title_value", + "description": "description_value", + "image": {}, + "footer": "footer_value", + } + ], + "image_display_options": 1, + }, + "table_card": { + "title": "title_value", + "subtitle": "subtitle_value", + "image": {}, + "column_properties": [ + { + "header": "header_value", + "horizontal_alignment": 1, + } + ], + "rows": [ + { + "cells": [{"text": "text_value"}], + "divider_after": True, + } + ], + "buttons": {}, + }, + "media_content": { + "media_type": 1, + "media_objects": [ + { + "name": "name_value", + "description": "description_value", + "large_image": {}, + "icon": {}, + "content_url": "content_url_value", + } + ], + }, + "platform": 1, + } + ], + "webhook_source": "webhook_source_value", + "webhook_payload": {}, + "output_contexts": [ + {"name": "name_value", "lifespan_count": 1498, "parameters": {}} + ], + "intent": { + "name": "name_value", + "display_name": "display_name_value", + "webhook_state": 1, + "priority": 898, + "is_fallback": True, + "ml_disabled": True, + "live_agent_handoff": True, + "end_interaction": True, + "input_context_names": [ + "input_context_names_value1", + "input_context_names_value2", + ], + "events": ["events_value1", "events_value2"], + "training_phrases": [ + { + "name": "name_value", + "type_": 1, + "parts": [ + { + "text": "text_value", + "entity_type": "entity_type_value", + "alias": "alias_value", + "user_defined": True, + } + ], + "times_added_count": 1787, + } + ], + "action": "action_value", + "output_contexts": {}, + "reset_contexts": True, + "parameters": [ + { + "name": "name_value", + "display_name": "display_name_value", + "value": "value_value", + "default_value": "default_value_value", + "entity_type_display_name": "entity_type_display_name_value", + "mandatory": True, + "prompts": ["prompts_value1", "prompts_value2"], + "is_list": True, + } + ], + "messages": {}, + "default_response_platforms": [1], + "root_followup_intent_name": "root_followup_intent_name_value", + "parent_followup_intent_name": "parent_followup_intent_name_value", + "followup_intent_info": [ + { + "followup_intent_name": "followup_intent_name_value", + "parent_followup_intent_name": "parent_followup_intent_name_value", + } + ], + }, + "intent_detection_confidence": 0.28450000000000003, + "diagnostic_info": {}, + "sentiment_analysis_result": { + "query_text_sentiment": { + "score": 0.54, + "magnitude": 0.9580000000000001, + } + }, + }, + "intent_suggestion": { + "display_name": "display_name_value", + "intent_v2": "intent_v2_value", + "description": "description_value", + }, + "answer_record": "answer_record_value", + }, }, } request = request_type(**request_init) @@ -2001,6 +2217,10 @@ def test_update_answer_record_rest_bad_request( "submit_time": {}, "summary_text": "summary_text_value", }, + "knowledge_search_feedback": { + "answer_copied": True, + "clicked_uris": ["clicked_uris_value1", "clicked_uris_value2"], + }, }, "clicked": True, "click_time": {}, @@ -2024,6 +2244,217 @@ def test_update_answer_record_rest_bad_request( "metadata": {}, "answer_record": "answer_record_value", }, + "dialogflow_assist_answer": { + "query_result": { + "query_text": "query_text_value", + "language_code": "language_code_value", + "speech_recognition_confidence": 0.3045, + "action": "action_value", + "parameters": {"fields": {}}, + "all_required_params_present": True, + "cancels_slot_filling": True, + "fulfillment_text": "fulfillment_text_value", + "fulfillment_messages": [ + { + "text": {"text": ["text_value1", "text_value2"]}, + "image": { + "image_uri": "image_uri_value", + "accessibility_text": "accessibility_text_value", + }, + "quick_replies": { + "title": "title_value", + "quick_replies": [ + "quick_replies_value1", + "quick_replies_value2", + ], + }, + "card": { + "title": "title_value", + "subtitle": "subtitle_value", + "image_uri": "image_uri_value", + "buttons": [ + {"text": "text_value", "postback": "postback_value"} + ], + }, + "payload": {}, + "simple_responses": { + "simple_responses": [ + { + "text_to_speech": "text_to_speech_value", + "ssml": "ssml_value", + "display_text": "display_text_value", + } + ] + }, + "basic_card": { + "title": "title_value", + "subtitle": "subtitle_value", + "formatted_text": "formatted_text_value", + "image": {}, + "buttons": [ + { + "title": "title_value", + "open_uri_action": {"uri": "uri_value"}, + } + ], + }, + "suggestions": {"suggestions": [{"title": "title_value"}]}, + "link_out_suggestion": { + "destination_name": "destination_name_value", + "uri": "uri_value", + }, + "list_select": { + "title": "title_value", + "items": [ + { + "info": { + "key": "key_value", + "synonyms": [ + "synonyms_value1", + "synonyms_value2", + ], + }, + "title": "title_value", + "description": "description_value", + "image": {}, + } + ], + "subtitle": "subtitle_value", + }, + "carousel_select": { + "items": [ + { + "info": {}, + "title": "title_value", + "description": "description_value", + "image": {}, + } + ] + }, + "browse_carousel_card": { + "items": [ + { + "open_uri_action": { + "url": "url_value", + "url_type_hint": 1, + }, + "title": "title_value", + "description": "description_value", + "image": {}, + "footer": "footer_value", + } + ], + "image_display_options": 1, + }, + "table_card": { + "title": "title_value", + "subtitle": "subtitle_value", + "image": {}, + "column_properties": [ + { + "header": "header_value", + "horizontal_alignment": 1, + } + ], + "rows": [ + { + "cells": [{"text": "text_value"}], + "divider_after": True, + } + ], + "buttons": {}, + }, + "media_content": { + "media_type": 1, + "media_objects": [ + { + "name": "name_value", + "description": "description_value", + "large_image": {}, + "icon": {}, + "content_url": "content_url_value", + } + ], + }, + "platform": 1, + } + ], + "webhook_source": "webhook_source_value", + "webhook_payload": {}, + "output_contexts": [ + {"name": "name_value", "lifespan_count": 1498, "parameters": {}} + ], + "intent": { + "name": "name_value", + "display_name": "display_name_value", + "webhook_state": 1, + "priority": 898, + "is_fallback": True, + "ml_disabled": True, + "live_agent_handoff": True, + "end_interaction": True, + "input_context_names": [ + "input_context_names_value1", + "input_context_names_value2", + ], + "events": ["events_value1", "events_value2"], + "training_phrases": [ + { + "name": "name_value", + "type_": 1, + "parts": [ + { + "text": "text_value", + "entity_type": "entity_type_value", + "alias": "alias_value", + "user_defined": True, + } + ], + "times_added_count": 1787, + } + ], + "action": "action_value", + "output_contexts": {}, + "reset_contexts": True, + "parameters": [ + { + "name": "name_value", + "display_name": "display_name_value", + "value": "value_value", + "default_value": "default_value_value", + "entity_type_display_name": "entity_type_display_name_value", + "mandatory": True, + "prompts": ["prompts_value1", "prompts_value2"], + "is_list": True, + } + ], + "messages": {}, + "default_response_platforms": [1], + "root_followup_intent_name": "root_followup_intent_name_value", + "parent_followup_intent_name": "parent_followup_intent_name_value", + "followup_intent_info": [ + { + "followup_intent_name": "followup_intent_name_value", + "parent_followup_intent_name": "parent_followup_intent_name_value", + } + ], + }, + "intent_detection_confidence": 0.28450000000000003, + "diagnostic_info": {}, + "sentiment_analysis_result": { + "query_text_sentiment": { + "score": 0.54, + "magnitude": 0.9580000000000001, + } + }, + }, + "intent_suggestion": { + "display_name": "display_name_value", + "intent_v2": "intent_v2_value", + "description": "description_value", + }, + "answer_record": "answer_record_value", + }, }, } request = request_type(**request_init) @@ -2677,8 +3108,57 @@ def test_parse_answer_record_path(): assert expected == actual +def test_context_path(): + project = "oyster" + session = "nudibranch" + context = "cuttlefish" + expected = "projects/{project}/agent/sessions/{session}/contexts/{context}".format( + project=project, + session=session, + context=context, + ) + actual = AnswerRecordsClient.context_path(project, session, context) + assert expected == actual + + +def test_parse_context_path(): + expected = { + "project": "mussel", + "session": "winkle", + "context": "nautilus", + } + path = AnswerRecordsClient.context_path(**expected) + + # Check that the path construction is reversible. + actual = AnswerRecordsClient.parse_context_path(path) + assert expected == actual + + +def test_intent_path(): + project = "scallop" + intent = "abalone" + expected = "projects/{project}/agent/intents/{intent}".format( + project=project, + intent=intent, + ) + actual = AnswerRecordsClient.intent_path(project, intent) + assert expected == actual + + +def test_parse_intent_path(): + expected = { + "project": "squid", + "intent": "clam", + } + path = AnswerRecordsClient.intent_path(**expected) + + # Check that the path construction is reversible. + actual = AnswerRecordsClient.parse_intent_path(path) + assert expected == actual + + def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2688,7 +3168,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "octopus", } path = AnswerRecordsClient.common_billing_account_path(**expected) @@ -2698,7 +3178,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "oyster" expected = "folders/{folder}".format( folder=folder, ) @@ -2708,7 +3188,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "nudibranch", } path = AnswerRecordsClient.common_folder_path(**expected) @@ -2718,7 +3198,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "cuttlefish" expected = "organizations/{organization}".format( organization=organization, ) @@ -2728,7 +3208,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "mussel", } path = AnswerRecordsClient.common_organization_path(**expected) @@ -2738,7 +3218,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "winkle" expected = "projects/{project}".format( project=project, ) @@ -2748,7 +3228,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "nautilus", } path = AnswerRecordsClient.common_project_path(**expected) @@ -2758,8 +3238,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -2770,8 +3250,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "squid", + "location": "clam", } path = AnswerRecordsClient.common_location_path(**expected) diff --git a/tests/unit/gapic/dialogflow_v2/test_contexts.py b/tests/unit/gapic/dialogflow_v2/test_contexts.py index 88346f16..df0389e4 100644 --- a/tests/unit/gapic/dialogflow_v2/test_contexts.py +++ b/tests/unit/gapic/dialogflow_v2/test_contexts.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py b/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py index c079c985..1ac13942 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_conversation_models.py b/tests/unit/gapic/dialogflow_v2/test_conversation_models.py index aaee227c..9138ffe5 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversation_models.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversation_models.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py b/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py index e75f391d..5e2d1399 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -3484,6 +3484,7 @@ def test_create_conversation_profile_rest(request_type): { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_smalltalk": True, "only_end_user": True, @@ -3498,7 +3499,10 @@ def test_create_conversation_profile_rest(request_type): "document_query_source": { "documents": ["documents_value1", "documents_value2"] }, - "dialogflow_query_source": {"agent": "agent_value"}, + "dialogflow_query_source": { + "agent": "agent_value", + "human_agent_side_config": {"agent": "agent_value"}, + }, "max_results": 1207, "confidence_threshold": 0.2106, "context_filter_settings": { @@ -3534,7 +3538,11 @@ def test_create_conversation_profile_rest(request_type): "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", @@ -3766,6 +3774,7 @@ def test_create_conversation_profile_rest_bad_request( { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_smalltalk": True, "only_end_user": True, @@ -3780,7 +3789,10 @@ def test_create_conversation_profile_rest_bad_request( "document_query_source": { "documents": ["documents_value1", "documents_value2"] }, - "dialogflow_query_source": {"agent": "agent_value"}, + "dialogflow_query_source": { + "agent": "agent_value", + "human_agent_side_config": {"agent": "agent_value"}, + }, "max_results": 1207, "confidence_threshold": 0.2106, "context_filter_settings": { @@ -3816,7 +3828,11 @@ def test_create_conversation_profile_rest_bad_request( "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", @@ -3947,6 +3963,7 @@ def test_update_conversation_profile_rest(request_type): { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_smalltalk": True, "only_end_user": True, @@ -3961,7 +3978,10 @@ def test_update_conversation_profile_rest(request_type): "document_query_source": { "documents": ["documents_value1", "documents_value2"] }, - "dialogflow_query_source": {"agent": "agent_value"}, + "dialogflow_query_source": { + "agent": "agent_value", + "human_agent_side_config": {"agent": "agent_value"}, + }, "max_results": 1207, "confidence_threshold": 0.2106, "context_filter_settings": { @@ -3997,7 +4017,11 @@ def test_update_conversation_profile_rest(request_type): "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", @@ -4230,6 +4254,7 @@ def test_update_conversation_profile_rest_bad_request( { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_smalltalk": True, "only_end_user": True, @@ -4244,7 +4269,10 @@ def test_update_conversation_profile_rest_bad_request( "document_query_source": { "documents": ["documents_value1", "documents_value2"] }, - "dialogflow_query_source": {"agent": "agent_value"}, + "dialogflow_query_source": { + "agent": "agent_value", + "human_agent_side_config": {"agent": "agent_value"}, + }, "max_results": 1207, "confidence_threshold": 0.2106, "context_filter_settings": { @@ -4280,7 +4308,11 @@ def test_update_conversation_profile_rest_bad_request( "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", diff --git a/tests/unit/gapic/dialogflow_v2/test_conversations.py b/tests/unit/gapic/dialogflow_v2/test_conversations.py index 178a5b0e..5c9b6997 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversations.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversations.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore from google.protobuf import json_format @@ -2799,6 +2799,150 @@ async def test_generate_stateless_summary_field_headers_async(): ) in kw["metadata"] +@pytest.mark.parametrize( + "request_type", + [ + conversation.SearchKnowledgeRequest, + dict, + ], +) +def test_search_knowledge(request_type, transport: str = "grpc"): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = conversation.SearchKnowledgeResponse() + response = client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == conversation.SearchKnowledgeRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, conversation.SearchKnowledgeResponse) + + +def test_search_knowledge_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + client.search_knowledge() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == conversation.SearchKnowledgeRequest() + + +@pytest.mark.asyncio +async def test_search_knowledge_async( + transport: str = "grpc_asyncio", request_type=conversation.SearchKnowledgeRequest +): + client = ConversationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + conversation.SearchKnowledgeResponse() + ) + response = await client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == conversation.SearchKnowledgeRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, conversation.SearchKnowledgeResponse) + + +@pytest.mark.asyncio +async def test_search_knowledge_async_from_dict(): + await test_search_knowledge_async(request_type=dict) + + +def test_search_knowledge_field_headers(): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = conversation.SearchKnowledgeRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + call.return_value = conversation.SearchKnowledgeResponse() + client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_search_knowledge_field_headers_async(): + client = ConversationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = conversation.SearchKnowledgeRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + conversation.SearchKnowledgeResponse() + ) + await client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + @pytest.mark.parametrize( "request_type", [ @@ -4846,6 +4990,224 @@ def test_generate_stateless_summary_rest_error(): ) +@pytest.mark.parametrize( + "request_type", + [ + conversation.SearchKnowledgeRequest, + dict, + ], +) +def test_search_knowledge_rest(request_type): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = conversation.SearchKnowledgeResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = conversation.SearchKnowledgeResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.search_knowledge(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, conversation.SearchKnowledgeResponse) + + +def test_search_knowledge_rest_required_fields( + request_type=conversation.SearchKnowledgeRequest, +): + transport_class = transports.ConversationsRestTransport + + request_init = {} + request_init["conversation_profile"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).search_knowledge._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["conversationProfile"] = "conversation_profile_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).search_knowledge._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "conversationProfile" in jsonified_request + assert jsonified_request["conversationProfile"] == "conversation_profile_value" + + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = conversation.SearchKnowledgeResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = conversation.SearchKnowledgeResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.search_knowledge(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_search_knowledge_rest_unset_required_fields(): + transport = transports.ConversationsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.search_knowledge._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "query", + "conversationProfile", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_search_knowledge_rest_interceptors(null_interceptor): + transport = transports.ConversationsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ConversationsRestInterceptor(), + ) + client = ConversationsClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ConversationsRestInterceptor, "post_search_knowledge" + ) as post, mock.patch.object( + transports.ConversationsRestInterceptor, "pre_search_knowledge" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = conversation.SearchKnowledgeRequest.pb( + conversation.SearchKnowledgeRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = conversation.SearchKnowledgeResponse.to_json( + conversation.SearchKnowledgeResponse() + ) + + request = conversation.SearchKnowledgeRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = conversation.SearchKnowledgeResponse() + + client.search_knowledge( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_search_knowledge_rest_bad_request( + transport: str = "rest", request_type=conversation.SearchKnowledgeRequest +): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.search_knowledge(request) + + +def test_search_knowledge_rest_error(): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ConversationsGrpcTransport( @@ -4992,6 +5354,7 @@ def test_conversations_base_transport(): "list_messages", "suggest_conversation_summary", "generate_stateless_summary", + "search_knowledge", "get_location", "list_locations", "get_operation", @@ -5288,6 +5651,9 @@ def test_conversations_client_transport_session_collision(transport_name): session1 = client1.transport.generate_stateless_summary._session session2 = client2.transport.generate_stateless_summary._session assert session1 != session2 + session1 = client1.transport.search_knowledge._session + session2 = client2.transport.search_knowledge._session + assert session1 != session2 def test_conversations_grpc_transport_channel(): diff --git a/tests/unit/gapic/dialogflow_v2/test_documents.py b/tests/unit/gapic/dialogflow_v2/test_documents.py index 91fbf3a6..35c34bd9 100644 --- a/tests/unit/gapic/dialogflow_v2/test_documents.py +++ b/tests/unit/gapic/dialogflow_v2/test_documents.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import any_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2/test_entity_types.py b/tests/unit/gapic/dialogflow_v2/test_entity_types.py index cd3c0089..cfb1f272 100644 --- a/tests/unit/gapic/dialogflow_v2/test_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2/test_entity_types.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2/test_environments.py b/tests/unit/gapic/dialogflow_v2/test_environments.py index 5d71346f..37e467fb 100644 --- a/tests/unit/gapic/dialogflow_v2/test_environments.py +++ b/tests/unit/gapic/dialogflow_v2/test_environments.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_fulfillments.py b/tests/unit/gapic/dialogflow_v2/test_fulfillments.py index 410b3451..fb6c4812 100644 --- a/tests/unit/gapic/dialogflow_v2/test_fulfillments.py +++ b/tests/unit/gapic/dialogflow_v2/test_fulfillments.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_intents.py b/tests/unit/gapic/dialogflow_v2/test_intents.py index 5746110b..2700d8e9 100644 --- a/tests/unit/gapic/dialogflow_v2/test_intents.py +++ b/tests/unit/gapic/dialogflow_v2/test_intents.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py b/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py index 53a09d71..39dfddb7 100644 --- a/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py +++ b/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_participants.py b/tests/unit/gapic/dialogflow_v2/test_participants.py index 4aaeff79..d7065c67 100644 --- a/tests/unit/gapic/dialogflow_v2/test_participants.py +++ b/tests/unit/gapic/dialogflow_v2/test_participants.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py b/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py index c97947cb..b33ab733 100644 --- a/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_sessions.py b/tests/unit/gapic/dialogflow_v2/test_sessions.py index 43caa469..c1de2aa0 100644 --- a/tests/unit/gapic/dialogflow_v2/test_sessions.py +++ b/tests/unit/gapic/dialogflow_v2/test_sessions.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2/test_versions.py b/tests/unit/gapic/dialogflow_v2/test_versions.py index d17c01f2..dab2d55c 100644 --- a/tests/unit/gapic/dialogflow_v2/test_versions.py +++ b/tests/unit/gapic/dialogflow_v2/test_versions.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_agents.py b/tests/unit/gapic/dialogflow_v2beta1/test_agents.py index d0b52a99..519e48c9 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_agents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_agents.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py b/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py index 1dff68fc..456c34f2 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format @@ -1965,6 +1965,10 @@ def test_update_answer_record_rest(request_type): "submit_timestamp": {}, "summary_text": "summary_text_value", }, + "knowledge_search_feedback": { + "answer_copied": True, + "clicked_uris": ["clicked_uris_value1", "clicked_uris_value2"], + }, }, "clicked": True, "click_time": {}, @@ -2446,6 +2450,10 @@ def test_update_answer_record_rest_bad_request( "submit_timestamp": {}, "summary_text": "summary_text_value", }, + "knowledge_search_feedback": { + "answer_copied": True, + "clicked_uris": ["clicked_uris_value1", "clicked_uris_value2"], + }, }, "clicked": True, "click_time": {}, diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py b/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py index 463aa6dd..a2789892 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py b/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py index a1197b7a..388aa7a0 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -3490,6 +3490,7 @@ def test_create_conversation_profile_rest(request_type): { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_small_talk": True, "only_end_user": True, @@ -3543,7 +3544,11 @@ def test_create_conversation_profile_rest(request_type): "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", @@ -3775,6 +3780,7 @@ def test_create_conversation_profile_rest_bad_request( { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_small_talk": True, "only_end_user": True, @@ -3828,7 +3834,11 @@ def test_create_conversation_profile_rest_bad_request( "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", @@ -3960,6 +3970,7 @@ def test_update_conversation_profile_rest(request_type): { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_small_talk": True, "only_end_user": True, @@ -4013,7 +4024,11 @@ def test_update_conversation_profile_rest(request_type): "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", @@ -4246,6 +4261,7 @@ def test_update_conversation_profile_rest_bad_request( { "suggestion_feature": {"type_": 1}, "enable_event_based_suggestion": True, + "disable_agent_query_logging": True, "suggestion_trigger_settings": { "no_small_talk": True, "only_end_user": True, @@ -4299,7 +4315,11 @@ def test_update_conversation_profile_rest_bad_request( "notification_config": {}, "logging_config": {"enable_stackdriver_logging": True}, "new_message_event_notification_config": {}, - "stt_config": {"speech_model_variant": 1, "model": "model_value"}, + "stt_config": { + "speech_model_variant": 1, + "model": "model_value", + "use_timeout_based_endpointing": True, + }, "language_code": "language_code_value", "time_zone": "time_zone_value", "security_settings": "security_settings_value", diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py b/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py index 9ccd8e23..d06f65cb 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore from google.protobuf import json_format @@ -3044,6 +3044,150 @@ async def test_generate_stateless_summary_field_headers_async(): ) in kw["metadata"] +@pytest.mark.parametrize( + "request_type", + [ + conversation.SearchKnowledgeRequest, + dict, + ], +) +def test_search_knowledge(request_type, transport: str = "grpc"): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = conversation.SearchKnowledgeResponse() + response = client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == conversation.SearchKnowledgeRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, conversation.SearchKnowledgeResponse) + + +def test_search_knowledge_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + client.search_knowledge() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == conversation.SearchKnowledgeRequest() + + +@pytest.mark.asyncio +async def test_search_knowledge_async( + transport: str = "grpc_asyncio", request_type=conversation.SearchKnowledgeRequest +): + client = ConversationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + conversation.SearchKnowledgeResponse() + ) + response = await client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == conversation.SearchKnowledgeRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, conversation.SearchKnowledgeResponse) + + +@pytest.mark.asyncio +async def test_search_knowledge_async_from_dict(): + await test_search_knowledge_async(request_type=dict) + + +def test_search_knowledge_field_headers(): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = conversation.SearchKnowledgeRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + call.return_value = conversation.SearchKnowledgeResponse() + client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_search_knowledge_field_headers_async(): + client = ConversationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = conversation.SearchKnowledgeRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_knowledge), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + conversation.SearchKnowledgeResponse() + ) + await client.search_knowledge(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + @pytest.mark.parametrize( "request_type", [ @@ -5369,6 +5513,224 @@ def test_generate_stateless_summary_rest_error(): ) +@pytest.mark.parametrize( + "request_type", + [ + conversation.SearchKnowledgeRequest, + dict, + ], +) +def test_search_knowledge_rest(request_type): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = conversation.SearchKnowledgeResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = conversation.SearchKnowledgeResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.search_knowledge(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, conversation.SearchKnowledgeResponse) + + +def test_search_knowledge_rest_required_fields( + request_type=conversation.SearchKnowledgeRequest, +): + transport_class = transports.ConversationsRestTransport + + request_init = {} + request_init["conversation_profile"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).search_knowledge._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["conversationProfile"] = "conversation_profile_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).search_knowledge._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "conversationProfile" in jsonified_request + assert jsonified_request["conversationProfile"] == "conversation_profile_value" + + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = conversation.SearchKnowledgeResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = conversation.SearchKnowledgeResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.search_knowledge(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_search_knowledge_rest_unset_required_fields(): + transport = transports.ConversationsRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.search_knowledge._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "query", + "conversationProfile", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_search_knowledge_rest_interceptors(null_interceptor): + transport = transports.ConversationsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ConversationsRestInterceptor(), + ) + client = ConversationsClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ConversationsRestInterceptor, "post_search_knowledge" + ) as post, mock.patch.object( + transports.ConversationsRestInterceptor, "pre_search_knowledge" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = conversation.SearchKnowledgeRequest.pb( + conversation.SearchKnowledgeRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = conversation.SearchKnowledgeResponse.to_json( + conversation.SearchKnowledgeResponse() + ) + + request = conversation.SearchKnowledgeRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = conversation.SearchKnowledgeResponse() + + client.search_knowledge( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_search_knowledge_rest_bad_request( + transport: str = "rest", request_type=conversation.SearchKnowledgeRequest +): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.search_knowledge(request) + + +def test_search_knowledge_rest_error(): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ConversationsGrpcTransport( @@ -5516,6 +5878,7 @@ def test_conversations_base_transport(): "list_messages", "suggest_conversation_summary", "generate_stateless_summary", + "search_knowledge", "get_location", "list_locations", "get_operation", @@ -5815,6 +6178,9 @@ def test_conversations_client_transport_session_collision(transport_name): session1 = client1.transport.generate_stateless_summary._session session2 = client2.transport.generate_stateless_summary._session assert session1 != session2 + session1 = client1.transport.search_knowledge._session + session2 = client2.transport.search_knowledge._session + assert session1 != session2 def test_conversations_grpc_transport_channel(): diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_documents.py b/tests/unit/gapic/dialogflow_v2beta1/test_documents.py index 6d5576e7..077db2ab 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_documents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_documents.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import any_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py b/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py index ef0a2e0a..c35916b2 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_environments.py b/tests/unit/gapic/dialogflow_v2beta1/test_environments.py index fc497a44..d8399ea1 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_environments.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_environments.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py b/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py index ee3d3324..1a449358 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_intents.py b/tests/unit/gapic/dialogflow_v2beta1/test_intents.py index 062702ad..f89c5bfd 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_intents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_intents.py @@ -42,7 +42,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py b/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py index b940bc76..d574d743 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_participants.py b/tests/unit/gapic/dialogflow_v2beta1/test_participants.py index a710aced..563ad2c4 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_participants.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_participants.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py b/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py index 64b53455..3b559904 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py b/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py index ce28066c..46f91c98 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore diff --git a/tests/unit/gapic/dialogflow_v2beta1/test_versions.py b/tests/unit/gapic/dialogflow_v2beta1/test_versions.py index b49c52af..c73c6c67 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_versions.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_versions.py @@ -33,7 +33,7 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.location import locations_pb2 -from google.longrunning import operations_pb2 +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import json_format pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy