diff --git a/packages/google-cloud-retail/google/cloud/retail/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail/gapic_version.py index 07924fc8c5a0..20a9cd975b02 100644 --- a/packages/google-cloud-retail/google/cloud/retail/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py index 07924fc8c5a0..20a9cd975b02 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/__init__.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/__init__.py index 8ce6eaadcae1..1e6fb43528f6 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/__init__.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/__init__.py @@ -244,6 +244,7 @@ PurgeUserEventsRequest, PurgeUserEventsResponse, ) +from .types.safety import HarmCategory, SafetySetting from .types.search_service import ( ExperimentInfo, ProductAttributeInterval, @@ -378,6 +379,7 @@ "GetProductRequest", "GetProjectRequest", "GetServingConfigRequest", + "HarmCategory", "Image", "ImportCompletionDataRequest", "ImportCompletionDataResponse", @@ -457,6 +459,7 @@ "ReplaceCatalogAttributeRequest", "ResumeModelRequest", "Rule", + "SafetySetting", "SearchRequest", "SearchResponse", "SearchServiceClient", diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py index 07924fc8c5a0..20a9cd975b02 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/__init__.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/__init__.py index b19555df6493..509209560e46 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/__init__.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/__init__.py @@ -196,6 +196,7 @@ PurgeUserEventsRequest, PurgeUserEventsResponse, ) +from .safety import HarmCategory, SafetySetting from .search_service import ( ExperimentInfo, ProductAttributeInterval, @@ -385,6 +386,8 @@ "PurgeProductsResponse", "PurgeUserEventsRequest", "PurgeUserEventsResponse", + "SafetySetting", + "HarmCategory", "ExperimentInfo", "ProductAttributeInterval", "ProductAttributeValue", diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/conversational_search_service.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/conversational_search_service.py index 70ee4c932171..2de60ad329cc 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/conversational_search_service.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/conversational_search_service.py @@ -19,7 +19,7 @@ import proto # type: ignore -from google.cloud.retail_v2alpha.types import common, search_service +from google.cloud.retail_v2alpha.types import common, safety, search_service __protobuf__ = proto.module( package="google.cloud.retail.v2alpha", @@ -95,6 +95,31 @@ class ConversationalSearchRequest(proto.Message): conversational_filtering_spec (google.cloud.retail_v2alpha.types.ConversationalSearchRequest.ConversationalFilteringSpec): Optional. This field specifies all conversational filtering related parameters. + user_labels (MutableMapping[str, str]): + Optional. The user labels applied to a resource must meet + the following requirements: + + - Each resource can have multiple labels, up to a maximum + of 64. + - Each label must be a key-value pair. + - Keys have a minimum length of 1 character and a maximum + length of 63 characters and cannot be empty. Values can + be empty and have a maximum length of 63 characters. + - Keys and values can contain only lowercase letters, + numeric characters, underscores, and dashes. All + characters must use UTF-8 encoding, and international + characters are allowed. + - The key portion of a label must be unique. However, you + can use the same key with multiple resources. + - Keys must start with a lowercase letter or international + character. + + See `Google Cloud + Document `__ + for more details. + safety_settings (MutableSequence[google.cloud.retail_v2alpha.types.SafetySetting]): + Optional. The safety settings to be applied + to the generated content. """ class SearchParams(proto.Message): @@ -228,11 +253,18 @@ class Mode(proto.Enum): Values: MODE_UNSPECIFIED (0): Default value. + DISABLED (1): + Disable Conversational Filtering. + ENABLED (2): + Enabled Conversational Filtering with default + Conversational Search. CONVERSATIONAL_FILTER_ONLY (3): Enabled Conversational Filtering without default Conversational Search. """ MODE_UNSPECIFIED = 0 + DISABLED = 1 + ENABLED = 2 CONVERSATIONAL_FILTER_ONLY = 3 enable_conversational_filtering: bool = proto.Field( @@ -289,6 +321,16 @@ class Mode(proto.Enum): number=8, message=ConversationalFilteringSpec, ) + user_labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=12, + ) + safety_settings: MutableSequence[safety.SafetySetting] = proto.RepeatedField( + proto.MESSAGE, + number=14, + message=safety.SafetySetting, + ) class ConversationalSearchResponse(proto.Message): @@ -297,6 +339,31 @@ class ConversationalSearchResponse(proto.Message): method. Attributes: + user_query_types (MutableSequence[str]): + The types Retail classifies the search query as. + + Supported values are: + + - "ADVERSARIAL" + - "CHITCHAT" + - "JAILBREAK" + - "ORDER_SUPPORT" + - "SIMPLE_PRODUCT_SEARCH" + - "INTENT_REFINEMENT" + - "PRODUCT_DETAILS" + - "PRODUCT_COMPARISON" + - "DEALS_AND_COUPONS" + - "STORE_RELEVANT" + - "BLOCKLISTED" + - "BEST_PRODUCT" + - "RETAIL_SUPPORT" + - "DISABLED" clang-format off clang-format on + conversational_text_response (str): + The conversational answer-based text response + generated by the Server. + followup_question (google.cloud.retail_v2alpha.types.ConversationalSearchResponse.FollowupQuestion): + The conversational followup question + generated for Intent refinement. conversation_id (str): Conversation UUID. This field will be stored in client side storage to maintain the conversation session with server and @@ -312,8 +379,26 @@ class ConversationalSearchResponse(proto.Message): This field specifies all related information that is needed on client side for UI rendering of conversational filtering search. + state (google.cloud.retail_v2alpha.types.ConversationalSearchResponse.State): + Output only. The state of the response + generation. """ + class State(proto.Enum): + r"""The state of the response generation. + + Values: + STATE_UNSPECIFIED (0): + Unknown. + STREAMING (1): + Response generation is being streamed. + SUCCEEDED (2): + Response generation has succeeded. + """ + STATE_UNSPECIFIED = 0 + STREAMING = 1 + SUCCEEDED = 2 + class FollowupQuestion(proto.Message): r"""The conversational followup question generated for Intent refinement. @@ -419,6 +504,19 @@ class AdditionalFilter(proto.Message): message="ConversationalSearchResponse.ConversationalFilteringResult.AdditionalFilter", ) + user_query_types: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=10, + ) + conversational_text_response: str = proto.Field( + proto.STRING, + number=2, + ) + followup_question: FollowupQuestion = proto.Field( + proto.MESSAGE, + number=3, + message=FollowupQuestion, + ) conversation_id: str = proto.Field( proto.STRING, number=4, @@ -433,6 +531,11 @@ class AdditionalFilter(proto.Message): number=7, message=ConversationalFilteringResult, ) + state: State = proto.Field( + proto.ENUM, + number=9, + enum=State, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/safety.py b/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/safety.py new file mode 100644 index 000000000000..0618c41cab43 --- /dev/null +++ b/packages/google-cloud-retail/google/cloud/retail_v2alpha/types/safety.py @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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. +# +from __future__ import annotations + +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +__protobuf__ = proto.module( + package="google.cloud.retail.v2alpha", + manifest={ + "HarmCategory", + "SafetySetting", + }, +) + + +class HarmCategory(proto.Enum): + r"""Harm categories that will block the content. + + Values: + HARM_CATEGORY_UNSPECIFIED (0): + The harm category is unspecified. + HARM_CATEGORY_HATE_SPEECH (1): + The harm category is hate speech. + HARM_CATEGORY_DANGEROUS_CONTENT (2): + The harm category is dangerous content. + HARM_CATEGORY_HARASSMENT (3): + The harm category is harassment. + HARM_CATEGORY_SEXUALLY_EXPLICIT (4): + The harm category is sexually explicit + content. + HARM_CATEGORY_CIVIC_INTEGRITY (5): + The harm category is civic integrity. + """ + HARM_CATEGORY_UNSPECIFIED = 0 + HARM_CATEGORY_HATE_SPEECH = 1 + HARM_CATEGORY_DANGEROUS_CONTENT = 2 + HARM_CATEGORY_HARASSMENT = 3 + HARM_CATEGORY_SEXUALLY_EXPLICIT = 4 + HARM_CATEGORY_CIVIC_INTEGRITY = 5 + + +class SafetySetting(proto.Message): + r"""Safety settings. + + Attributes: + category (google.cloud.retail_v2alpha.types.HarmCategory): + Harm category. + threshold (google.cloud.retail_v2alpha.types.SafetySetting.HarmBlockThreshold): + The harm block threshold. + method (google.cloud.retail_v2alpha.types.SafetySetting.HarmBlockMethod): + Optional. Specify if the threshold is used + for probability or severity score. If not + specified, the threshold is used for probability + score. + """ + + class HarmBlockThreshold(proto.Enum): + r"""Probability based thresholds levels for blocking. + + Values: + HARM_BLOCK_THRESHOLD_UNSPECIFIED (0): + Unspecified harm block threshold. + BLOCK_LOW_AND_ABOVE (1): + Block low threshold and above (i.e. block + more). + BLOCK_MEDIUM_AND_ABOVE (2): + Block medium threshold and above. + BLOCK_ONLY_HIGH (3): + Block only high threshold (i.e. block less). + BLOCK_NONE (4): + Block none. + OFF (5): + Turn off the safety filter. + """ + HARM_BLOCK_THRESHOLD_UNSPECIFIED = 0 + BLOCK_LOW_AND_ABOVE = 1 + BLOCK_MEDIUM_AND_ABOVE = 2 + BLOCK_ONLY_HIGH = 3 + BLOCK_NONE = 4 + OFF = 5 + + class HarmBlockMethod(proto.Enum): + r"""Probability vs severity. + + Values: + HARM_BLOCK_METHOD_UNSPECIFIED (0): + The harm block method is unspecified. + SEVERITY (1): + The harm block method uses both probability + and severity scores. + PROBABILITY (2): + The harm block method uses the probability + score. + """ + HARM_BLOCK_METHOD_UNSPECIFIED = 0 + SEVERITY = 1 + PROBABILITY = 2 + + category: "HarmCategory" = proto.Field( + proto.ENUM, + number=1, + enum="HarmCategory", + ) + threshold: HarmBlockThreshold = proto.Field( + proto.ENUM, + number=2, + enum=HarmBlockThreshold, + ) + method: HarmBlockMethod = proto.Field( + proto.ENUM, + number=3, + enum=HarmBlockMethod, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py b/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py index 07924fc8c5a0..20a9cd975b02 100644 --- a/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py +++ b/packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json index 1c2f193f9574..2551a0da71ff 100644 --- a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json +++ b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-retail", - "version": "2.4.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json index 6762949e46cb..72ad4687f06d 100644 --- a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json +++ b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-retail", - "version": "2.4.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json index 9b5a8309535c..5b91d0f376d7 100644 --- a/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json +++ b/packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-retail", - "version": "2.4.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-retail/scripts/fixup_retail_v2alpha_keywords.py b/packages/google-cloud-retail/scripts/fixup_retail_v2alpha_keywords.py index 4618b9f1bb81..30b3fe5f6b9f 100644 --- a/packages/google-cloud-retail/scripts/fixup_retail_v2alpha_keywords.py +++ b/packages/google-cloud-retail/scripts/fixup_retail_v2alpha_keywords.py @@ -48,7 +48,7 @@ class retailCallTransformer(cst.CSTTransformer): 'batch_update_generative_question_configs': ('requests', 'parent', ), 'collect_user_event': ('parent', 'user_event', 'prebuilt_rule', 'uri', 'ets', 'raw_json', ), 'complete_query': ('catalog', 'query', 'visitor_id', 'language_codes', 'device_type', 'dataset', 'max_suggestions', 'enable_attribute_suggestions', 'entity', ), - 'conversational_search': ('placement', 'branch', 'visitor_id', 'query', 'page_categories', 'conversation_id', 'search_params', 'user_info', 'conversational_filtering_spec', ), + 'conversational_search': ('placement', 'branch', 'visitor_id', 'query', 'page_categories', 'conversation_id', 'search_params', 'user_info', 'conversational_filtering_spec', 'user_labels', 'safety_settings', ), 'create_control': ('parent', 'control', 'control_id', ), 'create_merchant_center_account_link': ('parent', 'merchant_center_account_link', ), 'create_model': ('parent', 'model', 'dry_run', ), diff --git a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_conversational_search_service.py b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_conversational_search_service.py index 70a363469ad1..0b0183721f61 100644 --- a/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_conversational_search_service.py +++ b/packages/google-cloud-retail/tests/unit/gapic/retail_v2alpha/test_conversational_search_service.py @@ -62,6 +62,7 @@ from google.cloud.retail_v2alpha.types import ( common, conversational_search_service, + safety, search_service, ) @@ -1845,7 +1846,10 @@ def test_conversational_search_rest_call_success(request_type): with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. return_value = conversational_search_service.ConversationalSearchResponse( + user_query_types=["user_query_types_value"], + conversational_text_response="conversational_text_response_value", conversation_id="conversation_id_value", + state=conversational_search_service.ConversationalSearchResponse.State.STREAMING, ) # Wrap the value into a proper Response obj @@ -1870,7 +1874,13 @@ def test_conversational_search_rest_call_success(request_type): assert isinstance( response, conversational_search_service.ConversationalSearchResponse ) + assert response.user_query_types == ["user_query_types_value"] + assert response.conversational_text_response == "conversational_text_response_value" assert response.conversation_id == "conversation_id_value" + assert ( + response.state + == conversational_search_service.ConversationalSearchResponse.State.STREAMING + ) @pytest.mark.parametrize("null_interceptor", [True, False])