Skip to content

Commit 011e218

Browse files
yinghsienwucopybara-github
authored andcommitted
feat: support jailbreak in HarmCategory and BlockedReason
PiperOrigin-RevId: 822303432
1 parent 9ccc6ce commit 011e218

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

google/genai/types.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class HarmCategory(_common.CaseInSensitiveEnum):
200200
'HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT'
201201
)
202202
"""The harm category is image sexually explicit content."""
203+
HARM_CATEGORY_JAILBREAK = 'HARM_CATEGORY_JAILBREAK'
204+
"""The harm category is for jailbreak prompts."""
203205

204206

205207
class HarmBlockMethod(_common.CaseInSensitiveEnum):
@@ -356,20 +358,24 @@ class HarmSeverity(_common.CaseInSensitiveEnum):
356358

357359

358360
class BlockedReason(_common.CaseInSensitiveEnum):
359-
"""Output only. Blocked reason."""
361+
"""Output only. The reason why the prompt was blocked."""
360362

361363
BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED'
362-
"""Unspecified blocked reason."""
364+
"""The blocked reason is unspecified."""
363365
SAFETY = 'SAFETY'
364-
"""Candidates blocked due to safety."""
366+
"""The prompt was blocked for safety reasons."""
365367
OTHER = 'OTHER'
366-
"""Candidates blocked due to other reason."""
368+
"""The prompt was blocked for other reasons. For example, it may be due to the prompt's language, or because it contains other harmful content."""
367369
BLOCKLIST = 'BLOCKLIST'
368-
"""Candidates blocked due to the terms which are included from the terminology blocklist."""
370+
"""The prompt was blocked because it contains a term from the terminology blocklist."""
369371
PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'
370-
"""Candidates blocked due to prohibited content."""
372+
"""The prompt was blocked because it contains prohibited content."""
371373
IMAGE_SAFETY = 'IMAGE_SAFETY'
372-
"""Candidates blocked due to unsafe image generation content."""
374+
"""The prompt was blocked because it contains content that is unsafe for image generation."""
375+
MODEL_ARMOR = 'MODEL_ARMOR'
376+
"""The prompt was blocked by Model Armor."""
377+
JAILBREAK = 'JAILBREAK'
378+
"""The prompt was blocked as a jailbreak attempt."""
373379

374380

375381
class TrafficType(_common.CaseInSensitiveEnum):
@@ -5734,31 +5740,41 @@ class CandidateDict(TypedDict, total=False):
57345740

57355741

57365742
class GenerateContentResponsePromptFeedback(_common.BaseModel):
5737-
"""Content filter results for a prompt sent in the request."""
5743+
"""Content filter results for a prompt sent in the request.
5744+
5745+
Note: This is sent only in the first stream chunk and only if no candidates
5746+
were generated due to content violations.
5747+
"""
57385748

57395749
block_reason: Optional[BlockedReason] = Field(
5740-
default=None, description="""Output only. Blocked reason."""
5750+
default=None,
5751+
description="""Output only. The reason why the prompt was blocked.""",
57415752
)
57425753
block_reason_message: Optional[str] = Field(
57435754
default=None,
5744-
description="""Output only. A readable block reason message.""",
5755+
description="""Output only. A readable message that explains the reason why the prompt was blocked.""",
57455756
)
57465757
safety_ratings: Optional[list[SafetyRating]] = Field(
5747-
default=None, description="""Output only. Safety ratings."""
5758+
default=None,
5759+
description="""Output only. A list of safety ratings for the prompt. There is one rating per category.""",
57485760
)
57495761

57505762

57515763
class GenerateContentResponsePromptFeedbackDict(TypedDict, total=False):
5752-
"""Content filter results for a prompt sent in the request."""
5764+
"""Content filter results for a prompt sent in the request.
5765+
5766+
Note: This is sent only in the first stream chunk and only if no candidates
5767+
were generated due to content violations.
5768+
"""
57535769

57545770
block_reason: Optional[BlockedReason]
5755-
"""Output only. Blocked reason."""
5771+
"""Output only. The reason why the prompt was blocked."""
57565772

57575773
block_reason_message: Optional[str]
5758-
"""Output only. A readable block reason message."""
5774+
"""Output only. A readable message that explains the reason why the prompt was blocked."""
57595775

57605776
safety_ratings: Optional[list[SafetyRatingDict]]
5761-
"""Output only. Safety ratings."""
5777+
"""Output only. A list of safety ratings for the prompt. There is one rating per category."""
57625778

57635779

57645780
GenerateContentResponsePromptFeedbackOrDict = Union[

0 commit comments

Comments
 (0)