Skip to content

Commit 848d823

Browse files
feat(v2alpha): add new fields in conversational search public SDK (#14156)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 787249742 Source-Link: googleapis/googleapis@a083dfb Source-Link: googleapis/googleapis-gen@b07c0f2 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJldGFpbC8uT3dsQm90LnlhbWwiLCJoIjoiYjA3YzBmMmY0YmFkMDBmOTk4ZDA1ZjY4MDY1ZGMxMThiYjkxOWI1MSJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 1a37e18 commit 848d823

File tree

13 files changed

+259
-9
lines changed

13 files changed

+259
-9
lines changed

packages/google-cloud-retail/google/cloud/retail/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.4.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-retail/google/cloud/retail_v2/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.4.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-retail/google/cloud/retail_v2alpha/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
PurgeUserEventsRequest,
245245
PurgeUserEventsResponse,
246246
)
247+
from .types.safety import HarmCategory, SafetySetting
247248
from .types.search_service import (
248249
ExperimentInfo,
249250
ProductAttributeInterval,
@@ -378,6 +379,7 @@
378379
"GetProductRequest",
379380
"GetProjectRequest",
380381
"GetServingConfigRequest",
382+
"HarmCategory",
381383
"Image",
382384
"ImportCompletionDataRequest",
383385
"ImportCompletionDataResponse",
@@ -457,6 +459,7 @@
457459
"ReplaceCatalogAttributeRequest",
458460
"ResumeModelRequest",
459461
"Rule",
462+
"SafetySetting",
460463
"SearchRequest",
461464
"SearchResponse",
462465
"SearchServiceClient",

packages/google-cloud-retail/google/cloud/retail_v2alpha/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.4.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-retail/google/cloud/retail_v2alpha/types/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
PurgeUserEventsRequest,
197197
PurgeUserEventsResponse,
198198
)
199+
from .safety import HarmCategory, SafetySetting
199200
from .search_service import (
200201
ExperimentInfo,
201202
ProductAttributeInterval,
@@ -385,6 +386,8 @@
385386
"PurgeProductsResponse",
386387
"PurgeUserEventsRequest",
387388
"PurgeUserEventsResponse",
389+
"SafetySetting",
390+
"HarmCategory",
388391
"ExperimentInfo",
389392
"ProductAttributeInterval",
390393
"ProductAttributeValue",

packages/google-cloud-retail/google/cloud/retail_v2alpha/types/conversational_search_service.py

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import proto # type: ignore
2121

22-
from google.cloud.retail_v2alpha.types import common, search_service
22+
from google.cloud.retail_v2alpha.types import common, safety, search_service
2323

2424
__protobuf__ = proto.module(
2525
package="google.cloud.retail.v2alpha",
@@ -95,6 +95,31 @@ class ConversationalSearchRequest(proto.Message):
9595
conversational_filtering_spec (google.cloud.retail_v2alpha.types.ConversationalSearchRequest.ConversationalFilteringSpec):
9696
Optional. This field specifies all
9797
conversational filtering related parameters.
98+
user_labels (MutableMapping[str, str]):
99+
Optional. The user labels applied to a resource must meet
100+
the following requirements:
101+
102+
- Each resource can have multiple labels, up to a maximum
103+
of 64.
104+
- Each label must be a key-value pair.
105+
- Keys have a minimum length of 1 character and a maximum
106+
length of 63 characters and cannot be empty. Values can
107+
be empty and have a maximum length of 63 characters.
108+
- Keys and values can contain only lowercase letters,
109+
numeric characters, underscores, and dashes. All
110+
characters must use UTF-8 encoding, and international
111+
characters are allowed.
112+
- The key portion of a label must be unique. However, you
113+
can use the same key with multiple resources.
114+
- Keys must start with a lowercase letter or international
115+
character.
116+
117+
See `Google Cloud
118+
Document <https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements>`__
119+
for more details.
120+
safety_settings (MutableSequence[google.cloud.retail_v2alpha.types.SafetySetting]):
121+
Optional. The safety settings to be applied
122+
to the generated content.
98123
"""
99124

100125
class SearchParams(proto.Message):
@@ -228,11 +253,18 @@ class Mode(proto.Enum):
228253
Values:
229254
MODE_UNSPECIFIED (0):
230255
Default value.
256+
DISABLED (1):
257+
Disable Conversational Filtering.
258+
ENABLED (2):
259+
Enabled Conversational Filtering with default
260+
Conversational Search.
231261
CONVERSATIONAL_FILTER_ONLY (3):
232262
Enabled Conversational Filtering without
233263
default Conversational Search.
234264
"""
235265
MODE_UNSPECIFIED = 0
266+
DISABLED = 1
267+
ENABLED = 2
236268
CONVERSATIONAL_FILTER_ONLY = 3
237269

238270
enable_conversational_filtering: bool = proto.Field(
@@ -289,6 +321,16 @@ class Mode(proto.Enum):
289321
number=8,
290322
message=ConversationalFilteringSpec,
291323
)
324+
user_labels: MutableMapping[str, str] = proto.MapField(
325+
proto.STRING,
326+
proto.STRING,
327+
number=12,
328+
)
329+
safety_settings: MutableSequence[safety.SafetySetting] = proto.RepeatedField(
330+
proto.MESSAGE,
331+
number=14,
332+
message=safety.SafetySetting,
333+
)
292334

293335

294336
class ConversationalSearchResponse(proto.Message):
@@ -297,6 +339,31 @@ class ConversationalSearchResponse(proto.Message):
297339
method.
298340
299341
Attributes:
342+
user_query_types (MutableSequence[str]):
343+
The types Retail classifies the search query as.
344+
345+
Supported values are:
346+
347+
- "ADVERSARIAL"
348+
- "CHITCHAT"
349+
- "JAILBREAK"
350+
- "ORDER_SUPPORT"
351+
- "SIMPLE_PRODUCT_SEARCH"
352+
- "INTENT_REFINEMENT"
353+
- "PRODUCT_DETAILS"
354+
- "PRODUCT_COMPARISON"
355+
- "DEALS_AND_COUPONS"
356+
- "STORE_RELEVANT"
357+
- "BLOCKLISTED"
358+
- "BEST_PRODUCT"
359+
- "RETAIL_SUPPORT"
360+
- "DISABLED" clang-format off clang-format on
361+
conversational_text_response (str):
362+
The conversational answer-based text response
363+
generated by the Server.
364+
followup_question (google.cloud.retail_v2alpha.types.ConversationalSearchResponse.FollowupQuestion):
365+
The conversational followup question
366+
generated for Intent refinement.
300367
conversation_id (str):
301368
Conversation UUID. This field will be stored in client side
302369
storage to maintain the conversation session with server and
@@ -312,8 +379,26 @@ class ConversationalSearchResponse(proto.Message):
312379
This field specifies all related information
313380
that is needed on client side for UI rendering
314381
of conversational filtering search.
382+
state (google.cloud.retail_v2alpha.types.ConversationalSearchResponse.State):
383+
Output only. The state of the response
384+
generation.
315385
"""
316386

387+
class State(proto.Enum):
388+
r"""The state of the response generation.
389+
390+
Values:
391+
STATE_UNSPECIFIED (0):
392+
Unknown.
393+
STREAMING (1):
394+
Response generation is being streamed.
395+
SUCCEEDED (2):
396+
Response generation has succeeded.
397+
"""
398+
STATE_UNSPECIFIED = 0
399+
STREAMING = 1
400+
SUCCEEDED = 2
401+
317402
class FollowupQuestion(proto.Message):
318403
r"""The conversational followup question generated for Intent
319404
refinement.
@@ -419,6 +504,19 @@ class AdditionalFilter(proto.Message):
419504
message="ConversationalSearchResponse.ConversationalFilteringResult.AdditionalFilter",
420505
)
421506

507+
user_query_types: MutableSequence[str] = proto.RepeatedField(
508+
proto.STRING,
509+
number=10,
510+
)
511+
conversational_text_response: str = proto.Field(
512+
proto.STRING,
513+
number=2,
514+
)
515+
followup_question: FollowupQuestion = proto.Field(
516+
proto.MESSAGE,
517+
number=3,
518+
message=FollowupQuestion,
519+
)
422520
conversation_id: str = proto.Field(
423521
proto.STRING,
424522
number=4,
@@ -433,6 +531,11 @@ class AdditionalFilter(proto.Message):
433531
number=7,
434532
message=ConversationalFilteringResult,
435533
)
534+
state: State = proto.Field(
535+
proto.ENUM,
536+
number=9,
537+
enum=State,
538+
)
436539

437540

438541
__all__ = tuple(sorted(__protobuf__.manifest))
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
from __future__ import annotations
17+
18+
from typing import MutableMapping, MutableSequence
19+
20+
import proto # type: ignore
21+
22+
__protobuf__ = proto.module(
23+
package="google.cloud.retail.v2alpha",
24+
manifest={
25+
"HarmCategory",
26+
"SafetySetting",
27+
},
28+
)
29+
30+
31+
class HarmCategory(proto.Enum):
32+
r"""Harm categories that will block the content.
33+
34+
Values:
35+
HARM_CATEGORY_UNSPECIFIED (0):
36+
The harm category is unspecified.
37+
HARM_CATEGORY_HATE_SPEECH (1):
38+
The harm category is hate speech.
39+
HARM_CATEGORY_DANGEROUS_CONTENT (2):
40+
The harm category is dangerous content.
41+
HARM_CATEGORY_HARASSMENT (3):
42+
The harm category is harassment.
43+
HARM_CATEGORY_SEXUALLY_EXPLICIT (4):
44+
The harm category is sexually explicit
45+
content.
46+
HARM_CATEGORY_CIVIC_INTEGRITY (5):
47+
The harm category is civic integrity.
48+
"""
49+
HARM_CATEGORY_UNSPECIFIED = 0
50+
HARM_CATEGORY_HATE_SPEECH = 1
51+
HARM_CATEGORY_DANGEROUS_CONTENT = 2
52+
HARM_CATEGORY_HARASSMENT = 3
53+
HARM_CATEGORY_SEXUALLY_EXPLICIT = 4
54+
HARM_CATEGORY_CIVIC_INTEGRITY = 5
55+
56+
57+
class SafetySetting(proto.Message):
58+
r"""Safety settings.
59+
60+
Attributes:
61+
category (google.cloud.retail_v2alpha.types.HarmCategory):
62+
Harm category.
63+
threshold (google.cloud.retail_v2alpha.types.SafetySetting.HarmBlockThreshold):
64+
The harm block threshold.
65+
method (google.cloud.retail_v2alpha.types.SafetySetting.HarmBlockMethod):
66+
Optional. Specify if the threshold is used
67+
for probability or severity score. If not
68+
specified, the threshold is used for probability
69+
score.
70+
"""
71+
72+
class HarmBlockThreshold(proto.Enum):
73+
r"""Probability based thresholds levels for blocking.
74+
75+
Values:
76+
HARM_BLOCK_THRESHOLD_UNSPECIFIED (0):
77+
Unspecified harm block threshold.
78+
BLOCK_LOW_AND_ABOVE (1):
79+
Block low threshold and above (i.e. block
80+
more).
81+
BLOCK_MEDIUM_AND_ABOVE (2):
82+
Block medium threshold and above.
83+
BLOCK_ONLY_HIGH (3):
84+
Block only high threshold (i.e. block less).
85+
BLOCK_NONE (4):
86+
Block none.
87+
OFF (5):
88+
Turn off the safety filter.
89+
"""
90+
HARM_BLOCK_THRESHOLD_UNSPECIFIED = 0
91+
BLOCK_LOW_AND_ABOVE = 1
92+
BLOCK_MEDIUM_AND_ABOVE = 2
93+
BLOCK_ONLY_HIGH = 3
94+
BLOCK_NONE = 4
95+
OFF = 5
96+
97+
class HarmBlockMethod(proto.Enum):
98+
r"""Probability vs severity.
99+
100+
Values:
101+
HARM_BLOCK_METHOD_UNSPECIFIED (0):
102+
The harm block method is unspecified.
103+
SEVERITY (1):
104+
The harm block method uses both probability
105+
and severity scores.
106+
PROBABILITY (2):
107+
The harm block method uses the probability
108+
score.
109+
"""
110+
HARM_BLOCK_METHOD_UNSPECIFIED = 0
111+
SEVERITY = 1
112+
PROBABILITY = 2
113+
114+
category: "HarmCategory" = proto.Field(
115+
proto.ENUM,
116+
number=1,
117+
enum="HarmCategory",
118+
)
119+
threshold: HarmBlockThreshold = proto.Field(
120+
proto.ENUM,
121+
number=2,
122+
enum=HarmBlockThreshold,
123+
)
124+
method: HarmBlockMethod = proto.Field(
125+
proto.ENUM,
126+
number=3,
127+
enum=HarmBlockMethod,
128+
)
129+
130+
131+
__all__ = tuple(sorted(__protobuf__.manifest))

packages/google-cloud-retail/google/cloud/retail_v2beta/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.4.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-retail",
11-
"version": "2.4.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-retail/samples/generated_samples/snippet_metadata_google.cloud.retail.v2alpha.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-retail",
11-
"version": "2.4.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

0 commit comments

Comments
 (0)