Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename BlockThreshold to HarmBlockThreshold #6262

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import com.google.firebase.vertexai.common.shared.FunctionCall
import com.google.firebase.vertexai.common.shared.FunctionCallPart
import com.google.firebase.vertexai.common.shared.FunctionResponse
import com.google.firebase.vertexai.common.shared.FunctionResponsePart
import com.google.firebase.vertexai.common.shared.HarmBlockThreshold
import com.google.firebase.vertexai.type.BlobPart
import com.google.firebase.vertexai.type.BlockReason
import com.google.firebase.vertexai.type.BlockThreshold
import com.google.firebase.vertexai.type.Candidate
import com.google.firebase.vertexai.type.Citation
import com.google.firebase.vertexai.type.CitationMetadata
Expand All @@ -41,6 +39,7 @@ import com.google.firebase.vertexai.type.FunctionCallingConfig
import com.google.firebase.vertexai.type.FunctionDeclaration
import com.google.firebase.vertexai.type.GenerateContentResponse
import com.google.firebase.vertexai.type.GenerationConfig
import com.google.firebase.vertexai.type.HarmBlockThreshold
import com.google.firebase.vertexai.type.HarmCategory
import com.google.firebase.vertexai.type.HarmProbability
import com.google.firebase.vertexai.type.HarmSeverity
Expand Down Expand Up @@ -142,13 +141,18 @@ internal fun ToolConfig.toInternal() =
)
)

internal fun BlockThreshold.toInternal() =
internal fun HarmBlockThreshold.toInternal() =
when (this) {
BlockThreshold.NONE -> HarmBlockThreshold.BLOCK_NONE
BlockThreshold.ONLY_HIGH -> HarmBlockThreshold.BLOCK_ONLY_HIGH
BlockThreshold.MEDIUM_AND_ABOVE -> HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE
BlockThreshold.LOW_AND_ABOVE -> HarmBlockThreshold.BLOCK_LOW_AND_ABOVE
BlockThreshold.UNSPECIFIED -> HarmBlockThreshold.UNSPECIFIED
HarmBlockThreshold.NONE ->
com.google.firebase.vertexai.common.shared.HarmBlockThreshold.BLOCK_NONE
HarmBlockThreshold.ONLY_HIGH ->
com.google.firebase.vertexai.common.shared.HarmBlockThreshold.BLOCK_ONLY_HIGH
HarmBlockThreshold.MEDIUM_AND_ABOVE ->
com.google.firebase.vertexai.common.shared.HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE
HarmBlockThreshold.LOW_AND_ABOVE ->
com.google.firebase.vertexai.common.shared.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE
HarmBlockThreshold.UNSPECIFIED ->
com.google.firebase.vertexai.common.shared.HarmBlockThreshold.UNSPECIFIED
}

internal fun Tool.toInternal() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.google.firebase.vertexai.type
/**
* Represents the threshold for some [HarmCategory] that is allowed and blocked by [SafetySetting].
*/
enum class BlockThreshold {
enum class HarmBlockThreshold {
/** The threshold was not specified. */
UNSPECIFIED,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package com.google.firebase.vertexai.type

/**
* A configuration for a [BlockThreshold] of some [HarmCategory] allowed and blocked in responses.
* A configuration for a [HarmBlockThreshold] of some [HarmCategory] allowed and blocked in
* responses.
*
* @param harmCategory The relevant [HarmCategory].
* @param threshold The threshold form harm allowable.
*/
class SafetySetting(val harmCategory: HarmCategory, val threshold: BlockThreshold) {}
class SafetySetting(val harmCategory: HarmCategory, val threshold: HarmBlockThreshold) {}
Loading