Skip to content

Commit

Permalink
feat(client-bedrock-runtime): Added new fields to Amazon Bedrock Guar…
Browse files Browse the repository at this point in the history
…drails trace
  • Loading branch information
awstools committed Oct 2, 2024
1 parent a692f70 commit cea0513
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M
* // { // GuardrailContentFilter
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
* // action: "BLOCKED", // required
* // },
* // ],
Expand Down Expand Up @@ -129,8 +130,31 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M
* // },
* // ],
* // },
* // invocationMetrics: { // GuardrailInvocationMetrics
* // guardrailProcessingLatency: Number("long"),
* // usage: {
* // topicPolicyUnits: Number("int"), // required
* // contentPolicyUnits: Number("int"), // required
* // wordPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
* // contextualGroundingPolicyUnits: Number("int"), // required
* // },
* // guardrailCoverage: { // GuardrailCoverage
* // textCharacters: { // GuardrailTextCharactersCoverage
* // guarded: Number("int"),
* // total: Number("int"),
* // },
* // },
* // },
* // },
* // ],
* // guardrailCoverage: {
* // textCharacters: {
* // guarded: Number("int"),
* // total: Number("int"),
* // },
* // },
* // };
*
* ```
Expand Down
36 changes: 36 additions & 0 deletions clients/client-bedrock-runtime/src/commands/ConverseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* // { // GuardrailContentFilter
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
* // action: "BLOCKED", // required
* // },
* // ],
Expand Down Expand Up @@ -298,6 +299,23 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* // },
* // ],
* // },
* // invocationMetrics: { // GuardrailInvocationMetrics
* // guardrailProcessingLatency: Number("long"),
* // usage: { // GuardrailUsage
* // topicPolicyUnits: Number("int"), // required
* // contentPolicyUnits: Number("int"), // required
* // wordPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
* // contextualGroundingPolicyUnits: Number("int"), // required
* // },
* // guardrailCoverage: { // GuardrailCoverage
* // textCharacters: { // GuardrailTextCharactersCoverage
* // guarded: Number("int"),
* // total: Number("int"),
* // },
* // },
* // },
* // },
* // },
* // outputAssessments: { // GuardrailAssessmentListMap
Expand All @@ -317,6 +335,7 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* // {
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
* // action: "BLOCKED", // required
* // },
* // ],
Expand Down Expand Up @@ -363,6 +382,23 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* // },
* // ],
* // },
* // invocationMetrics: {
* // guardrailProcessingLatency: Number("long"),
* // usage: {
* // topicPolicyUnits: Number("int"), // required
* // contentPolicyUnits: Number("int"), // required
* // wordPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
* // contextualGroundingPolicyUnits: Number("int"), // required
* // },
* // guardrailCoverage: {
* // textCharacters: {
* // guarded: Number("int"),
* // total: Number("int"),
* // },
* // },
* // },
* // },
* // ],
* // },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
* // { // GuardrailContentFilter
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
* // action: "BLOCKED", // required
* // },
* // ],
Expand Down Expand Up @@ -278,6 +279,23 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
* // },
* // ],
* // },
* // invocationMetrics: { // GuardrailInvocationMetrics
* // guardrailProcessingLatency: Number("long"),
* // usage: { // GuardrailUsage
* // topicPolicyUnits: Number("int"), // required
* // contentPolicyUnits: Number("int"), // required
* // wordPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
* // contextualGroundingPolicyUnits: Number("int"), // required
* // },
* // guardrailCoverage: { // GuardrailCoverage
* // textCharacters: { // GuardrailTextCharactersCoverage
* // guarded: Number("int"),
* // total: Number("int"),
* // },
* // },
* // },
* // },
* // },
* // outputAssessments: { // GuardrailAssessmentListMap
Expand All @@ -297,6 +315,7 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
* // {
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
* // filterStrength: "NONE" || "LOW" || "MEDIUM" || "HIGH",
* // action: "BLOCKED", // required
* // },
* // ],
Expand Down Expand Up @@ -343,6 +362,23 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
* // },
* // ],
* // },
* // invocationMetrics: {
* // guardrailProcessingLatency: Number("long"),
* // usage: {
* // topicPolicyUnits: Number("int"), // required
* // contentPolicyUnits: Number("int"), // required
* // wordPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyUnits: Number("int"), // required
* // sensitiveInformationPolicyFreeUnits: Number("int"), // required
* // contextualGroundingPolicyUnits: Number("int"), // required
* // },
* // guardrailCoverage: {
* // textCharacters: {
* // guarded: Number("int"),
* // total: Number("int"),
* // },
* // },
* // },
* // },
* // ],
* // },
Expand Down
173 changes: 131 additions & 42 deletions clients/client-bedrock-runtime/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,23 @@ export const GuardrailContentFilterConfidence = {
export type GuardrailContentFilterConfidence =
(typeof GuardrailContentFilterConfidence)[keyof typeof GuardrailContentFilterConfidence];

/**
* @public
* @enum
*/
export const GuardrailContentFilterStrength = {
HIGH: "HIGH",
LOW: "LOW",
MEDIUM: "MEDIUM",
NONE: "NONE",
} as const;

/**
* @public
*/
export type GuardrailContentFilterStrength =
(typeof GuardrailContentFilterStrength)[keyof typeof GuardrailContentFilterStrength];

/**
* @public
* @enum
Expand Down Expand Up @@ -219,6 +236,12 @@ export interface GuardrailContentFilter {
*/
confidence: GuardrailContentFilterConfidence | undefined;

/**
* <p>The filter strength setting for the guardrail content filter.</p>
* @public
*/
filterStrength?: GuardrailContentFilterStrength;

/**
* <p>The guardrail action.</p>
* @public
Expand Down Expand Up @@ -310,6 +333,102 @@ export interface GuardrailContextualGroundingPolicyAssessment {
filters?: GuardrailContextualGroundingFilter[];
}

/**
* <p>The guardrail coverage for the text characters.</p>
* @public
*/
export interface GuardrailTextCharactersCoverage {
/**
* <p>The text characters that were guarded by the guardrail coverage.</p>
* @public
*/
guarded?: number;

/**
* <p>The total text characters by the guardrail coverage.</p>
* @public
*/
total?: number;
}

/**
* <p>The action of the guardrail coverage details.</p>
* @public
*/
export interface GuardrailCoverage {
/**
* <p>The text characters of the guardrail coverage details.</p>
* @public
*/
textCharacters?: GuardrailTextCharactersCoverage;
}

/**
* <p>The details on the use of the guardrail.</p>
* @public
*/
export interface GuardrailUsage {
/**
* <p>The topic policy units processed by the guardrail.</p>
* @public
*/
topicPolicyUnits: number | undefined;

/**
* <p>The content policy units processed by the guardrail.</p>
* @public
*/
contentPolicyUnits: number | undefined;

/**
* <p>The word policy units processed by the guardrail.</p>
* @public
*/
wordPolicyUnits: number | undefined;

/**
* <p>The sensitive information policy units processed by the guardrail.</p>
* @public
*/
sensitiveInformationPolicyUnits: number | undefined;

/**
* <p>The sensitive information policy free units processed by the guardrail.</p>
* @public
*/
sensitiveInformationPolicyFreeUnits: number | undefined;

/**
* <p>The contextual grounding policy units processed by the guardrail.</p>
* @public
*/
contextualGroundingPolicyUnits: number | undefined;
}

/**
* <p>The invocation metrics for the guardrail.</p>
* @public
*/
export interface GuardrailInvocationMetrics {
/**
* <p>The processing latency details for the guardrail invocation metrics.</p>
* @public
*/
guardrailProcessingLatency?: number;

/**
* <p>The usage details for the guardrail invocation metrics.</p>
* @public
*/
usage?: GuardrailUsage;

/**
* <p>The coverage details for the guardrail invocation metrics.</p>
* @public
*/
guardrailCoverage?: GuardrailCoverage;
}

/**
* @public
* @enum
Expand Down Expand Up @@ -622,60 +741,24 @@ export interface GuardrailAssessment {
* @public
*/
contextualGroundingPolicy?: GuardrailContextualGroundingPolicyAssessment;
}

/**
* <p>The output content produced by the guardrail.</p>
* @public
*/
export interface GuardrailOutputContent {
/**
* <p>The specific text for the output content produced by the guardrail.</p>
* <p>The invocation metrics for the guardrail assessment.</p>
* @public
*/
text?: string;
invocationMetrics?: GuardrailInvocationMetrics;
}

/**
* <p>The details on the use of the guardrail.</p>
* <p>The output content produced by the guardrail.</p>
* @public
*/
export interface GuardrailUsage {
/**
* <p>The topic policy units processed by the guardrail.</p>
* @public
*/
topicPolicyUnits: number | undefined;

/**
* <p>The content policy units processed by the guardrail.</p>
* @public
*/
contentPolicyUnits: number | undefined;

/**
* <p>The word policy units processed by the guardrail.</p>
* @public
*/
wordPolicyUnits: number | undefined;

/**
* <p>The sensitive information policy units processed by the guardrail.</p>
* @public
*/
sensitiveInformationPolicyUnits: number | undefined;

/**
* <p>The sensitive information policy free units processed by the guardrail.</p>
* @public
*/
sensitiveInformationPolicyFreeUnits: number | undefined;

export interface GuardrailOutputContent {
/**
* <p>The contextual grounding policy units processed by the guardrail.</p>
* <p>The specific text for the output content produced by the guardrail.</p>
* @public
*/
contextualGroundingPolicyUnits: number | undefined;
text?: string;
}

/**
Expand Down Expand Up @@ -705,6 +788,12 @@ export interface ApplyGuardrailResponse {
* @public
*/
assessments: GuardrailAssessment[] | undefined;

/**
* <p>The guardrail coverage details in the apply guardrail response.</p>
* @public
*/
guardrailCoverage?: GuardrailCoverage;
}

/**
Expand Down
Loading

0 comments on commit cea0513

Please sign in to comment.