|
16 | 16 |
|
17 | 17 | package com.google.firebase.vertexai
|
18 | 18 |
|
| 19 | +import android.util.Log |
19 | 20 | import com.google.firebase.Firebase
|
20 | 21 | import com.google.firebase.FirebaseApp
|
21 | 22 | import com.google.firebase.app
|
@@ -68,6 +69,15 @@ internal constructor(
|
68 | 69 | if (location.trim().isEmpty() || location.contains("/")) {
|
69 | 70 | throw InvalidLocationException(location)
|
70 | 71 | }
|
| 72 | + if (!modelName.startsWith(GEMINI_MODEL_NAME_PREFIX)) { |
| 73 | + Log.w( |
| 74 | + TAG, |
| 75 | + """Unsupported Gemini model "${modelName}"; see |
| 76 | + https://firebase.google.com/docs/vertex-ai/models for a list supported Gemini model names. |
| 77 | + """ |
| 78 | + .trimIndent() |
| 79 | + ) |
| 80 | + } |
71 | 81 | return GenerativeModel(
|
72 | 82 | "projects/${firebaseApp.options.projectId}/locations/${location}/publishers/google/models/${modelName}",
|
73 | 83 | firebaseApp.options.apiKey,
|
@@ -102,6 +112,15 @@ internal constructor(
|
102 | 112 | if (location.trim().isEmpty() || location.contains("/")) {
|
103 | 113 | throw InvalidLocationException(location)
|
104 | 114 | }
|
| 115 | + if (!modelName.startsWith(IMAGEN_MODEL_NAME_PREFIX)) { |
| 116 | + Log.w( |
| 117 | + TAG, |
| 118 | + """Unsupported Imagen model "${modelName}"; see |
| 119 | + https://firebase.google.com/docs/vertex-ai/models for a list supported Imagen model names. |
| 120 | + """ |
| 121 | + .trimIndent() |
| 122 | + ) |
| 123 | + } |
105 | 124 | return ImagenModel(
|
106 | 125 | "projects/${firebaseApp.options.projectId}/locations/${location}/publishers/google/models/${modelName}",
|
107 | 126 | firebaseApp.options.apiKey,
|
@@ -134,6 +153,12 @@ internal constructor(
|
134 | 153 | val multiResourceComponent = app[FirebaseVertexAIMultiResourceComponent::class.java]
|
135 | 154 | return multiResourceComponent.get(location)
|
136 | 155 | }
|
| 156 | + |
| 157 | + private const val GEMINI_MODEL_NAME_PREFIX = "gemini-" |
| 158 | + |
| 159 | + private const val IMAGEN_MODEL_NAME_PREFIX = "imagen-" |
| 160 | + |
| 161 | + private val TAG = FirebaseVertexAI::class.java.simpleName |
137 | 162 | }
|
138 | 163 | }
|
139 | 164 |
|
|
0 commit comments