Skip to content

Commit a6c1c48

Browse files
committed
Merge branch 'main' into bidi
2 parents f8b1d12 + f67d32d commit a6c1c48

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

firebase-vertexai/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Unreleased
2+
* [feature] Emits a warning when attempting to use an incompatible model with
3+
`GenerativeModel` or `ImagenModel`.
24
* [changed] Added new exception type for quota exceeded scenarios.
35
* [feature] `CountTokenRequest` now includes `GenerationConfig` from the model.
46
* [feature] Public Preview: Added support for streaming input and output (including audio) using the [Multimodal Live API](/docs/vertex-ai/live-api?platform=android)

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/FirebaseVertexAI.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.firebase.vertexai
1818

19+
import android.util.Log
1920
import com.google.firebase.Firebase
2021
import com.google.firebase.FirebaseApp
2122
import com.google.firebase.app
@@ -69,6 +70,15 @@ internal constructor(
6970
if (location.trim().isEmpty() || location.contains("/")) {
7071
throw InvalidLocationException(location)
7172
}
73+
if (!modelName.startsWith(GEMINI_MODEL_NAME_PREFIX)) {
74+
Log.w(
75+
TAG,
76+
"""Unsupported Gemini model "${modelName}"; see
77+
https://firebase.google.com/docs/vertex-ai/models for a list supported Gemini model names.
78+
"""
79+
.trimIndent()
80+
)
81+
}
7282
return GenerativeModel(
7383
"projects/${firebaseApp.options.projectId}/locations/${location}/publishers/google/models/${modelName}",
7484
firebaseApp.options.apiKey,
@@ -140,6 +150,15 @@ internal constructor(
140150
if (location.trim().isEmpty() || location.contains("/")) {
141151
throw InvalidLocationException(location)
142152
}
153+
if (!modelName.startsWith(IMAGEN_MODEL_NAME_PREFIX)) {
154+
Log.w(
155+
TAG,
156+
"""Unsupported Imagen model "${modelName}"; see
157+
https://firebase.google.com/docs/vertex-ai/models for a list supported Imagen model names.
158+
"""
159+
.trimIndent()
160+
)
161+
}
143162
return ImagenModel(
144163
"projects/${firebaseApp.options.projectId}/locations/${location}/publishers/google/models/${modelName}",
145164
firebaseApp.options.apiKey,
@@ -173,6 +192,12 @@ internal constructor(
173192
val multiResourceComponent = app[FirebaseVertexAIMultiResourceComponent::class.java]
174193
return multiResourceComponent.get(location)
175194
}
195+
196+
private const val GEMINI_MODEL_NAME_PREFIX = "gemini-"
197+
198+
private const val IMAGEN_MODEL_NAME_PREFIX = "imagen-"
199+
200+
private val TAG = FirebaseVertexAI::class.java.simpleName
176201
}
177202
}
178203

0 commit comments

Comments
 (0)