Skip to content

Commit e183baf

Browse files
Google APIscopybara-github
authored andcommitted
feat: Add Grounding feature to PredictionService.GenerateContent
feat: Add Retrieval feat: Add GoogleSearchRetrieval feat: Add VertexAiSearch feat: Add Tool.retrieval feat: Add Tool.google_search_retrieval feat: Add Candidate.grounding_metadata docs: A comment for message `Tool` is changed docs: A comment for field `tools` in message `.google.cloud.aiplatform.v1beta1.GenerateContentRequest` is changed docs: A comment for field `tools` in message `.google.cloud.aiplatform.v1beta1.GenerateContentRequest` is changed PiperOrigin-RevId: 605743031
1 parent 0e50601 commit e183baf

2 files changed

Lines changed: 96 additions & 1 deletion

File tree

google/cloud/aiplatform/v1beta1/content.proto

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,60 @@ message Candidate {
291291
// Output only. Source attribution of the generated content.
292292
CitationMetadata citation_metadata = 6
293293
[(google.api.field_behavior) = OUTPUT_ONLY];
294+
295+
// Output only. Metadata specifies sources used to ground generated content.
296+
GroundingMetadata grounding_metadata = 7
297+
[(google.api.field_behavior) = OUTPUT_ONLY];
298+
}
299+
300+
// Segment of the content.
301+
message Segment {
302+
// Output only. The index of a Part object within its parent Content object.
303+
int32 part_index = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
304+
305+
// Output only. Start index in the given Part, measured in bytes. Offset from
306+
// the start of the Part, inclusive, starting at zero.
307+
int32 start_index = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
308+
309+
// Output only. End index in the given Part, measured in bytes. Offset from
310+
// the start of the Part, exclusive, starting at zero.
311+
int32 end_index = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
312+
}
313+
314+
// Grounding attribution.
315+
message GroundingAttribution {
316+
// Attribution from the web.
317+
message Web {
318+
// Output only. URI reference of the attribution.
319+
string uri = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
320+
321+
// Output only. Title of the attribution.
322+
string title = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
323+
}
324+
325+
oneof reference {
326+
// Optional. Attribution from the web.
327+
Web web = 3 [(google.api.field_behavior) = OPTIONAL];
328+
}
329+
330+
// Output only. Segment of the content this attribution belongs to.
331+
Segment segment = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
332+
333+
// Optional. Output only. Confidence score of the attribution. Ranges from 0
334+
// to 1. 1 is the most confident.
335+
optional float confidence_score = 2 [
336+
(google.api.field_behavior) = OPTIONAL,
337+
(google.api.field_behavior) = OUTPUT_ONLY
338+
];
339+
}
340+
341+
// Metadata returned to client when grounding is enabled.
342+
message GroundingMetadata {
343+
// Optional. Web search queries for the following-up web search.
344+
repeated string web_search_queries = 1
345+
[(google.api.field_behavior) = OPTIONAL];
346+
347+
// Optional. List of grounding attributions.
348+
repeated GroundingAttribution grounding_attributions = 2
349+
[(google.api.field_behavior) = OPTIONAL];
294350
}

google/cloud/aiplatform/v1beta1/tool.proto

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ option ruby_package = "Google::Cloud::AIPlatform::V1beta1";
3232
//
3333
// A `Tool` is a piece of code that enables the system to interact with
3434
// external systems to perform an action, or set of actions, outside of
35-
// knowledge and scope of the model.
35+
// knowledge and scope of the model. A Tool object should contain exactly
36+
// one type of Tool.
3637
message Tool {
3738
// Optional. One or more function declarations to be passed to the model along
3839
// with the current user query. Model may decide to call a subset of these
@@ -44,6 +45,15 @@ message Tool {
4445
// provided.
4546
repeated FunctionDeclaration function_declarations = 1
4647
[(google.api.field_behavior) = OPTIONAL];
48+
49+
// Optional. System will always execute the provided retrieval tool(s) to get
50+
// external knowledge to answer the prompt. Retrieval results are presented to
51+
// the model for generation.
52+
Retrieval retrieval = 2 [(google.api.field_behavior) = OPTIONAL];
53+
54+
// Optional. Specialized retrieval tool that is powered by Google search.
55+
GoogleSearchRetrieval google_search_retrieval = 3
56+
[(google.api.field_behavior) = OPTIONAL];
4757
}
4858

4959
// Structured representation of a function declaration as defined by the
@@ -102,3 +112,32 @@ message FunctionResponse {
102112
// Required. The function response in JSON object format.
103113
google.protobuf.Struct response = 2 [(google.api.field_behavior) = REQUIRED];
104114
}
115+
116+
// Defines a retrieval tool that model can call to access external knowledge.
117+
message Retrieval {
118+
oneof source {
119+
// Set to use data source powered by Vertex AI Search.
120+
VertexAISearch vertex_ai_search = 2;
121+
}
122+
123+
// Optional. Disable using the result from this tool in detecting grounding
124+
// attribution. This does not affect how the result is given to the model for
125+
// generation.
126+
bool disable_attribution = 3 [(google.api.field_behavior) = OPTIONAL];
127+
}
128+
129+
// Retrieve from Vertex AI Search datastore for grounding.
130+
// See https://cloud.google.com/vertex-ai-search-and-conversation
131+
message VertexAISearch {
132+
// Required. Fully-qualified Vertex AI Search's datastore resource ID.
133+
// projects/<>/locations/<>/collections/<>/dataStores/<>
134+
string datastore = 1 [(google.api.field_behavior) = REQUIRED];
135+
}
136+
137+
// Tool to retrieve public web data for grounding, powered by Google.
138+
message GoogleSearchRetrieval {
139+
// Optional. Disable using the result from this tool in detecting grounding
140+
// attribution. This does not affect how the result is given to the model for
141+
// generation.
142+
bool disable_attribution = 1 [(google.api.field_behavior) = OPTIONAL];
143+
}

0 commit comments

Comments
 (0)