recommendation_service.proto 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. syntax = "proto3";
  15. package google.cloud.discoveryengine.v1beta;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/cloud/discoveryengine/v1beta/document.proto";
  21. import "google/cloud/discoveryengine/v1beta/user_event.proto";
  22. import "google/protobuf/struct.proto";
  23. option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/discoveryengine/v1beta;discoveryengine";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "RecommendationServiceProto";
  27. option java_package = "com.google.cloud.discoveryengine.v1beta";
  28. option objc_class_prefix = "DISCOVERYENGINE";
  29. option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta";
  30. option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta";
  31. // Service for making recommendations.
  32. service RecommendationService {
  33. option (google.api.default_host) = "discoveryengine.googleapis.com";
  34. option (google.api.oauth_scopes) =
  35. "https://www.googleapis.com/auth/cloud-platform";
  36. // Makes a recommendation, which requires a contextual user event.
  37. rpc Recommend(RecommendRequest) returns (RecommendResponse) {
  38. option (google.api.http) = {
  39. post: "/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:recommend"
  40. body: "*"
  41. };
  42. }
  43. }
  44. // Request message for Recommend method.
  45. message RecommendRequest {
  46. // Required. Full resource name of the format:
  47. // projects/*/locations/global/dataStores/*/servingConfigs/*
  48. //
  49. // Before you can request recommendations from your model, you must create at
  50. // least one serving config for it.
  51. string serving_config = 1 [
  52. (google.api.field_behavior) = REQUIRED,
  53. (google.api.resource_reference) = {
  54. type: "discoveryengine.googleapis.com/ServingConfig"
  55. }
  56. ];
  57. // Required. Context about the user, what they are looking at and what action
  58. // they took to trigger the Recommend request. Note that this user event
  59. // detail won't be ingested to userEvent logs. Thus, a separate userEvent
  60. // write request is required for event logging.
  61. //
  62. // Don't set
  63. // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id]
  64. // or
  65. // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id]
  66. // to the same fixed ID for different users. If you are trying to receive
  67. // non-personalized recommendations (not recommended; this can negatively
  68. // impact model performance), instead set
  69. // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id]
  70. // to a random unique ID and leave
  71. // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id]
  72. // unset.
  73. UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED];
  74. // Maximum number of results to return. Set this property
  75. // to the number of recommendation results needed. If zero, the service will
  76. // choose a reasonable default. The maximum allowed value is 100. Values
  77. // above 100 will be coerced to 100.
  78. int32 page_size = 3;
  79. // Filter for restricting recommendation results with a length limit of 5,000
  80. // characters. Currently, only filter expressions on the `filter_tags`
  81. // attribute is supported.
  82. //
  83. //
  84. // Examples:
  85. //
  86. // * (filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))
  87. // * (filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))
  88. //
  89. // If your filter blocks all results, the API will return generic
  90. // (unfiltered) popular Documents. If you only want results strictly matching
  91. // the filters, set `strictFiltering` to True in
  92. // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]
  93. // to receive empty results instead.
  94. //
  95. // Note that the API will never return Documents with storageStatus of
  96. // "EXPIRED" or "DELETED" regardless of filter choices.
  97. string filter = 4;
  98. // Use validate only mode for this recommendation query. If set to true, a
  99. // fake model will be used that returns arbitrary Document IDs.
  100. // Note that the validate only mode should only be used for testing the API,
  101. // or if the model is not ready.
  102. bool validate_only = 5;
  103. // Additional domain specific parameters for the recommendations.
  104. //
  105. // Allowed values:
  106. //
  107. // * `returnDocument`: Boolean. If set to true, the associated Document
  108. // object will be returned in
  109. // [RecommendResponse.results.document][RecommendationResult.document].
  110. // * `returnScore`: Boolean. If set to true, the recommendation 'score'
  111. // corresponding to each returned Document will be set in
  112. // [RecommendResponse.results.metadata][RecommendationResult.metadata]. The
  113. // given 'score' indicates the probability of a Document conversion given
  114. // the user's context and history.
  115. // * `strictFiltering`: Boolean. True by default. If set to false, the service
  116. // will return generic (unfiltered) popular Documents instead of empty if
  117. // your filter blocks all recommendation results.
  118. // * `diversityLevel`: String. Default empty. If set to be non-empty, then
  119. // it needs to be one of:
  120. // * 'no-diversity'
  121. // * 'low-diversity'
  122. // * 'medium-diversity'
  123. // * 'high-diversity'
  124. // * 'auto-diversity'
  125. // This gives request-level control and adjusts recommendation results
  126. // based on Document category.
  127. map<string, google.protobuf.Value> params = 6;
  128. // The user labels applied to a resource must meet the following requirements:
  129. //
  130. // * Each resource can have multiple labels, up to a maximum of 64.
  131. // * Each label must be a key-value pair.
  132. // * Keys have a minimum length of 1 character and a maximum length of 63
  133. // characters and cannot be empty. Values can be empty and have a maximum
  134. // length of 63 characters.
  135. // * Keys and values can contain only lowercase letters, numeric characters,
  136. // underscores, and dashes. All characters must use UTF-8 encoding, and
  137. // international characters are allowed.
  138. // * The key portion of a label must be unique. However, you can use the same
  139. // key with multiple resources.
  140. // * Keys must start with a lowercase letter or international character.
  141. //
  142. // See [Google Cloud
  143. // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
  144. // for more details.
  145. map<string, string> user_labels = 8;
  146. }
  147. // Response message for Recommend method.
  148. message RecommendResponse {
  149. // RecommendationResult represents a generic recommendation result with
  150. // associated metadata.
  151. message RecommendationResult {
  152. // Resource ID of the recommended Document.
  153. string id = 1;
  154. // Set if `returnDocument` is set to true in
  155. // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params].
  156. Document document = 2;
  157. // Additional Document metadata / annotations.
  158. //
  159. // Possible values:
  160. //
  161. // * `score`: Recommendation score in double value. Is set if
  162. // `returnScore` is set to true in
  163. // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params].
  164. map<string, google.protobuf.Value> metadata = 3;
  165. }
  166. // A list of recommended Documents. The order represents the ranking (from the
  167. // most relevant Document to the least).
  168. repeated RecommendationResult results = 1;
  169. // A unique attribution token. This should be included in the
  170. // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting
  171. // from this recommendation, which enables accurate attribution of
  172. // recommendation model performance.
  173. string attribution_token = 2;
  174. // IDs of documents in the request that were missing from the default Branch
  175. // associated with the requested ServingConfig.
  176. repeated string missing_ids = 3;
  177. // True if
  178. // [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only]
  179. // was set.
  180. bool validate_only = 4;
  181. }