From 8863b77e5bd997ae9daaad9a56c847296d017298 Mon Sep 17 00:00:00 2001 From: awstools Date: Wed, 10 Jul 2024 18:50:47 +0000 Subject: [PATCH] feat(client-bedrock-runtime): Add support for contextual grounding check and ApplyGuardrail API for Guardrails for Amazon Bedrock. --- clients/client-bedrock-runtime/README.md | 8 + .../src/BedrockRuntime.ts | 20 + .../src/BedrockRuntimeClient.ts | 3 + .../src/commands/ApplyGuardrailCommand.ts | 189 ++ .../src/commands/ConverseCommand.ts | 29 + .../src/commands/ConverseStreamCommand.ts | 26 + .../src/commands/index.ts | 1 + .../src/models/models_0.ts | 2235 ++++++++++------- .../src/protocols/Aws_restJson1.ts | 240 +- .../aws-models/bedrock-runtime.json | 485 +++- 10 files changed, 2253 insertions(+), 983 deletions(-) create mode 100644 clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts diff --git a/clients/client-bedrock-runtime/README.md b/clients/client-bedrock-runtime/README.md index 0459090c4767..c292df4217b7 100644 --- a/clients/client-bedrock-runtime/README.md +++ b/clients/client-bedrock-runtime/README.md @@ -203,6 +203,14 @@ see LICENSE for more information. ## Client Commands (Operations List) +
+ +ApplyGuardrail + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/ApplyGuardrailCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ApplyGuardrailCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ApplyGuardrailCommandOutput/) + +
Converse diff --git a/clients/client-bedrock-runtime/src/BedrockRuntime.ts b/clients/client-bedrock-runtime/src/BedrockRuntime.ts index e706a5e01c6a..d69c6eb0a735 100644 --- a/clients/client-bedrock-runtime/src/BedrockRuntime.ts +++ b/clients/client-bedrock-runtime/src/BedrockRuntime.ts @@ -3,6 +3,11 @@ import { createAggregatedClient } from "@smithy/smithy-client"; import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types"; import { BedrockRuntimeClient, BedrockRuntimeClientConfig } from "./BedrockRuntimeClient"; +import { + ApplyGuardrailCommand, + ApplyGuardrailCommandInput, + ApplyGuardrailCommandOutput, +} from "./commands/ApplyGuardrailCommand"; import { ConverseCommand, ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand"; import { ConverseStreamCommand, @@ -17,6 +22,7 @@ import { } from "./commands/InvokeModelWithResponseStreamCommand"; const commands = { + ApplyGuardrailCommand, ConverseCommand, ConverseStreamCommand, InvokeModelCommand, @@ -24,6 +30,20 @@ const commands = { }; export interface BedrockRuntime { + /** + * @see {@link ApplyGuardrailCommand} + */ + applyGuardrail( + args: ApplyGuardrailCommandInput, + options?: __HttpHandlerOptions + ): Promise; + applyGuardrail(args: ApplyGuardrailCommandInput, cb: (err: any, data?: ApplyGuardrailCommandOutput) => void): void; + applyGuardrail( + args: ApplyGuardrailCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: ApplyGuardrailCommandOutput) => void + ): void; + /** * @see {@link ConverseCommand} */ diff --git a/clients/client-bedrock-runtime/src/BedrockRuntimeClient.ts b/clients/client-bedrock-runtime/src/BedrockRuntimeClient.ts index 32917a1fbdb5..6ef7c15b3e91 100644 --- a/clients/client-bedrock-runtime/src/BedrockRuntimeClient.ts +++ b/clients/client-bedrock-runtime/src/BedrockRuntimeClient.ts @@ -59,6 +59,7 @@ import { HttpAuthSchemeResolvedConfig, resolveHttpAuthSchemeConfig, } from "./auth/httpAuthSchemeProvider"; +import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "./commands/ApplyGuardrailCommand"; import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand"; import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand"; import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand"; @@ -81,6 +82,7 @@ export { __Client }; * @public */ export type ServiceInputTypes = + | ApplyGuardrailCommandInput | ConverseCommandInput | ConverseStreamCommandInput | InvokeModelCommandInput @@ -90,6 +92,7 @@ export type ServiceInputTypes = * @public */ export type ServiceOutputTypes = + | ApplyGuardrailCommandOutput | ConverseCommandOutput | ConverseStreamCommandOutput | InvokeModelCommandOutput diff --git a/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts b/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts new file mode 100644 index 000000000000..4d97be9f189b --- /dev/null +++ b/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts @@ -0,0 +1,189 @@ +// smithy-typescript generated code +import { getEndpointPlugin } from "@smithy/middleware-endpoint"; +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { Command as $Command } from "@smithy/smithy-client"; +import { MetadataBearer as __MetadataBearer } from "@smithy/types"; + +import { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BedrockRuntimeClient"; +import { commonParams } from "../endpoint/EndpointParameters"; +import { ApplyGuardrailRequest, ApplyGuardrailResponse } from "../models/models_0"; +import { de_ApplyGuardrailCommand, se_ApplyGuardrailCommand } from "../protocols/Aws_restJson1"; + +/** + * @public + */ +export type { __MetadataBearer }; +export { $Command }; +/** + * @public + * + * The input for {@link ApplyGuardrailCommand}. + */ +export interface ApplyGuardrailCommandInput extends ApplyGuardrailRequest {} +/** + * @public + * + * The output of {@link ApplyGuardrailCommand}. + */ +export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __MetadataBearer {} + +/** + *

The action to apply a guardrail.

+ * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { BedrockRuntimeClient, ApplyGuardrailCommand } from "@aws-sdk/client-bedrock-runtime"; // ES Modules import + * // const { BedrockRuntimeClient, ApplyGuardrailCommand } = require("@aws-sdk/client-bedrock-runtime"); // CommonJS import + * const client = new BedrockRuntimeClient(config); + * const input = { // ApplyGuardrailRequest + * guardrailIdentifier: "STRING_VALUE", // required + * guardrailVersion: "STRING_VALUE", // required + * source: "INPUT" || "OUTPUT", // required + * content: [ // GuardrailContentBlockList // required + * { // GuardrailContentBlock Union: only one key present + * text: { // GuardrailTextBlock + * text: "STRING_VALUE", // required + * qualifiers: [ // GuardrailContentQualifierList + * "grounding_source" || "query" || "guard_content", + * ], + * }, + * }, + * ], + * }; + * const command = new ApplyGuardrailCommand(input); + * const response = await client.send(command); + * // { // ApplyGuardrailResponse + * // 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 + * // }, + * // action: "NONE" || "GUARDRAIL_INTERVENED", // required + * // outputs: [ // GuardrailOutputContentList // required + * // { // GuardrailOutputContent + * // text: "STRING_VALUE", + * // }, + * // ], + * // assessments: [ // GuardrailAssessmentList // required + * // { // GuardrailAssessment + * // topicPolicy: { // GuardrailTopicPolicyAssessment + * // topics: [ // GuardrailTopicList // required + * // { // GuardrailTopic + * // name: "STRING_VALUE", // required + * // type: "DENY", // required + * // action: "BLOCKED", // required + * // }, + * // ], + * // }, + * // contentPolicy: { // GuardrailContentPolicyAssessment + * // filters: [ // GuardrailContentFilterList // required + * // { // GuardrailContentFilter + * // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required + * // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required + * // action: "BLOCKED", // required + * // }, + * // ], + * // }, + * // wordPolicy: { // GuardrailWordPolicyAssessment + * // customWords: [ // GuardrailCustomWordList // required + * // { // GuardrailCustomWord + * // match: "STRING_VALUE", // required + * // action: "BLOCKED", // required + * // }, + * // ], + * // managedWordLists: [ // GuardrailManagedWordList // required + * // { // GuardrailManagedWord + * // match: "STRING_VALUE", // required + * // type: "PROFANITY", // required + * // action: "BLOCKED", // required + * // }, + * // ], + * // }, + * // sensitiveInformationPolicy: { // GuardrailSensitiveInformationPolicyAssessment + * // piiEntities: [ // GuardrailPiiEntityFilterList // required + * // { // GuardrailPiiEntityFilter + * // match: "STRING_VALUE", // required + * // type: "ADDRESS" || "AGE" || "AWS_ACCESS_KEY" || "AWS_SECRET_KEY" || "CA_HEALTH_NUMBER" || "CA_SOCIAL_INSURANCE_NUMBER" || "CREDIT_DEBIT_CARD_CVV" || "CREDIT_DEBIT_CARD_EXPIRY" || "CREDIT_DEBIT_CARD_NUMBER" || "DRIVER_ID" || "EMAIL" || "INTERNATIONAL_BANK_ACCOUNT_NUMBER" || "IP_ADDRESS" || "LICENSE_PLATE" || "MAC_ADDRESS" || "NAME" || "PASSWORD" || "PHONE" || "PIN" || "SWIFT_CODE" || "UK_NATIONAL_HEALTH_SERVICE_NUMBER" || "UK_NATIONAL_INSURANCE_NUMBER" || "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER" || "URL" || "USERNAME" || "US_BANK_ACCOUNT_NUMBER" || "US_BANK_ROUTING_NUMBER" || "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER" || "US_PASSPORT_NUMBER" || "US_SOCIAL_SECURITY_NUMBER" || "VEHICLE_IDENTIFICATION_NUMBER", // required + * // action: "ANONYMIZED" || "BLOCKED", // required + * // }, + * // ], + * // regexes: [ // GuardrailRegexFilterList // required + * // { // GuardrailRegexFilter + * // name: "STRING_VALUE", + * // match: "STRING_VALUE", + * // regex: "STRING_VALUE", + * // action: "ANONYMIZED" || "BLOCKED", // required + * // }, + * // ], + * // }, + * // contextualGroundingPolicy: { // GuardrailContextualGroundingPolicyAssessment + * // filters: [ // GuardrailContextualGroundingFilters + * // { // GuardrailContextualGroundingFilter + * // type: "GROUNDING" || "RELEVANCE", // required + * // threshold: Number("double"), // required + * // score: Number("double"), // required + * // action: "BLOCKED" || "NONE", // required + * // }, + * // ], + * // }, + * // }, + * // ], + * // }; + * + * ``` + * + * @param ApplyGuardrailCommandInput - {@link ApplyGuardrailCommandInput} + * @returns {@link ApplyGuardrailCommandOutput} + * @see {@link ApplyGuardrailCommandInput} for command's `input` shape. + * @see {@link ApplyGuardrailCommandOutput} for command's `response` shape. + * @see {@link BedrockRuntimeClientResolvedConfig | config} for BedrockRuntimeClient's `config` shape. + * + * @throws {@link AccessDeniedException} (client fault) + *

The request is denied because of missing access permissions.

+ * + * @throws {@link InternalServerException} (server fault) + *

An internal server error occurred. Retry your request.

+ * + * @throws {@link ResourceNotFoundException} (client fault) + *

The specified resource ARN was not found. Check the ARN and try your request again.

+ * + * @throws {@link ServiceQuotaExceededException} (client fault) + *

The number of requests exceeds the service quota. Resubmit your request later.

+ * + * @throws {@link ThrottlingException} (client fault) + *

The number of requests exceeds the limit. Resubmit your request later.

+ * + * @throws {@link ValidationException} (client fault) + *

Input validation failed. Check your request parameters and retry the request.

+ * + * @throws {@link BedrockRuntimeServiceException} + *

Base exception class for all service exceptions from BedrockRuntime service.

+ * + * @public + */ +export class ApplyGuardrailCommand extends $Command + .classBuilder< + ApplyGuardrailCommandInput, + ApplyGuardrailCommandOutput, + BedrockRuntimeClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes + >() + .ep({ + ...commonParams, + }) + .m(function (this: any, Command: any, cs: any, config: BedrockRuntimeClientResolvedConfig, o: any) { + return [ + getSerdePlugin(config, this.serialize, this.deserialize), + getEndpointPlugin(config, Command.getEndpointParameterInstructions()), + ]; + }) + .s("AmazonBedrockFrontendService", "ApplyGuardrail", {}) + .n("BedrockRuntimeClient", "ApplyGuardrailCommand") + .f(void 0, void 0) + .ser(se_ApplyGuardrailCommand) + .de(de_ApplyGuardrailCommand) + .build() {} diff --git a/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts b/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts index ce891e0cce0b..88844a57cc4a 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts @@ -98,6 +98,9 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * guardContent: { // GuardrailConverseContentBlock Union: only one key present * text: { // GuardrailConverseTextBlock * text: "STRING_VALUE", // required + * qualifiers: [ // GuardrailConverseContentQualifierList + * "grounding_source" || "query" || "guard_content", + * ], * }, * }, * }, @@ -110,6 +113,9 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * guardContent: {// Union: only one key present * text: { * text: "STRING_VALUE", // required + * qualifiers: [ + * "grounding_source" || "query" || "guard_content", + * ], * }, * }, * }, @@ -205,6 +211,9 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // guardContent: { // GuardrailConverseContentBlock Union: only one key present * // text: { // GuardrailConverseTextBlock * // text: "STRING_VALUE", // required + * // qualifiers: [ // GuardrailConverseContentQualifierList + * // "grounding_source" || "query" || "guard_content", + * // ], * // }, * // }, * // }, @@ -278,6 +287,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // }, * // ], * // }, + * // contextualGroundingPolicy: { // GuardrailContextualGroundingPolicyAssessment + * // filters: [ // GuardrailContextualGroundingFilters + * // { // GuardrailContextualGroundingFilter + * // type: "GROUNDING" || "RELEVANCE", // required + * // threshold: Number("double"), // required + * // score: Number("double"), // required + * // action: "BLOCKED" || "NONE", // required + * // }, + * // ], + * // }, * // }, * // }, * // outputAssessments: { // GuardrailAssessmentListMap @@ -333,6 +352,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // }, * // ], * // }, + * // contextualGroundingPolicy: { + * // filters: [ + * // { + * // type: "GROUNDING" || "RELEVANCE", // required + * // threshold: Number("double"), // required + * // score: Number("double"), // required + * // action: "BLOCKED" || "NONE", // required + * // }, + * // ], + * // }, * // }, * // ], * // }, diff --git a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts index f2f2c95994e8..15561205dcc0 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts @@ -105,6 +105,9 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * guardContent: { // GuardrailConverseContentBlock Union: only one key present * text: { // GuardrailConverseTextBlock * text: "STRING_VALUE", // required + * qualifiers: [ // GuardrailConverseContentQualifierList + * "grounding_source" || "query" || "guard_content", + * ], * }, * }, * }, @@ -117,6 +120,9 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * guardContent: {// Union: only one key present * text: { * text: "STRING_VALUE", // required + * qualifiers: [ + * "grounding_source" || "query" || "guard_content", + * ], * }, * }, * }, @@ -258,6 +264,16 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * // }, * // ], * // }, + * // contextualGroundingPolicy: { // GuardrailContextualGroundingPolicyAssessment + * // filters: [ // GuardrailContextualGroundingFilters + * // { // GuardrailContextualGroundingFilter + * // type: "GROUNDING" || "RELEVANCE", // required + * // threshold: Number("double"), // required + * // score: Number("double"), // required + * // action: "BLOCKED" || "NONE", // required + * // }, + * // ], + * // }, * // }, * // }, * // outputAssessments: { // GuardrailAssessmentListMap @@ -313,6 +329,16 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * // }, * // ], * // }, + * // contextualGroundingPolicy: { + * // filters: [ + * // { + * // type: "GROUNDING" || "RELEVANCE", // required + * // threshold: Number("double"), // required + * // score: Number("double"), // required + * // action: "BLOCKED" || "NONE", // required + * // }, + * // ], + * // }, * // }, * // ], * // }, diff --git a/clients/client-bedrock-runtime/src/commands/index.ts b/clients/client-bedrock-runtime/src/commands/index.ts index 7e766da55f68..d8eed6a0bb8a 100644 --- a/clients/client-bedrock-runtime/src/commands/index.ts +++ b/clients/client-bedrock-runtime/src/commands/index.ts @@ -1,4 +1,5 @@ // smithy-typescript generated code +export * from "./ApplyGuardrailCommand"; export * from "./ConverseCommand"; export * from "./ConverseStreamCommand"; export * from "./InvokeModelCommand"; diff --git a/clients/client-bedrock-runtime/src/models/models_0.ts b/clients/client-bedrock-runtime/src/models/models_0.ts index 47a4952fbfcb..cb83451b5114 100644 --- a/clients/client-bedrock-runtime/src/models/models_0.ts +++ b/clients/client-bedrock-runtime/src/models/models_0.ts @@ -29,870 +29,907 @@ export class AccessDeniedException extends __BaseException { * @public * @enum */ -export const GuardrailTrace = { - DISABLED: "disabled", - ENABLED: "enabled", +export const GuardrailContentQualifier = { + GROUNDING_SOURCE: "grounding_source", + GUARD_CONTENT: "guard_content", + QUERY: "query", } as const; /** * @public */ -export type GuardrailTrace = (typeof GuardrailTrace)[keyof typeof GuardrailTrace]; +export type GuardrailContentQualifier = (typeof GuardrailContentQualifier)[keyof typeof GuardrailContentQualifier]; /** - *

Configuration information for a guardrail that you use with the Converse action.

+ *

The text block to be evaluated by the guardrail.

* @public */ -export interface GuardrailConfiguration { +export interface GuardrailTextBlock { /** - *

The identifier for the guardrail.

+ *

The input text details to be evaluated by the guardrail.

* @public */ - guardrailIdentifier: string | undefined; + text: string | undefined; /** - *

The version of the guardrail.

+ *

The qualifiers describing the text block.

* @public */ - guardrailVersion: string | undefined; + qualifiers?: GuardrailContentQualifier[]; +} + +/** + *

The content block to be evaluated by the guardrail.

+ * @public + */ +export type GuardrailContentBlock = GuardrailContentBlock.TextMember | GuardrailContentBlock.$UnknownMember; + +/** + * @public + */ +export namespace GuardrailContentBlock { + /** + *

Text within content block to be evaluated by the guardrail.

+ * @public + */ + export interface TextMember { + text: GuardrailTextBlock; + $unknown?: never; + } /** - *

The trace behavior for the guardrail.

* @public */ - trace?: GuardrailTrace; + export interface $UnknownMember { + text?: never; + $unknown: [string, any]; + } + + export interface Visitor { + text: (value: GuardrailTextBlock) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: GuardrailContentBlock, visitor: Visitor): T => { + if (value.text !== undefined) return visitor.text(value.text); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; } /** - *

Base inference parameters to pass to a model in a call to Converse or ConverseStream. For more information, - * see Inference parameters for foundation models.

- *

If you need to pass additional parameters that the model - * supports, use the additionalModelRequestFields request field in the call to Converse - * or ConverseStream. - * For more information, see Model parameters.

* @public + * @enum */ -export interface InferenceConfiguration { +export const GuardrailContentSource = { + INPUT: "INPUT", + OUTPUT: "OUTPUT", +} as const; + +/** + * @public + */ +export type GuardrailContentSource = (typeof GuardrailContentSource)[keyof typeof GuardrailContentSource]; + +/** + * @public + */ +export interface ApplyGuardrailRequest { /** - *

The maximum number of tokens to allow in the generated response. The default value is - * the maximum allowed value for the model that you are using. For more information, see - * Inference parameters for foundation models.

+ *

The guardrail identifier used in the request to apply the guardrail.

* @public */ - maxTokens?: number; + guardrailIdentifier: string | undefined; /** - *

The likelihood of the model selecting higher-probability options while generating a - * response. A lower value makes the model more likely to choose higher-probability options, - * while a higher value makes the model more likely to choose lower-probability - * options.

- *

The default value is the default value for the model that - * you are using. For more information, see Inference parameters for foundation - * models.

+ *

The guardrail version used in the request to apply the guardrail.

* @public */ - temperature?: number; + guardrailVersion: string | undefined; /** - *

The percentage of most-likely candidates that the model considers for the next token. For - * example, if you choose a value of 0.8 for topP, the model selects from the top 80% of the - * probability distribution of tokens that could be next in the sequence.

- *

The default value is the default value for the model that you are using. For more information, see - * Inference parameters for foundation models.

+ *

The source of data used in the request to apply the guardrail.

* @public */ - topP?: number; + source: GuardrailContentSource | undefined; /** - *

A list of stop sequences. A stop sequence is a sequence of characters that causes the - * model to stop generating the response.

+ *

The content details used in the request to apply the guardrail.

* @public */ - stopSequences?: string[]; + content: GuardrailContentBlock[] | undefined; } /** * @public * @enum */ -export const DocumentFormat = { - CSV: "csv", - DOC: "doc", - DOCX: "docx", - HTML: "html", - MD: "md", - PDF: "pdf", - TXT: "txt", - XLS: "xls", - XLSX: "xlsx", +export const GuardrailAction = { + GUARDRAIL_INTERVENED: "GUARDRAIL_INTERVENED", + NONE: "NONE", } as const; /** * @public */ -export type DocumentFormat = (typeof DocumentFormat)[keyof typeof DocumentFormat]; +export type GuardrailAction = (typeof GuardrailAction)[keyof typeof GuardrailAction]; /** - *

Contains the content of the document included in a message when sending a Converse or ConverseStream request or in the response.

* @public + * @enum */ -export type DocumentSource = DocumentSource.BytesMember | DocumentSource.$UnknownMember; +export const GuardrailContentPolicyAction = { + BLOCKED: "BLOCKED", +} as const; /** * @public */ -export namespace DocumentSource { - /** - *

A base64-encoded string of a UTF-8 encoded file, that is the document to include in the message.

- * @public - */ - export interface BytesMember { - bytes: Uint8Array; - $unknown?: never; - } +export type GuardrailContentPolicyAction = + (typeof GuardrailContentPolicyAction)[keyof typeof GuardrailContentPolicyAction]; - /** - * @public - */ - export interface $UnknownMember { - bytes?: never; - $unknown: [string, any]; - } +/** + * @public + * @enum + */ +export const GuardrailContentFilterConfidence = { + HIGH: "HIGH", + LOW: "LOW", + MEDIUM: "MEDIUM", + NONE: "NONE", +} as const; - export interface Visitor { - bytes: (value: Uint8Array) => T; - _: (name: string, value: any) => T; - } +/** + * @public + */ +export type GuardrailContentFilterConfidence = + (typeof GuardrailContentFilterConfidence)[keyof typeof GuardrailContentFilterConfidence]; - export const visit = (value: DocumentSource, visitor: Visitor): T => { - if (value.bytes !== undefined) return visitor.bytes(value.bytes); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; -} +/** + * @public + * @enum + */ +export const GuardrailContentFilterType = { + HATE: "HATE", + INSULTS: "INSULTS", + MISCONDUCT: "MISCONDUCT", + PROMPT_ATTACK: "PROMPT_ATTACK", + SEXUAL: "SEXUAL", + VIOLENCE: "VIOLENCE", +} as const; /** - *

A document to include in a message when sending a Converse or ConverseStream request. You can include up to 5 documents in a request. The maximum document size is 50 MB.

* @public */ -export interface DocumentBlock { +export type GuardrailContentFilterType = (typeof GuardrailContentFilterType)[keyof typeof GuardrailContentFilterType]; + +/** + *

The content filter for a guardrail.

+ * @public + */ +export interface GuardrailContentFilter { /** - *

The format of a document, or its extension.

+ *

The guardrail type.

* @public */ - format: DocumentFormat | undefined; + type: GuardrailContentFilterType | undefined; /** - *

A name for the document.

+ *

The guardrail confidence.

* @public */ - name: string | undefined; + confidence: GuardrailContentFilterConfidence | undefined; /** - *

Contains the content of the document.

+ *

The guardrail action.

* @public */ - source: DocumentSource | undefined; + action: GuardrailContentPolicyAction | undefined; } /** - *

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

+ *

An assessment of a content policy for a guardrail.

* @public */ -export interface GuardrailConverseTextBlock { +export interface GuardrailContentPolicyAssessment { /** - *

The text that you want to guard.

+ *

The content policy filters.

* @public */ - text: string | undefined; + filters: GuardrailContentFilter[] | undefined; } /** - *

- *

A content block for selective guarding with the Converse API (Converse and ConverseStream). - *

* @public + * @enum */ -export type GuardrailConverseContentBlock = - | GuardrailConverseContentBlock.TextMember - | GuardrailConverseContentBlock.$UnknownMember; +export const GuardrailContextualGroundingPolicyAction = { + BLOCKED: "BLOCKED", + NONE: "NONE", +} as const; /** * @public */ -export namespace GuardrailConverseContentBlock { - /** - *

The text to guard.

- * @public - */ - export interface TextMember { - text: GuardrailConverseTextBlock; - $unknown?: never; - } - - /** - * @public - */ - export interface $UnknownMember { - text?: never; - $unknown: [string, any]; - } - - export interface Visitor { - text: (value: GuardrailConverseTextBlock) => T; - _: (name: string, value: any) => T; - } - - export const visit = (value: GuardrailConverseContentBlock, visitor: Visitor): T => { - if (value.text !== undefined) return visitor.text(value.text); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; -} +export type GuardrailContextualGroundingPolicyAction = + (typeof GuardrailContextualGroundingPolicyAction)[keyof typeof GuardrailContextualGroundingPolicyAction]; /** * @public * @enum */ -export const ImageFormat = { - GIF: "gif", - JPEG: "jpeg", - PNG: "png", - WEBP: "webp", +export const GuardrailContextualGroundingFilterType = { + GROUNDING: "GROUNDING", + RELEVANCE: "RELEVANCE", } as const; /** * @public */ -export type ImageFormat = (typeof ImageFormat)[keyof typeof ImageFormat]; - -/** - *

The source for an image.

- * @public - */ -export type ImageSource = ImageSource.BytesMember | ImageSource.$UnknownMember; +export type GuardrailContextualGroundingFilterType = + (typeof GuardrailContextualGroundingFilterType)[keyof typeof GuardrailContextualGroundingFilterType]; /** + *

The details for the guardrails contextual grounding filter.

* @public */ -export namespace ImageSource { +export interface GuardrailContextualGroundingFilter { /** - *

The raw image bytes for the image. If you use an AWS SDK, you don't need to base64 encode the image bytes.

+ *

The contextual grounding filter type.

* @public */ - export interface BytesMember { - bytes: Uint8Array; - $unknown?: never; - } + type: GuardrailContextualGroundingFilterType | undefined; /** + *

The threshold used by contextual grounding filter to determine whether the content is grounded or not.

* @public */ - export interface $UnknownMember { - bytes?: never; - $unknown: [string, any]; - } - - export interface Visitor { - bytes: (value: Uint8Array) => T; - _: (name: string, value: any) => T; - } - - export const visit = (value: ImageSource, visitor: Visitor): T => { - if (value.bytes !== undefined) return visitor.bytes(value.bytes); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; -} + threshold: number | undefined; -/** - *

Image content for a message.

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

The format of the image.

+ *

The score generated by contextual grounding filter.

* @public */ - format: ImageFormat | undefined; + score: number | undefined; /** - *

The source for the image.

+ *

The action performed by the guardrails contextual grounding filter.

* @public */ - source: ImageSource | undefined; + action: GuardrailContextualGroundingPolicyAction | undefined; } /** - *

The tool result content block.

+ *

The policy assessment details for the guardrails contextual grounding filter.

* @public */ -export type ToolResultContentBlock = - | ToolResultContentBlock.DocumentMember - | ToolResultContentBlock.ImageMember - | ToolResultContentBlock.JsonMember - | ToolResultContentBlock.TextMember - | ToolResultContentBlock.$UnknownMember; +export interface GuardrailContextualGroundingPolicyAssessment { + /** + *

The filter details for the guardrails contextual grounding filter.

+ * @public + */ + filters?: GuardrailContextualGroundingFilter[]; +} /** * @public + * @enum */ -export namespace ToolResultContentBlock { +export const GuardrailSensitiveInformationPolicyAction = { + ANONYMIZED: "ANONYMIZED", + BLOCKED: "BLOCKED", +} as const; + +/** + * @public + */ +export type GuardrailSensitiveInformationPolicyAction = + (typeof GuardrailSensitiveInformationPolicyAction)[keyof typeof GuardrailSensitiveInformationPolicyAction]; + +/** + * @public + * @enum + */ +export const GuardrailPiiEntityType = { + ADDRESS: "ADDRESS", + AGE: "AGE", + AWS_ACCESS_KEY: "AWS_ACCESS_KEY", + AWS_SECRET_KEY: "AWS_SECRET_KEY", + CA_HEALTH_NUMBER: "CA_HEALTH_NUMBER", + CA_SOCIAL_INSURANCE_NUMBER: "CA_SOCIAL_INSURANCE_NUMBER", + CREDIT_DEBIT_CARD_CVV: "CREDIT_DEBIT_CARD_CVV", + CREDIT_DEBIT_CARD_EXPIRY: "CREDIT_DEBIT_CARD_EXPIRY", + CREDIT_DEBIT_CARD_NUMBER: "CREDIT_DEBIT_CARD_NUMBER", + DRIVER_ID: "DRIVER_ID", + EMAIL: "EMAIL", + INTERNATIONAL_BANK_ACCOUNT_NUMBER: "INTERNATIONAL_BANK_ACCOUNT_NUMBER", + IP_ADDRESS: "IP_ADDRESS", + LICENSE_PLATE: "LICENSE_PLATE", + MAC_ADDRESS: "MAC_ADDRESS", + NAME: "NAME", + PASSWORD: "PASSWORD", + PHONE: "PHONE", + PIN: "PIN", + SWIFT_CODE: "SWIFT_CODE", + UK_NATIONAL_HEALTH_SERVICE_NUMBER: "UK_NATIONAL_HEALTH_SERVICE_NUMBER", + UK_NATIONAL_INSURANCE_NUMBER: "UK_NATIONAL_INSURANCE_NUMBER", + UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER: "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER", + URL: "URL", + USERNAME: "USERNAME", + US_BANK_ACCOUNT_NUMBER: "US_BANK_ACCOUNT_NUMBER", + US_BANK_ROUTING_NUMBER: "US_BANK_ROUTING_NUMBER", + US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER: "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER", + US_PASSPORT_NUMBER: "US_PASSPORT_NUMBER", + US_SOCIAL_SECURITY_NUMBER: "US_SOCIAL_SECURITY_NUMBER", + VEHICLE_IDENTIFICATION_NUMBER: "VEHICLE_IDENTIFICATION_NUMBER", +} as const; + +/** + * @public + */ +export type GuardrailPiiEntityType = (typeof GuardrailPiiEntityType)[keyof typeof GuardrailPiiEntityType]; + +/** + *

A Personally Identifiable Information (PII) entity configured in a guardrail.

+ * @public + */ +export interface GuardrailPiiEntityFilter { /** - *

A tool result that is JSON format data.

+ *

The PII entity filter match.

* @public */ - export interface JsonMember { - json: __DocumentType; - text?: never; - image?: never; - document?: never; - $unknown?: never; - } + match: string | undefined; /** - *

A tool result that is text.

+ *

The PII entity filter type.

* @public */ - export interface TextMember { - json?: never; - text: string; - image?: never; - document?: never; - $unknown?: never; - } + type: GuardrailPiiEntityType | undefined; /** - *

A tool result that is an image.

- * - *

This field is only supported by Anthropic Claude 3 models.

- *
+ *

The PII entity filter action.

* @public */ - export interface ImageMember { - json?: never; - text?: never; - image: ImageBlock; - document?: never; - $unknown?: never; - } + action: GuardrailSensitiveInformationPolicyAction | undefined; +} +/** + *

A Regex filter configured in a guardrail.

+ * @public + */ +export interface GuardrailRegexFilter { /** - *

A tool result that is a document.

+ *

The regex filter name.

* @public */ - export interface DocumentMember { - json?: never; - text?: never; - image?: never; - document: DocumentBlock; - $unknown?: never; - } + name?: string; /** + *

The regesx filter match.

* @public */ - export interface $UnknownMember { - json?: never; - text?: never; - image?: never; - document?: never; - $unknown: [string, any]; - } + match?: string; - export interface Visitor { - json: (value: __DocumentType) => T; - text: (value: string) => T; - image: (value: ImageBlock) => T; - document: (value: DocumentBlock) => T; - _: (name: string, value: any) => T; - } + /** + *

The regex query.

+ * @public + */ + regex?: string; - export const visit = (value: ToolResultContentBlock, visitor: Visitor): T => { - if (value.json !== undefined) return visitor.json(value.json); - if (value.text !== undefined) return visitor.text(value.text); - if (value.image !== undefined) return visitor.image(value.image); - if (value.document !== undefined) return visitor.document(value.document); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; + /** + *

The region filter action.

+ * @public + */ + action: GuardrailSensitiveInformationPolicyAction | undefined; +} + +/** + *

The assessment for aPersonally Identifiable Information (PII) policy.

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

The PII entities in the assessment.

+ * @public + */ + piiEntities: GuardrailPiiEntityFilter[] | undefined; + + /** + *

The regex queries in the assessment.

+ * @public + */ + regexes: GuardrailRegexFilter[] | undefined; } /** * @public * @enum */ -export const ToolResultStatus = { - ERROR: "error", - SUCCESS: "success", +export const GuardrailTopicPolicyAction = { + BLOCKED: "BLOCKED", } as const; /** * @public */ -export type ToolResultStatus = (typeof ToolResultStatus)[keyof typeof ToolResultStatus]; +export type GuardrailTopicPolicyAction = (typeof GuardrailTopicPolicyAction)[keyof typeof GuardrailTopicPolicyAction]; /** - *

A tool result block that contains the results for a tool request that - * the model previously made.

* @public + * @enum */ -export interface ToolResultBlock { +export const GuardrailTopicType = { + DENY: "DENY", +} as const; + +/** + * @public + */ +export type GuardrailTopicType = (typeof GuardrailTopicType)[keyof typeof GuardrailTopicType]; + +/** + *

Information about a topic guardrail.

+ * @public + */ +export interface GuardrailTopic { /** - *

The ID of the tool request that this is the result for.

+ *

The name for the guardrail.

* @public */ - toolUseId: string | undefined; + name: string | undefined; /** - *

The content for tool result content block.

+ *

The type behavior that the guardrail should perform when the model detects the topic.

* @public */ - content: ToolResultContentBlock[] | undefined; + type: GuardrailTopicType | undefined; /** - *

The status for the tool result content block.

- * - *

This field is only supported Anthropic Claude 3 models.

- *
+ *

The action the guardrail should take when it intervenes on a topic.

* @public */ - status?: ToolResultStatus; + action: GuardrailTopicPolicyAction | undefined; } /** - *

A tool use content block. Contains information about a tool that the model - * is requesting be run., The model uses the result from the tool to generate a response.

+ *

A behavior assessment of a topic policy.

* @public */ -export interface ToolUseBlock { +export interface GuardrailTopicPolicyAssessment { /** - *

The ID for the tool request.

+ *

The topics in the assessment.

* @public */ - toolUseId: string | undefined; + topics: GuardrailTopic[] | undefined; +} + +/** + * @public + * @enum + */ +export const GuardrailWordPolicyAction = { + BLOCKED: "BLOCKED", +} as const; + +/** + * @public + */ +export type GuardrailWordPolicyAction = (typeof GuardrailWordPolicyAction)[keyof typeof GuardrailWordPolicyAction]; +/** + *

A custom word configured in a guardrail.

+ * @public + */ +export interface GuardrailCustomWord { /** - *

The name of the tool that the model wants to use.

+ *

The match for the custom word.

* @public */ - name: string | undefined; + match: string | undefined; /** - *

The input to pass to the tool.

+ *

The action for the custom word.

* @public */ - input: __DocumentType | undefined; + action: GuardrailWordPolicyAction | undefined; } /** - *

A block of content for a message that you pass to, or receive from, a model with the Converse API (Converse and ConverseStream).

* @public + * @enum */ -export type ContentBlock = - | ContentBlock.DocumentMember - | ContentBlock.GuardContentMember - | ContentBlock.ImageMember - | ContentBlock.TextMember - | ContentBlock.ToolResultMember - | ContentBlock.ToolUseMember - | ContentBlock.$UnknownMember; - +export const GuardrailManagedWordType = { + PROFANITY: "PROFANITY", +} as const; + /** * @public */ -export namespace ContentBlock { +export type GuardrailManagedWordType = (typeof GuardrailManagedWordType)[keyof typeof GuardrailManagedWordType]; + +/** + *

A managed word configured in a guardrail.

+ * @public + */ +export interface GuardrailManagedWord { /** - *

Text to include in the message.

+ *

The match for the managed word.

* @public */ - export interface TextMember { - text: string; - image?: never; - document?: never; - toolUse?: never; - toolResult?: never; - guardContent?: never; - $unknown?: never; - } + match: string | undefined; /** - *

Image to include in the message.

- * - *

This field is only supported by Anthropic Claude 3 models.

- *
+ *

The type for the managed word.

* @public */ - export interface ImageMember { - text?: never; - image: ImageBlock; - document?: never; - toolUse?: never; - toolResult?: never; - guardContent?: never; - $unknown?: never; - } + type: GuardrailManagedWordType | undefined; /** - *

A document to include in the message.

+ *

The action for the managed word.

* @public */ - export interface DocumentMember { - text?: never; - image?: never; - document: DocumentBlock; - toolUse?: never; - toolResult?: never; - guardContent?: never; - $unknown?: never; - } + action: GuardrailWordPolicyAction | undefined; +} +/** + *

The word policy assessment.

+ * @public + */ +export interface GuardrailWordPolicyAssessment { /** - *

Information about a tool use request from a model.

+ *

Custom words in the assessment.

* @public */ - export interface ToolUseMember { - text?: never; - image?: never; - document?: never; - toolUse: ToolUseBlock; - toolResult?: never; - guardContent?: never; - $unknown?: never; - } + customWords: GuardrailCustomWord[] | undefined; /** - *

The result for a tool request that a model makes.

+ *

Managed word lists in the assessment.

* @public */ - export interface ToolResultMember { - text?: never; - image?: never; - document?: never; - toolUse?: never; - toolResult: ToolResultBlock; - guardContent?: never; - $unknown?: never; - } + managedWordLists: GuardrailManagedWord[] | undefined; +} +/** + *

A behavior assessment of the guardrail policies used in a call to the Converse API.

+ * @public + */ +export interface GuardrailAssessment { /** - *

Contains the content to assess with the guardrail. If you don't specify - * guardContent in a call to the Converse API, the guardrail (if passed in the - * Converse API) assesses the entire message.

- *

For more information, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide. - * - *

+ *

The topic policy.

* @public */ - export interface GuardContentMember { - text?: never; - image?: never; - document?: never; - toolUse?: never; - toolResult?: never; - guardContent: GuardrailConverseContentBlock; - $unknown?: never; - } + topicPolicy?: GuardrailTopicPolicyAssessment; /** + *

The content policy.

* @public */ - export interface $UnknownMember { - text?: never; - image?: never; - document?: never; - toolUse?: never; - toolResult?: never; - guardContent?: never; - $unknown: [string, any]; - } - - export interface Visitor { - text: (value: string) => T; - image: (value: ImageBlock) => T; - document: (value: DocumentBlock) => T; - toolUse: (value: ToolUseBlock) => T; - toolResult: (value: ToolResultBlock) => T; - guardContent: (value: GuardrailConverseContentBlock) => T; - _: (name: string, value: any) => T; - } - - export const visit = (value: ContentBlock, visitor: Visitor): T => { - if (value.text !== undefined) return visitor.text(value.text); - if (value.image !== undefined) return visitor.image(value.image); - if (value.document !== undefined) return visitor.document(value.document); - if (value.toolUse !== undefined) return visitor.toolUse(value.toolUse); - if (value.toolResult !== undefined) return visitor.toolResult(value.toolResult); - if (value.guardContent !== undefined) return visitor.guardContent(value.guardContent); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; -} - -/** - * @public - * @enum - */ -export const ConversationRole = { - ASSISTANT: "assistant", - USER: "user", -} as const; + contentPolicy?: GuardrailContentPolicyAssessment; -/** - * @public - */ -export type ConversationRole = (typeof ConversationRole)[keyof typeof ConversationRole]; + /** + *

The word policy.

+ * @public + */ + wordPolicy?: GuardrailWordPolicyAssessment; -/** - *

A message input, or returned from, a call to Converse or ConverseStream.

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

The role that the message plays in the message.

+ *

The sensitive information policy.

* @public */ - role: ConversationRole | undefined; + sensitiveInformationPolicy?: GuardrailSensitiveInformationPolicyAssessment; /** - *

The message content.

+ *

The contextual grounding policy used for the guardrail assessment.

* @public */ - content: ContentBlock[] | undefined; + contextualGroundingPolicy?: GuardrailContextualGroundingPolicyAssessment; } /** - *

A system content block.

+ *

The output content produced by the guardrail.

* @public */ -export type SystemContentBlock = - | SystemContentBlock.GuardContentMember - | SystemContentBlock.TextMember - | SystemContentBlock.$UnknownMember; +export interface GuardrailOutputContent { + /** + *

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

+ * @public + */ + text?: string; +} /** + *

The details on the use of the guardrail.

* @public */ -export namespace SystemContentBlock { +export interface GuardrailUsage { /** - *

A system prompt for the model.

+ *

The topic policy units processed by the guardrail.

* @public */ - export interface TextMember { - text: string; - guardContent?: never; - $unknown?: never; - } + topicPolicyUnits: number | undefined; /** - *

A content block to assess with the guardrail. Use with the Converse API (Converse and ConverseStream).

- *

For more information, see Use a guardrail with the Converse - * API in the Amazon Bedrock User Guide.

+ *

The content policy units processed by the guardrail.

* @public */ - export interface GuardContentMember { - text?: never; - guardContent: GuardrailConverseContentBlock; - $unknown?: never; - } + contentPolicyUnits: number | undefined; /** + *

The word policy units processed by the guardrail.

* @public */ - export interface $UnknownMember { - text?: never; - guardContent?: never; - $unknown: [string, any]; - } - - export interface Visitor { - text: (value: string) => T; - guardContent: (value: GuardrailConverseContentBlock) => T; - _: (name: string, value: any) => T; - } - - export const visit = (value: SystemContentBlock, visitor: Visitor): T => { - if (value.text !== undefined) return visitor.text(value.text); - if (value.guardContent !== undefined) return visitor.guardContent(value.guardContent); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; -} + wordPolicyUnits: number | undefined; -/** - *

The model must request at least one tool (no text is generated). For example, \{"any" : \{\}\}.

- * @public - */ -export interface AnyToolChoice {} + /** + *

The sensitive information policy units processed by the guardrail.

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

The Model automatically decides if a tool should be called or whether to generate text instead. - * For example, \{"auto" : \{\}\}.

- * @public - */ -export interface AutoToolChoice {} + /** + *

The sensitive information policy free units processed by the guardrail.

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

The model must request a specific tool. For example, \{"tool" : \{"name" : "Your tool name"\}\}.

- * - *

This field is only supported by Anthropic Claude 3 models.

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

The name of the tool that the model must request.

+ *

The contextual grounding policy units processed by the guardrail.

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

Determines which tools the model should request in a call to Converse or ConverseStream. - * ToolChoice is only supported by - * Anthropic Claude 3 models and by Mistral AI Mistral Large.

* @public */ -export type ToolChoice = - | ToolChoice.AnyMember - | ToolChoice.AutoMember - | ToolChoice.ToolMember - | ToolChoice.$UnknownMember; +export interface ApplyGuardrailResponse { + /** + *

The usage details in the response from the guardrail.

+ * @public + */ + usage: GuardrailUsage | undefined; -/** - * @public - */ -export namespace ToolChoice { /** - *

(Default). The Model automatically decides if a tool should be called or whether to generate text instead.

+ *

The action taken in the response from the guardrail.

* @public */ - export interface AutoMember { - auto: AutoToolChoice; - any?: never; - tool?: never; - $unknown?: never; - } + action: GuardrailAction | undefined; /** - *

The model must request at least one tool (no text is generated).

+ *

The output details in the response from the guardrail.

* @public */ - export interface AnyMember { - auto?: never; - any: AnyToolChoice; - tool?: never; - $unknown?: never; - } + outputs: GuardrailOutputContent[] | undefined; /** - *

The Model must request the specified tool. Only supported by Anthropic Claude 3 models.

+ *

The assessment details in the response from the guardrail.

* @public */ - export interface ToolMember { - auto?: never; - any?: never; - tool: SpecificToolChoice; - $unknown?: never; - } + assessments: GuardrailAssessment[] | undefined; +} +/** + *

An internal server error occurred. Retry your request.

+ * @public + */ +export class InternalServerException extends __BaseException { + readonly name: "InternalServerException" = "InternalServerException"; + readonly $fault: "server" = "server"; /** - * @public + * @internal */ - export interface $UnknownMember { - auto?: never; - any?: never; - tool?: never; - $unknown: [string, any]; + constructor(opts: __ExceptionOptionType) { + super({ + name: "InternalServerException", + $fault: "server", + ...opts, + }); + Object.setPrototypeOf(this, InternalServerException.prototype); } +} - export interface Visitor { - auto: (value: AutoToolChoice) => T; - any: (value: AnyToolChoice) => T; - tool: (value: SpecificToolChoice) => T; - _: (name: string, value: any) => T; +/** + *

The specified resource ARN was not found. Check the ARN and try your request again.

+ * @public + */ +export class ResourceNotFoundException extends __BaseException { + readonly name: "ResourceNotFoundException" = "ResourceNotFoundException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ResourceNotFoundException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ResourceNotFoundException.prototype); } +} - export const visit = (value: ToolChoice, visitor: Visitor): T => { - if (value.auto !== undefined) return visitor.auto(value.auto); - if (value.any !== undefined) return visitor.any(value.any); - if (value.tool !== undefined) return visitor.tool(value.tool); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; +/** + *

The number of requests exceeds the service quota. Resubmit your request later.

+ * @public + */ +export class ServiceQuotaExceededException extends __BaseException { + readonly name: "ServiceQuotaExceededException" = "ServiceQuotaExceededException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ServiceQuotaExceededException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype); + } } /** - *

The schema for the tool. The top level schema type must be object.

+ *

The number of requests exceeds the limit. Resubmit your request later.

* @public */ -export type ToolInputSchema = ToolInputSchema.JsonMember | ToolInputSchema.$UnknownMember; +export class ThrottlingException extends __BaseException { + readonly name: "ThrottlingException" = "ThrottlingException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ThrottlingException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ThrottlingException.prototype); + } +} /** + *

Input validation failed. Check your request parameters and retry the request.

* @public */ -export namespace ToolInputSchema { +export class ValidationException extends __BaseException { + readonly name: "ValidationException" = "ValidationException"; + readonly $fault: "client" = "client"; /** - *

The JSON schema for the tool. For more information, see JSON Schema Reference.

- * @public + * @internal */ - export interface JsonMember { - json: __DocumentType; - $unknown?: never; + constructor(opts: __ExceptionOptionType) { + super({ + name: "ValidationException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ValidationException.prototype); } +} + +/** + * @public + * @enum + */ +export const GuardrailTrace = { + DISABLED: "disabled", + ENABLED: "enabled", +} as const; + +/** + * @public + */ +export type GuardrailTrace = (typeof GuardrailTrace)[keyof typeof GuardrailTrace]; +/** + *

Configuration information for a guardrail that you use with the Converse operation.

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

The identifier for the guardrail.

* @public */ - export interface $UnknownMember { - json?: never; - $unknown: [string, any]; - } + guardrailIdentifier: string | undefined; - export interface Visitor { - json: (value: __DocumentType) => T; - _: (name: string, value: any) => T; - } + /** + *

The version of the guardrail.

+ * @public + */ + guardrailVersion: string | undefined; - export const visit = (value: ToolInputSchema, visitor: Visitor): T => { - if (value.json !== undefined) return visitor.json(value.json); - return visitor._(value.$unknown[0], value.$unknown[1]); - }; + /** + *

The trace behavior for the guardrail.

+ * @public + */ + trace?: GuardrailTrace; } /** - *

The specification for the tool.

+ *

Base inference parameters to pass to a model in a call to Converse or ConverseStream. For more information, + * see Inference parameters for foundation models.

+ *

If you need to pass additional parameters that the model + * supports, use the additionalModelRequestFields request field in the call to Converse + * or ConverseStream. + * For more information, see Model parameters.

* @public */ -export interface ToolSpecification { +export interface InferenceConfiguration { /** - *

The name for the tool.

+ *

The maximum number of tokens to allow in the generated response. The default value is + * the maximum allowed value for the model that you are using. For more information, see + * Inference parameters for foundation models.

* @public */ - name: string | undefined; + maxTokens?: number; /** - *

The description for the tool.

+ *

The likelihood of the model selecting higher-probability options while generating a + * response. A lower value makes the model more likely to choose higher-probability options, + * while a higher value makes the model more likely to choose lower-probability + * options.

+ *

The default value is the default value for the model that + * you are using. For more information, see Inference parameters for foundation + * models.

* @public */ - description?: string; + temperature?: number; /** - *

The input schema for the tool in JSON format.

+ *

The percentage of most-likely candidates that the model considers for the next token. For + * example, if you choose a value of 0.8 for topP, the model selects from the top 80% of the + * probability distribution of tokens that could be next in the sequence.

+ *

The default value is the default value for the model that you are using. For more information, see + * Inference parameters for foundation models.

* @public */ - inputSchema: ToolInputSchema | undefined; + topP?: number; + + /** + *

A list of stop sequences. A stop sequence is a sequence of characters that causes the + * model to stop generating the response.

+ * @public + */ + stopSequences?: string[]; } /** - *

Information about a tool that you can use with the Converse API.

* @public + * @enum */ -export type Tool = Tool.ToolSpecMember | Tool.$UnknownMember; +export const DocumentFormat = { + CSV: "csv", + DOC: "doc", + DOCX: "docx", + HTML: "html", + MD: "md", + PDF: "pdf", + TXT: "txt", + XLS: "xls", + XLSX: "xlsx", +} as const; /** * @public */ -export namespace Tool { +export type DocumentFormat = (typeof DocumentFormat)[keyof typeof DocumentFormat]; + +/** + *

Contains the content of a document.

+ * @public + */ +export type DocumentSource = DocumentSource.BytesMember | DocumentSource.$UnknownMember; + +/** + * @public + */ +export namespace DocumentSource { /** - *

The specfication for the tool.

+ *

The raw bytes for the document. If you use an Amazon Web Services SDK, you don't need to encode the bytes in base64.

* @public */ - export interface ToolSpecMember { - toolSpec: ToolSpecification; + export interface BytesMember { + bytes: Uint8Array; $unknown?: never; } @@ -900,156 +937,119 @@ export namespace Tool { * @public */ export interface $UnknownMember { - toolSpec?: never; + bytes?: never; $unknown: [string, any]; } export interface Visitor { - toolSpec: (value: ToolSpecification) => T; + bytes: (value: Uint8Array) => T; _: (name: string, value: any) => T; } - export const visit = (value: Tool, visitor: Visitor): T => { - if (value.toolSpec !== undefined) return visitor.toolSpec(value.toolSpec); + export const visit = (value: DocumentSource, visitor: Visitor): T => { + if (value.bytes !== undefined) return visitor.bytes(value.bytes); return visitor._(value.$unknown[0], value.$unknown[1]); }; } /** - *

Configuration information for the tools that you pass to a model.

- * - *

This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.

- *
+ *

A document to include in a message.

* @public */ -export interface ToolConfiguration { +export interface DocumentBlock { /** - *

An array of tools that you want to pass to a model.

+ *

The format of a document, or its extension.

* @public */ - tools: Tool[] | undefined; + format: DocumentFormat | undefined; /** - *

If supported by model, forces the model to request a tool.

- * @public - */ - toolChoice?: ToolChoice; -} - -/** - * @public - */ -export interface ConverseRequest { - /** - *

The identifier for the model that you want to call.

- *

The modelId to provide depends on the type of model that you use:

+ *

A name for the document. The name can only contain the following characters:

*
    *
  • - *

    If you use a base model, specify the model ID or its ARN. For a list of model IDs for base models, see Amazon Bedrock base model IDs (on-demand throughput) in the Amazon Bedrock User Guide.

    + *

    Alphanumeric characters

    *
  • *
  • - *

    If you use a provisioned model, specify the ARN of the Provisioned Throughput. For more information, see Run inference using a Provisioned Throughput in the Amazon Bedrock User Guide.

    + *

    Whitespace characters (no more than one in a row)

    *
  • *
  • - *

    If you use a custom model, first purchase Provisioned Throughput for it. Then specify the ARN of the resulting provisioned model. For more information, see Use a custom model in Amazon Bedrock in the Amazon Bedrock User Guide.

    + *

    Hyphens

    + *
  • + *
  • + *

    Parentheses

    + *
  • + *
  • + *

    Square brackets

    *
  • *
- * @public - */ - modelId: string | undefined; - - /** - *

The messages that you want to send to the model.

- * @public - */ - messages: Message[] | undefined; - - /** - *

A system prompt to pass to the model.

- * @public - */ - system?: SystemContentBlock[]; - - /** - *

Inference parameters to pass to the model. Converse supports a base - * set of inference parameters. If you need to pass additional parameters that the model - * supports, use the additionalModelRequestFields request field.

- * @public - */ - inferenceConfig?: InferenceConfiguration; - - /** - *

Configuration information for the tools that the model can use when generating a response.

* - *

This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.

+ *

This field is vulnerable to prompt injections, because the model might inadvertently interpret it as instructions. Therefore, we recommend that you specify a neutral name.

*
* @public */ - toolConfig?: ToolConfiguration; + name: string | undefined; /** - *

Configuration information for a guardrail that you want to use in the request.

+ *

Contains the content of the document.

* @public */ - guardrailConfig?: GuardrailConfiguration; + source: DocumentSource | undefined; +} - /** - *

Additional inference parameters that the model supports, beyond the - * base set of inference parameters that Converse supports in the inferenceConfig - * field. For more information, see Model parameters.

- * @public - */ - additionalModelRequestFields?: __DocumentType; +/** + * @public + * @enum + */ +export const GuardrailConverseContentQualifier = { + GROUNDING_SOURCE: "grounding_source", + GUARD_CONTENT: "guard_content", + QUERY: "query", +} as const; - /** - *

Additional model parameters field paths to return in the - * response. Converse returns the requested fields as a JSON Pointer object in the - * additionalModelResponseFields field. The following is example JSON for additionalModelResponseFieldPaths.

- *

- * [ - * "/stop_sequence" - * ] - *

- *

For information about the JSON Pointer syntax, see the - * Internet Engineering Task Force (IETF) documentation.

- *

- * Converse rejects an empty JSON Pointer or incorrectly structured - * JSON Pointer with a 400 error code. if the JSON Pointer is valid, but the requested - * field is not in the model response, it is ignored by Converse.

- * @public - */ - additionalModelResponseFieldPaths?: string[]; -} +/** + * @public + */ +export type GuardrailConverseContentQualifier = + (typeof GuardrailConverseContentQualifier)[keyof typeof GuardrailConverseContentQualifier]; /** - *

Metrics for a call to Converse.

+ *

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

* @public */ -export interface ConverseMetrics { +export interface GuardrailConverseTextBlock { /** - *

The latency of the call to Converse, in milliseconds. - *

+ *

The text that you want to guard.

* @public */ - latencyMs: number | undefined; + text: string | undefined; + + /** + *

The qualifier details for the guardrails contextual grounding filter.

+ * @public + */ + qualifiers?: GuardrailConverseContentQualifier[]; } /** - *

The output from a call to Converse.

+ *

+ *

A content block for selective guarding with the Converse or ConverseStream API operations. + *

* @public */ -export type ConverseOutput = ConverseOutput.MessageMember | ConverseOutput.$UnknownMember; +export type GuardrailConverseContentBlock = + | GuardrailConverseContentBlock.TextMember + | GuardrailConverseContentBlock.$UnknownMember; /** * @public */ -export namespace ConverseOutput { +export namespace GuardrailConverseContentBlock { /** - *

The message that the model generates.

+ *

The text to guard.

* @public */ - export interface MessageMember { - message: Message; + export interface TextMember { + text: GuardrailConverseTextBlock; $unknown?: never; } @@ -1057,17 +1057,17 @@ export namespace ConverseOutput { * @public */ export interface $UnknownMember { - message?: never; + text?: never; $unknown: [string, any]; } export interface Visitor { - message: (value: Message) => T; + text: (value: GuardrailConverseTextBlock) => T; _: (name: string, value: any) => T; } - export const visit = (value: ConverseOutput, visitor: Visitor): T => { - if (value.message !== undefined) return visitor.message(value.message); + export const visit = (value: GuardrailConverseContentBlock, visitor: Visitor): T => { + if (value.text !== undefined) return visitor.text(value.text); return visitor._(value.$unknown[0], value.$unknown[1]); }; } @@ -1076,413 +1076,858 @@ export namespace ConverseOutput { * @public * @enum */ -export const StopReason = { - CONTENT_FILTERED: "content_filtered", - END_TURN: "end_turn", - GUARDRAIL_INTERVENED: "guardrail_intervened", - MAX_TOKENS: "max_tokens", - STOP_SEQUENCE: "stop_sequence", - TOOL_USE: "tool_use", +export const ImageFormat = { + GIF: "gif", + JPEG: "jpeg", + PNG: "png", + WEBP: "webp", } as const; /** * @public */ -export type StopReason = (typeof StopReason)[keyof typeof StopReason]; +export type ImageFormat = (typeof ImageFormat)[keyof typeof ImageFormat]; /** + *

The source for an image.

* @public - * @enum */ -export const GuardrailContentPolicyAction = { - BLOCKED: "BLOCKED", -} as const; +export type ImageSource = ImageSource.BytesMember | ImageSource.$UnknownMember; /** * @public */ -export type GuardrailContentPolicyAction = - (typeof GuardrailContentPolicyAction)[keyof typeof GuardrailContentPolicyAction]; +export namespace ImageSource { + /** + *

The raw image bytes for the image. If you use an AWS SDK, you don't need to encode the image bytes in base64.

+ * @public + */ + export interface BytesMember { + bytes: Uint8Array; + $unknown?: never; + } -/** - * @public - * @enum - */ -export const GuardrailContentFilterConfidence = { - HIGH: "HIGH", - LOW: "LOW", - MEDIUM: "MEDIUM", - NONE: "NONE", -} as const; + /** + * @public + */ + export interface $UnknownMember { + bytes?: never; + $unknown: [string, any]; + } -/** - * @public - */ -export type GuardrailContentFilterConfidence = - (typeof GuardrailContentFilterConfidence)[keyof typeof GuardrailContentFilterConfidence]; + export interface Visitor { + bytes: (value: Uint8Array) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: ImageSource, visitor: Visitor): T => { + if (value.bytes !== undefined) return visitor.bytes(value.bytes); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} /** + *

Image content for a message.

* @public - * @enum */ -export const GuardrailContentFilterType = { - HATE: "HATE", - INSULTS: "INSULTS", - MISCONDUCT: "MISCONDUCT", - PROMPT_ATTACK: "PROMPT_ATTACK", - SEXUAL: "SEXUAL", - VIOLENCE: "VIOLENCE", -} as const; +export interface ImageBlock { + /** + *

The format of the image.

+ * @public + */ + format: ImageFormat | undefined; + + /** + *

The source for the image.

+ * @public + */ + source: ImageSource | undefined; +} /** + *

The tool result content block.

* @public */ -export type GuardrailContentFilterType = (typeof GuardrailContentFilterType)[keyof typeof GuardrailContentFilterType]; +export type ToolResultContentBlock = + | ToolResultContentBlock.DocumentMember + | ToolResultContentBlock.ImageMember + | ToolResultContentBlock.JsonMember + | ToolResultContentBlock.TextMember + | ToolResultContentBlock.$UnknownMember; /** - *

The content filter for a guardrail.

* @public */ -export interface GuardrailContentFilter { +export namespace ToolResultContentBlock { /** - *

The guardrail type.

+ *

A tool result that is JSON format data.

* @public */ - type: GuardrailContentFilterType | undefined; + export interface JsonMember { + json: __DocumentType; + text?: never; + image?: never; + document?: never; + $unknown?: never; + } /** - *

The guardrail confidence.

+ *

A tool result that is text.

* @public */ - confidence: GuardrailContentFilterConfidence | undefined; + export interface TextMember { + json?: never; + text: string; + image?: never; + document?: never; + $unknown?: never; + } /** - *

The guardrail action.

+ *

A tool result that is an image.

+ * + *

This field is only supported by Anthropic Claude 3 models.

+ *
* @public */ - action: GuardrailContentPolicyAction | undefined; -} + export interface ImageMember { + json?: never; + text?: never; + image: ImageBlock; + document?: never; + $unknown?: never; + } -/** - *

An assessment of a content policy for a guardrail.

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

The content policy filters.

+ *

A tool result that is a document.

* @public */ - filters: GuardrailContentFilter[] | undefined; -} - -/** + export interface DocumentMember { + json?: never; + text?: never; + image?: never; + document: DocumentBlock; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + json?: never; + text?: never; + image?: never; + document?: never; + $unknown: [string, any]; + } + + export interface Visitor { + json: (value: __DocumentType) => T; + text: (value: string) => T; + image: (value: ImageBlock) => T; + document: (value: DocumentBlock) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: ToolResultContentBlock, visitor: Visitor): T => { + if (value.json !== undefined) return visitor.json(value.json); + if (value.text !== undefined) return visitor.text(value.text); + if (value.image !== undefined) return visitor.image(value.image); + if (value.document !== undefined) return visitor.document(value.document); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} + +/** * @public * @enum */ -export const GuardrailSensitiveInformationPolicyAction = { - ANONYMIZED: "ANONYMIZED", - BLOCKED: "BLOCKED", +export const ToolResultStatus = { + ERROR: "error", + SUCCESS: "success", } as const; /** * @public */ -export type GuardrailSensitiveInformationPolicyAction = - (typeof GuardrailSensitiveInformationPolicyAction)[keyof typeof GuardrailSensitiveInformationPolicyAction]; +export type ToolResultStatus = (typeof ToolResultStatus)[keyof typeof ToolResultStatus]; + +/** + *

A tool result block that contains the results for a tool request that + * the model previously made.

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

The ID of the tool request that this is the result for.

+ * @public + */ + toolUseId: string | undefined; + + /** + *

The content for tool result content block.

+ * @public + */ + content: ToolResultContentBlock[] | undefined; + + /** + *

The status for the tool result content block.

+ * + *

This field is only supported Anthropic Claude 3 models.

+ *
+ * @public + */ + status?: ToolResultStatus; +} + +/** + *

A tool use content block. Contains information about a tool that the model + * is requesting be run., The model uses the result from the tool to generate a response.

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

The ID for the tool request.

+ * @public + */ + toolUseId: string | undefined; + + /** + *

The name of the tool that the model wants to use.

+ * @public + */ + name: string | undefined; + + /** + *

The input to pass to the tool.

+ * @public + */ + input: __DocumentType | undefined; +} + +/** + *

A block of content for a message that you pass to, or receive from, a model with the Converse or ConverseStream API operations.

+ * @public + */ +export type ContentBlock = + | ContentBlock.DocumentMember + | ContentBlock.GuardContentMember + | ContentBlock.ImageMember + | ContentBlock.TextMember + | ContentBlock.ToolResultMember + | ContentBlock.ToolUseMember + | ContentBlock.$UnknownMember; + +/** + * @public + */ +export namespace ContentBlock { + /** + *

Text to include in the message.

+ * @public + */ + export interface TextMember { + text: string; + image?: never; + document?: never; + toolUse?: never; + toolResult?: never; + guardContent?: never; + $unknown?: never; + } + + /** + *

Image to include in the message.

+ * + *

This field is only supported by Anthropic Claude 3 models.

+ *
+ * @public + */ + export interface ImageMember { + text?: never; + image: ImageBlock; + document?: never; + toolUse?: never; + toolResult?: never; + guardContent?: never; + $unknown?: never; + } + + /** + *

A document to include in the message.

+ * @public + */ + export interface DocumentMember { + text?: never; + image?: never; + document: DocumentBlock; + toolUse?: never; + toolResult?: never; + guardContent?: never; + $unknown?: never; + } + + /** + *

Information about a tool use request from a model.

+ * @public + */ + export interface ToolUseMember { + text?: never; + image?: never; + document?: never; + toolUse: ToolUseBlock; + toolResult?: never; + guardContent?: never; + $unknown?: never; + } + + /** + *

The result for a tool request that a model makes.

+ * @public + */ + export interface ToolResultMember { + text?: never; + image?: never; + document?: never; + toolUse?: never; + toolResult: ToolResultBlock; + guardContent?: never; + $unknown?: never; + } + + /** + *

Contains the content to assess with the guardrail. If you don't specify + * guardContent in a call to the Converse API, the guardrail (if passed in the + * Converse API) assesses the entire message.

+ *

For more information, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide. + * + *

+ * @public + */ + export interface GuardContentMember { + text?: never; + image?: never; + document?: never; + toolUse?: never; + toolResult?: never; + guardContent: GuardrailConverseContentBlock; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + text?: never; + image?: never; + document?: never; + toolUse?: never; + toolResult?: never; + guardContent?: never; + $unknown: [string, any]; + } + + export interface Visitor { + text: (value: string) => T; + image: (value: ImageBlock) => T; + document: (value: DocumentBlock) => T; + toolUse: (value: ToolUseBlock) => T; + toolResult: (value: ToolResultBlock) => T; + guardContent: (value: GuardrailConverseContentBlock) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: ContentBlock, visitor: Visitor): T => { + if (value.text !== undefined) return visitor.text(value.text); + if (value.image !== undefined) return visitor.image(value.image); + if (value.document !== undefined) return visitor.document(value.document); + if (value.toolUse !== undefined) return visitor.toolUse(value.toolUse); + if (value.toolResult !== undefined) return visitor.toolResult(value.toolResult); + if (value.guardContent !== undefined) return visitor.guardContent(value.guardContent); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} /** * @public * @enum */ -export const GuardrailPiiEntityType = { - ADDRESS: "ADDRESS", - AGE: "AGE", - AWS_ACCESS_KEY: "AWS_ACCESS_KEY", - AWS_SECRET_KEY: "AWS_SECRET_KEY", - CA_HEALTH_NUMBER: "CA_HEALTH_NUMBER", - CA_SOCIAL_INSURANCE_NUMBER: "CA_SOCIAL_INSURANCE_NUMBER", - CREDIT_DEBIT_CARD_CVV: "CREDIT_DEBIT_CARD_CVV", - CREDIT_DEBIT_CARD_EXPIRY: "CREDIT_DEBIT_CARD_EXPIRY", - CREDIT_DEBIT_CARD_NUMBER: "CREDIT_DEBIT_CARD_NUMBER", - DRIVER_ID: "DRIVER_ID", - EMAIL: "EMAIL", - INTERNATIONAL_BANK_ACCOUNT_NUMBER: "INTERNATIONAL_BANK_ACCOUNT_NUMBER", - IP_ADDRESS: "IP_ADDRESS", - LICENSE_PLATE: "LICENSE_PLATE", - MAC_ADDRESS: "MAC_ADDRESS", - NAME: "NAME", - PASSWORD: "PASSWORD", - PHONE: "PHONE", - PIN: "PIN", - SWIFT_CODE: "SWIFT_CODE", - UK_NATIONAL_HEALTH_SERVICE_NUMBER: "UK_NATIONAL_HEALTH_SERVICE_NUMBER", - UK_NATIONAL_INSURANCE_NUMBER: "UK_NATIONAL_INSURANCE_NUMBER", - UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER: "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER", - URL: "URL", - USERNAME: "USERNAME", - US_BANK_ACCOUNT_NUMBER: "US_BANK_ACCOUNT_NUMBER", - US_BANK_ROUTING_NUMBER: "US_BANK_ROUTING_NUMBER", - US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER: "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER", - US_PASSPORT_NUMBER: "US_PASSPORT_NUMBER", - US_SOCIAL_SECURITY_NUMBER: "US_SOCIAL_SECURITY_NUMBER", - VEHICLE_IDENTIFICATION_NUMBER: "VEHICLE_IDENTIFICATION_NUMBER", +export const ConversationRole = { + ASSISTANT: "assistant", + USER: "user", } as const; /** * @public */ -export type GuardrailPiiEntityType = (typeof GuardrailPiiEntityType)[keyof typeof GuardrailPiiEntityType]; +export type ConversationRole = (typeof ConversationRole)[keyof typeof ConversationRole]; + +/** + *

A message input, or returned from, a call to Converse or ConverseStream.

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

The role that the message plays in the message.

+ * @public + */ + role: ConversationRole | undefined; + + /** + *

The message content. Note the following restrictions:

+ *
    + *
  • + *

    You can include up to 20 images. Each image's size, height, and width must be no more than 3.75 MB, 8000 px, and 8000 px, respectively.

    + *
  • + *
  • + *

    You can include up to five documents. Each document's size must be no more than 4.5 MB.

    + *
  • + *
  • + *

    If you include a ContentBlock with a document field in the array, you must also include a ContentBlock with a text field.

    + *
  • + *
  • + *

    You can only include images and documents if the role is user.

    + *
  • + *
+ * @public + */ + content: ContentBlock[] | undefined; +} + +/** + *

A system content block.

+ * @public + */ +export type SystemContentBlock = + | SystemContentBlock.GuardContentMember + | SystemContentBlock.TextMember + | SystemContentBlock.$UnknownMember; /** - *

A Personally Identifiable Information (PII) entity configured in a guardrail.

* @public */ -export interface GuardrailPiiEntityFilter { +export namespace SystemContentBlock { /** - *

The PII entity filter match.

+ *

A system prompt for the model.

* @public */ - match: string | undefined; + export interface TextMember { + text: string; + guardContent?: never; + $unknown?: never; + } /** - *

The PII entity filter type.

+ *

A content block to assess with the guardrail. Use with the Converse or ConverseStream API operations.

+ *

For more information, see Use a guardrail with the Converse + * API in the Amazon Bedrock User Guide.

* @public */ - type: GuardrailPiiEntityType | undefined; + export interface GuardContentMember { + text?: never; + guardContent: GuardrailConverseContentBlock; + $unknown?: never; + } /** - *

The PII entity filter action.

* @public */ - action: GuardrailSensitiveInformationPolicyAction | undefined; + export interface $UnknownMember { + text?: never; + guardContent?: never; + $unknown: [string, any]; + } + + export interface Visitor { + text: (value: string) => T; + guardContent: (value: GuardrailConverseContentBlock) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: SystemContentBlock, visitor: Visitor): T => { + if (value.text !== undefined) return visitor.text(value.text); + if (value.guardContent !== undefined) return visitor.guardContent(value.guardContent); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; } /** - *

A Regex filter configured in a guardrail.

+ *

The model must request at least one tool (no text is generated). For example, \{"any" : \{\}\}.

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

The regex filter name.

- * @public - */ - name?: string; +export interface AnyToolChoice {} + +/** + *

The Model automatically decides if a tool should be called or whether to generate text instead. + * For example, \{"auto" : \{\}\}.

+ * @public + */ +export interface AutoToolChoice {} +/** + *

The model must request a specific tool. For example, \{"tool" : \{"name" : "Your tool name"\}\}.

+ * + *

This field is only supported by Anthropic Claude 3 models.

+ *
+ * @public + */ +export interface SpecificToolChoice { /** - *

The regesx filter match.

+ *

The name of the tool that the model must request.

* @public */ - match?: string; + name: string | undefined; +} + +/** + *

Determines which tools the model should request in a call to Converse or ConverseStream. + * ToolChoice is only supported by + * Anthropic Claude 3 models and by Mistral AI Mistral Large.

+ * @public + */ +export type ToolChoice = + | ToolChoice.AnyMember + | ToolChoice.AutoMember + | ToolChoice.ToolMember + | ToolChoice.$UnknownMember; +/** + * @public + */ +export namespace ToolChoice { /** - *

The regex query.

+ *

(Default). The Model automatically decides if a tool should be called or whether to generate text instead.

* @public */ - regex?: string; + export interface AutoMember { + auto: AutoToolChoice; + any?: never; + tool?: never; + $unknown?: never; + } /** - *

The region filter action.

+ *

The model must request at least one tool (no text is generated).

* @public */ - action: GuardrailSensitiveInformationPolicyAction | undefined; -} + export interface AnyMember { + auto?: never; + any: AnyToolChoice; + tool?: never; + $unknown?: never; + } -/** - *

The assessment for aPersonally Identifiable Information (PII) policy.

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

The PII entities in the assessment.

+ *

The Model must request the specified tool. Only supported by Anthropic Claude 3 models.

* @public */ - piiEntities: GuardrailPiiEntityFilter[] | undefined; + export interface ToolMember { + auto?: never; + any?: never; + tool: SpecificToolChoice; + $unknown?: never; + } /** - *

The regex queries in the assessment.

* @public */ - regexes: GuardrailRegexFilter[] | undefined; + export interface $UnknownMember { + auto?: never; + any?: never; + tool?: never; + $unknown: [string, any]; + } + + export interface Visitor { + auto: (value: AutoToolChoice) => T; + any: (value: AnyToolChoice) => T; + tool: (value: SpecificToolChoice) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: ToolChoice, visitor: Visitor): T => { + if (value.auto !== undefined) return visitor.auto(value.auto); + if (value.any !== undefined) return visitor.any(value.any); + if (value.tool !== undefined) return visitor.tool(value.tool); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; } /** + *

The schema for the tool. The top level schema type must be object.

* @public - * @enum */ -export const GuardrailTopicPolicyAction = { - BLOCKED: "BLOCKED", -} as const; +export type ToolInputSchema = ToolInputSchema.JsonMember | ToolInputSchema.$UnknownMember; /** * @public */ -export type GuardrailTopicPolicyAction = (typeof GuardrailTopicPolicyAction)[keyof typeof GuardrailTopicPolicyAction]; +export namespace ToolInputSchema { + /** + *

The JSON schema for the tool. For more information, see JSON Schema Reference.

+ * @public + */ + export interface JsonMember { + json: __DocumentType; + $unknown?: never; + } -/** - * @public - * @enum - */ -export const GuardrailTopicType = { - DENY: "DENY", -} as const; + /** + * @public + */ + export interface $UnknownMember { + json?: never; + $unknown: [string, any]; + } -/** - * @public - */ -export type GuardrailTopicType = (typeof GuardrailTopicType)[keyof typeof GuardrailTopicType]; + export interface Visitor { + json: (value: __DocumentType) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: ToolInputSchema, visitor: Visitor): T => { + if (value.json !== undefined) return visitor.json(value.json); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} /** - *

Information about a topic guardrail.

+ *

The specification for the tool.

* @public */ -export interface GuardrailTopic { +export interface ToolSpecification { /** - *

The name for the guardrail.

+ *

The name for the tool.

* @public */ name: string | undefined; /** - *

The type behavior that the guardrail should perform when the model detects the topic.

+ *

The description for the tool.

* @public */ - type: GuardrailTopicType | undefined; + description?: string; /** - *

The action the guardrail should take when it intervenes on a topic.

+ *

The input schema for the tool in JSON format.

* @public */ - action: GuardrailTopicPolicyAction | undefined; + inputSchema: ToolInputSchema | undefined; } /** - *

A behavior assessment of a topic policy.

+ *

Information about a tool that you can use with the Converse API. For more information, see Tool use (function calling) in the Amazon Bedrock User Guide.

* @public */ -export interface GuardrailTopicPolicyAssessment { +export type Tool = Tool.ToolSpecMember | Tool.$UnknownMember; + +/** + * @public + */ +export namespace Tool { /** - *

The topics in the assessment.

+ *

The specfication for the tool.

* @public */ - topics: GuardrailTopic[] | undefined; + export interface ToolSpecMember { + toolSpec: ToolSpecification; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + toolSpec?: never; + $unknown: [string, any]; + } + + export interface Visitor { + toolSpec: (value: ToolSpecification) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: Tool, visitor: Visitor): T => { + if (value.toolSpec !== undefined) return visitor.toolSpec(value.toolSpec); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; } /** + *

Configuration information for the tools that you pass to a model. For more information, see Tool use (function calling) in the Amazon Bedrock User Guide.

+ * + *

This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.

+ *
* @public - * @enum */ -export const GuardrailWordPolicyAction = { - BLOCKED: "BLOCKED", -} as const; +export interface ToolConfiguration { + /** + *

An array of tools that you want to pass to a model.

+ * @public + */ + tools: Tool[] | undefined; -/** - * @public - */ -export type GuardrailWordPolicyAction = (typeof GuardrailWordPolicyAction)[keyof typeof GuardrailWordPolicyAction]; + /** + *

If supported by model, forces the model to request a tool.

+ * @public + */ + toolChoice?: ToolChoice; +} /** - *

A custom word configured in a guardrail.

* @public */ -export interface GuardrailCustomWord { +export interface ConverseRequest { /** - *

The match for the custom word.

+ *

The identifier for the model that you want to call.

+ *

The modelId to provide depends on the type of model that you use:

+ * * @public */ - match: string | undefined; + modelId: string | undefined; /** - *

The action for the custom word.

+ *

The messages that you want to send to the model.

* @public */ - action: GuardrailWordPolicyAction | undefined; -} - -/** - * @public - * @enum - */ -export const GuardrailManagedWordType = { - PROFANITY: "PROFANITY", -} as const; + messages: Message[] | undefined; -/** - * @public - */ -export type GuardrailManagedWordType = (typeof GuardrailManagedWordType)[keyof typeof GuardrailManagedWordType]; + /** + *

A system prompt to pass to the model.

+ * @public + */ + system?: SystemContentBlock[]; -/** - *

A managed word configured in a guardrail.

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

The match for the managed word.

+ *

Inference parameters to pass to the model. Converse supports a base + * set of inference parameters. If you need to pass additional parameters that the model + * supports, use the additionalModelRequestFields request field.

* @public */ - match: string | undefined; + inferenceConfig?: InferenceConfiguration; /** - *

The type for the managed word.

+ *

Configuration information for the tools that the model can use when generating a response.

+ * + *

This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.

+ *
* @public */ - type: GuardrailManagedWordType | undefined; + toolConfig?: ToolConfiguration; /** - *

The action for the managed word.

+ *

Configuration information for a guardrail that you want to use in the request.

* @public */ - action: GuardrailWordPolicyAction | undefined; -} + guardrailConfig?: GuardrailConfiguration; -/** - *

The word policy assessment.

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

Custom words in the assessment.

+ *

Additional inference parameters that the model supports, beyond the + * base set of inference parameters that Converse supports in the inferenceConfig + * field. For more information, see Model parameters.

* @public */ - customWords: GuardrailCustomWord[] | undefined; + additionalModelRequestFields?: __DocumentType; /** - *

Managed word lists in the assessment.

+ *

Additional model parameters field paths to return in the + * response. Converse returns the requested fields as a JSON Pointer object in the + * additionalModelResponseFields field. The following is example JSON for additionalModelResponseFieldPaths.

+ *

+ * [ + * "/stop_sequence" + * ] + *

+ *

For information about the JSON Pointer syntax, see the + * Internet Engineering Task Force (IETF) documentation.

+ *

+ * Converse rejects an empty JSON Pointer or incorrectly structured + * JSON Pointer with a 400 error code. if the JSON Pointer is valid, but the requested + * field is not in the model response, it is ignored by Converse.

* @public */ - managedWordLists: GuardrailManagedWord[] | undefined; + additionalModelResponseFieldPaths?: string[]; } /** - *

A behavior assessment of the guardrail policies used in a call to the Converse API.

+ *

Metrics for a call to Converse.

* @public */ -export interface GuardrailAssessment { +export interface ConverseMetrics { /** - *

The topic policy.

+ *

The latency of the call to Converse, in milliseconds. + *

* @public */ - topicPolicy?: GuardrailTopicPolicyAssessment; + latencyMs: number | undefined; +} - /** - *

The content policy.

- * @public - */ - contentPolicy?: GuardrailContentPolicyAssessment; +/** + *

The output from a call to Converse.

+ * @public + */ +export type ConverseOutput = ConverseOutput.MessageMember | ConverseOutput.$UnknownMember; +/** + * @public + */ +export namespace ConverseOutput { /** - *

The word policy.

+ *

The message that the model generates.

* @public */ - wordPolicy?: GuardrailWordPolicyAssessment; + export interface MessageMember { + message: Message; + $unknown?: never; + } /** - *

The sensitive information policy.

* @public */ - sensitiveInformationPolicy?: GuardrailSensitiveInformationPolicyAssessment; + export interface $UnknownMember { + message?: never; + $unknown: [string, any]; + } + + export interface Visitor { + message: (value: Message) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: ConverseOutput, visitor: Visitor): T => { + if (value.message !== undefined) return visitor.message(value.message); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; } +/** + * @public + * @enum + */ +export const StopReason = { + CONTENT_FILTERED: "content_filtered", + END_TURN: "end_turn", + GUARDRAIL_INTERVENED: "guardrail_intervened", + MAX_TOKENS: "max_tokens", + STOP_SEQUENCE: "stop_sequence", + TOOL_USE: "tool_use", +} as const; + +/** + * @public + */ +export type StopReason = (typeof StopReason)[keyof typeof StopReason]; + /** *

A Top level guardrail trace object. For more information, see ConverseTrace.

* @public @@ -1508,7 +1953,7 @@ export interface GuardrailTraceAssessment { } /** - *

The trace object in a response from Converse. Currently, you can only trace guardrails.

+ *

The trace object in a response from Converse. Currently, you can only trace guardrails.

* @public */ export interface ConverseTrace { @@ -1585,26 +2030,6 @@ export interface ConverseResponse { trace?: ConverseTrace; } -/** - *

An internal server error occurred. Retry your request.

- * @public - */ -export class InternalServerException extends __BaseException { - readonly name: "InternalServerException" = "InternalServerException"; - readonly $fault: "server" = "server"; - /** - * @internal - */ - constructor(opts: __ExceptionOptionType) { - super({ - name: "InternalServerException", - $fault: "server", - ...opts, - }); - Object.setPrototypeOf(this, InternalServerException.prototype); - } -} - /** *

The request failed due to an error while processing the model.

* @public @@ -1679,66 +2104,6 @@ export class ModelTimeoutException extends __BaseException { } } -/** - *

The specified resource ARN was not found. Check the ARN and try your request again.

- * @public - */ -export class ResourceNotFoundException extends __BaseException { - readonly name: "ResourceNotFoundException" = "ResourceNotFoundException"; - readonly $fault: "client" = "client"; - /** - * @internal - */ - constructor(opts: __ExceptionOptionType) { - super({ - name: "ResourceNotFoundException", - $fault: "client", - ...opts, - }); - Object.setPrototypeOf(this, ResourceNotFoundException.prototype); - } -} - -/** - *

The number of requests exceeds the limit. Resubmit your request later.

- * @public - */ -export class ThrottlingException extends __BaseException { - readonly name: "ThrottlingException" = "ThrottlingException"; - readonly $fault: "client" = "client"; - /** - * @internal - */ - constructor(opts: __ExceptionOptionType) { - super({ - name: "ThrottlingException", - $fault: "client", - ...opts, - }); - Object.setPrototypeOf(this, ThrottlingException.prototype); - } -} - -/** - *

Input validation failed. Check your request parameters and retry the request.

- * @public - */ -export class ValidationException extends __BaseException { - readonly name: "ValidationException" = "ValidationException"; - readonly $fault: "client" = "client"; - /** - * @internal - */ - constructor(opts: __ExceptionOptionType) { - super({ - name: "ValidationException", - $fault: "client", - ...opts, - }); - Object.setPrototypeOf(this, ValidationException.prototype); - } -} - /** * @public * @enum @@ -2086,7 +2451,7 @@ export interface ConverseStreamMetrics { } /** - *

The trace object in a response from ConverseStream. Currently, you can only trace guardrails.

+ *

The trace object in a response from ConverseStream. Currently, you can only trace guardrails.

* @public */ export interface ConverseStreamTrace { @@ -2115,7 +2480,7 @@ export interface ConverseStreamMetadataEvent { metrics: ConverseStreamMetrics | undefined; /** - *

The trace object in the response from ConverseStream that contains information about the guardrail behavior.

+ *

The trace object in the response from ConverseStream that contains information about the guardrail behavior.

* @public */ trace?: ConverseStreamTrace; @@ -2519,26 +2884,6 @@ export interface InvokeModelResponse { contentType: string | undefined; } -/** - *

The number of requests exceeds the service quota. Resubmit your request later.

- * @public - */ -export class ServiceQuotaExceededException extends __BaseException { - readonly name: "ServiceQuotaExceededException" = "ServiceQuotaExceededException"; - readonly $fault: "client" = "client"; - /** - * @internal - */ - constructor(opts: __ExceptionOptionType) { - super({ - name: "ServiceQuotaExceededException", - $fault: "client", - ...opts, - }); - Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype); - } -} - /** * @public */ diff --git a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts index ee3b3fbc1cfb..ea4109208633 100644 --- a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts @@ -15,6 +15,7 @@ import { expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, + limitedParseDouble as __limitedParseDouble, map, resolvedPath as __resolvedPath, serializeFloat as __serializeFloat, @@ -29,6 +30,7 @@ import { SerdeContext as __SerdeContext, } from "@smithy/types"; +import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "../commands/ApplyGuardrailCommand"; import { ConverseCommandInput, ConverseCommandOutput } from "../commands/ConverseCommand"; import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "../commands/ConverseStreamCommand"; import { InvokeModelCommandInput, InvokeModelCommandOutput } from "../commands/InvokeModelCommand"; @@ -48,12 +50,22 @@ import { ConverseOutput, ConverseStreamMetadataEvent, ConverseStreamOutput, + ConverseStreamTrace, + ConverseTrace, DocumentBlock, DocumentSource, + GuardrailAssessment, GuardrailConfiguration, + GuardrailContentBlock, + GuardrailContentQualifier, + GuardrailContextualGroundingFilter, + GuardrailContextualGroundingPolicyAssessment, GuardrailConverseContentBlock, + GuardrailConverseContentQualifier, GuardrailConverseTextBlock, GuardrailStreamConfiguration, + GuardrailTextBlock, + GuardrailTraceAssessment, ImageBlock, ImageSource, InferenceConfiguration, @@ -83,6 +95,31 @@ import { ValidationException, } from "../models/models_0"; +/** + * serializeAws_restJson1ApplyGuardrailCommand + */ +export const se_ApplyGuardrailCommand = async ( + input: ApplyGuardrailCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const b = rb(input, context); + const headers: any = { + "content-type": "application/json", + }; + b.bp("/guardrail/{guardrailIdentifier}/version/{guardrailVersion}/apply"); + b.p("guardrailIdentifier", () => input.guardrailIdentifier!, "{guardrailIdentifier}", false); + b.p("guardrailVersion", () => input.guardrailVersion!, "{guardrailVersion}", false); + let body: any; + body = JSON.stringify( + take(input, { + content: (_) => _json(_), + source: [], + }) + ); + b.m("POST").h(headers).b(body); + return b.build(); +}; + /** * serializeAws_restJson1ConverseCommand */ @@ -191,6 +228,30 @@ export const se_InvokeModelWithResponseStreamCommand = async ( return b.build(); }; +/** + * deserializeAws_restJson1ApplyGuardrailCommand + */ +export const de_ApplyGuardrailCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return de_CommandError(output, context); + } + const contents: any = map({ + $metadata: deserializeMetadata(output), + }); + const data: Record = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body"); + const doc = take(data, { + action: __expectString, + assessments: (_) => de_GuardrailAssessmentList(_, context), + outputs: _json, + usage: _json, + }); + Object.assign(contents, doc); + return contents; +}; + /** * deserializeAws_restJson1ConverseCommand */ @@ -210,7 +271,7 @@ export const de_ConverseCommand = async ( metrics: _json, output: (_) => de_ConverseOutput(__expectUnion(_), context), stopReason: __expectString, - trace: _json, + trace: (_) => de_ConverseTrace(_, context), usage: _json, }); Object.assign(contents, doc); @@ -289,27 +350,27 @@ const de_CommandError = async (output: __HttpResponse, context: __SerdeContext): case "InternalServerException": case "com.amazonaws.bedrockruntime#InternalServerException": throw await de_InternalServerExceptionRes(parsedOutput, context); - case "ModelErrorException": - case "com.amazonaws.bedrockruntime#ModelErrorException": - throw await de_ModelErrorExceptionRes(parsedOutput, context); - case "ModelNotReadyException": - case "com.amazonaws.bedrockruntime#ModelNotReadyException": - throw await de_ModelNotReadyExceptionRes(parsedOutput, context); - case "ModelTimeoutException": - case "com.amazonaws.bedrockruntime#ModelTimeoutException": - throw await de_ModelTimeoutExceptionRes(parsedOutput, context); case "ResourceNotFoundException": case "com.amazonaws.bedrockruntime#ResourceNotFoundException": throw await de_ResourceNotFoundExceptionRes(parsedOutput, context); + case "ServiceQuotaExceededException": + case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException": + throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context); case "ThrottlingException": case "com.amazonaws.bedrockruntime#ThrottlingException": throw await de_ThrottlingExceptionRes(parsedOutput, context); case "ValidationException": case "com.amazonaws.bedrockruntime#ValidationException": throw await de_ValidationExceptionRes(parsedOutput, context); - case "ServiceQuotaExceededException": - case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException": - throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context); + case "ModelErrorException": + case "com.amazonaws.bedrockruntime#ModelErrorException": + throw await de_ModelErrorExceptionRes(parsedOutput, context); + case "ModelNotReadyException": + case "com.amazonaws.bedrockruntime#ModelNotReadyException": + throw await de_ModelNotReadyExceptionRes(parsedOutput, context); + case "ModelTimeoutException": + case "com.amazonaws.bedrockruntime#ModelTimeoutException": + throw await de_ModelTimeoutExceptionRes(parsedOutput, context); case "ModelStreamErrorException": case "com.amazonaws.bedrockruntime#ModelStreamErrorException": throw await de_ModelStreamErrorExceptionRes(parsedOutput, context); @@ -657,7 +718,7 @@ const de_ConverseStreamMetadataEvent_event = async ( ): Promise => { const contents: ConverseStreamMetadataEvent = {} as any; const data: any = await parseBody(output.body, context); - Object.assign(contents, _json(data)); + Object.assign(contents, de_ConverseStreamMetadataEvent(data, context)); return contents; }; const de_InternalServerException_event = async ( @@ -774,12 +835,22 @@ const se_DocumentSource = (input: DocumentSource, context: __SerdeContext): any // se_GuardrailConfiguration omitted. +// se_GuardrailContentBlock omitted. + +// se_GuardrailContentBlockList omitted. + +// se_GuardrailContentQualifierList omitted. + // se_GuardrailConverseContentBlock omitted. +// se_GuardrailConverseContentQualifierList omitted. + // se_GuardrailConverseTextBlock omitted. // se_GuardrailStreamConfiguration omitted. +// se_GuardrailTextBlock omitted. + /** * serializeAws_restJson1ImageBlock */ @@ -1019,13 +1090,36 @@ const de_ConverseOutput = (output: any, context: __SerdeContext): ConverseOutput return { $unknown: Object.entries(output)[0] }; }; -// de_ConverseStreamMetadataEvent omitted. +/** + * deserializeAws_restJson1ConverseStreamMetadataEvent + */ +const de_ConverseStreamMetadataEvent = (output: any, context: __SerdeContext): ConverseStreamMetadataEvent => { + return take(output, { + metrics: _json, + trace: (_: any) => de_ConverseStreamTrace(_, context), + usage: _json, + }) as any; +}; // de_ConverseStreamMetrics omitted. -// de_ConverseStreamTrace omitted. +/** + * deserializeAws_restJson1ConverseStreamTrace + */ +const de_ConverseStreamTrace = (output: any, context: __SerdeContext): ConverseStreamTrace => { + return take(output, { + guardrail: (_: any) => de_GuardrailTraceAssessment(_, context), + }) as any; +}; -// de_ConverseTrace omitted. +/** + * deserializeAws_restJson1ConverseTrace + */ +const de_ConverseTrace = (output: any, context: __SerdeContext): ConverseTrace => { + return take(output, { + guardrail: (_: any) => de_GuardrailTraceAssessment(_, context), + }) as any; +}; /** * deserializeAws_restJson1DocumentBlock @@ -1050,13 +1144,56 @@ const de_DocumentSource = (output: any, context: __SerdeContext): DocumentSource return { $unknown: Object.entries(output)[0] }; }; -// de_GuardrailAssessment omitted. +/** + * deserializeAws_restJson1GuardrailAssessment + */ +const de_GuardrailAssessment = (output: any, context: __SerdeContext): GuardrailAssessment => { + return take(output, { + contentPolicy: _json, + contextualGroundingPolicy: (_: any) => de_GuardrailContextualGroundingPolicyAssessment(_, context), + sensitiveInformationPolicy: _json, + topicPolicy: _json, + wordPolicy: _json, + }) as any; +}; -// de_GuardrailAssessmentList omitted. +/** + * deserializeAws_restJson1GuardrailAssessmentList + */ +const de_GuardrailAssessmentList = (output: any, context: __SerdeContext): GuardrailAssessment[] => { + const retVal = (output || []) + .filter((e: any) => e != null) + .map((entry: any) => { + return de_GuardrailAssessment(entry, context); + }); + return retVal; +}; -// de_GuardrailAssessmentListMap omitted. +/** + * deserializeAws_restJson1GuardrailAssessmentListMap + */ +const de_GuardrailAssessmentListMap = (output: any, context: __SerdeContext): Record => { + return Object.entries(output).reduce((acc: Record, [key, value]: [string, any]) => { + if (value === null) { + return acc; + } + acc[key as string] = de_GuardrailAssessmentList(value, context); + return acc; + }, {} as Record); +}; -// de_GuardrailAssessmentMap omitted. +/** + * deserializeAws_restJson1GuardrailAssessmentMap + */ +const de_GuardrailAssessmentMap = (output: any, context: __SerdeContext): Record => { + return Object.entries(output).reduce((acc: Record, [key, value]: [string, any]) => { + if (value === null) { + return acc; + } + acc[key as string] = de_GuardrailAssessment(value, context); + return acc; + }, {} as Record); +}; // de_GuardrailContentFilter omitted. @@ -1064,8 +1201,52 @@ const de_DocumentSource = (output: any, context: __SerdeContext): DocumentSource // de_GuardrailContentPolicyAssessment omitted. +/** + * deserializeAws_restJson1GuardrailContextualGroundingFilter + */ +const de_GuardrailContextualGroundingFilter = ( + output: any, + context: __SerdeContext +): GuardrailContextualGroundingFilter => { + return take(output, { + action: __expectString, + score: __limitedParseDouble, + threshold: __limitedParseDouble, + type: __expectString, + }) as any; +}; + +/** + * deserializeAws_restJson1GuardrailContextualGroundingFilters + */ +const de_GuardrailContextualGroundingFilters = ( + output: any, + context: __SerdeContext +): GuardrailContextualGroundingFilter[] => { + const retVal = (output || []) + .filter((e: any) => e != null) + .map((entry: any) => { + return de_GuardrailContextualGroundingFilter(entry, context); + }); + return retVal; +}; + +/** + * deserializeAws_restJson1GuardrailContextualGroundingPolicyAssessment + */ +const de_GuardrailContextualGroundingPolicyAssessment = ( + output: any, + context: __SerdeContext +): GuardrailContextualGroundingPolicyAssessment => { + return take(output, { + filters: (_: any) => de_GuardrailContextualGroundingFilters(_, context), + }) as any; +}; + // de_GuardrailConverseContentBlock omitted. +// de_GuardrailConverseContentQualifierList omitted. + // de_GuardrailConverseTextBlock omitted. // de_GuardrailCustomWord omitted. @@ -1076,6 +1257,10 @@ const de_DocumentSource = (output: any, context: __SerdeContext): DocumentSource // de_GuardrailManagedWordList omitted. +// de_GuardrailOutputContent omitted. + +// de_GuardrailOutputContentList omitted. + // de_GuardrailPiiEntityFilter omitted. // de_GuardrailPiiEntityFilterList omitted. @@ -1092,7 +1277,18 @@ const de_DocumentSource = (output: any, context: __SerdeContext): DocumentSource // de_GuardrailTopicPolicyAssessment omitted. -// de_GuardrailTraceAssessment omitted. +/** + * deserializeAws_restJson1GuardrailTraceAssessment + */ +const de_GuardrailTraceAssessment = (output: any, context: __SerdeContext): GuardrailTraceAssessment => { + return take(output, { + inputAssessment: (_: any) => de_GuardrailAssessmentMap(_, context), + modelOutput: _json, + outputAssessments: (_: any) => de_GuardrailAssessmentListMap(_, context), + }) as any; +}; + +// de_GuardrailUsage omitted. // de_GuardrailWordPolicyAssessment omitted. diff --git a/codegen/sdk-codegen/aws-models/bedrock-runtime.json b/codegen/sdk-codegen/aws-models/bedrock-runtime.json index 39c202c5201b..63d7f38d9697 100644 --- a/codegen/sdk-codegen/aws-models/bedrock-runtime.json +++ b/codegen/sdk-codegen/aws-models/bedrock-runtime.json @@ -35,6 +35,9 @@ "type": "service", "version": "2023-09-30", "resources": [ + { + "target": "com.amazonaws.bedrockruntime#GuardrailResource" + }, { "target": "com.amazonaws.bedrockruntime#InferenceResource" } @@ -724,6 +727,117 @@ "smithy.api#documentation": "

The model must request at least one tool (no text is generated). For example, {\"any\" : {}}.

" } }, + "com.amazonaws.bedrockruntime#ApplyGuardrail": { + "type": "operation", + "input": { + "target": "com.amazonaws.bedrockruntime#ApplyGuardrailRequest" + }, + "output": { + "target": "com.amazonaws.bedrockruntime#ApplyGuardrailResponse" + }, + "errors": [ + { + "target": "com.amazonaws.bedrockruntime#AccessDeniedException" + }, + { + "target": "com.amazonaws.bedrockruntime#InternalServerException" + }, + { + "target": "com.amazonaws.bedrockruntime#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.bedrockruntime#ServiceQuotaExceededException" + }, + { + "target": "com.amazonaws.bedrockruntime#ThrottlingException" + }, + { + "target": "com.amazonaws.bedrockruntime#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "

The action to apply a guardrail.

", + "smithy.api#http": { + "code": 200, + "method": "POST", + "uri": "/guardrail/{guardrailIdentifier}/version/{guardrailVersion}/apply" + } + } + }, + "com.amazonaws.bedrockruntime#ApplyGuardrailRequest": { + "type": "structure", + "members": { + "guardrailIdentifier": { + "target": "com.amazonaws.bedrockruntime#GuardrailIdentifier", + "traits": { + "smithy.api#documentation": "

The guardrail identifier used in the request to apply the guardrail.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "guardrailVersion": { + "target": "com.amazonaws.bedrockruntime#GuardrailVersion", + "traits": { + "smithy.api#documentation": "

The guardrail version used in the request to apply the guardrail.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "source": { + "target": "com.amazonaws.bedrockruntime#GuardrailContentSource", + "traits": { + "smithy.api#documentation": "

The source of data used in the request to apply the guardrail.

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

The content details used in the request to apply the guardrail.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.bedrockruntime#ApplyGuardrailResponse": { + "type": "structure", + "members": { + "usage": { + "target": "com.amazonaws.bedrockruntime#GuardrailUsage", + "traits": { + "smithy.api#documentation": "

The usage details in the response from the guardrail.

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

The action taken in the response from the guardrail.

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

The output details in the response from the guardrail.

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

The assessment details in the response from the guardrail.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, "com.amazonaws.bedrockruntime#AutoToolChoice": { "type": "structure", "members": {}, @@ -764,7 +878,7 @@ "toolUse": { "target": "com.amazonaws.bedrockruntime#ToolUseBlock", "traits": { - "smithy.api#documentation": "

Information about a tool use request from a model.

" + "smithy.api#documentation": "

Information about a tool use request from a model.

" } }, "toolResult": { @@ -781,7 +895,7 @@ } }, "traits": { - "smithy.api#documentation": "

A block of content for a message that you pass to, or receive from, a model with the Converse API (Converse and ConverseStream).

" + "smithy.api#documentation": "

A block of content for a message that you pass to, or receive from, a model with the Converse or ConverseStream API operations.

" } }, "com.amazonaws.bedrockruntime#ContentBlockDelta": { @@ -1155,7 +1269,7 @@ "trace": { "target": "com.amazonaws.bedrockruntime#ConverseStreamTrace", "traits": { - "smithy.api#documentation": "

The trace object in the response from ConverseStream that contains information about the guardrail behavior.

" + "smithy.api#documentation": "

The trace object in the response from ConverseStream that contains information about the guardrail behavior.

" } } }, @@ -1335,7 +1449,7 @@ } }, "traits": { - "smithy.api#documentation": "

The trace object in a response from ConverseStream. Currently, you can only trace guardrails.

" + "smithy.api#documentation": "

The trace object in a response from ConverseStream. Currently, you can only trace guardrails.

" } }, "com.amazonaws.bedrockruntime#ConverseTrace": { @@ -1349,7 +1463,7 @@ } }, "traits": { - "smithy.api#documentation": "

The trace object in a response from Converse. Currently, you can only trace guardrails.

" + "smithy.api#documentation": "

The trace object in a response from Converse. Currently, you can only trace guardrails.

" } }, "com.amazonaws.bedrockruntime#DocumentBlock": { @@ -1365,7 +1479,7 @@ "name": { "target": "smithy.api#String", "traits": { - "smithy.api#documentation": "

A name for the document.

", + "smithy.api#documentation": "

A name for the document. The name can only contain the following characters:

\n
    \n
  • \n

    Alphanumeric characters

    \n
  • \n
  • \n

    Whitespace characters (no more than one in a row)

    \n
  • \n
  • \n

    Hyphens

    \n
  • \n
  • \n

    Parentheses

    \n
  • \n
  • \n

    Square brackets

    \n
  • \n
\n \n

This field is vulnerable to prompt injections, because the model might inadvertently interpret it as instructions. Therefore, we recommend that you specify a neutral name.

\n
", "smithy.api#length": { "min": 1, "max": 200 @@ -1382,7 +1496,7 @@ } }, "traits": { - "smithy.api#documentation": "

A document to include in a message when sending a Converse or ConverseStream request. You can include up to 5 documents in a request. The maximum document size is 50 MB.

" + "smithy.api#documentation": "

A document to include in a message.

" } }, "com.amazonaws.bedrockruntime#DocumentFormat": { @@ -1450,7 +1564,7 @@ "bytes": { "target": "smithy.api#Blob", "traits": { - "smithy.api#documentation": "

A base64-encoded string of a UTF-8 encoded file, that is the document to include in the message.

", + "smithy.api#documentation": "

The raw bytes for the document. If you use an Amazon Web Services SDK, you don't need to encode the bytes in base64.

", "smithy.api#length": { "min": 1 } @@ -1458,7 +1572,24 @@ } }, "traits": { - "smithy.api#documentation": "

Contains the content of the document included in a message when sending a Converse or ConverseStream request or in the response.

" + "smithy.api#documentation": "

Contains the content of a document.

" + } + }, + "com.amazonaws.bedrockruntime#GuardrailAction": { + "type": "enum", + "members": { + "NONE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "NONE" + } + }, + "GUARDRAIL_INTERVENED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "GUARDRAIL_INTERVENED" + } + } } }, "com.amazonaws.bedrockruntime#GuardrailAssessment": { @@ -1487,6 +1618,12 @@ "traits": { "smithy.api#documentation": "

The sensitive information policy.

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

The contextual grounding policy used for the guardrail assessment.

" + } } }, "traits": { @@ -1543,7 +1680,27 @@ } }, "traits": { - "smithy.api#documentation": "

Configuration information for a guardrail that you use with the Converse action.

" + "smithy.api#documentation": "

Configuration information for a guardrail that you use with the Converse operation.

" + } + }, + "com.amazonaws.bedrockruntime#GuardrailContentBlock": { + "type": "union", + "members": { + "text": { + "target": "com.amazonaws.bedrockruntime#GuardrailTextBlock", + "traits": { + "smithy.api#documentation": "

Text within content block to be evaluated by the guardrail.

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

The content block to be evaluated by the guardrail.

" + } + }, + "com.amazonaws.bedrockruntime#GuardrailContentBlockList": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockruntime#GuardrailContentBlock" } }, "com.amazonaws.bedrockruntime#GuardrailContentFilter": { @@ -1677,6 +1834,156 @@ "smithy.api#documentation": "

An assessment of a content policy for a guardrail.

" } }, + "com.amazonaws.bedrockruntime#GuardrailContentPolicyUnitsProcessed": { + "type": "integer" + }, + "com.amazonaws.bedrockruntime#GuardrailContentQualifier": { + "type": "enum", + "members": { + "GROUNDING_SOURCE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "grounding_source" + } + }, + "QUERY": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "query" + } + }, + "GUARD_CONTENT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "guard_content" + } + } + } + }, + "com.amazonaws.bedrockruntime#GuardrailContentQualifierList": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockruntime#GuardrailContentQualifier" + } + }, + "com.amazonaws.bedrockruntime#GuardrailContentSource": { + "type": "enum", + "members": { + "INPUT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "INPUT" + } + }, + "OUTPUT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "OUTPUT" + } + } + } + }, + "com.amazonaws.bedrockruntime#GuardrailContextualGroundingFilter": { + "type": "structure", + "members": { + "type": { + "target": "com.amazonaws.bedrockruntime#GuardrailContextualGroundingFilterType", + "traits": { + "smithy.api#documentation": "

The contextual grounding filter type.

", + "smithy.api#required": {} + } + }, + "threshold": { + "target": "smithy.api#Double", + "traits": { + "smithy.api#documentation": "

The threshold used by contextual grounding filter to determine whether the content is grounded or not.

", + "smithy.api#range": { + "min": 0, + "max": 1 + }, + "smithy.api#required": {} + } + }, + "score": { + "target": "smithy.api#Double", + "traits": { + "smithy.api#documentation": "

The score generated by contextual grounding filter.

", + "smithy.api#range": { + "min": 0, + "max": 1 + }, + "smithy.api#required": {} + } + }, + "action": { + "target": "com.amazonaws.bedrockruntime#GuardrailContextualGroundingPolicyAction", + "traits": { + "smithy.api#documentation": "

The action performed by the guardrails contextual grounding filter.

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

The details for the guardrails contextual grounding filter.

" + } + }, + "com.amazonaws.bedrockruntime#GuardrailContextualGroundingFilterType": { + "type": "enum", + "members": { + "GROUNDING": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "GROUNDING" + } + }, + "RELEVANCE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "RELEVANCE" + } + } + } + }, + "com.amazonaws.bedrockruntime#GuardrailContextualGroundingFilters": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockruntime#GuardrailContextualGroundingFilter" + } + }, + "com.amazonaws.bedrockruntime#GuardrailContextualGroundingPolicyAction": { + "type": "enum", + "members": { + "BLOCKED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "BLOCKED" + } + }, + "NONE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "NONE" + } + } + } + }, + "com.amazonaws.bedrockruntime#GuardrailContextualGroundingPolicyAssessment": { + "type": "structure", + "members": { + "filters": { + "target": "com.amazonaws.bedrockruntime#GuardrailContextualGroundingFilters", + "traits": { + "smithy.api#documentation": "

The filter details for the guardrails contextual grounding filter.

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

The policy assessment details for the guardrails contextual grounding filter.

" + } + }, + "com.amazonaws.bedrockruntime#GuardrailContextualGroundingPolicyUnitsProcessed": { + "type": "integer" + }, "com.amazonaws.bedrockruntime#GuardrailConverseContentBlock": { "type": "union", "members": { @@ -1688,7 +1995,36 @@ } }, "traits": { - "smithy.api#documentation": "

\n

A content block for selective guarding with the Converse API (Converse and ConverseStream).\n

" + "smithy.api#documentation": "

\n

A content block for selective guarding with the Converse or ConverseStream API operations.\n

" + } + }, + "com.amazonaws.bedrockruntime#GuardrailConverseContentQualifier": { + "type": "enum", + "members": { + "GROUNDING_SOURCE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "grounding_source" + } + }, + "QUERY": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "query" + } + }, + "GUARD_CONTENT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "guard_content" + } + } + } + }, + "com.amazonaws.bedrockruntime#GuardrailConverseContentQualifierList": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockruntime#GuardrailConverseContentQualifier" } }, "com.amazonaws.bedrockruntime#GuardrailConverseTextBlock": { @@ -1700,6 +2036,12 @@ "smithy.api#documentation": "

The text that you want to guard.

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

The qualifier details for the guardrails contextual grounding filter.

" + } } }, "traits": { @@ -1789,6 +2131,26 @@ } } }, + "com.amazonaws.bedrockruntime#GuardrailOutputContent": { + "type": "structure", + "members": { + "text": { + "target": "com.amazonaws.bedrockruntime#GuardrailOutputText", + "traits": { + "smithy.api#documentation": "

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

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

The output content produced by the guardrail.

" + } + }, + "com.amazonaws.bedrockruntime#GuardrailOutputContentList": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockruntime#GuardrailOutputContent" + } + }, "com.amazonaws.bedrockruntime#GuardrailOutputText": { "type": "string" }, @@ -2057,6 +2419,14 @@ "target": "com.amazonaws.bedrockruntime#GuardrailRegexFilter" } }, + "com.amazonaws.bedrockruntime#GuardrailResource": { + "type": "resource", + "operations": [ + { + "target": "com.amazonaws.bedrockruntime#ApplyGuardrail" + } + ] + }, "com.amazonaws.bedrockruntime#GuardrailSensitiveInformationPolicyAction": { "type": "enum", "members": { @@ -2096,6 +2466,12 @@ "smithy.api#documentation": "

The assessment for aPersonally Identifiable Information (PII) policy.

" } }, + "com.amazonaws.bedrockruntime#GuardrailSensitiveInformationPolicyFreeUnitsProcessed": { + "type": "integer" + }, + "com.amazonaws.bedrockruntime#GuardrailSensitiveInformationPolicyUnitsProcessed": { + "type": "integer" + }, "com.amazonaws.bedrockruntime#GuardrailStreamConfiguration": { "type": "structure", "members": { @@ -2149,6 +2525,27 @@ } } }, + "com.amazonaws.bedrockruntime#GuardrailTextBlock": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "

The input text details to be evaluated by the guardrail.

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

The qualifiers describing the text block.

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

The text block to be evaluated by the guardrail.

" + } + }, "com.amazonaws.bedrockruntime#GuardrailTopic": { "type": "structure", "members": { @@ -2210,6 +2607,9 @@ "smithy.api#documentation": "

A behavior assessment of a topic policy.

" } }, + "com.amazonaws.bedrockruntime#GuardrailTopicPolicyUnitsProcessed": { + "type": "integer" + }, "com.amazonaws.bedrockruntime#GuardrailTopicType": { "type": "enum", "members": { @@ -2264,6 +2664,56 @@ "smithy.api#documentation": "

A Top level guardrail trace object. For more information, see ConverseTrace.

" } }, + "com.amazonaws.bedrockruntime#GuardrailUsage": { + "type": "structure", + "members": { + "topicPolicyUnits": { + "target": "com.amazonaws.bedrockruntime#GuardrailTopicPolicyUnitsProcessed", + "traits": { + "smithy.api#documentation": "

The topic policy units processed by the guardrail.

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

The content policy units processed by the guardrail.

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

The word policy units processed by the guardrail.

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

The sensitive information policy units processed by the guardrail.

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

The sensitive information policy free units processed by the guardrail.

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

The contextual grounding policy units processed by the guardrail.

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

The details on the use of the guardrail.

" + } + }, "com.amazonaws.bedrockruntime#GuardrailVersion": { "type": "string", "traits": { @@ -2303,6 +2753,9 @@ "smithy.api#documentation": "

The word policy assessment.

" } }, + "com.amazonaws.bedrockruntime#GuardrailWordPolicyUnitsProcessed": { + "type": "integer" + }, "com.amazonaws.bedrockruntime#ImageBlock": { "type": "structure", "members": { @@ -2360,7 +2813,7 @@ "bytes": { "target": "smithy.api#Blob", "traits": { - "smithy.api#documentation": "

The raw image bytes for the image. If you use an AWS SDK, you don't need to base64 encode the image bytes.

", + "smithy.api#documentation": "

The raw image bytes for the image. If you use an AWS SDK, you don't need to encode the image bytes in base64.

", "smithy.api#length": { "min": 1 } @@ -2731,7 +3184,7 @@ "content": { "target": "com.amazonaws.bedrockruntime#ContentBlocks", "traits": { - "smithy.api#documentation": "

The message content.

", + "smithy.api#documentation": "

The message content. Note the following restrictions:

\n
    \n
  • \n

    You can include up to 20 images. Each image's size, height, and width must be no more than 3.75 MB, 8000 px, and 8000 px, respectively.

    \n
  • \n
  • \n

    You can include up to five documents. Each document's size must be no more than 4.5 MB.

    \n
  • \n
  • \n

    If you include a ContentBlock with a document field in the array, you must also include a ContentBlock with a text field.

    \n
  • \n
  • \n

    You can only include images and documents if the role is user.

    \n
  • \n
", "smithy.api#required": {} } } @@ -3067,7 +3520,7 @@ "guardContent": { "target": "com.amazonaws.bedrockruntime#GuardrailConverseContentBlock", "traits": { - "smithy.api#documentation": "

A content block to assess with the guardrail. Use with the Converse API (Converse and ConverseStream).

\n

For more information, see Use a guardrail with the Converse\n API in the Amazon Bedrock User Guide.

" + "smithy.api#documentation": "

A content block to assess with the guardrail. Use with the Converse or ConverseStream API operations.

\n

For more information, see Use a guardrail with the Converse\n API in the Amazon Bedrock User Guide.

" } } }, @@ -3143,7 +3596,7 @@ } }, "traits": { - "smithy.api#documentation": "

Information about a tool that you can use with the Converse API.

" + "smithy.api#documentation": "

Information about a tool that you can use with the Converse API. For more information, see Tool use (function calling) in the Amazon Bedrock User Guide.

" } }, "com.amazonaws.bedrockruntime#ToolChoice": { @@ -3193,7 +3646,7 @@ } }, "traits": { - "smithy.api#documentation": "

Configuration information for the tools that you pass to a model.

\n \n

This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.

\n
" + "smithy.api#documentation": "

Configuration information for the tools that you pass to a model. For more information, see Tool use (function calling) in the Amazon Bedrock User Guide.

\n \n

This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.

\n
" } }, "com.amazonaws.bedrockruntime#ToolInputSchema": {