@@ -88,6 +88,40 @@ struct ServerPromptTemplateIntegrationTests {
8888 #expect( text. localizedCaseInsensitiveContains ( " museum " ) )
8989 }
9090
91+ @Test ( arguments: [
92+ InstanceConfig . googleAI_v1beta,
93+ ] )
94+ func generateContentWithTemplateMapsGroundingSnippet( _ config: InstanceConfig ) async throws {
95+ let latAndLong = CLLocationCoordinate2D ( latitude: 30.2672 , longitude: - 97.7431 )
96+ let retrievalConfig = RetrievalConfig ( location: latAndLong, languageCode: " en_US " )
97+ let templateToolConfig = TemplateToolConfig ( retrievalConfig: retrievalConfig)
98+
99+ let model = FirebaseAI . componentInstance ( config) . templateGenerativeModel ( )
100+ let response = try await model. generateContent (
101+ templateID: " grounding-with-google-maps-v1-0-0 " ,
102+ inputs: [
103+ " question " : " restaurants near me? " ,
104+ ] ,
105+ toolConfig: templateToolConfig
106+ )
107+
108+ let text = try #require( response. text)
109+ #expect( !text. isEmpty)
110+
111+ // Validate grounding metadata
112+ let candidate = try #require( response. candidates. first)
113+ let groundingMetadata = try #require( candidate. groundingMetadata)
114+ let mapChunks = groundingMetadata. groundingChunks. compactMap { $0. maps }
115+ #expect( !mapChunks. isEmpty)
116+ for mapsChunk in mapChunks {
117+ #expect( mapsChunk. url != nil )
118+ let title = try #require( mapsChunk. title)
119+ #expect( !title. isEmpty)
120+ let placeID = try #require( mapsChunk. placeID)
121+ #expect( !placeID. isEmpty)
122+ }
123+ }
124+
91125 @Test ( arguments: [
92126 InstanceConfig . googleAI_v1beta,
93127 InstanceConfig . vertexAI_v1beta,
0 commit comments