Skip to content

Commit 74b0b5c

Browse files
committed
Update API to avoid breaking change
1 parent 9aad869 commit 74b0b5c

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

firebase-ai/api.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ package com.google.firebase.ai {
2323
method public com.google.firebase.ai.GenerativeModel generativeModel(String modelName, com.google.firebase.ai.type.GenerationConfig? generationConfig = null, java.util.List<com.google.firebase.ai.type.SafetySetting>? safetySettings = null, java.util.List<com.google.firebase.ai.type.Tool>? tools = null, com.google.firebase.ai.type.ToolConfig? toolConfig = null, com.google.firebase.ai.type.Content? systemInstruction = null, com.google.firebase.ai.type.RequestOptions requestOptions = com.google.firebase.ai.type.RequestOptions());
2424
method public static com.google.firebase.ai.FirebaseAI getInstance();
2525
method public static com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.ai.type.GenerativeBackend backend);
26+
method public static com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.ai.type.GenerativeBackend backend, boolean useLimitedUseAppCheckTokens);
2627
method public static com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app);
2728
method public static com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend);
28-
method public static com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend, boolean useLimitedUseAppCheckTokens = false);
29+
method public static com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend, boolean useLimitedUseAppCheckTokens);
2930
method @com.google.firebase.ai.type.PublicPreviewAPI public com.google.firebase.ai.ImagenModel imagenModel(String modelName);
3031
method @com.google.firebase.ai.type.PublicPreviewAPI public com.google.firebase.ai.ImagenModel imagenModel(String modelName, com.google.firebase.ai.type.ImagenGenerationConfig? generationConfig = null);
3132
method @com.google.firebase.ai.type.PublicPreviewAPI public com.google.firebase.ai.ImagenModel imagenModel(String modelName, com.google.firebase.ai.type.ImagenGenerationConfig? generationConfig = null, com.google.firebase.ai.type.ImagenSafetySettings? safetySettings = null);
@@ -42,14 +43,16 @@ package com.google.firebase.ai {
4243
public static final class FirebaseAI.Companion {
4344
method public com.google.firebase.ai.FirebaseAI getInstance();
4445
method public com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.ai.type.GenerativeBackend backend);
46+
method public com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.ai.type.GenerativeBackend backend, boolean useLimitedUseAppCheckTokens);
4547
method public com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app);
4648
method public com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend);
47-
method public com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend, boolean useLimitedUseAppCheckTokens = false);
49+
method public com.google.firebase.ai.FirebaseAI getInstance(com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend, boolean useLimitedUseAppCheckTokens);
4850
property public final com.google.firebase.ai.FirebaseAI instance;
4951
}
5052

5153
public final class FirebaseAIKt {
52-
method public static com.google.firebase.ai.FirebaseAI ai(com.google.firebase.Firebase, com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend = GenerativeBackend.googleAI(), boolean useLimitedUseAppCheckTokens = false);
54+
method public static com.google.firebase.ai.FirebaseAI ai(com.google.firebase.Firebase, com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend = GenerativeBackend.googleAI());
55+
method public static com.google.firebase.ai.FirebaseAI ai(com.google.firebase.Firebase, com.google.firebase.FirebaseApp app = Firebase.app, com.google.firebase.ai.type.GenerativeBackend backend = GenerativeBackend.googleAI(), boolean useLimitedUseAppCheckTokens);
5356
method public static com.google.firebase.ai.FirebaseAI getAi(com.google.firebase.Firebase);
5457
}
5558

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,20 @@ internal constructor(
212212
public val instance: FirebaseAI
213213
get() = getInstance(backend = GenerativeBackend.googleAI())
214214

215+
/**
216+
* Returns the [FirebaseAI] instance for the provided [FirebaseApp] and [backend].
217+
*
218+
* @param backend the backend reference to make generative AI requests to.
219+
*/
220+
@JvmStatic
221+
@JvmOverloads
222+
public fun getInstance(
223+
app: FirebaseApp = Firebase.app,
224+
backend: GenerativeBackend
225+
): FirebaseAI {
226+
return getInstance(app, backend, false)
227+
}
228+
215229
/**
216230
* Returns the [FirebaseAI] instance for the provided [FirebaseApp] and [backend].
217231
*
@@ -237,7 +251,7 @@ internal constructor(
237251
public fun getInstance(
238252
app: FirebaseApp = Firebase.app,
239253
backend: GenerativeBackend,
240-
useLimitedUseAppCheckTokens: Boolean = false,
254+
useLimitedUseAppCheckTokens: Boolean,
241255
): FirebaseAI {
242256
val multiResourceComponent = app[FirebaseAIMultiResourceComponent::class.java]
243257
return multiResourceComponent.get(InstanceKey(backend, useLimitedUseAppCheckTokens))
@@ -260,6 +274,16 @@ internal constructor(
260274
public val Firebase.ai: FirebaseAI
261275
get() = FirebaseAI.instance
262276

277+
/**
278+
* Returns the [FirebaseAI] instance for the provided [FirebaseApp] and [backend].
279+
*
280+
* @param backend the backend reference to make generative AI requests to.
281+
*/
282+
public fun Firebase.ai(
283+
app: FirebaseApp = Firebase.app,
284+
backend: GenerativeBackend = GenerativeBackend.googleAI()
285+
): FirebaseAI = FirebaseAI.getInstance(app, backend)
286+
263287
/**
264288
* Returns the [FirebaseAI] instance for the provided [FirebaseApp] and [backend].
265289
*
@@ -270,5 +294,5 @@ public val Firebase.ai: FirebaseAI
270294
public fun Firebase.ai(
271295
app: FirebaseApp = Firebase.app,
272296
backend: GenerativeBackend = GenerativeBackend.googleAI(),
273-
useLimitedUseAppCheckTokens: Boolean = false
297+
useLimitedUseAppCheckTokens: Boolean
274298
): FirebaseAI = FirebaseAI.getInstance(app, backend, useLimitedUseAppCheckTokens)

0 commit comments

Comments
 (0)