Skip to content

Commit a9ba7a9

Browse files
committed
Merge branch 'main' into add_interrupt_support
2 parents 80e444b + 1246b69 commit a9ba7a9

File tree

45 files changed

+835
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+835
-88
lines changed

.github/workflows/dataconnect.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ env:
3434
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
3535
FDC_ANDROID_EMULATOR_API_LEVEL: ${{ inputs.androidEmulatorApiLevel || '34' }}
3636
FDC_NODEJS_VERSION: ${{ inputs.nodeJsVersion || '20' }}
37-
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.15.1' }}
37+
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.18.0' }}
3838
FDC_FIREBASE_TOOLS_DIR: /tmp/firebase-tools
3939
FDC_FIREBASE_COMMAND: /tmp/firebase-tools/node_modules/.bin/firebase
4040
FDC_PYTHON_VERSION: ${{ inputs.pythonVersion || '3.13' }}

.github/workflows/dataconnect_demo_app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818

1919
env:
2020
FDC_NODE_VERSION: ${{ inputs.nodeVersion || '20' }}
21-
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.15.1' }}
21+
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.18.0' }}
2222
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
2323
FDC_FIREBASE_TOOLS_DIR: ${{ github.workspace }}/firebase-tools
2424
FDC_FIREBASE_COMMAND: ${{ github.workspace }}/firebase-tools/node_modules/.bin/firebase

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fun Project.applySpotless() {
6262
}
6363
format("styling") {
6464
target("src/**/*.md", "*.md", "docs/**/*.md")
65-
targetExclude("**/third_party/**", "src/test/resources/**")
65+
targetExclude("**/third_party/**", "src/test/resources/**", "release_report.md")
6666
prettier().config(mapOf("printWidth" to 100, "proseWrap" to "always"))
6767
}
6868
}

firebase-ai/CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Unreleased
22

33
- [changed] **Breaking Change**: Removed the `candidateCount` option from `LiveGenerationConfig`
4-
- [changed] Added better error messages to `ServiceConnectionHandshakeFailedException`
54
- [changed] Added support for user interrupts for the `startAudioConversation` method in the
65
`LiveSession` class.
6+
- [changed] Added support for the URL context tool, which allows the model to access content from
7+
provided public web URLs to inform and enhance its responses. (#7382)
8+
- [changed] Added better error messages to `ServiceConnectionHandshakeFailedException` (#7412)
9+
- [changed] Marked the public constructor for `UsageMetadata` as deprecated (#7420)
10+
- [changed] Using Firebase AI Logic with the Gemini Developer API is now Generally Available (GA).
11+
- [changed] Using Firebase AI Logic with the Imagen generation APIs is now Generally Available (GA).
712

813
# 17.3.0
914

@@ -47,7 +52,7 @@
4752

4853
- [feature] Added support for configuring the "thinking" budget when using Gemini 2.5 series models.
4954
(#6990)
50-
- [feature] **Breaking Change**: Add support for Grounding with Google Search (#7042).
55+
- [feature] **Breaking Change**: Add support for grounding with Google Search (#7042).
5156
- **Action Required:** Update all references of `groundingAttributions`, `webSearchQueries`,
5257
`retrievalQueries` in `GroundingMetadata` to be non-optional.
5358
- [changed] require at least one argument for `generateContent()`, `generateContentStream()` and

firebase-ai/api.txt

Lines changed: 59 additions & 19 deletions
Large diffs are not rendered by default.

firebase-ai/src/main/kotlin/com/google/firebase/ai/FirebaseAI.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ internal constructor(
170170
* @return The initialized [ImagenModel] instance.
171171
*/
172172
@JvmOverloads
173-
@PublicPreviewAPI
174173
public fun imagenModel(
175174
modelName: String,
176175
generationConfig: ImagenGenerationConfig? = null,

firebase-ai/src/main/kotlin/com/google/firebase/ai/ImagenModel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import com.google.firebase.auth.internal.InternalAuthProvider
4545
* See the documentation for a list of
4646
* [supported models](https://firebase.google.com/docs/ai-logic/models).
4747
*/
48-
@PublicPreviewAPI
4948
public class ImagenModel
5049
internal constructor(
5150
private val modelName: String,
@@ -106,6 +105,7 @@ internal constructor(
106105
* @param prompt the text input given to the model as a prompt
107106
* @param config the editing configuration settings
108107
*/
108+
@PublicPreviewAPI
109109
public suspend fun editImage(
110110
referenceImages: List<ImagenReferenceImage>,
111111
prompt: String,
@@ -130,6 +130,7 @@ internal constructor(
130130
* @param mask the mask which defines where in the image can be painted by Imagen.
131131
* @param config the editing configuration settings, it should include an [ImagenEditMode]
132132
*/
133+
@PublicPreviewAPI
133134
public suspend fun inpaintImage(
134135
image: ImagenInlineImage,
135136
prompt: String,
@@ -154,6 +155,7 @@ internal constructor(
154155
* @param config the editing configuration settings
155156
* @see [ImagenMaskReference.generateMaskAndPadForOutpainting]
156157
*/
158+
@PublicPreviewAPI
157159
public suspend fun outpaintImage(
158160
image: ImagenInlineImage,
159161
newDimensions: Dimensions,
@@ -172,6 +174,7 @@ internal constructor(
172174
prompt: String,
173175
generationConfig: ImagenGenerationConfig? = null,
174176
): GenerateImageRequest {
177+
@OptIn(PublicPreviewAPI::class)
175178
return GenerateImageRequest(
176179
listOf(GenerateImageRequest.ImagenPrompt(prompt, null)),
177180
GenerateImageRequest.ImagenParameters(
@@ -191,6 +194,7 @@ internal constructor(
191194
)
192195
}
193196

197+
@PublicPreviewAPI
194198
private fun constructEditRequest(
195199
referenceImages: List<ImagenReferenceImage>,
196200
prompt: String,

firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Request.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ internal data class CountTokensRequest(
7777
}
7878

7979
@Serializable
80-
@PublicPreviewAPI
80+
@OptIn(PublicPreviewAPI::class)
8181
internal data class GenerateImageRequest(
8282
val instances: List<ImagenPrompt>,
8383
val parameters: ImagenParameters,
@@ -88,7 +88,6 @@ internal data class GenerateImageRequest(
8888
val referenceImages: List<ImagenReferenceImage.Internal>?
8989
)
9090

91-
@OptIn(PublicPreviewAPI::class)
9291
@Serializable
9392
internal data class ImagenParameters(
9493
val sampleCount: Int,
@@ -102,7 +101,7 @@ internal data class GenerateImageRequest(
102101
val addWatermark: Boolean?,
103102
val imageOutputOptions: ImagenImageFormat.Internal?,
104103
val editMode: String?,
105-
val editConfig: ImagenEditingConfig.Internal?,
104+
@OptIn(PublicPreviewAPI::class) val editConfig: ImagenEditingConfig.Internal?,
106105
)
107106

108107
@Serializable

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

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,47 @@ import kotlinx.serialization.json.JsonNames
3333
* @property safetyRatings A list of [SafetyRating]s describing the generated content.
3434
* @property citationMetadata Metadata about the sources used to generate this content.
3535
* @property finishReason The reason the model stopped generating content, if it exist.
36-
* @property groundingMetadata Metadata returned to the client when grounding is enabled.
36+
* @property groundingMetadata Metadata returned to the client when the model grounds its response.
37+
* @property urlContextMetadata Metadata returned to the client when the [UrlContext] tool is
38+
* enabled.
3739
*/
3840
public class Candidate
41+
@OptIn(PublicPreviewAPI::class)
3942
internal constructor(
4043
public val content: Content,
4144
public val safetyRatings: List<SafetyRating>,
4245
public val citationMetadata: CitationMetadata?,
4346
public val finishReason: FinishReason?,
44-
public val groundingMetadata: GroundingMetadata?
47+
public val groundingMetadata: GroundingMetadata?,
48+
@property:PublicPreviewAPI public val urlContextMetadata: UrlContextMetadata?
4549
) {
4650

51+
@OptIn(PublicPreviewAPI::class)
4752
@Serializable
4853
internal data class Internal(
4954
val content: Content.Internal? = null,
5055
val finishReason: FinishReason.Internal? = null,
5156
val safetyRatings: List<SafetyRating.Internal>? = null,
5257
val citationMetadata: CitationMetadata.Internal? = null,
53-
val groundingMetadata: GroundingMetadata.Internal? = null
58+
val groundingMetadata: GroundingMetadata.Internal? = null,
59+
val urlContextMetadata: UrlContextMetadata.Internal? = null
5460
) {
61+
62+
@OptIn(PublicPreviewAPI::class)
5563
internal fun toPublic(): Candidate {
5664
val safetyRatings = safetyRatings?.mapNotNull { it.toPublic() }.orEmpty()
5765
val citations = citationMetadata?.toPublic()
5866
val finishReason = finishReason?.toPublic()
5967
val groundingMetadata = groundingMetadata?.toPublic()
68+
val urlContextMetadata = urlContextMetadata?.toPublic()
6069

6170
return Candidate(
6271
this.content?.toPublic() ?: content("model") {},
6372
safetyRatings,
6473
citations,
6574
finishReason,
66-
groundingMetadata
75+
groundingMetadata,
76+
urlContextMetadata
6777
)
6878
}
6979
}
@@ -297,7 +307,7 @@ public class FinishReason private constructor(public val name: String, public va
297307
/**
298308
* Metadata returned to the client when grounding is enabled.
299309
*
300-
* If using Grounding with Google Search, you are required to comply with the "Grounding with Google
310+
* If using grounding with Google Search, you are required to comply with the "Grounding with Google
301311
* Search" usage requirements for your chosen API provider:
302312
* [Gemini Developer API](https://ai.google.dev/gemini-api/terms#grounding-with-google-search) or
303313
* Vertex AI Gemini API (see [Service Terms](https://cloud.google.com/terms/service-terms) section
@@ -372,8 +382,7 @@ public class SearchEntryPoint(
372382
}
373383

374384
/**
375-
* Represents a chunk of retrieved data that supports a claim in the model's response. This is part
376-
* of the grounding information provided when grounding is enabled.
385+
* Represents a chunk of retrieved data that supports a claim in the model's response.
377386
*
378387
* @property web Contains details if the grounding chunk is from a web source.
379388
*/
@@ -492,3 +501,87 @@ public class Segment(
492501
)
493502
}
494503
}
504+
505+
/**
506+
* Metadata related to the [UrlContext] tool.
507+
*
508+
* @property urlMetadata List of [UrlMetadata] used to provide context to the Gemini model.
509+
*/
510+
@PublicPreviewAPI
511+
public class UrlContextMetadata internal constructor(public val urlMetadata: List<UrlMetadata>) {
512+
513+
@Serializable
514+
@PublicPreviewAPI
515+
internal data class Internal(val urlMetadata: List<UrlMetadata.Internal>?) {
516+
internal fun toPublic() = UrlContextMetadata(urlMetadata?.map { it.toPublic() } ?: emptyList())
517+
}
518+
}
519+
520+
/**
521+
* Metadata for a single URL retrieved by the [UrlContext] tool.
522+
*
523+
* @property retrievedUrl The retrieved URL.
524+
* @property urlRetrievalStatus The status of the URL retrieval.
525+
*/
526+
@PublicPreviewAPI
527+
public class UrlMetadata
528+
internal constructor(
529+
public val retrievedUrl: String?,
530+
public val urlRetrievalStatus: UrlRetrievalStatus
531+
) {
532+
@Serializable
533+
internal data class Internal(
534+
val retrievedUrl: String?,
535+
val urlRetrievalStatus: UrlRetrievalStatus.Internal
536+
) {
537+
internal fun toPublic() = UrlMetadata(retrievedUrl, urlRetrievalStatus.toPublic())
538+
}
539+
}
540+
541+
/**
542+
* The status of a URL retrieval.
543+
*
544+
* @property name The name of the retrieval status.
545+
* @property ordinal The ordinal value of the retrieval status.
546+
*/
547+
@PublicPreviewAPI
548+
public class UrlRetrievalStatus
549+
private constructor(public val name: String, public val ordinal: Int) {
550+
551+
@Serializable(Internal.Serializer::class)
552+
internal enum class Internal {
553+
@SerialName("URL_RETRIEVAL_STATUS_UNSPECIFIED") UNSPECIFIED,
554+
@SerialName("URL_RETRIEVAL_STATUS_SUCCESS") SUCCESS,
555+
@SerialName("URL_RETRIEVAL_STATUS_ERROR") ERROR,
556+
@SerialName("URL_RETRIEVAL_STATUS_PAYWALL") PAYWALL,
557+
@SerialName("URL_RETRIEVAL_STATUS_UNSAFE") UNSAFE;
558+
559+
internal object Serializer : KSerializer<Internal> by FirstOrdinalSerializer(Internal::class)
560+
561+
internal fun toPublic() =
562+
when (this) {
563+
SUCCESS -> UrlRetrievalStatus.SUCCESS
564+
ERROR -> UrlRetrievalStatus.ERROR
565+
PAYWALL -> UrlRetrievalStatus.PAYWALL
566+
UNSAFE -> UrlRetrievalStatus.UNSAFE
567+
else -> UrlRetrievalStatus.UNSPECIFIED
568+
}
569+
}
570+
571+
public companion object {
572+
/** Unspecified retrieval status. */
573+
@JvmField public val UNSPECIFIED: UrlRetrievalStatus = UrlRetrievalStatus("UNSPECIFIED", 0)
574+
575+
/** The URL retrieval was successful. */
576+
@JvmField public val SUCCESS: UrlRetrievalStatus = UrlRetrievalStatus("SUCCESS", 1)
577+
578+
/** The URL retrieval failed. */
579+
@JvmField public val ERROR: UrlRetrievalStatus = UrlRetrievalStatus("ERROR", 2)
580+
581+
/** The URL retrieval failed because the content is behind a paywall. */
582+
@JvmField public val PAYWALL: UrlRetrievalStatus = UrlRetrievalStatus("PAYWALL", 3)
583+
584+
/** The URL retrieval failed because the content is unsafe. */
585+
@JvmField public val UNSAFE: UrlRetrievalStatus = UrlRetrievalStatus("UNSAFE", 4)
586+
}
587+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import kotlinx.serialization.Serializable
2222
* A tool that allows the generative model to connect to Google Search to access and incorporate
2323
* up-to-date information from the web into its responses.
2424
*
25-
* When using this feature, you are required to comply with the "Grounding with Google Search" usage
25+
* When using this feature, you are required to comply with the "grounding with Google Search" usage
2626
* requirements for your chosen API provider:
2727
* [Gemini Developer API](https://ai.google.dev/gemini-api/terms#grounding-with-google-search) or
2828
* Vertex AI Gemini API (see [Service Terms](https://cloud.google.com/terms/service-terms) section

0 commit comments

Comments
 (0)