From d6a84ae29f90465a7e44da35582eaa31d0c59733 Mon Sep 17 00:00:00 2001 From: Mila <107142260+milaGGL@users.noreply.github.com> Date: Fri, 4 Sep 2026 11:41:10 -0400 Subject: [PATCH 1/6] [AI] Add warning note for hybrid structured output --- .../kotlin/com/google/firebase/ai/GenerativeModel.kt | 12 ++++++++++++ .../kotlin/com/google/firebase/ai/type/JsonSchema.kt | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt index 389d54434c5..e4fd0fe69e7 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt @@ -166,6 +166,12 @@ internal constructor( /** * Generates an object from the input [Content] given to the model as a prompt. * + * **Note for Structured Output:** + * + * * **On-Device (Hybrid):** Requires using the `@Generable` annotation on a `data class`. Manual + * schemas and direct `enum class` annotations are not supported. + * * **Cloud-Only:** Supports both `@Generable` annotations and manual schemas. + * * @param jsonSchema A schema for the output * @param prompt The input(s) given to the model as a prompt. * @return The content generated by the model. @@ -181,6 +187,12 @@ internal constructor( /** * Generates an object from the text input given to the model as a prompt. * + * **Note for Structured Output:** + * + * * **On-Device (Hybrid):** Requires using the `@Generable` annotation on a `data class`. Manual + * schemas and direct `enum class` annotations are not supported. + * * **Cloud-Only:** Supports both `@Generable` annotations and manual schemas. + * * @param jsonSchema A schema for the output * @param prompt The text to be send to the model as a prompt. * @return The content generated by the model. diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt index f2b98d5c213..81e1e75b325 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt @@ -32,6 +32,12 @@ import kotlinx.serialization.serializerOrNull * **Note:** While optional, including a `description` field in your `JsonSchema` is strongly * encouraged. The more information the model has about what it's expected to generate, the better * the results. + * + * **Note for Structured Output:** + * + * * **On-Device (Hybrid):** Requires using the `@Generable` annotation on a `data class`. Manual + * schemas and direct `enum class` annotations are not supported. + * * **Cloud-Only:** Supports both `@Generable` annotations and manual schemas. */ public class JsonSchema internal constructor( From 595fff1d6bf6b517529ee053b2ebcffc2f06724e Mon Sep 17 00:00:00 2001 From: Mila <107142260+milaGGL@users.noreply.github.com> Date: Fri, 4 Sep 2026 12:32:34 -0400 Subject: [PATCH 2/6] Update ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt Co-authored-by: rachelsaunders <52258509+rachelsaunders@users.noreply.github.com> --- .../src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt index 81e1e75b325..bf4e08903c3 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt @@ -35,7 +35,7 @@ import kotlinx.serialization.serializerOrNull * * **Note for Structured Output:** * - * * **On-Device (Hybrid):** Requires using the `@Generable` annotation on a `data class`. Manual + * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data class`. Manual * schemas and direct `enum class` annotations are not supported. * * **Cloud-Only:** Supports both `@Generable` annotations and manual schemas. */ From a6c477ca84f0011219787d367d2df4d0a45294b8 Mon Sep 17 00:00:00 2001 From: Mila <107142260+milaGGL@users.noreply.github.com> Date: Fri, 4 Sep 2026 12:32:44 -0400 Subject: [PATCH 3/6] Update ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt Co-authored-by: rachelsaunders <52258509+rachelsaunders@users.noreply.github.com> --- .../src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt index bf4e08903c3..d912b79065d 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt @@ -37,7 +37,7 @@ import kotlinx.serialization.serializerOrNull * * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data class`. Manual * schemas and direct `enum class` annotations are not supported. - * * **Cloud-Only:** Supports both `@Generable` annotations and manual schemas. + * * **Cloud-based inference:** Supports both `@Generable` annotations and manual schemas. */ public class JsonSchema internal constructor( From 903bb77528ec458129b240ea998bd0eb5756fed2 Mon Sep 17 00:00:00 2001 From: Mila <107142260+milaGGL@users.noreply.github.com> Date: Fri, 4 Sep 2026 12:40:46 -0400 Subject: [PATCH 4/6] format --- .../kotlin/com/google/firebase/ai/GenerativeModel.kt | 12 ++++++------ .../kotlin/com/google/firebase/ai/type/JsonSchema.kt | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt index e4fd0fe69e7..c20ce37e9bb 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt @@ -168,9 +168,9 @@ internal constructor( * * **Note for Structured Output:** * - * * **On-Device (Hybrid):** Requires using the `@Generable` annotation on a `data class`. Manual - * schemas and direct `enum class` annotations are not supported. - * * **Cloud-Only:** Supports both `@Generable` annotations and manual schemas. + * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data + * class`. Manual schemas and direct `enum class` annotations are not supported. + * * **Cloud-based inference:** Supportsboth `@Generable` annotations and manual schemas. * * @param jsonSchema A schema for the output * @param prompt The input(s) given to the model as a prompt. @@ -189,9 +189,9 @@ internal constructor( * * **Note for Structured Output:** * - * * **On-Device (Hybrid):** Requires using the `@Generable` annotation on a `data class`. Manual - * schemas and direct `enum class` annotations are not supported. - * * **Cloud-Only:** Supports both `@Generable` annotations and manual schemas. + * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data + * class`. Manual schemas and direct `enum class` annotations are not supported. + * * **Cloud-based inference:** Supportsboth `@Generable` annotations and manual schemas. * * @param jsonSchema A schema for the output * @param prompt The text to be send to the model as a prompt. diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt index d912b79065d..82f2ee178c7 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt @@ -35,8 +35,8 @@ import kotlinx.serialization.serializerOrNull * * **Note for Structured Output:** * - * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data class`. Manual - * schemas and direct `enum class` annotations are not supported. + * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data class`. + * Manual schemas and direct `enum class` annotations are not supported. * * **Cloud-based inference:** Supports both `@Generable` annotations and manual schemas. */ public class JsonSchema From c350e39824879919d95d88f427fb4b809437d4f1 Mon Sep 17 00:00:00 2001 From: Mila Date: Fri, 18 Sep 2026 15:25:13 -0400 Subject: [PATCH 5/6] update the comment --- .../com/google/firebase/ai/GenerativeModel.kt | 16 ++++++++++------ .../com/google/firebase/ai/type/JsonSchema.kt | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt index c20ce37e9bb..a553187b2eb 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt @@ -168,9 +168,11 @@ internal constructor( * * **Note for Structured Output:** * - * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data - * class`. Manual schemas and direct `enum class` annotations are not supported. - * * **Cloud-based inference:** Supportsboth `@Generable` annotations and manual schemas. + * * **For on-device and hybrid inference (`ONLY_ON_DEVICE`, `PREFER_ON_DEVICE`, and + * `PREFER_IN_CLOUD`):** Requires using the `@Generable` annotation on a `data class`. Manual + * schemas are not supported. + * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations and + * manual schemas. * * @param jsonSchema A schema for the output * @param prompt The input(s) given to the model as a prompt. @@ -189,9 +191,11 @@ internal constructor( * * **Note for Structured Output:** * - * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data - * class`. Manual schemas and direct `enum class` annotations are not supported. - * * **Cloud-based inference:** Supportsboth `@Generable` annotations and manual schemas. + * * **For on-device and hybrid inference (`ONLY_ON_DEVICE`, `PREFER_ON_DEVICE`, and + * `PREFER_IN_CLOUD`):** Requires using the `@Generable` annotation on a `data class`. Manual + * schemas are not supported. + * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations and + * manual schemas. * * @param jsonSchema A schema for the output * @param prompt The text to be send to the model as a prompt. diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt index 82f2ee178c7..5e17c3ef862 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt @@ -35,9 +35,11 @@ import kotlinx.serialization.serializerOrNull * * **Note for Structured Output:** * - * * **On-device (hybrid) inference:** Requires using the `@Generable` annotation on a `data class`. - * Manual schemas and direct `enum class` annotations are not supported. - * * **Cloud-based inference:** Supports both `@Generable` annotations and manual schemas. + * * **For on-device and hybrid inference (`ONLY_ON_DEVICE`, `PREFER_ON_DEVICE`, and + * `PREFER_IN_CLOUD`):** Requires using the `@Generable` annotation on a `data class`. Manual + * schemas are not supported. + * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations and + * manual schemas. */ public class JsonSchema internal constructor( From c442ae7c3b5541d485e1e507aab9f81c2e9bca39 Mon Sep 17 00:00:00 2001 From: Mila Date: Fri, 18 Sep 2026 16:27:27 -0400 Subject: [PATCH 6/6] resolve comment --- .../main/kotlin/com/google/firebase/ai/GenerativeModel.kt | 8 ++++---- .../main/kotlin/com/google/firebase/ai/type/JsonSchema.kt | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt index a553187b2eb..84010bba7a4 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/GenerativeModel.kt @@ -171,8 +171,8 @@ internal constructor( * * **For on-device and hybrid inference (`ONLY_ON_DEVICE`, `PREFER_ON_DEVICE`, and * `PREFER_IN_CLOUD`):** Requires using the `@Generable` annotation on a `data class`. Manual * schemas are not supported. - * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations and - * manual schemas. + * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations + * (recommended) and manual schemas. * * @param jsonSchema A schema for the output * @param prompt The input(s) given to the model as a prompt. @@ -194,8 +194,8 @@ internal constructor( * * **For on-device and hybrid inference (`ONLY_ON_DEVICE`, `PREFER_ON_DEVICE`, and * `PREFER_IN_CLOUD`):** Requires using the `@Generable` annotation on a `data class`. Manual * schemas are not supported. - * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations and - * manual schemas. + * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations + * (recommended) and manual schemas. * * @param jsonSchema A schema for the output * @param prompt The text to be send to the model as a prompt. diff --git a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt index 5e17c3ef862..6a68f924c65 100644 --- a/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt +++ b/ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/JsonSchema.kt @@ -38,8 +38,8 @@ import kotlinx.serialization.serializerOrNull * * **For on-device and hybrid inference (`ONLY_ON_DEVICE`, `PREFER_ON_DEVICE`, and * `PREFER_IN_CLOUD`):** Requires using the `@Generable` annotation on a `data class`. Manual * schemas are not supported. - * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations and - * manual schemas. + * * **For cloud-only inference (`ONLY_IN_CLOUD`):** Supports both `@Generable` annotations + * (recommended) and manual schemas. */ public class JsonSchema internal constructor(