Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions firebase-ai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
configured.
* [changed] Added a `dilation` parameter to `ImagenMaskReference.generateMaskAndPadForOutpainting`
(#7260)
* [feature] Added a new configuration option to enable limited-use App Check tokens for attesting
Firebase AI Logic requests. This enhances security against replay attacks. To use this feature,
configure it explicitly via the new `useLimitedUseAppCheckTokens` parameter when initializing
`FirebaseAI`. We recommend migrating to limited-use tokens now, so your app will be ready to take
advantage of replay protection when it becomes available for Firebase AI Logic.
* [feature] Added support for limited-use tokens with Firebase App Check. These short-lived tokens
provide greater protection for the APIs that give you access to Gemini and Imagen models. Learn
how to [enable usage of limited-use tokens](https://firebase.google.com/docs/ai-logic/app-check).
(#7285)


# 17.1.0
=======
Expand Down
20 changes: 6 additions & 14 deletions firebase-ai/src/main/kotlin/com/google/firebase/ai/FirebaseAI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,12 @@ internal constructor(
*
* @param backend the backend reference to make generative AI requests to.
* @param useLimitedUseAppCheckTokens when sending tokens to the backend, this option enables
* the usage of App Check's limited-use tokens instead of the standard cached tokens.
*
* A new limited-use tokens will be generated for each request; providing a smaller attack
* surface for malicious parties to hijack tokens. When used alongside replay protection,
* limited-use tokens are also _consumed_ after each request, ensuring they can't be used again.
* the usage of App Check's limited-use tokens instead of the standard cached tokens. Learn more
* about [limited-use tokens](https://firebase.google.com/docs/ai-logic/app-check), including
* their nuances, when to use them, and best practices for integrating them into your app.
*
* _This flag is set to `false` by default._
*
* **Important:** Replay protection is not currently supported for the FirebaseAI backend. While
* this feature is being developed, you can still migrate to using limited-use tokens. Because
* limited-use tokens are backwards compatible, you can still use them without replay
* protection. Due to their shorter TTL over standard App Check tokens, they still provide a
* security benefit. Migrating to limited-use tokens sooner minimizes disruption when support
* for replay protection is added.
*/
// TODO(b/440356335): Update docs above when web page goes live in M170
@JvmStatic
@JvmOverloads
public fun getInstance(
Expand Down Expand Up @@ -290,7 +280,9 @@ public fun Firebase.ai(
*
* @param backend the backend reference to make generative AI requests to.
* @param useLimitedUseAppCheckTokens use App Check's limited-use tokens when sending requests to
* the backend. To learn more about what this means, see the full docs on [FirebaseAI.getInstance].
* the backend. Learn more about
* [limited-use tokens](https://firebase.google.com/docs/ai-logic/app-check), including their
* nuances, when to use them, and best practices for integrating them into your app.
*/
// TODO(b/440356335): Update docs above when web page goes live in M170
public fun Firebase.ai(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal class UnsupportedUserLocationException(cause: Throwable? = null) :
FirebaseCommonAIException("User location is not supported for the API use.", cause)

/**
* The user's project has not been configured and enabled for the selected API.
* The Firebase project has not been configured and enabled for the selected API.
*
* For the Gemini Developer API, see
* [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public class UnsupportedUserLocationException internal constructor(cause: Throwa
FirebaseAIException("User location is not supported for the API use.", cause)

/**
* The user's project has not been configured and enabled for the selected API.
* The Firebase project has not been configured and enabled for the selected API.
*
* For the Gemini Developer API, see
* [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class GenerateContentResponse(

/**
* Convenience field representing all the text parts in the response that are marked as thoughts
* as a single string, if they exists.
* as a single string, if they exist.
*
* Learn more about [thinking](https://firebase.google.com/docs/ai-logic/thinking?api=dev).
*/
Expand Down
59 changes: 27 additions & 32 deletions firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Part.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ internal constructor(
/**
* Represents image data sent to and received from requests. The image is converted client-side to
* JPEG encoding at 80% quality before being sent to the server.
*
* @param image [Bitmap] to convert into a [Part]
*/
public class ImagePart
internal constructor(
Expand All @@ -116,6 +114,7 @@ internal constructor(
internal val thoughtSignature: String?
) : Part {

/** @param image [Bitmap] to convert into a [Part] */
public constructor(image: Bitmap) : this(image, false, null)

internal fun toInlineDataPart() =
Expand All @@ -127,13 +126,7 @@ internal constructor(
)
}

/**
* Represents binary data with an associated MIME type sent to and received from requests.
*
* @param inlineData the binary data as a [ByteArray]
* @param mimeType an IANA standard MIME type. For supported values, see the
* [Firebase documentation](https://firebase.google.com/docs/vertex-ai/input-file-requirements).
*/
/** Represents binary data with an associated MIME type sent to and received from requests. */
public class InlineDataPart
internal constructor(
public val inlineData: ByteArray,
Expand All @@ -142,6 +135,11 @@ internal constructor(
internal val thoughtSignature: String?
) : Part {

/**
* @param inlineData the binary data as a [ByteArray]
* @param mimeType an IANA standard MIME type. For supported values, see the
* [Firebase documentation](https://firebase.google.com/docs/vertex-ai/input-file-requirements).
*/
public constructor(
inlineData: ByteArray,
mimeType: String
Expand All @@ -159,14 +157,7 @@ internal constructor(
}
}

/**
* Represents function call name and params received from requests.
*
* @param name the name of the function to call
* @param args the function parameters and values as a [Map]
* @param id Unique id of the function call. If present, the returned [FunctionResponsePart] should
* have a matching `id` field.
*/
/** Represents function call name and params received from requests. */
public class FunctionCallPart
internal constructor(
public val name: String,
Expand All @@ -176,6 +167,12 @@ internal constructor(
internal val thoughtSignature: String?
) : Part {

/**
* @param name the name of the function to call
* @param args the function parameters and values as a [Map]
* @param id Unique id of the function call. If present, the returned [FunctionResponsePart]
* should have a matching `id` field.
*/
@JvmOverloads
public constructor(
name: String,
Expand All @@ -199,13 +196,7 @@ internal constructor(
}
}

/**
* Represents function call output to be returned to the model when it requests a function call.
*
* @param name The name of the called function.
* @param response The response produced by the function as a [JSONObject].
* @param id Matching `id` for a [FunctionCallPart], if one was provided.
*/
/** Represents function call output to be returned to the model when it requests a function call. */
public class FunctionResponsePart
internal constructor(
public val name: String,
Expand All @@ -215,6 +206,11 @@ internal constructor(
internal val thoughtSignature: String?
) : Part {

/**
* @param name The name of the called function.
* @param response The response produced by the function as a [JSONObject].
* @param id Matching `id` for a [FunctionCallPart], if one was provided.
*/
@JvmOverloads
public constructor(
name: String,
Expand Down Expand Up @@ -242,14 +238,7 @@ internal constructor(
}
}

/**
* Represents file data stored in Cloud Storage for Firebase, referenced by URI.
*
* @param uri The `"gs://"`-prefixed URI of the file in Cloud Storage for Firebase, for example,
* `"gs://bucket-name/path/image.jpg"`
* @param mimeType an IANA standard MIME type. For supported MIME type values see the
* [Firebase documentation](https://firebase.google.com/docs/vertex-ai/input-file-requirements).
*/
/** Represents file data stored in Cloud Storage for Firebase, referenced by URI. */
public class FileDataPart
internal constructor(
public val uri: String,
Expand All @@ -258,6 +247,12 @@ internal constructor(
internal val thoughtSignature: String?
) : Part {

/**
* @param uri The `"gs://"`-prefixed URI of the file in Cloud Storage for Firebase, for example,
* `"gs://bucket-name/path/image.jpg"`
* @param mimeType an IANA standard MIME type. For supported MIME type values see the
* [Firebase documentation](https://firebase.google.com/docs/vertex-ai/input-file-requirements).
*/
public constructor(uri: String, mimeType: String) : this(uri, mimeType, false, null)

@Serializable
Expand Down
10 changes: 10 additions & 0 deletions release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "m169",
"libraries": [
":firebase-ai",
":firebase-crashlytics",
":firebase-crashlytics-ndk",
":firebase-sessions",
":firebase-perf"
]
}
Loading
Loading