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"; 23 24option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; 25option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; 26option java_multiple_files = true; 27option java_outer_classname = "RankServiceProto"; 28option java_package = "com.google.cloud.discoveryengine.v1beta"; 29option objc_class_prefix = "DISCOVERYENGINE"; 30option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; 31option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; 32 33// Service for ranking text records. 34service RankService { 35 option (google.api.default_host) = "discoveryengine.googleapis.com"; 36 option (google.api.oauth_scopes) = 37 "https://www.googleapis.com/auth/cloud-platform"; 38 39 // Ranks a list of text records based on the given input query. 40 rpc Rank(RankRequest) returns (RankResponse) { 41 option (google.api.http) = { 42 post: "/v1beta/{ranking_config=projects/*/locations/*/rankingConfigs/*}:rank" 43 body: "*" 44 }; 45 } 46} 47 48// Record message for 49// [RankService.Rank][google.cloud.discoveryengine.v1beta.RankService.Rank] 50// method. 51message RankingRecord { 52 // The unique ID to represent the record. 53 string id = 1; 54 55 // The title of the record. Empty by default. 56 // At least one of 57 // [title][google.cloud.discoveryengine.v1beta.RankingRecord.title] or 58 // [content][google.cloud.discoveryengine.v1beta.RankingRecord.content] should 59 // be set otherwise an INVALID_ARGUMENT error is thrown. 60 string title = 2; 61 62 // The content of the record. Empty by default. 63 // At least one of 64 // [title][google.cloud.discoveryengine.v1beta.RankingRecord.title] or 65 // [content][google.cloud.discoveryengine.v1beta.RankingRecord.content] should 66 // be set otherwise an INVALID_ARGUMENT error is thrown. 67 string content = 3; 68 69 // The score of this record based on the given query and selected model. 70 float score = 4; 71} 72 73// Request message for 74// [RankService.Rank][google.cloud.discoveryengine.v1beta.RankService.Rank] 75// method. 76message RankRequest { 77 // Required. The resource name of the rank service config, such as 78 // `projects/{project_num}/locations/{location_id}/rankingConfigs/default_ranking_config`. 79 string ranking_config = 1 [ 80 (google.api.field_behavior) = REQUIRED, 81 (google.api.resource_reference) = { 82 type: "discoveryengine.googleapis.com/RankingConfig" 83 } 84 ]; 85 86 // The identifier of the model to use. It is one of: 87 // 88 // * `semantic-ranker-512@latest`: Semantic ranking model with maxiumn input 89 // token size 512. 90 // 91 // It is set to `semantic-ranker-512@latest` by default if unspecified. 92 string model = 2; 93 94 // The number of results to return. If this is unset or no bigger than zero, 95 // returns all results. 96 int32 top_n = 3; 97 98 // The query to use. 99 string query = 4; 100 101 // Required. A list of records to rank. At most 200 records to rank. 102 repeated RankingRecord records = 5 [(google.api.field_behavior) = REQUIRED]; 103 104 // If true, the response will contain only record ID and score. By default, it 105 // is false, the response will contain record details. 106 bool ignore_record_details_in_response = 6; 107} 108 109// Response message for 110// [RankService.Rank][google.cloud.discoveryengine.v1beta.RankService.Rank] 111// method. 112message RankResponse { 113 // A list of records sorted by descending score. 114 repeated RankingRecord records = 5; 115} 116