xref: /aosp_15_r20/external/googleapis/google/cloud/aiplatform/v1beta1/vertex_rag_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 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.aiplatform.v1beta1;
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.AIPlatform.V1Beta1";
25option go_package = "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb;aiplatformpb";
26option java_multiple_files = true;
27option java_outer_classname = "VertexRagServiceProto";
28option java_package = "com.google.cloud.aiplatform.v1beta1";
29option php_namespace = "Google\\Cloud\\AIPlatform\\V1beta1";
30option ruby_package = "Google::Cloud::AIPlatform::V1beta1";
31
32// A service for retrieving relevant contexts.
33service VertexRagService {
34  option (google.api.default_host) = "aiplatform.googleapis.com";
35  option (google.api.oauth_scopes) =
36      "https://www.googleapis.com/auth/cloud-platform";
37
38  // Retrieves relevant contexts for a query.
39  rpc RetrieveContexts(RetrieveContextsRequest)
40      returns (RetrieveContextsResponse) {
41    option (google.api.http) = {
42      post: "/v1beta1/{parent=projects/*/locations/*}:retrieveContexts"
43      body: "*"
44    };
45    option (google.api.method_signature) = "parent,query";
46  }
47}
48
49// A query to retrieve relevant contexts.
50message RagQuery {
51  oneof query {
52    // Optional. The query in text format to get relevant contexts.
53    string text = 1 [(google.api.field_behavior) = OPTIONAL];
54  }
55
56  // Optional. The number of contexts to retrieve.
57  int32 similarity_top_k = 2 [(google.api.field_behavior) = OPTIONAL];
58}
59
60// Request message for
61// [VertexRagService.RetrieveContexts][google.cloud.aiplatform.v1beta1.VertexRagService.RetrieveContexts].
62message RetrieveContextsRequest {
63  // The data source for Vertex RagStore.
64  message VertexRagStore {
65    // Required. RagCorpora resource name.
66    // Format:
67    // `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}`
68    // Currently only one corpus is allowed.
69    // In the future we may open up multiple corpora support. However, they
70    // should be from the same project and location.
71    repeated string rag_corpora = 1 [(google.api.field_behavior) = REQUIRED];
72  }
73
74  // Data Source to retrieve contexts.
75  oneof data_source {
76    // The data source for Vertex RagStore.
77    VertexRagStore vertex_rag_store = 2;
78  }
79
80  // Required. The resource name of the Location from which to retrieve
81  // RagContexts. The users must have permission to make a call in the project.
82  // Format:
83  // `projects/{project}/locations/{location}`.
84  string parent = 1 [
85    (google.api.field_behavior) = REQUIRED,
86    (google.api.resource_reference) = {
87      type: "locations.googleapis.com/Location"
88    }
89  ];
90
91  // Required. Single RAG retrieve query.
92  RagQuery query = 3 [(google.api.field_behavior) = REQUIRED];
93}
94
95// Relevant contexts for one query.
96message RagContexts {
97  // A context of the query.
98  message Context {
99    // For vertex RagStore, if the file is imported from Cloud Storage or Google
100    // Drive, source_uri will be original file URI in Cloud Storage or Google
101    // Drive; if file is uploaded, source_uri will be file display name.
102    string source_uri = 1;
103
104    // The text chunk.
105    string text = 2;
106
107    // The distance between the query vector and the context text vector.
108    double distance = 3;
109  }
110
111  // All its contexts.
112  repeated Context contexts = 1;
113}
114
115// Response message for
116// [VertexRagService.RetrieveContexts][google.cloud.aiplatform.v1beta1.VertexRagService.RetrieveContexts].
117message RetrieveContextsResponse {
118  // The contexts of the query.
119  RagContexts contexts = 1;
120}
121