Skip to content

Commit

Permalink
Include probabilyScore too
Browse files Browse the repository at this point in the history
  • Loading branch information
rlazo committed Apr 18, 2024
1 parent b85e522 commit eb414d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ data class SafetyRating(
val category: HarmCategory,
val probability: HarmProbability,
val blocked: Boolean? = null, // TODO(): any reason not to default to false?
val probabilityScore: Float? = null,
val severity: HarmSeverity? = null,
val severityScore: Float? = null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.google.ai.client.generativeai.common

import com.google.ai.client.generativeai.common.server.BlockReason
import com.google.ai.client.generativeai.common.server.FinishReason
import com.google.ai.client.generativeai.common.server.HarmProbability
import com.google.ai.client.generativeai.common.server.HarmSeverity
import com.google.ai.client.generativeai.common.shared.HarmCategory
import com.google.ai.client.generativeai.common.util.goldenUnaryFile
Expand Down Expand Up @@ -79,6 +80,11 @@ internal class UnarySnapshotTests {

response.candidates?.isEmpty() shouldBe false
response.candidates?.first()?.safetyRatings?.isEmpty() shouldBe false
response.candidates?.first()?.safetyRatings?.all {
it.probability == HarmProbability.NEGLIGIBLE
} shouldBe true
response.candidates?.first()?.safetyRatings?.all { it.probabilityScore != null } shouldBe
true
response.candidates?.first()?.safetyRatings?.all {
it.severity == HarmSeverity.NEGLIGIBLE
} shouldBe true
Expand Down

0 comments on commit eb414d9

Please sign in to comment.