diff --git a/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts b/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts index 34dbf864f7b0..7f02c521d8ac 100644 --- a/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts @@ -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 * // }, * // ], @@ -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"), + * // }, + * // }, * // }; * * ``` diff --git a/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts b/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts index 31c905934d0b..3ecd9d3ee307 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts @@ -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 * // }, * // ], @@ -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 @@ -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 * // }, * // ], @@ -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"), + * // }, + * // }, + * // }, * // }, * // ], * // }, diff --git a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts index 10d97c4e145d..88fbb839db6c 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts @@ -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 * // }, * // ], @@ -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 @@ -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 * // }, * // ], @@ -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"), + * // }, + * // }, + * // }, * // }, * // ], * // }, diff --git a/clients/client-bedrock-runtime/src/models/models_0.ts b/clients/client-bedrock-runtime/src/models/models_0.ts index ac67882953b2..5b4073806d8d 100644 --- a/clients/client-bedrock-runtime/src/models/models_0.ts +++ b/clients/client-bedrock-runtime/src/models/models_0.ts @@ -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 @@ -219,6 +236,12 @@ export interface GuardrailContentFilter { */ confidence: GuardrailContentFilterConfidence | undefined; + /** + *

The filter strength setting for the guardrail content filter.

+ * @public + */ + filterStrength?: GuardrailContentFilterStrength; + /** *

The guardrail action.

* @public @@ -310,6 +333,102 @@ export interface GuardrailContextualGroundingPolicyAssessment { filters?: GuardrailContextualGroundingFilter[]; } +/** + *

The guardrail coverage for the text characters.

+ * @public + */ +export interface GuardrailTextCharactersCoverage { + /** + *

The text characters that were guarded by the guardrail coverage.

+ * @public + */ + guarded?: number; + + /** + *

The total text characters by the guardrail coverage.

+ * @public + */ + total?: number; +} + +/** + *

The action of the guardrail coverage details.

+ * @public + */ +export interface GuardrailCoverage { + /** + *

The text characters of the guardrail coverage details.

+ * @public + */ + textCharacters?: GuardrailTextCharactersCoverage; +} + +/** + *

The details on the use of the guardrail.

+ * @public + */ +export interface GuardrailUsage { + /** + *

The topic policy units processed by the guardrail.

+ * @public + */ + topicPolicyUnits: number | undefined; + + /** + *

The content policy units processed by the guardrail.

+ * @public + */ + contentPolicyUnits: number | undefined; + + /** + *

The word policy units processed by the guardrail.

+ * @public + */ + wordPolicyUnits: number | undefined; + + /** + *

The sensitive information policy units processed by the guardrail.

+ * @public + */ + sensitiveInformationPolicyUnits: number | undefined; + + /** + *

The sensitive information policy free units processed by the guardrail.

+ * @public + */ + sensitiveInformationPolicyFreeUnits: number | undefined; + + /** + *

The contextual grounding policy units processed by the guardrail.

+ * @public + */ + contextualGroundingPolicyUnits: number | undefined; +} + +/** + *

The invocation metrics for the guardrail.

+ * @public + */ +export interface GuardrailInvocationMetrics { + /** + *

The processing latency details for the guardrail invocation metrics.

+ * @public + */ + guardrailProcessingLatency?: number; + + /** + *

The usage details for the guardrail invocation metrics.

+ * @public + */ + usage?: GuardrailUsage; + + /** + *

The coverage details for the guardrail invocation metrics.

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

The output content produced by the guardrail.

- * @public - */ -export interface GuardrailOutputContent { /** - *

The specific text for the output content produced by the guardrail.

+ *

The invocation metrics for the guardrail assessment.

* @public */ - text?: string; + invocationMetrics?: GuardrailInvocationMetrics; } /** - *

The details on the use of the guardrail.

+ *

The output content produced by the guardrail.

* @public */ -export interface GuardrailUsage { - /** - *

The topic policy units processed by the guardrail.

- * @public - */ - topicPolicyUnits: number | undefined; - - /** - *

The content policy units processed by the guardrail.

- * @public - */ - contentPolicyUnits: number | undefined; - - /** - *

The word policy units processed by the guardrail.

- * @public - */ - wordPolicyUnits: number | undefined; - - /** - *

The sensitive information policy units processed by the guardrail.

- * @public - */ - sensitiveInformationPolicyUnits: number | undefined; - - /** - *

The sensitive information policy free units processed by the guardrail.

- * @public - */ - sensitiveInformationPolicyFreeUnits: number | undefined; - +export interface GuardrailOutputContent { /** - *

The contextual grounding policy units processed by the guardrail.

+ *

The specific text for the output content produced by the guardrail.

* @public */ - contextualGroundingPolicyUnits: number | undefined; + text?: string; } /** @@ -705,6 +788,12 @@ export interface ApplyGuardrailResponse { * @public */ assessments: GuardrailAssessment[] | undefined; + + /** + *

The guardrail coverage details in the apply guardrail response.

+ * @public + */ + guardrailCoverage?: GuardrailCoverage; } /** diff --git a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts index 6db4bd88636a..37d761b99356 100644 --- a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts @@ -247,6 +247,7 @@ export const de_ApplyGuardrailCommand = async ( const doc = take(data, { action: __expectString, assessments: (_) => de_GuardrailAssessmentList(_, context), + guardrailCoverage: _json, outputs: _json, usage: _json, }); @@ -1202,6 +1203,7 @@ const de_GuardrailAssessment = (output: any, context: __SerdeContext): Guardrail return take(output, { contentPolicy: _json, contextualGroundingPolicy: (_: any) => de_GuardrailContextualGroundingPolicyAssessment(_, context), + invocationMetrics: _json, sensitiveInformationPolicy: _json, topicPolicy: _json, wordPolicy: _json, @@ -1300,10 +1302,14 @@ const de_GuardrailContextualGroundingPolicyAssessment = ( // de_GuardrailConverseTextBlock omitted. +// de_GuardrailCoverage omitted. + // de_GuardrailCustomWord omitted. // de_GuardrailCustomWordList omitted. +// de_GuardrailInvocationMetrics omitted. + // de_GuardrailManagedWord omitted. // de_GuardrailManagedWordList omitted. @@ -1322,6 +1328,8 @@ const de_GuardrailContextualGroundingPolicyAssessment = ( // de_GuardrailSensitiveInformationPolicyAssessment omitted. +// de_GuardrailTextCharactersCoverage omitted. + // de_GuardrailTopic omitted. // de_GuardrailTopicList omitted. diff --git a/codegen/sdk-codegen/aws-models/bedrock-runtime.json b/codegen/sdk-codegen/aws-models/bedrock-runtime.json index acbeddb68d83..c477169472d8 100644 --- a/codegen/sdk-codegen/aws-models/bedrock-runtime.json +++ b/codegen/sdk-codegen/aws-models/bedrock-runtime.json @@ -832,6 +832,12 @@ "smithy.api#documentation": "

The assessment details in the response from the guardrail.

", "smithy.api#required": {} } + }, + "guardrailCoverage": { + "target": "com.amazonaws.bedrockruntime#GuardrailCoverage", + "traits": { + "smithy.api#documentation": "

The guardrail coverage details in the apply guardrail response.

" + } } }, "traits": { @@ -1636,6 +1642,12 @@ "traits": { "smithy.api#documentation": "

The contextual grounding policy used for the guardrail assessment.

" } + }, + "invocationMetrics": { + "target": "com.amazonaws.bedrockruntime#GuardrailInvocationMetrics", + "traits": { + "smithy.api#documentation": "

The invocation metrics for the guardrail assessment.

" + } } }, "traits": { @@ -1732,6 +1744,12 @@ "smithy.api#required": {} } }, + "filterStrength": { + "target": "com.amazonaws.bedrockruntime#GuardrailContentFilterStrength", + "traits": { + "smithy.api#documentation": "

The filter strength setting for the guardrail content filter.

" + } + }, "action": { "target": "com.amazonaws.bedrockruntime#GuardrailContentPolicyAction", "traits": { @@ -1779,6 +1797,35 @@ "target": "com.amazonaws.bedrockruntime#GuardrailContentFilter" } }, + "com.amazonaws.bedrockruntime#GuardrailContentFilterStrength": { + "type": "enum", + "members": { + "NONE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "NONE" + } + }, + "LOW": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "LOW" + } + }, + "MEDIUM": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "MEDIUM" + } + }, + "HIGH": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "HIGH" + } + } + } + }, "com.amazonaws.bedrockruntime#GuardrailContentFilterType": { "type": "enum", "members": { @@ -2060,6 +2107,20 @@ "smithy.api#documentation": "

A text block that contains text that you want to assess with a guardrail. For more information, see GuardrailConverseContentBlock.

" } }, + "com.amazonaws.bedrockruntime#GuardrailCoverage": { + "type": "structure", + "members": { + "textCharacters": { + "target": "com.amazonaws.bedrockruntime#GuardrailTextCharactersCoverage", + "traits": { + "smithy.api#documentation": "

The text characters of the guardrail coverage details.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The action of the guardrail coverage details.

" + } + }, "com.amazonaws.bedrockruntime#GuardrailCustomWord": { "type": "structure", "members": { @@ -2097,6 +2158,32 @@ "smithy.api#pattern": "^(([a-z0-9]+)|(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:guardrail/[a-z0-9]+))$" } }, + "com.amazonaws.bedrockruntime#GuardrailInvocationMetrics": { + "type": "structure", + "members": { + "guardrailProcessingLatency": { + "target": "com.amazonaws.bedrockruntime#GuardrailProcessingLatency", + "traits": { + "smithy.api#documentation": "

The processing latency details for the guardrail invocation metrics.

" + } + }, + "usage": { + "target": "com.amazonaws.bedrockruntime#GuardrailUsage", + "traits": { + "smithy.api#documentation": "

The usage details for the guardrail invocation metrics.

" + } + }, + "guardrailCoverage": { + "target": "com.amazonaws.bedrockruntime#GuardrailCoverage", + "traits": { + "smithy.api#documentation": "

The coverage details for the guardrail invocation metrics.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The invocation metrics for the guardrail.

" + } + }, "com.amazonaws.bedrockruntime#GuardrailManagedWord": { "type": "structure", "members": { @@ -2392,6 +2479,9 @@ } } }, + "com.amazonaws.bedrockruntime#GuardrailProcessingLatency": { + "type": "long" + }, "com.amazonaws.bedrockruntime#GuardrailRegexFilter": { "type": "structure", "members": { @@ -2558,6 +2648,26 @@ "smithy.api#documentation": "

The text block to be evaluated by the guardrail.

" } }, + "com.amazonaws.bedrockruntime#GuardrailTextCharactersCoverage": { + "type": "structure", + "members": { + "guarded": { + "target": "com.amazonaws.bedrockruntime#TextCharactersGuarded", + "traits": { + "smithy.api#documentation": "

The text characters that were guarded by the guardrail coverage.

" + } + }, + "total": { + "target": "com.amazonaws.bedrockruntime#TextCharactersTotal", + "traits": { + "smithy.api#documentation": "

The total text characters by the guardrail coverage.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The guardrail coverage for the text characters.

" + } + }, "com.amazonaws.bedrockruntime#GuardrailTopic": { "type": "structure", "members": { @@ -3569,6 +3679,12 @@ "target": "com.amazonaws.bedrockruntime#SystemContentBlock" } }, + "com.amazonaws.bedrockruntime#TextCharactersGuarded": { + "type": "integer" + }, + "com.amazonaws.bedrockruntime#TextCharactersTotal": { + "type": "integer" + }, "com.amazonaws.bedrockruntime#ThrottlingException": { "type": "structure", "members": {