|
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,
|
@@ -103,6 +113,15 @@ internal constructor(
|
103 | 113 | if (location.trim().isEmpty() || location.contains("/")) {
|
104 | 114 | throw InvalidLocationException(location)
|
105 | 115 | }
|
| 116 | + if (!modelName.startsWith(IMAGEN_MODEL_NAME_PREFIX)) { |
| 117 | + Log.w( |
| 118 | + TAG, |
| 119 | + """Unsupported Imagen model "${modelName}"; see |
| 120 | + https://firebase.google.com/docs/vertex-ai/models for a list supported Imagen model names. |
| 121 | + """ |
| 122 | + .trimIndent() |
| 123 | + ) |
| 124 | + } |
106 | 125 | return ImagenModel(
|
107 | 126 | "projects/${firebaseApp.options.projectId}/locations/${location}/publishers/google/models/${modelName}",
|
108 | 127 | firebaseApp.options.apiKey,
|
@@ -136,6 +155,12 @@ internal constructor(
|
136 | 155 | val multiResourceComponent = app[FirebaseVertexAIMultiResourceComponent::class.java]
|
137 | 156 | return multiResourceComponent.get(location)
|
138 | 157 | }
|
| 158 | + |
| 159 | + private const val GEMINI_MODEL_NAME_PREFIX = "gemini-" |
| 160 | + |
| 161 | + private const val IMAGEN_MODEL_NAME_PREFIX = "imagen-" |
| 162 | + |
| 163 | + private val TAG = FirebaseVertexAI::class.java.simpleName |
139 | 164 | }
|
140 | 165 | }
|
141 | 166 |
|
|
0 commit comments