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