Skip to content

Commit d7665c3

Browse files
author
David Motsonashvili
committed
HarmBlockMethod should now throw if the backend is googleAI
1 parent 6fded91 commit d7665c3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import com.google.firebase.vertexai.type.FirebaseVertexAIException
3131
import com.google.firebase.vertexai.type.GenerateContentResponse
3232
import com.google.firebase.vertexai.type.GenerationConfig
3333
import com.google.firebase.vertexai.type.GenerativeBackend
34+
import com.google.firebase.vertexai.type.InvalidStateException
3435
import com.google.firebase.vertexai.type.PromptBlockedException
3536
import com.google.firebase.vertexai.type.RequestOptions
3637
import 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(),

0 commit comments

Comments
 (0)