Skip to content

Commit cea0513

Browse files
author
awstools
committed
feat(client-bedrock-runtime): Added new fields to Amazon Bedrock Guardrails trace
1 parent a692f70 commit cea0513

File tree

6 files changed

+351
-42
lines changed

6 files changed

+351
-42
lines changed

clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts

+24
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M
8383
* // { // GuardrailContentFilter
8484
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
8585
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
86+
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
8687
* // action: "BLOCKED", // required
8788
* // },
8889
* // ],
@@ -129,8 +130,31 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M
129130
* // },
130131
* // ],
131132
* // },
133+
* // invocationMetrics: { // GuardrailInvocationMetrics
134+
* // guardrailProcessingLatency: Number("long"),
135+
* // usage: {
136+
* // topicPolicyUnits: Number("int"), // required
137+
* // contentPolicyUnits: Number("int"), // required
138+
* // wordPolicyUnits: Number("int"), // required
139+
* // sensitiveInformationPolicyUnits: Number("int"), // required
140+
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
141+
* // contextualGroundingPolicyUnits: Number("int"), // required
142+
* // },
143+
* // guardrailCoverage: { // GuardrailCoverage
144+
* // textCharacters: { // GuardrailTextCharactersCoverage
145+
* // guarded: Number("int"),
146+
* // total: Number("int"),
147+
* // },
148+
* // },
149+
* // },
132150
* // },
133151
* // ],
152+
* // guardrailCoverage: {
153+
* // textCharacters: {
154+
* // guarded: Number("int"),
155+
* // total: Number("int"),
156+
* // },
157+
* // },
134158
* // };
135159
*
136160
* ```

clients/client-bedrock-runtime/src/commands/ConverseCommand.ts

+36
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
252252
* // { // GuardrailContentFilter
253253
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
254254
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
255+
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
255256
* // action: "BLOCKED", // required
256257
* // },
257258
* // ],
@@ -298,6 +299,23 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
298299
* // },
299300
* // ],
300301
* // },
302+
* // invocationMetrics: { // GuardrailInvocationMetrics
303+
* // guardrailProcessingLatency: Number("long"),
304+
* // usage: { // GuardrailUsage
305+
* // topicPolicyUnits: Number("int"), // required
306+
* // contentPolicyUnits: Number("int"), // required
307+
* // wordPolicyUnits: Number("int"), // required
308+
* // sensitiveInformationPolicyUnits: Number("int"), // required
309+
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
310+
* // contextualGroundingPolicyUnits: Number("int"), // required
311+
* // },
312+
* // guardrailCoverage: { // GuardrailCoverage
313+
* // textCharacters: { // GuardrailTextCharactersCoverage
314+
* // guarded: Number("int"),
315+
* // total: Number("int"),
316+
* // },
317+
* // },
318+
* // },
301319
* // },
302320
* // },
303321
* // outputAssessments: { // GuardrailAssessmentListMap
@@ -317,6 +335,7 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
317335
* // {
318336
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
319337
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
338+
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
320339
* // action: "BLOCKED", // required
321340
* // },
322341
* // ],
@@ -363,6 +382,23 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
363382
* // },
364383
* // ],
365384
* // },
385+
* // invocationMetrics: {
386+
* // guardrailProcessingLatency: Number("long"),
387+
* // usage: {
388+
* // topicPolicyUnits: Number("int"), // required
389+
* // contentPolicyUnits: Number("int"), // required
390+
* // wordPolicyUnits: Number("int"), // required
391+
* // sensitiveInformationPolicyUnits: Number("int"), // required
392+
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
393+
* // contextualGroundingPolicyUnits: Number("int"), // required
394+
* // },
395+
* // guardrailCoverage: {
396+
* // textCharacters: {
397+
* // guarded: Number("int"),
398+
* // total: Number("int"),
399+
* // },
400+
* // },
401+
* // },
366402
* // },
367403
* // ],
368404
* // },

clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts

+36
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
232232
* // { // GuardrailContentFilter
233233
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
234234
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
235+
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
235236
* // action: "BLOCKED", // required
236237
* // },
237238
* // ],
@@ -278,6 +279,23 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
278279
* // },
279280
* // ],
280281
* // },
282+
* // invocationMetrics: { // GuardrailInvocationMetrics
283+
* // guardrailProcessingLatency: Number("long"),
284+
* // usage: { // GuardrailUsage
285+
* // topicPolicyUnits: Number("int"), // required
286+
* // contentPolicyUnits: Number("int"), // required
287+
* // wordPolicyUnits: Number("int"), // required
288+
* // sensitiveInformationPolicyUnits: Number("int"), // required
289+
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
290+
* // contextualGroundingPolicyUnits: Number("int"), // required
291+
* // },
292+
* // guardrailCoverage: { // GuardrailCoverage
293+
* // textCharacters: { // GuardrailTextCharactersCoverage
294+
* // guarded: Number("int"),
295+
* // total: Number("int"),
296+
* // },
297+
* // },
298+
* // },
281299
* // },
282300
* // },
283301
* // outputAssessments: { // GuardrailAssessmentListMap
@@ -297,6 +315,7 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
297315
* // {
298316
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
299317
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
318+
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
300319
* // action: "BLOCKED", // required
301320
* // },
302321
* // ],
@@ -343,6 +362,23 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
343362
* // },
344363
* // ],
345364
* // },
365+
* // invocationMetrics: {
366+
* // guardrailProcessingLatency: Number("long"),
367+
* // usage: {
368+
* // topicPolicyUnits: Number("int"), // required
369+
* // contentPolicyUnits: Number("int"), // required
370+
* // wordPolicyUnits: Number("int"), // required
371+
* // sensitiveInformationPolicyUnits: Number("int"), // required
372+
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
373+
* // contextualGroundingPolicyUnits: Number("int"), // required
374+
* // },
375+
* // guardrailCoverage: {
376+
* // textCharacters: {
377+
* // guarded: Number("int"),
378+
* // total: Number("int"),
379+
* // },
380+
* // },
381+
* // },
346382
* // },
347383
* // ],
348384
* // },

clients/client-bedrock-runtime/src/models/models_0.ts

+131-42
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,23 @@ export const GuardrailContentFilterConfidence = {
184184
export type GuardrailContentFilterConfidence =
185185
(typeof GuardrailContentFilterConfidence)[keyof typeof GuardrailContentFilterConfidence];
186186

187+
/**
188+
* @public
189+
* @enum
190+
*/
191+
export const GuardrailContentFilterStrength = {
192+
HIGH: "HIGH",
193+
LOW: "LOW",
194+
MEDIUM: "MEDIUM",
195+
NONE: "NONE",
196+
} as const;
197+
198+
/**
199+
* @public
200+
*/
201+
export type GuardrailContentFilterStrength =
202+
(typeof GuardrailContentFilterStrength)[keyof typeof GuardrailContentFilterStrength];
203+
187204
/**
188205
* @public
189206
* @enum
@@ -219,6 +236,12 @@ export interface GuardrailContentFilter {
219236
*/
220237
confidence: GuardrailContentFilterConfidence | undefined;
221238

239+
/**
240+
* <p>The filter strength setting for the guardrail content filter.</p>
241+
* @public
242+
*/
243+
filterStrength?: GuardrailContentFilterStrength;
244+
222245
/**
223246
* <p>The guardrail action.</p>
224247
* @public
@@ -310,6 +333,102 @@ export interface GuardrailContextualGroundingPolicyAssessment {
310333
filters?: GuardrailContextualGroundingFilter[];
311334
}
312335

336+
/**
337+
* <p>The guardrail coverage for the text characters.</p>
338+
* @public
339+
*/
340+
export interface GuardrailTextCharactersCoverage {
341+
/**
342+
* <p>The text characters that were guarded by the guardrail coverage.</p>
343+
* @public
344+
*/
345+
guarded?: number;
346+
347+
/**
348+
* <p>The total text characters by the guardrail coverage.</p>
349+
* @public
350+
*/
351+
total?: number;
352+
}
353+
354+
/**
355+
* <p>The action of the guardrail coverage details.</p>
356+
* @public
357+
*/
358+
export interface GuardrailCoverage {
359+
/**
360+
* <p>The text characters of the guardrail coverage details.</p>
361+
* @public
362+
*/
363+
textCharacters?: GuardrailTextCharactersCoverage;
364+
}
365+
366+
/**
367+
* <p>The details on the use of the guardrail.</p>
368+
* @public
369+
*/
370+
export interface GuardrailUsage {
371+
/**
372+
* <p>The topic policy units processed by the guardrail.</p>
373+
* @public
374+
*/
375+
topicPolicyUnits: number | undefined;
376+
377+
/**
378+
* <p>The content policy units processed by the guardrail.</p>
379+
* @public
380+
*/
381+
contentPolicyUnits: number | undefined;
382+
383+
/**
384+
* <p>The word policy units processed by the guardrail.</p>
385+
* @public
386+
*/
387+
wordPolicyUnits: number | undefined;
388+
389+
/**
390+
* <p>The sensitive information policy units processed by the guardrail.</p>
391+
* @public
392+
*/
393+
sensitiveInformationPolicyUnits: number | undefined;
394+
395+
/**
396+
* <p>The sensitive information policy free units processed by the guardrail.</p>
397+
* @public
398+
*/
399+
sensitiveInformationPolicyFreeUnits: number | undefined;
400+
401+
/**
402+
* <p>The contextual grounding policy units processed by the guardrail.</p>
403+
* @public
404+
*/
405+
contextualGroundingPolicyUnits: number | undefined;
406+
}
407+
408+
/**
409+
* <p>The invocation metrics for the guardrail.</p>
410+
* @public
411+
*/
412+
export interface GuardrailInvocationMetrics {
413+
/**
414+
* <p>The processing latency details for the guardrail invocation metrics.</p>
415+
* @public
416+
*/
417+
guardrailProcessingLatency?: number;
418+
419+
/**
420+
* <p>The usage details for the guardrail invocation metrics.</p>
421+
* @public
422+
*/
423+
usage?: GuardrailUsage;
424+
425+
/**
426+
* <p>The coverage details for the guardrail invocation metrics.</p>
427+
* @public
428+
*/
429+
guardrailCoverage?: GuardrailCoverage;
430+
}
431+
313432
/**
314433
* @public
315434
* @enum
@@ -622,60 +741,24 @@ export interface GuardrailAssessment {
622741
* @public
623742
*/
624743
contextualGroundingPolicy?: GuardrailContextualGroundingPolicyAssessment;
625-
}
626744

627-
/**
628-
* <p>The output content produced by the guardrail.</p>
629-
* @public
630-
*/
631-
export interface GuardrailOutputContent {
632745
/**
633-
* <p>The specific text for the output content produced by the guardrail.</p>
746+
* <p>The invocation metrics for the guardrail assessment.</p>
634747
* @public
635748
*/
636-
text?: string;
749+
invocationMetrics?: GuardrailInvocationMetrics;
637750
}
638751

639752
/**
640-
* <p>The details on the use of the guardrail.</p>
753+
* <p>The output content produced by the guardrail.</p>
641754
* @public
642755
*/
643-
export interface GuardrailUsage {
644-
/**
645-
* <p>The topic policy units processed by the guardrail.</p>
646-
* @public
647-
*/
648-
topicPolicyUnits: number | undefined;
649-
650-
/**
651-
* <p>The content policy units processed by the guardrail.</p>
652-
* @public
653-
*/
654-
contentPolicyUnits: number | undefined;
655-
656-
/**
657-
* <p>The word policy units processed by the guardrail.</p>
658-
* @public
659-
*/
660-
wordPolicyUnits: number | undefined;
661-
662-
/**
663-
* <p>The sensitive information policy units processed by the guardrail.</p>
664-
* @public
665-
*/
666-
sensitiveInformationPolicyUnits: number | undefined;
667-
668-
/**
669-
* <p>The sensitive information policy free units processed by the guardrail.</p>
670-
* @public
671-
*/
672-
sensitiveInformationPolicyFreeUnits: number | undefined;
673-
756+
export interface GuardrailOutputContent {
674757
/**
675-
* <p>The contextual grounding policy units processed by the guardrail.</p>
758+
* <p>The specific text for the output content produced by the guardrail.</p>
676759
* @public
677760
*/
678-
contextualGroundingPolicyUnits: number | undefined;
761+
text?: string;
679762
}
680763

681764
/**
@@ -705,6 +788,12 @@ export interface ApplyGuardrailResponse {
705788
* @public
706789
*/
707790
assessments: GuardrailAssessment[] | undefined;
791+
792+
/**
793+
* <p>The guardrail coverage details in the apply guardrail response.</p>
794+
* @public
795+
*/
796+
guardrailCoverage?: GuardrailCoverage;
708797
}
709798

710799
/**

0 commit comments

Comments
 (0)