xref: /aosp_15_r20/external/googleapis/google/cloud/discoveryengine/v1beta/recommendation_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.discoveryengine.v1beta;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/cloud/discoveryengine/v1beta/document.proto";
24import "google/cloud/discoveryengine/v1beta/user_event.proto";
25import "google/protobuf/struct.proto";
26
27option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta";
28option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb";
29option java_multiple_files = true;
30option java_outer_classname = "RecommendationServiceProto";
31option java_package = "com.google.cloud.discoveryengine.v1beta";
32option objc_class_prefix = "DISCOVERYENGINE";
33option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta";
34option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta";
35
36// Service for making recommendations.
37service RecommendationService {
38  option (google.api.default_host) = "discoveryengine.googleapis.com";
39  option (google.api.oauth_scopes) =
40      "https://www.googleapis.com/auth/cloud-platform";
41
42  // Makes a recommendation, which requires a contextual user event.
43  rpc Recommend(RecommendRequest) returns (RecommendResponse) {
44    option (google.api.http) = {
45      post: "/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:recommend"
46      body: "*"
47      additional_bindings {
48        post: "/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:recommend"
49        body: "*"
50      }
51      additional_bindings {
52        post: "/v1beta/{serving_config=projects/*/locations/*/collections/*/engines/*/servingConfigs/*}:recommend"
53        body: "*"
54      }
55    };
56  }
57}
58
59// Request message for Recommend method.
60message RecommendRequest {
61  // Required. Full resource name of a
62  // [ServingConfig][google.cloud.discoveryengine.v1beta.ServingConfig]:
63  // `projects/*/locations/global/collections/*/engines/*/servingConfigs/*`, or
64  // `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*`
65  //
66  // One default serving config is created along with your recommendation engine
67  // creation. The engine ID will be used as the ID of the default serving
68  // config. For example, for Engine
69  // `projects/*/locations/global/collections/*/engines/my-engine`, you can use
70  // `projects/*/locations/global/collections/*/engines/my-engine/servingConfigs/my-engine`
71  // for your
72  // [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]
73  // requests.
74  string serving_config = 1 [
75    (google.api.field_behavior) = REQUIRED,
76    (google.api.resource_reference) = {
77      type: "discoveryengine.googleapis.com/ServingConfig"
78    }
79  ];
80
81  // Required. Context about the user, what they are looking at and what action
82  // they took to trigger the Recommend request. Note that this user event
83  // detail won't be ingested to userEvent logs. Thus, a separate userEvent
84  // write request is required for event logging.
85  //
86  // Don't set
87  // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id]
88  // or
89  // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id]
90  // to the same fixed ID for different users. If you are trying to receive
91  // non-personalized recommendations (not recommended; this can negatively
92  // impact model performance), instead set
93  // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id]
94  // to a random unique ID and leave
95  // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id]
96  // unset.
97  UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED];
98
99  // Maximum number of results to return. Set this property
100  // to the number of recommendation results needed. If zero, the service will
101  // choose a reasonable default. The maximum allowed value is 100. Values
102  // above 100 will be coerced to 100.
103  int32 page_size = 3;
104
105  // Filter for restricting recommendation results with a length limit of 5,000
106  // characters. Currently, only filter expressions on the `filter_tags`
107  // attribute is supported.
108  //
109  //
110  // Examples:
111  //
112  //  * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))`
113  //  * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))`
114  //
115  // If `attributeFilteringSyntax` is set to true under the `params` field, then
116  // attribute-based expressions are expected instead of the above described
117  // tag-based syntax. Examples:
118  //
119  //  * (launguage: ANY("en", "es")) AND NOT (categories: ANY("Movie"))
120  //  * (available: true) AND
121  //    (launguage: ANY("en", "es")) OR (categories: ANY("Movie"))
122  //
123  // If your filter blocks all results, the API will return generic
124  // (unfiltered) popular Documents. If you only want results strictly matching
125  // the filters, set `strictFiltering` to True in
126  // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]
127  // to receive empty results instead.
128  //
129  // Note that the API will never return
130  // [Document][google.cloud.discoveryengine.v1beta.Document]s with
131  // `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices.
132  string filter = 4;
133
134  // Use validate only mode for this recommendation query. If set to true, a
135  // fake model will be used that returns arbitrary Document IDs.
136  // Note that the validate only mode should only be used for testing the API,
137  // or if the model is not ready.
138  bool validate_only = 5;
139
140  // Additional domain specific parameters for the recommendations.
141  //
142  // Allowed values:
143  //
144  // * `returnDocument`: Boolean. If set to true, the associated Document
145  //    object will be returned in
146  //    [RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document].
147  // * `returnScore`: Boolean. If set to true, the recommendation 'score'
148  //    corresponding to each returned Document will be set in
149  //    [RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata].
150  //    The given 'score' indicates the probability of a Document conversion
151  //    given the user's context and history.
152  // * `strictFiltering`: Boolean. True by default. If set to false, the service
153  //    will return generic (unfiltered) popular Documents instead of empty if
154  //    your filter blocks all recommendation results.
155  // * `diversityLevel`: String. Default empty. If set to be non-empty, then
156  //    it needs to be one of:
157  //     *  `no-diversity`
158  //     *  `low-diversity`
159  //     *  `medium-diversity`
160  //     *  `high-diversity`
161  //     *  `auto-diversity`
162  //    This gives request-level control and adjusts recommendation results
163  //    based on Document category.
164  // * `attributeFilteringSyntax`: Boolean. False by default. If set to true,
165  //    the `filter` field is interpreted according to the new,
166  //    attribute-based syntax.
167  map<string, google.protobuf.Value> params = 6;
168
169  // The user labels applied to a resource must meet the following requirements:
170  //
171  // * Each resource can have multiple labels, up to a maximum of 64.
172  // * Each label must be a key-value pair.
173  // * Keys have a minimum length of 1 character and a maximum length of 63
174  //   characters and cannot be empty. Values can be empty and have a maximum
175  //   length of 63 characters.
176  // * Keys and values can contain only lowercase letters, numeric characters,
177  //   underscores, and dashes. All characters must use UTF-8 encoding, and
178  //   international characters are allowed.
179  // * The key portion of a label must be unique. However, you can use the same
180  //   key with multiple resources.
181  // * Keys must start with a lowercase letter or international character.
182  //
183  // See [Requirements for
184  // labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
185  // for more details.
186  map<string, string> user_labels = 8;
187}
188
189// Response message for Recommend method.
190message RecommendResponse {
191  // RecommendationResult represents a generic recommendation result with
192  // associated metadata.
193  message RecommendationResult {
194    // Resource ID of the recommended Document.
195    string id = 1;
196
197    // Set if `returnDocument` is set to true in
198    // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params].
199    Document document = 2;
200
201    // Additional Document metadata / annotations.
202    //
203    // Possible values:
204    //
205    // * `score`: Recommendation score in double value. Is set if
206    //   `returnScore` is set to true in
207    //   [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params].
208    map<string, google.protobuf.Value> metadata = 3;
209  }
210
211  // A list of recommended Documents. The order represents the ranking (from the
212  // most relevant Document to the least).
213  repeated RecommendationResult results = 1;
214
215  // A unique attribution token. This should be included in the
216  // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting
217  // from this recommendation, which enables accurate attribution of
218  // recommendation model performance.
219  string attribution_token = 2;
220
221  // IDs of documents in the request that were missing from the default Branch
222  // associated with the requested ServingConfig.
223  repeated string missing_ids = 3;
224
225  // True if
226  // [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only]
227  // was set.
228  bool validate_only = 4;
229}
230