File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import com.google.firebase.vertexai.type.FirebaseVertexAIException
3131import com.google.firebase.vertexai.type.GenerateContentResponse
3232import com.google.firebase.vertexai.type.GenerationConfig
3333import com.google.firebase.vertexai.type.GenerativeBackend
34+ import com.google.firebase.vertexai.type.InvalidStateException
3435import com.google.firebase.vertexai.type.PromptBlockedException
3536import com.google.firebase.vertexai.type.RequestOptions
3637import com.google.firebase.vertexai.type.ResponseStoppedException
@@ -212,7 +213,18 @@ internal constructor(
212213 GenerateContentRequest (
213214 modelName,
214215 prompt.map { it.toInternal() },
215- safetySettings?.map { it.toInternal() },
216+ safetySettings
217+ ?.also { safetySettingList ->
218+ if (
219+ generativeBackend == GenerativeBackend .GOOGLE_AI &&
220+ safetySettingList.any { it.method != null }
221+ ) {
222+ throw InvalidStateException (
223+ " HarmBlockMethod is unsupported by the Google Developer API"
224+ )
225+ }
226+ }
227+ ?.map { it.toInternal() },
216228 generationConfig?.toInternal(),
217229 tools?.map { it.toInternal() },
218230 toolConfig?.toInternal(),
You can’t perform that action at this time.
0 commit comments