Skip to content

Commit 8ea196e

Browse files
author
David Motsonashvili
committed
fixes for comments
1 parent 6c28594 commit 8ea196e

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ import com.google.firebase.ai.type.GenerativeBackend
2525
import com.google.firebase.ai.type.GenerativeBackendEnum
2626
import com.google.firebase.ai.type.ImagenGenerationConfig
2727
import com.google.firebase.ai.type.ImagenSafetySettings
28-
import com.google.firebase.ai.type.InvalidLocationException
28+
import com.google.firebase.ai.type.InvalidStateException
2929
import com.google.firebase.ai.type.LiveGenerationConfig
3030
import com.google.firebase.ai.type.PublicPreviewAPI
3131
import com.google.firebase.ai.type.RequestOptions
3232
import com.google.firebase.ai.type.SafetySetting
33-
import com.google.firebase.ai.type.ServiceDisabledException
3433
import com.google.firebase.ai.type.Tool
3534
import com.google.firebase.ai.type.ToolConfig
3635
import com.google.firebase.annotations.concurrent.Blocking
@@ -49,9 +48,6 @@ internal constructor(
4948
private val appCheckProvider: Provider<InteropAppCheckTokenProvider>,
5049
private val internalAuthProvider: Provider<InternalAuthProvider>,
5150
) {
52-
init {
53-
validateLocation()
54-
}
5551

5652
/**
5753
* Instantiates a new [GenerativeModel] given the provided parameters.
@@ -142,7 +138,7 @@ internal constructor(
142138
GenerativeBackendEnum.VERTEX_AI ->
143139
"projects/${firebaseApp.options.projectId}/locations/${backend.location}/publishers/google/models/${modelName}"
144140
GenerativeBackendEnum.GOOGLE_AI ->
145-
throw ServiceDisabledException("Live Model is not yet available on the Google AI backend")
141+
throw InvalidStateException("Live Model is not yet available on the Google AI backend")
146142
},
147143
firebaseApp.options.apiKey,
148144
firebaseApp,
@@ -202,15 +198,6 @@ internal constructor(
202198
)
203199
}
204200

205-
private fun validateLocation() {
206-
if (backend.backend != GenerativeBackendEnum.VERTEX_AI) {
207-
return
208-
}
209-
if (backend.location.isBlank() || backend.location.contains("/")) {
210-
throw InvalidLocationException(backend.location)
211-
}
212-
}
213-
214201
public companion object {
215202
/** The [FirebaseAI] instance for the default [FirebaseApp] using the Google AI Backend. */
216203
@JvmStatic

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ internal constructor(internal val location: String, internal val backend: Genera
3333
*/
3434
@JvmStatic
3535
@JvmOverloads
36-
public fun vertexAI(location: String = "us-central1"): GenerativeBackend =
37-
GenerativeBackend(location, GenerativeBackendEnum.VERTEX_AI)
36+
public fun vertexAI(location: String = "us-central1"): GenerativeBackend {
37+
if (location.isBlank() || location.contains("/")) {
38+
throw InvalidLocationException(location)
39+
}
40+
return GenerativeBackend(location, GenerativeBackendEnum.VERTEX_AI)
41+
}
3842
}
3943
}
4044

Submodule crashpad updated from 21a20ef to c902f6b
Submodule lss updated from ed31caa to 9719c1e
Submodule mini_chromium updated from 7477036 to 4332ddb

0 commit comments

Comments
 (0)