prediction_service.proto 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // Copyright 2021 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. syntax = "proto3";
  15. package google.cloud.retail.v2alpha;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/cloud/retail/v2alpha/user_event.proto";
  20. import "google/protobuf/struct.proto";
  21. option csharp_namespace = "Google.Cloud.Retail.V2Alpha";
  22. option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "PredictionServiceProto";
  25. option java_package = "com.google.cloud.retail.v2alpha";
  26. option objc_class_prefix = "RETAIL";
  27. option php_namespace = "Google\\Cloud\\Retail\\V2alpha";
  28. option ruby_package = "Google::Cloud::Retail::V2alpha";
  29. // Service for making recommendation prediction.
  30. service PredictionService {
  31. option (google.api.default_host) = "retail.googleapis.com";
  32. option (google.api.oauth_scopes) =
  33. "https://www.googleapis.com/auth/cloud-platform";
  34. // Makes a recommendation prediction.
  35. rpc Predict(PredictRequest) returns (PredictResponse) {
  36. option (google.api.http) = {
  37. post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict"
  38. body: "*"
  39. };
  40. }
  41. }
  42. // Request message for Predict method.
  43. message PredictRequest {
  44. // Required. Full resource name of the format:
  45. // {name=projects/*/locations/global/catalogs/default_catalog/placements/*}
  46. // The ID of the Recommendations AI placement. Before you can request
  47. // predictions from your model, you must create at least one placement for it.
  48. // For more information, see [Managing
  49. // placements](https://cloud.google.com/retail/recommendations-ai/docs/manage-placements).
  50. //
  51. // The full list of available placements can be seen at
  52. // https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements
  53. string placement = 1 [(google.api.field_behavior) = REQUIRED];
  54. // Required. Context about the user, what they are looking at and what action
  55. // they took to trigger the predict request. Note that this user event detail
  56. // won't be ingested to userEvent logs. Thus, a separate userEvent write
  57. // request is required for event logging.
  58. UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED];
  59. // Maximum number of results to return per page. Set this property
  60. // to the number of prediction results needed. If zero, the service will
  61. // choose a reasonable default. The maximum allowed value is 100. Values
  62. // above 100 will be coerced to 100.
  63. int32 page_size = 3;
  64. // The previous PredictResponse.next_page_token.
  65. string page_token = 4;
  66. // Filter for restricting prediction results with a length limit of 5,000
  67. // characters. Accepts values for tags and the `filterOutOfStockItems` flag.
  68. //
  69. // * Tag expressions. Restricts predictions to products that match all of the
  70. // specified tags. Boolean operators `OR` and `NOT` are supported if the
  71. // expression is enclosed in parentheses, and must be separated from the
  72. // tag values by a space. `-"tagA"` is also supported and is equivalent to
  73. // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings
  74. // with a size limit of 1,000 characters.
  75. //
  76. // Note: "Recently viewed" models don't support tag filtering at the
  77. // moment.
  78. //
  79. // * filterOutOfStockItems. Restricts predictions to products that do not
  80. // have a
  81. // stockState value of OUT_OF_STOCK.
  82. //
  83. // Examples:
  84. //
  85. // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional")
  86. // * filterOutOfStockItems tag=(-"promotional")
  87. // * filterOutOfStockItems
  88. //
  89. // If your filter blocks all prediction results, nothing will be returned. If
  90. // you want generic (unfiltered) popular products to be returned instead, set
  91. // `strictFiltering` to false in `PredictRequest.params`.
  92. string filter = 5;
  93. // Use validate only mode for this prediction query. If set to true, a
  94. // dummy model will be used that returns arbitrary products.
  95. // Note that the validate only mode should only be used for testing the API,
  96. // or if the model is not ready.
  97. bool validate_only = 6;
  98. // Additional domain specific parameters for the predictions.
  99. //
  100. // Allowed values:
  101. //
  102. // * `returnProduct`: Boolean. If set to true, the associated product
  103. // object will be returned in the `results.metadata` field in the
  104. // prediction response.
  105. // * `returnScore`: Boolean. If set to true, the prediction 'score'
  106. // corresponding to each returned product will be set in the
  107. // `results.metadata` field in the prediction response. The given
  108. // 'score' indicates the probability of an product being clicked/purchased
  109. // given the user's context and history.
  110. // * `strictFiltering`: Boolean. True by default. If set to false, the service
  111. // will return generic (unfiltered) popular products instead of empty if
  112. // your filter blocks all prediction results.
  113. // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then
  114. // it needs to be one of {'no-price-reranking', 'low-price-reranking',
  115. // 'medium-price-reranking', 'high-price-reranking'}. This gives
  116. // request-level control and adjusts prediction results based on product
  117. // price.
  118. // * `diversityLevel`: String. Default empty. If set to be non-empty, then
  119. // it needs to be one of {'no-diversity', 'low-diversity',
  120. // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives
  121. // request-level control and adjusts prediction results based on product
  122. // category.
  123. map<string, google.protobuf.Value> params = 7;
  124. // The labels applied to a resource must meet the following requirements:
  125. //
  126. // * Each resource can have multiple labels, up to a maximum of 64.
  127. // * Each label must be a key-value pair.
  128. // * Keys have a minimum length of 1 character and a maximum length of 63
  129. // characters, and cannot be empty. Values can be empty, and have a maximum
  130. // length of 63 characters.
  131. // * Keys and values can contain only lowercase letters, numeric characters,
  132. // underscores, and dashes. All characters must use UTF-8 encoding, and
  133. // international characters are allowed.
  134. // * The key portion of a label must be unique. However, you can use the same
  135. // key with multiple resources.
  136. // * Keys must start with a lowercase letter or international character.
  137. //
  138. // See [Google Cloud
  139. // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
  140. // for more details.
  141. map<string, string> labels = 8;
  142. }
  143. // Response message for predict method.
  144. message PredictResponse {
  145. // PredictionResult represents the recommendation prediction results.
  146. message PredictionResult {
  147. // ID of the recommended product
  148. string id = 1;
  149. // Additional product metadata / annotations.
  150. //
  151. // Possible values:
  152. //
  153. // * `product`: JSON representation of the product. Will be set if
  154. // `returnProduct` is set to true in `PredictRequest.params`.
  155. // * `score`: Prediction score in double value. Will be set if
  156. // `returnScore` is set to true in `PredictRequest.params`.
  157. map<string, google.protobuf.Value> metadata = 2;
  158. }
  159. // A list of recommended products. The order represents the ranking (from the
  160. // most relevant product to the least).
  161. repeated PredictionResult results = 1;
  162. // A unique attribution token. This should be included in the
  163. // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this
  164. // recommendation, which enables accurate attribution of recommendation model
  165. // performance.
  166. string attribution_token = 2;
  167. // IDs of products in the request that were missing from the inventory.
  168. repeated string missing_ids = 3;
  169. // True if the validateOnly property was set in the request.
  170. bool validate_only = 4;
  171. }