Skip to content

Commit cd79a83

Browse files
yinghsienwucopybara-github
authored andcommitted
feat: support jailbreak in HarmCategory and BlockedReason
PiperOrigin-RevId: 822303432
1 parent 0e95d72 commit cd79a83

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

api-report/genai-node.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ export enum BlockedReason {
230230
BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
231231
BLOCKLIST = "BLOCKLIST",
232232
IMAGE_SAFETY = "IMAGE_SAFETY",
233+
JAILBREAK = "JAILBREAK",
234+
MODEL_ARMOR = "MODEL_ARMOR",
233235
OTHER = "OTHER",
234236
PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
235237
SAFETY = "SAFETY"
@@ -1612,6 +1614,7 @@ export enum HarmCategory {
16121614
HARM_CATEGORY_IMAGE_HARASSMENT = "HARM_CATEGORY_IMAGE_HARASSMENT",
16131615
HARM_CATEGORY_IMAGE_HATE = "HARM_CATEGORY_IMAGE_HATE",
16141616
HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",
1617+
HARM_CATEGORY_JAILBREAK = "HARM_CATEGORY_JAILBREAK",
16151618
HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT",
16161619
HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED"
16171620
}

api-report/genai-web.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ export enum BlockedReason {
230230
BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
231231
BLOCKLIST = "BLOCKLIST",
232232
IMAGE_SAFETY = "IMAGE_SAFETY",
233+
JAILBREAK = "JAILBREAK",
234+
MODEL_ARMOR = "MODEL_ARMOR",
233235
OTHER = "OTHER",
234236
PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
235237
SAFETY = "SAFETY"
@@ -1612,6 +1614,7 @@ export enum HarmCategory {
16121614
HARM_CATEGORY_IMAGE_HARASSMENT = "HARM_CATEGORY_IMAGE_HARASSMENT",
16131615
HARM_CATEGORY_IMAGE_HATE = "HARM_CATEGORY_IMAGE_HATE",
16141616
HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",
1617+
HARM_CATEGORY_JAILBREAK = "HARM_CATEGORY_JAILBREAK",
16151618
HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT",
16161619
HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED"
16171620
}

api-report/genai.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ export enum BlockedReason {
230230
BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
231231
BLOCKLIST = "BLOCKLIST",
232232
IMAGE_SAFETY = "IMAGE_SAFETY",
233+
JAILBREAK = "JAILBREAK",
234+
MODEL_ARMOR = "MODEL_ARMOR",
233235
OTHER = "OTHER",
234236
PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
235237
SAFETY = "SAFETY"
@@ -1612,6 +1614,7 @@ export enum HarmCategory {
16121614
HARM_CATEGORY_IMAGE_HARASSMENT = "HARM_CATEGORY_IMAGE_HARASSMENT",
16131615
HARM_CATEGORY_IMAGE_HATE = "HARM_CATEGORY_IMAGE_HATE",
16141616
HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = "HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",
1617+
HARM_CATEGORY_JAILBREAK = "HARM_CATEGORY_JAILBREAK",
16151618
HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT",
16161619
HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED"
16171620
}

src/types.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ export enum HarmCategory {
142142
* The harm category is image sexually explicit content.
143143
*/
144144
HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT',
145+
/**
146+
* The harm category is for jailbreak prompts.
147+
*/
148+
HARM_CATEGORY_JAILBREAK = 'HARM_CATEGORY_JAILBREAK',
145149
}
146150

147151
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
@@ -383,32 +387,40 @@ export enum HarmSeverity {
383387
HARM_SEVERITY_HIGH = 'HARM_SEVERITY_HIGH',
384388
}
385389

386-
/** Output only. Blocked reason. */
390+
/** Output only. The reason why the prompt was blocked. */
387391
export enum BlockedReason {
388392
/**
389-
* Unspecified blocked reason.
393+
* The blocked reason is unspecified.
390394
*/
391395
BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED',
392396
/**
393-
* Candidates blocked due to safety.
397+
* The prompt was blocked for safety reasons.
394398
*/
395399
SAFETY = 'SAFETY',
396400
/**
397-
* Candidates blocked due to other reason.
401+
* 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.
398402
*/
399403
OTHER = 'OTHER',
400404
/**
401-
* Candidates blocked due to the terms which are included from the terminology blocklist.
405+
* The prompt was blocked because it contains a term from the terminology blocklist.
402406
*/
403407
BLOCKLIST = 'BLOCKLIST',
404408
/**
405-
* Candidates blocked due to prohibited content.
409+
* The prompt was blocked because it contains prohibited content.
406410
*/
407411
PROHIBITED_CONTENT = 'PROHIBITED_CONTENT',
408412
/**
409-
* Candidates blocked due to unsafe image generation content.
413+
* The prompt was blocked because it contains content that is unsafe for image generation.
410414
*/
411415
IMAGE_SAFETY = 'IMAGE_SAFETY',
416+
/**
417+
* The prompt was blocked by Model Armor.
418+
*/
419+
MODEL_ARMOR = 'MODEL_ARMOR',
420+
/**
421+
* The prompt was blocked as a jailbreak attempt.
422+
*/
423+
JAILBREAK = 'JAILBREAK',
412424
}
413425

414426
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
@@ -2428,13 +2440,13 @@ export declare interface Candidate {
24282440
safetyRatings?: SafetyRating[];
24292441
}
24302442

2431-
/** Content filter results for a prompt sent in the request. */
2443+
/** Content filter results for a prompt sent in the request. Note: This is sent only in the first stream chunk and only if no candidates were generated due to content violations. */
24322444
export class GenerateContentResponsePromptFeedback {
2433-
/** Output only. Blocked reason. */
2445+
/** Output only. The reason why the prompt was blocked. */
24342446
blockReason?: BlockedReason;
2435-
/** Output only. A readable block reason message. */
2447+
/** Output only. A readable message that explains the reason why the prompt was blocked. */
24362448
blockReasonMessage?: string;
2437-
/** Output only. Safety ratings. */
2449+
/** Output only. A list of safety ratings for the prompt. There is one rating per category. */
24382450
safetyRatings?: SafetyRating[];
24392451
}
24402452

0 commit comments

Comments
 (0)