Skip to content

Commit 074cf9f

Browse files
committed
review
1 parent 57d10a4 commit 074cf9f

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

FirebaseAI/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
- [feature] Added support for GoogleMaps grounding.
3+
14
# 12.9.0
25
- [changed] The URL context tool APIs are now GA.
36
- [feature] Added support for implicit caching (context caching) metadata in `GenerateContentResponse`.

FirebaseAI/Sources/Tool.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public struct Tool: Sendable {
145145
/// "Grounding with Google Maps" usage requirements for your chosen API provider.
146146
///
147147
/// - Parameters:
148-
/// - googleMaps: A ``GoogleMapsConfig`` object. The presence of this object in the list
148+
/// - googleMaps: A ``GoogleMaps`` object. The presence of this object in the list
149149
/// of tools enables the model to use Google Maps.
150150
///
151151
/// - Returns: A `Tool` configured for Google Maps.
@@ -253,6 +253,8 @@ public struct LatLng: Sendable, Encodable {
253253
public let longitude: Double
254254

255255
public init(latitude: Double, longitude: Double) {
256+
precondition(latitude >= -90.0 && latitude <= 90.0, "Latitude must be in the range [-90.0, 90.0].")
257+
precondition(longitude >= -180.0 && longitude <= 180.0, "Longitude must be in the range [-180.0, 180.0].")
256258
self.latitude = latitude
257259
self.longitude = longitude
258260
}

FirebaseAI/Tests/TestApp/Tests/Integration/MapsGroundingIntegrationTests.swift

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,14 @@ struct MapsGroundingIntegrationTests {
3434
let candidate = try #require(response.candidates.first)
3535
let groundingMetadata = try #require(candidate.groundingMetadata)
3636

37-
#expect(!groundingMetadata.groundingChunks.isEmpty)
37+
let mapChunks = groundingMetadata.groundingChunks.compactMap { $0.maps }
38+
#expect(!mapChunks.isEmpty)
3839

39-
var foundMapChunk = false
40-
for chunk in groundingMetadata.groundingChunks {
41-
if let mapsChunk = chunk.maps {
42-
#expect(!mapsChunk.uri.isEmpty)
43-
#expect(!mapsChunk.title.isEmpty)
44-
#expect(!mapsChunk.placeId.isEmpty)
45-
foundMapChunk = true
46-
}
40+
for mapsChunk in mapChunks {
41+
#expect(!mapsChunk.uri.isEmpty)
42+
#expect(!mapsChunk.title.isEmpty)
43+
#expect(!mapsChunk.placeId.isEmpty)
4744
}
48-
#expect(foundMapChunk)
4945
}
5046

5147
@Test(
@@ -70,17 +66,13 @@ struct MapsGroundingIntegrationTests {
7066
let candidate = try #require(response.candidates.first)
7167
let groundingMetadata = try #require(candidate.groundingMetadata)
7268

73-
#expect(!groundingMetadata.groundingChunks.isEmpty)
69+
let mapChunks = groundingMetadata.groundingChunks.compactMap { $0.maps }
70+
#expect(!mapChunks.isEmpty)
7471

75-
var foundMapChunk = false
76-
for chunk in groundingMetadata.groundingChunks {
77-
if let mapsChunk = chunk.maps {
78-
#expect(!mapsChunk.uri.isEmpty)
79-
#expect(!mapsChunk.title.isEmpty)
80-
#expect(!mapsChunk.placeId.isEmpty)
81-
foundMapChunk = true
82-
}
72+
for mapsChunk in mapChunks {
73+
#expect(!mapsChunk.uri.isEmpty)
74+
#expect(!mapsChunk.title.isEmpty)
75+
#expect(!mapsChunk.placeId.isEmpty)
8376
}
84-
#expect(foundMapChunk)
8577
}
8678
}

0 commit comments

Comments
 (0)