Skip to content

Commit 1f42240

Browse files
committed
make existing fields required lists
1 parent 7dbe236 commit 1f42240

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

firebase-ai/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
2-
* [feature] Add support for Grounding with Google Search (#7042).
2+
* [feature] **Breaking Change**: Add support for Grounding with Google Search (#7042).
3+
* **Action Required:** Update all references of `groundingAttributions`, `webSearchQueries`, `retrievalQueries` in `GroundingMetadata` to be non-optional.
34
* [changed] Deprecate the `totalBillableCharacters` field (only usable with pre-2.0 models). (#7042)
45
* [feature] Added support for extra schema properties like `title`, `minItems`, `maxItems`, `minimum`
56
and `maximum`. As well as support for the `anyOf` schema. (#7013)

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Candidate.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ public class FinishReason private constructor(public val name: String, public va
312312
* specific segments of the model's response are supported by the `groundingChunks`.
313313
*/
314314
public class GroundingMetadata(
315-
public val webSearchQueries: List<String>?,
315+
public val webSearchQueries: List<String>,
316316
public val searchEntryPoint: SearchEntryPoint?,
317-
public val retrievalQueries: List<String>?,
317+
public val retrievalQueries: List<String>,
318318
@Deprecated("Use groundingChunks instead")
319-
public val groundingAttribution: List<GroundingAttribution>?,
319+
public val groundingAttribution: List<GroundingAttribution>,
320320
public val groundingChunks: List<GroundingChunk>,
321321
public val groundingSupports: List<GroundingSupport>,
322322
) {
@@ -332,10 +332,10 @@ public class GroundingMetadata(
332332
) {
333333
internal fun toPublic() =
334334
GroundingMetadata(
335-
webSearchQueries = webSearchQueries,
335+
webSearchQueries = webSearchQueries.orEmpty(),
336336
searchEntryPoint = searchEntryPoint?.toPublic(),
337-
retrievalQueries = retrievalQueries,
338-
groundingAttribution = groundingAttribution?.map { it.toPublic() },
337+
retrievalQueries = retrievalQueries.orEmpty(),
338+
groundingAttribution = groundingAttribution?.map { it.toPublic() }.orEmpty(),
339339
groundingChunks = groundingChunks?.map { it.toPublic() }.orEmpty(),
340340
groundingSupports = groundingSupports?.map { it.toPublic() }.orEmpty()
341341
)

firebase-ai/src/test/java/com/google/firebase/ai/VertexAIUnarySnapshotTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ internal class VertexAIUnarySnapshotTests {
604604
val groundingMetadata = candidate.groundingMetadata
605605
groundingMetadata.shouldNotBeNull()
606606

607-
groundingMetadata.webSearchQueries?.first() shouldBe "current weather in London"
607+
groundingMetadata.webSearchQueries.first() shouldBe "current weather in London"
608608
groundingMetadata.searchEntryPoint.shouldNotBeNull()
609609
groundingMetadata.searchEntryPoint?.renderedContent.shouldNotBeEmpty()
610610

0 commit comments

Comments
 (0)