prediction_service.proto 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. // Copyright 2020 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.recommendationengine.v1beta1;
  16. import "google/api/annotations.proto";
  17. import "google/api/field_behavior.proto";
  18. import "google/api/resource.proto";
  19. import "google/cloud/recommendationengine/v1beta1/user_event.proto";
  20. import "google/protobuf/struct.proto";
  21. import "google/api/client.proto";
  22. option csharp_namespace = "Google.Cloud.RecommendationEngine.V1Beta1";
  23. option go_package = "google.golang.org/genproto/googleapis/cloud/recommendationengine/v1beta1;recommendationengine";
  24. option java_multiple_files = true;
  25. option java_package = "com.google.cloud.recommendationengine.v1beta1";
  26. option objc_class_prefix = "RECAI";
  27. option php_namespace = "Google\\Cloud\\RecommendationEngine\\V1beta1";
  28. option ruby_package = "Google::Cloud::RecommendationEngine::V1beta1";
  29. // Service for making recommendation prediction.
  30. service PredictionService {
  31. option (google.api.default_host) = "recommendationengine.googleapis.com";
  32. option (google.api.oauth_scopes) =
  33. "https://www.googleapis.com/auth/cloud-platform";
  34. // Makes a recommendation prediction. If using API Key based authentication,
  35. // the API Key must be registered using the
  36. // [PredictionApiKeyRegistry][google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry]
  37. // service. [Learn more](/recommendations-ai/docs/setting-up#register-key).
  38. rpc Predict(PredictRequest) returns (PredictResponse) {
  39. option (google.api.http) = {
  40. post: "/v1beta1/{name=projects/*/locations/*/catalogs/*/eventStores/*/placements/*}:predict"
  41. body: "*"
  42. };
  43. option (google.api.method_signature) = "name,user_event";
  44. }
  45. }
  46. // Request message for Predict method.
  47. message PredictRequest {
  48. // Required. Full resource name of the format:
  49. // `{name=projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/placements/*}`
  50. // The id of the recommendation engine placement. This id is used to identify
  51. // the set of models that will be used to make the prediction.
  52. //
  53. // We currently support three placements with the following IDs by default:
  54. //
  55. // * `shopping_cart`: Predicts items frequently bought together with one or
  56. // more catalog items in the same shopping session. Commonly displayed after
  57. // `add-to-cart` events, on product detail pages, or on the shopping cart
  58. // page.
  59. //
  60. // * `home_page`: Predicts the next product that a user will most likely
  61. // engage with or purchase based on the shopping or viewing history of the
  62. // specified `userId` or `visitorId`. For example - Recommendations for you.
  63. //
  64. // * `product_detail`: Predicts the next product that a user will most likely
  65. // engage with or purchase. The prediction is based on the shopping or
  66. // viewing history of the specified `userId` or `visitorId` and its
  67. // relevance to a specified `CatalogItem`. Typically used on product detail
  68. // pages. For example - More items like this.
  69. //
  70. // * `recently_viewed_default`: Returns up to 75 items recently viewed by the
  71. // specified `userId` or `visitorId`, most recent ones first. Returns
  72. // nothing if neither of them has viewed any items yet. For example -
  73. // Recently viewed.
  74. //
  75. // The full list of available placements can be seen at
  76. // https://console.cloud.google.com/recommendation/datafeeds/default_catalog/dashboard
  77. string name = 1 [
  78. (google.api.field_behavior) = REQUIRED,
  79. (google.api.resource_reference) = {
  80. type: "recommendationengine.googleapis.com/Placement"
  81. }
  82. ];
  83. // Required. Context about the user, what they are looking at and what action
  84. // they took to trigger the predict request. Note that this user event detail
  85. // won't be ingested to userEvent logs. Thus, a separate userEvent write
  86. // request is required for event logging.
  87. UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED];
  88. // Optional. Maximum number of results to return per page. Set this property
  89. // to the number of prediction results required. If zero, the service will
  90. // choose a reasonable default.
  91. int32 page_size = 7 [(google.api.field_behavior) = OPTIONAL];
  92. // Optional. The previous PredictResponse.next_page_token.
  93. string page_token = 8 [(google.api.field_behavior) = OPTIONAL];
  94. // Optional. Filter for restricting prediction results. Accepts values for
  95. // tags and the `filterOutOfStockItems` flag.
  96. //
  97. // * Tag expressions. Restricts predictions to items that match all of the
  98. // specified tags. Boolean operators `OR` and `NOT` are supported if the
  99. // expression is enclosed in parentheses, and must be separated from the
  100. // tag values by a space. `-"tagA"` is also supported and is equivalent to
  101. // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings
  102. // with a size limit of 1 KiB.
  103. //
  104. // * filterOutOfStockItems. Restricts predictions to items that do not have a
  105. // stockState value of OUT_OF_STOCK.
  106. //
  107. // Examples:
  108. //
  109. // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional")
  110. // * filterOutOfStockItems tag=(-"promotional")
  111. // * filterOutOfStockItems
  112. string filter = 3 [(google.api.field_behavior) = OPTIONAL];
  113. // Optional. Use dryRun mode for this prediction query. If set to true, a
  114. // dummy model will be used that returns arbitrary catalog items.
  115. // Note that the dryRun mode should only be used for testing the API, or if
  116. // the model is not ready.
  117. bool dry_run = 4 [(google.api.field_behavior) = OPTIONAL];
  118. // Optional. Additional domain specific parameters for the predictions.
  119. //
  120. // Allowed values:
  121. //
  122. // * `returnCatalogItem`: Boolean. If set to true, the associated catalogItem
  123. // object will be returned in the
  124. // `PredictResponse.PredictionResult.itemMetadata` object in the method
  125. // response.
  126. // * `returnItemScore`: Boolean. If set to true, the prediction 'score'
  127. // corresponding to each returned item will be set in the `metadata`
  128. // field in the prediction response. The given 'score' indicates the
  129. // probability of an item being clicked/purchased given the user's context
  130. // and history.
  131. map<string, google.protobuf.Value> params = 6
  132. [(google.api.field_behavior) = OPTIONAL];
  133. // Optional. The labels for the predict request.
  134. //
  135. // * Label keys can contain lowercase letters, digits and hyphens, must start
  136. // with a letter, and must end with a letter or digit.
  137. // * Non-zero label values can contain lowercase letters, digits and hyphens,
  138. // must start with a letter, and must end with a letter or digit.
  139. // * No more than 64 labels can be associated with a given request.
  140. //
  141. // See https://goo.gl/xmQnxf for more information on and examples of labels.
  142. map<string, string> labels = 9 [(google.api.field_behavior) = OPTIONAL];
  143. }
  144. // Response message for predict method.
  145. message PredictResponse {
  146. // PredictionResult represents the recommendation prediction results.
  147. message PredictionResult {
  148. // ID of the recommended catalog item
  149. string id = 1;
  150. // Additional item metadata / annotations.
  151. //
  152. // Possible values:
  153. //
  154. // * `catalogItem`: JSON representation of the catalogItem. Will be set if
  155. // `returnCatalogItem` is set to true in `PredictRequest.params`.
  156. // * `score`: Prediction score in double value. Will be set if
  157. // `returnItemScore` is set to true in `PredictRequest.params`.
  158. map<string, google.protobuf.Value> item_metadata = 2;
  159. }
  160. // A list of recommended items. The order represents the ranking (from the
  161. // most relevant item to the least).
  162. repeated PredictionResult results = 1;
  163. // A unique recommendation token. This should be included in the user event
  164. // logs resulting from this recommendation, which enables accurate attribution
  165. // of recommendation model performance.
  166. string recommendation_token = 2;
  167. // IDs of items in the request that were missing from the catalog.
  168. repeated string items_missing_in_catalog = 3;
  169. // True if the dryRun property was set in the request.
  170. bool dry_run = 4;
  171. // Additional domain specific prediction response metadata.
  172. map<string, google.protobuf.Value> metadata = 5;
  173. // If empty, the list is complete. If nonempty, the token to pass to the next
  174. // request's PredictRequest.page_token.
  175. string next_page_token = 6;
  176. }