Skip to content

Commit 869263a

Browse files
feat: [generativelanguage] add support for GoogleMaps and FileSearch tools (#6957)
* feat: add IMAGE_RECITATION reason when generation is stopped due to recitation feat: add support for GroundingMetadata.google_maps_widget_context_token feat: add json_name for GenerationConfig.response_json_schema_ordered field PiperOrigin-RevId: 846116816 Source-Link: googleapis/googleapis@c631c69 Source-Link: googleapis/googleapis-gen@287df78 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFpLWdlbmVyYXRpdmVsYW5ndWFnZS8uT3dsQm90LnlhbWwiLCJoIjoiMjg3ZGY3ODg5NWI0N2YxMjlhN2Y4OGYwZTlhYTFhOTYyN2ZmMTVkZSJ9 * feat: add support for GoogleMaps and FileSearch tools feat: add support for RetrievalConfig PiperOrigin-RevId: 846118142 Source-Link: googleapis/googleapis@bc7e3ba Source-Link: googleapis/googleapis-gen@f9c0ecd Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFpLWdlbmVyYXRpdmVsYW5ndWFnZS8uT3dsQm90LnlhbWwiLCJoIjoiZjljMGVjZGVhN2FlMzk0OGVkZDdlZWI1NTQ5NmY3ODUyNzljNmZlNSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8e48753 commit 869263a

File tree

6 files changed

+4327
-13
lines changed

6 files changed

+4327
-13
lines changed

packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1/generative_service.proto

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ enum TaskType {
145145
}
146146

147147
// Request to generate a completion from the model.
148-
// NEXT ID: 18
149148
message GenerateContentRequest {
150149
// Required. The name of the `Model` to use for generating the completion.
151150
//
@@ -192,7 +191,6 @@ message GenerateContentRequest {
192191

193192
// Configuration options for model generation and outputs. Not all parameters
194193
// are configurable for every model.
195-
// Next ID: 29
196194
message GenerationConfig {
197195
// Optional. Number of generated responses to return. If unset, this will
198196
// default to 1. Please note that this doesn't work for previous generation
@@ -253,8 +251,10 @@ message GenerationConfig {
253251

254252
// Optional. An internal detail. Use `responseJsonSchema` rather than this
255253
// field.
256-
google.protobuf.Value response_json_schema_ordered = 28
257-
[(google.api.field_behavior) = OPTIONAL];
254+
google.protobuf.Value response_json_schema_ordered = 28 [
255+
json_name = "responseJsonSchema",
256+
(google.api.field_behavior) = OPTIONAL
257+
];
258258

259259
// Optional. Presence penalty applied to the next token's logprobs if the
260260
// token has already been seen in the response.
@@ -461,6 +461,9 @@ message Candidate {
461461
// The model was expected to generate an image, but none was generated.
462462
NO_IMAGE = 16;
463463

464+
// Image generation stopped due to recitation.
465+
IMAGE_RECITATION = 17;
466+
464467
// Model generated a tool call but no tools were enabled in the request.
465468
UNEXPECTED_TOOL_CALL = 12;
466469

@@ -616,6 +619,13 @@ message GroundingMetadata {
616619

617620
// Web search queries for the following-up web search.
618621
repeated string web_search_queries = 5;
622+
623+
// Optional. Resource name of the Google Maps widget context token that can be
624+
// used with the PlacesContextElement widget in order to render contextual
625+
// data. Only populated in the case that grounding with Google Maps is
626+
// enabled.
627+
optional string google_maps_widget_context_token = 7
628+
[(google.api.field_behavior) = OPTIONAL];
619629
}
620630

621631
// Google search entry point.

packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/content.proto

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import "google/api/field_behavior.proto";
2020
import "google/protobuf/duration.proto";
2121
import "google/protobuf/struct.proto";
2222
import "google/type/interval.proto";
23+
import "google/type/latlng.proto";
2324

2425
option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb;generativelanguagepb";
2526
option java_multiple_files = true;
@@ -353,11 +354,58 @@ message Tool {
353354

354355
// Optional. Tool to support URL context retrieval.
355356
UrlContext url_context = 8 [(google.api.field_behavior) = OPTIONAL];
357+
358+
// Optional. FileSearch tool type.
359+
// Tool to retrieve knowledge from Semantic Retrieval corpora.
360+
FileSearch file_search = 9 [(google.api.field_behavior) = OPTIONAL];
361+
362+
// Optional. Tool that allows grounding the model's response with geospatial
363+
// context related to the user's query.
364+
GoogleMaps google_maps = 11 [(google.api.field_behavior) = OPTIONAL];
365+
}
366+
367+
// The GoogleMaps Tool that provides geospatial context for the user's query.
368+
message GoogleMaps {
369+
// Optional. Whether to return a widget context token in the GroundingMetadata
370+
// of the response. Developers can use the widget context token to render a
371+
// Google Maps widget with geospatial context related to the places that the
372+
// model references in the response.
373+
bool enable_widget = 1 [(google.api.field_behavior) = OPTIONAL];
356374
}
357375

358376
// Tool to support URL context retrieval.
359377
message UrlContext {}
360378

379+
// The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora.
380+
// Files are imported to Semantic Retrieval corpora using the ImportFile API.
381+
message FileSearch {
382+
// The semantic retrieval resource to retrieve from.
383+
message RetrievalResource {
384+
// Required. The name of the semantic retrieval resource to retrieve from.
385+
// Example: `ragStores/my-rag-store-123`
386+
string rag_store_name = 1 [(google.api.field_behavior) = REQUIRED];
387+
}
388+
389+
// Semantic retrieval configuration.
390+
message RetrievalConfig {
391+
// Optional. The number of semantic retrieval chunks to retrieve.
392+
optional int32 top_k = 1 [(google.api.field_behavior) = OPTIONAL];
393+
394+
// Optional. Metadata filter to apply to the semantic retrieval documents
395+
// and chunks.
396+
string metadata_filter = 3 [(google.api.field_behavior) = OPTIONAL];
397+
}
398+
399+
// Required. Semantic retrieval resources to retrieve from.
400+
// Currently only supports one corpus. In the future we may open up multiple
401+
// corpora support.
402+
repeated RetrievalResource retrieval_resources = 1
403+
[(google.api.field_behavior) = REQUIRED];
404+
405+
// Optional. The configuration for the retrieval.
406+
RetrievalConfig retrieval_config = 2 [(google.api.field_behavior) = OPTIONAL];
407+
}
408+
361409
// Tool to retrieve public web data for grounding, powered by Google.
362410
message GoogleSearchRetrieval {
363411
// Specifies the dynamic retrieval configuration for the given source.
@@ -396,6 +444,20 @@ message ToolConfig {
396444
// Optional. Function calling config.
397445
FunctionCallingConfig function_calling_config = 1
398446
[(google.api.field_behavior) = OPTIONAL];
447+
448+
// Optional. Retrieval config.
449+
RetrievalConfig retrieval_config = 2 [(google.api.field_behavior) = OPTIONAL];
450+
}
451+
452+
// Retrieval config.
453+
message RetrievalConfig {
454+
// Optional. The location of the user.
455+
google.type.LatLng lat_lng = 1 [(google.api.field_behavior) = OPTIONAL];
456+
457+
// Optional. The language code of the user.
458+
// Language code for content. Use language tags defined by
459+
// [BCP47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt).
460+
string language_code = 2 [(google.api.field_behavior) = OPTIONAL];
399461
}
400462

401463
// Configuration for specifying function calling behavior.

packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/generative_service.proto

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ enum TaskType {
163163
}
164164

165165
// Request to generate a completion from the model.
166-
// NEXT ID: 18
167166
message GenerateContentRequest {
168167
// Required. The name of the `Model` to use for generating the completion.
169168
//
@@ -316,7 +315,6 @@ message ImageConfig {
316315

317316
// Configuration options for model generation and outputs. Not all parameters
318317
// are configurable for every model.
319-
// Next ID: 29
320318
message GenerationConfig {
321319
// Supported modalities of the response.
322320
enum Modality {
@@ -947,6 +945,13 @@ message GroundingMetadata {
947945

948946
// Web search queries for the following-up web search.
949947
repeated string web_search_queries = 5;
948+
949+
// Optional. Resource name of the Google Maps widget context token that can be
950+
// used with the PlacesContextElement widget in order to render contextual
951+
// data. Only populated in the case that grounding with Google Maps is
952+
// enabled.
953+
optional string google_maps_widget_context_token = 7
954+
[(google.api.field_behavior) = OPTIONAL];
950955
}
951956

952957
// Google search entry point.
@@ -971,10 +976,75 @@ message GroundingChunk {
971976
optional string title = 2;
972977
}
973978

979+
// Chunk from context retrieved by the file search tool.
980+
message RetrievedContext {
981+
// Optional. URI reference of the semantic retrieval document.
982+
optional string uri = 1 [(google.api.field_behavior) = OPTIONAL];
983+
984+
// Optional. Title of the document.
985+
optional string title = 2 [(google.api.field_behavior) = OPTIONAL];
986+
987+
// Optional. Text of the chunk.
988+
optional string text = 3 [(google.api.field_behavior) = OPTIONAL];
989+
}
990+
991+
// A grounding chunk from Google Maps. A Maps chunk corresponds to a single
992+
// place.
993+
message Maps {
994+
// Collection of sources that provide answers about the features of a given
995+
// place in Google Maps. Each PlaceAnswerSources message corresponds to a
996+
// specific place in Google Maps. The Google Maps tool used these sources in
997+
// order to answer questions about features of the place (e.g: "does Bar Foo
998+
// have Wifi" or "is Foo Bar wheelchair accessible?"). Currently we only
999+
// support review snippets as sources.
1000+
message PlaceAnswerSources {
1001+
// Encapsulates a snippet of a user review that answers a question about
1002+
// the features of a specific place in Google Maps.
1003+
message ReviewSnippet {
1004+
// The ID of the review snippet.
1005+
optional string review_id = 1;
1006+
1007+
// A link that corresponds to the user review on Google Maps.
1008+
optional string google_maps_uri = 2;
1009+
1010+
// Title of the review.
1011+
optional string title = 3;
1012+
}
1013+
1014+
// Snippets of reviews that are used to generate answers about the
1015+
// features of a given place in Google Maps.
1016+
repeated ReviewSnippet review_snippets = 1;
1017+
}
1018+
1019+
// URI reference of the place.
1020+
optional string uri = 1;
1021+
1022+
// Title of the place.
1023+
optional string title = 2;
1024+
1025+
// Text description of the place answer.
1026+
optional string text = 3;
1027+
1028+
// This ID of the place, in `places/{place_id}` format. A user can use this
1029+
// ID to look up that place.
1030+
optional string place_id = 4;
1031+
1032+
// Sources that provide answers about the features of a given place in
1033+
// Google Maps.
1034+
optional PlaceAnswerSources place_answer_sources = 5;
1035+
}
1036+
9741037
// Chunk type.
9751038
oneof chunk_type {
9761039
// Grounding chunk from the web.
9771040
Web web = 1;
1041+
1042+
// Optional. Grounding chunk from context retrieved by the file search tool.
1043+
RetrievedContext retrieved_context = 2
1044+
[(google.api.field_behavior) = OPTIONAL];
1045+
1046+
// Optional. Grounding chunk from Google Maps.
1047+
Maps maps = 3 [(google.api.field_behavior) = OPTIONAL];
9781048
}
9791049
}
9801050

0 commit comments

Comments
 (0)