diff --git a/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts b/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts index fb492fdb98d8..6638985b5575 100644 --- a/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ApplyGuardrailCommand.ts @@ -6,7 +6,11 @@ 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 { + ApplyGuardrailRequest, + ApplyGuardrailRequestFilterSensitiveLog, + ApplyGuardrailResponse, +} from "../models/models_0"; import { de_ApplyGuardrailCommand, se_ApplyGuardrailCommand } from "../protocols/Aws_restJson1"; /** @@ -49,6 +53,12 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M * "grounding_source" || "query" || "guard_content", * ], * }, + * image: { // GuardrailImageBlock + * format: "png" || "jpeg", // required + * source: { // GuardrailImageSource Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * }, * ], * }; @@ -147,6 +157,10 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M * // guarded: Number("int"), * // total: Number("int"), * // }, + * // images: { // GuardrailImageCoverage + * // guarded: Number("int"), + * // total: Number("int"), + * // }, * // }, * // }, * // }, @@ -156,6 +170,10 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M * // guarded: Number("int"), * // total: Number("int"), * // }, + * // images: { + * // guarded: Number("int"), + * // total: Number("int"), + * // }, * // }, * // }; * @@ -212,7 +230,7 @@ export class ApplyGuardrailCommand extends $Command }) .s("AmazonBedrockFrontendService", "ApplyGuardrail", {}) .n("BedrockRuntimeClient", "ApplyGuardrailCommand") - .f(void 0, void 0) + .f(ApplyGuardrailRequestFilterSensitiveLog, 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 50679f59b2e9..52da3360583c 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts @@ -6,7 +6,12 @@ import { MetadataBearer as __MetadataBearer } from "@smithy/types"; import { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BedrockRuntimeClient"; import { commonParams } from "../endpoint/EndpointParameters"; -import { ConverseRequest, ConverseRequestFilterSensitiveLog, ConverseResponse } from "../models/models_0"; +import { + ConverseRequest, + ConverseRequestFilterSensitiveLog, + ConverseResponse, + ConverseResponseFilterSensitiveLog, +} from "../models/models_0"; import { de_ConverseCommand, se_ConverseCommand } from "../protocols/Aws_restJson1"; /** @@ -134,6 +139,12 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * "grounding_source" || "query" || "guard_content", * ], * }, + * image: { // GuardrailConverseImageBlock + * format: "png" || "jpeg", // required + * source: { // GuardrailConverseImageSource Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * }, * }, * ], @@ -149,6 +160,12 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * "grounding_source" || "query" || "guard_content", * ], * }, + * image: { + * format: "png" || "jpeg", // required + * source: {// Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * }, * }, * ], @@ -278,6 +295,12 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // "grounding_source" || "query" || "guard_content", * // ], * // }, + * // image: { // GuardrailConverseImageBlock + * // format: "png" || "jpeg", // required + * // source: { // GuardrailConverseImageSource Union: only one key present + * // bytes: new Uint8Array(), + * // }, + * // }, * // }, * // }, * // ], @@ -376,6 +399,10 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // guarded: Number("int"), * // total: Number("int"), * // }, + * // images: { // GuardrailImageCoverage + * // guarded: Number("int"), + * // total: Number("int"), + * // }, * // }, * // }, * // }, @@ -459,12 +486,19 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // guarded: Number("int"), * // total: Number("int"), * // }, + * // images: { + * // guarded: Number("int"), + * // total: Number("int"), + * // }, * // }, * // }, * // }, * // ], * // }, * // }, + * // promptRouter: { // PromptRouterTrace + * // invokedModelId: "STRING_VALUE", + * // }, * // }, * // performanceConfig: { // PerformanceConfiguration * // latency: "standard" || "optimized", @@ -537,7 +571,7 @@ export class ConverseCommand extends $Command }) .s("AmazonBedrockFrontendService", "Converse", {}) .n("BedrockRuntimeClient", "ConverseCommand") - .f(ConverseRequestFilterSensitiveLog, void 0) + .f(ConverseRequestFilterSensitiveLog, ConverseResponseFilterSensitiveLog) .ser(se_ConverseCommand) .de(de_ConverseCommand) .build() { diff --git a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts index c42c37d51941..feec26f1c0f2 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts @@ -145,6 +145,12 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * "grounding_source" || "query" || "guard_content", * ], * }, + * image: { // GuardrailConverseImageBlock + * format: "png" || "jpeg", // required + * source: { // GuardrailConverseImageSource Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * }, * }, * ], @@ -160,6 +166,12 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * "grounding_source" || "query" || "guard_content", * ], * }, + * image: { + * format: "png" || "jpeg", // required + * source: {// Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * }, * }, * ], @@ -337,6 +349,10 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * // guarded: Number("int"), * // total: Number("int"), * // }, + * // images: { // GuardrailImageCoverage + * // guarded: Number("int"), + * // total: Number("int"), + * // }, * // }, * // }, * // }, @@ -420,12 +436,19 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * // guarded: Number("int"), * // total: Number("int"), * // }, + * // images: { + * // guarded: Number("int"), + * // total: Number("int"), + * // }, * // }, * // }, * // }, * // ], * // }, * // }, + * // promptRouter: { // PromptRouterTrace + * // invokedModelId: "STRING_VALUE", + * // }, * // }, * // performanceConfig: { // PerformanceConfiguration * // latency: "standard" || "optimized", diff --git a/clients/client-bedrock-runtime/src/models/models_0.ts b/clients/client-bedrock-runtime/src/models/models_0.ts index 01e85425ce37..668e24daaded 100644 --- a/clients/client-bedrock-runtime/src/models/models_0.ts +++ b/clients/client-bedrock-runtime/src/models/models_0.ts @@ -535,6 +535,76 @@ export interface StartAsyncInvokeResponse { invocationArn: string | undefined; } +/** + * @public + * @enum + */ +export const GuardrailImageFormat = { + JPEG: "jpeg", + PNG: "png", +} as const; + +/** + * @public + */ +export type GuardrailImageFormat = (typeof GuardrailImageFormat)[keyof typeof GuardrailImageFormat]; + +/** + *
The image source (image bytes) of the guardrail image source. Object used in independent api.
+ * @public + */ +export type GuardrailImageSource = GuardrailImageSource.BytesMember | GuardrailImageSource.$UnknownMember; + +/** + * @public + */ +export namespace GuardrailImageSource { + /** + *The bytes details of the guardrail image source. Object used in independent api.
+ * @public + */ + export interface BytesMember { + bytes: Uint8Array; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + bytes?: never; + $unknown: [string, any]; + } + + export interface VisitorContain an image which user wants guarded. This block is accepted by the guardrails independent API.
+ * @public + */ +export interface GuardrailImageBlock { + /** + *The format details for the file type of the image blocked by the guardrail.
+ * @public + */ + format: GuardrailImageFormat | undefined; + + /** + *The image source (image bytes) details of the image blocked by the guardrail.
+ * @public + */ + source: GuardrailImageSource | undefined; +} + /** * @public * @enum @@ -572,7 +642,10 @@ export interface GuardrailTextBlock { *The content block to be evaluated by the guardrail.
* @public */ -export type GuardrailContentBlock = GuardrailContentBlock.TextMember | GuardrailContentBlock.$UnknownMember; +export type GuardrailContentBlock = + | GuardrailContentBlock.ImageMember + | GuardrailContentBlock.TextMember + | GuardrailContentBlock.$UnknownMember; /** * @public @@ -584,6 +657,17 @@ export namespace GuardrailContentBlock { */ export interface TextMember { text: GuardrailTextBlock; + image?: never; + $unknown?: never; + } + + /** + *Image within guardrail content block to be evaluated by the guardrail.
+ * @public + */ + export interface ImageMember { + text?: never; + image: GuardrailImageBlock; $unknown?: never; } @@ -592,16 +676,19 @@ export namespace GuardrailContentBlock { */ export interface $UnknownMember { text?: never; + image?: never; $unknown: [string, any]; } export interface VisitorThe details of the guardrail image coverage.
+ * @public + */ +export interface GuardrailImageCoverage { + /** + *The count (integer) of images guardrails guarded.
+ * @public + */ + guarded?: number | undefined; + + /** + *Represents the total number of images (integer) that were in the request (guarded and unguarded).
+ * @public + */ + total?: number | undefined; +} + /** *The guardrail coverage for the text characters.
* @public @@ -871,6 +976,12 @@ export interface GuardrailCoverage { * @public */ textCharacters?: GuardrailTextCharactersCoverage | undefined; + + /** + *The guardrail coverage for images (the number of images that guardrails guarded).
+ * @public + */ + images?: GuardrailImageCoverage | undefined; } /** @@ -1495,6 +1606,79 @@ export interface DocumentBlock { source: DocumentSource | undefined; } +/** + * @public + * @enum + */ +export const GuardrailConverseImageFormat = { + JPEG: "jpeg", + PNG: "png", +} as const; + +/** + * @public + */ +export type GuardrailConverseImageFormat = + (typeof GuardrailConverseImageFormat)[keyof typeof GuardrailConverseImageFormat]; + +/** + *The image source (image bytes) of the guardrail converse image source.
+ * @public + */ +export type GuardrailConverseImageSource = + | GuardrailConverseImageSource.BytesMember + | GuardrailConverseImageSource.$UnknownMember; + +/** + * @public + */ +export namespace GuardrailConverseImageSource { + /** + *The raw image bytes for the image.
+ * @public + */ + export interface BytesMember { + bytes: Uint8Array; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + bytes?: never; + $unknown: [string, any]; + } + + export interface VisitorAn image block that contains images that you want to assess with a guardrail.
+ * @public + */ +export interface GuardrailConverseImageBlock { + /** + *The format details for the image type of the guardrail converse image block.
+ * @public + */ + format: GuardrailConverseImageFormat | undefined; + + /** + *The image source (image bytes) of the guardrail converse image block.
+ * @public + */ + source: GuardrailConverseImageSource | undefined; +} + /** * @public * @enum @@ -1536,6 +1720,7 @@ export interface GuardrailConverseTextBlock { * @public */ export type GuardrailConverseContentBlock = + | GuardrailConverseContentBlock.ImageMember | GuardrailConverseContentBlock.TextMember | GuardrailConverseContentBlock.$UnknownMember; @@ -1549,6 +1734,17 @@ export namespace GuardrailConverseContentBlock { */ export interface TextMember { text: GuardrailConverseTextBlock; + image?: never; + $unknown?: never; + } + + /** + *Image within converse content block to be evaluated by the guardrail.
+ * @public + */ + export interface ImageMember { + text?: never; + image: GuardrailConverseImageBlock; $unknown?: never; } @@ -1557,16 +1753,19 @@ export namespace GuardrailConverseContentBlock { */ export interface $UnknownMember { text?: never; + image?: never; $unknown: [string, any]; } export interface VisitorA prompt router trace.
+ * @public + */ +export interface PromptRouterTrace { + /** + *The ID of the invoked model.
+ * @public + */ + invokedModelId?: string | undefined; +} + /** *The trace object in a response from Converse. Currently, you can only trace guardrails.
* @public @@ -2702,6 +2913,12 @@ export interface ConverseTrace { * @public */ guardrail?: GuardrailTraceAssessment | undefined; + + /** + *The request's prompt router.
+ * @public + */ + promptRouter?: PromptRouterTrace | undefined; } /** @@ -3233,6 +3450,12 @@ export interface ConverseStreamTrace { * @public */ guardrail?: GuardrailTraceAssessment | undefined; + + /** + *The request's prompt router.
+ * @public + */ + promptRouter?: PromptRouterTrace | undefined; } /** @@ -4039,25 +4262,132 @@ export const StartAsyncInvokeRequestFilterSensitiveLog = (obj: StartAsyncInvokeR ...(obj.outputDataConfig && { outputDataConfig: obj.outputDataConfig }), }); +/** + * @internal + */ +export const GuardrailImageSourceFilterSensitiveLog = (obj: GuardrailImageSource): any => { + if (obj.bytes !== undefined) return { bytes: obj.bytes }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const GuardrailImageBlockFilterSensitiveLog = (obj: GuardrailImageBlock): any => ({ + ...obj, + ...(obj.source && { source: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const GuardrailContentBlockFilterSensitiveLog = (obj: GuardrailContentBlock): any => { + if (obj.text !== undefined) return { text: obj.text }; + if (obj.image !== undefined) return { image: SENSITIVE_STRING }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const ApplyGuardrailRequestFilterSensitiveLog = (obj: ApplyGuardrailRequest): any => ({ + ...obj, + ...(obj.content && { content: obj.content.map((item) => GuardrailContentBlockFilterSensitiveLog(item)) }), +}); + +/** + * @internal + */ +export const GuardrailConverseImageSourceFilterSensitiveLog = (obj: GuardrailConverseImageSource): any => { + if (obj.bytes !== undefined) return { bytes: obj.bytes }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const GuardrailConverseImageBlockFilterSensitiveLog = (obj: GuardrailConverseImageBlock): any => ({ + ...obj, + ...(obj.source && { source: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const GuardrailConverseContentBlockFilterSensitiveLog = (obj: GuardrailConverseContentBlock): any => { + if (obj.text !== undefined) return { text: obj.text }; + if (obj.image !== undefined) return { image: SENSITIVE_STRING }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const ContentBlockFilterSensitiveLog = (obj: ContentBlock): any => { + if (obj.text !== undefined) return { text: obj.text }; + if (obj.image !== undefined) return { image: obj.image }; + if (obj.document !== undefined) return { document: obj.document }; + if (obj.video !== undefined) return { video: obj.video }; + if (obj.toolUse !== undefined) return { toolUse: obj.toolUse }; + if (obj.toolResult !== undefined) return { toolResult: obj.toolResult }; + if (obj.guardContent !== undefined) + return { guardContent: GuardrailConverseContentBlockFilterSensitiveLog(obj.guardContent) }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const MessageFilterSensitiveLog = (obj: Message): any => ({ + ...obj, + ...(obj.content && { content: obj.content.map((item) => ContentBlockFilterSensitiveLog(item)) }), +}); + +/** + * @internal + */ +export const SystemContentBlockFilterSensitiveLog = (obj: SystemContentBlock): any => { + if (obj.text !== undefined) return { text: obj.text }; + if (obj.guardContent !== undefined) + return { guardContent: GuardrailConverseContentBlockFilterSensitiveLog(obj.guardContent) }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + /** * @internal */ export const ConverseRequestFilterSensitiveLog = (obj: ConverseRequest): any => ({ ...obj, - ...(obj.messages && { messages: obj.messages.map((item) => item) }), - ...(obj.system && { system: obj.system.map((item) => item) }), + ...(obj.messages && { messages: obj.messages.map((item) => MessageFilterSensitiveLog(item)) }), + ...(obj.system && { system: obj.system.map((item) => SystemContentBlockFilterSensitiveLog(item)) }), ...(obj.toolConfig && { toolConfig: obj.toolConfig }), ...(obj.promptVariables && { promptVariables: SENSITIVE_STRING }), ...(obj.requestMetadata && { requestMetadata: SENSITIVE_STRING }), }); +/** + * @internal + */ +export const ConverseOutputFilterSensitiveLog = (obj: ConverseOutput): any => { + if (obj.message !== undefined) return { message: MessageFilterSensitiveLog(obj.message) }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const ConverseResponseFilterSensitiveLog = (obj: ConverseResponse): any => ({ + ...obj, + ...(obj.output && { output: ConverseOutputFilterSensitiveLog(obj.output) }), +}); + /** * @internal */ export const ConverseStreamRequestFilterSensitiveLog = (obj: ConverseStreamRequest): any => ({ ...obj, - ...(obj.messages && { messages: obj.messages.map((item) => item) }), - ...(obj.system && { system: obj.system.map((item) => item) }), + ...(obj.messages && { messages: obj.messages.map((item) => MessageFilterSensitiveLog(item)) }), + ...(obj.system && { system: obj.system.map((item) => SystemContentBlockFilterSensitiveLog(item)) }), ...(obj.toolConfig && { toolConfig: obj.toolConfig }), ...(obj.promptVariables && { promptVariables: SENSITIVE_STRING }), ...(obj.requestMetadata && { requestMetadata: SENSITIVE_STRING }), diff --git a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts index fd0303c985e6..739d4470f7f4 100644 --- a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts @@ -74,7 +74,11 @@ import { GuardrailContextualGroundingPolicyAssessment, GuardrailConverseContentBlock, GuardrailConverseContentQualifier, + GuardrailConverseImageBlock, + GuardrailConverseImageSource, GuardrailConverseTextBlock, + GuardrailImageBlock, + GuardrailImageSource, GuardrailStreamConfiguration, GuardrailTextBlock, GuardrailTraceAssessment, @@ -131,7 +135,7 @@ export const se_ApplyGuardrailCommand = async ( let body: any; body = JSON.stringify( take(input, { - content: (_) => _json(_), + content: (_) => se_GuardrailContentBlockList(_, context), source: [], }) ); @@ -163,7 +167,7 @@ export const se_ConverseCommand = async ( performanceConfig: (_) => _json(_), promptVariables: (_) => _json(_), requestMetadata: (_) => _json(_), - system: (_) => _json(_), + system: (_) => se_SystemContentBlocks(_, context), toolConfig: (_) => se_ToolConfiguration(_, context), }) ); @@ -195,7 +199,7 @@ export const se_ConverseStreamCommand = async ( performanceConfig: (_) => _json(_), promptVariables: (_) => _json(_), requestMetadata: (_) => _json(_), - system: (_) => _json(_), + system: (_) => se_SystemContentBlocks(_, context), toolConfig: (_) => se_ToolConfiguration(_, context), }) ); @@ -1034,7 +1038,7 @@ const de_ValidationException_event = async (output: any, context: __SerdeContext const se_ContentBlock = (input: ContentBlock, context: __SerdeContext): any => { return ContentBlock.visit(input, { document: (value) => ({ document: se_DocumentBlock(value, context) }), - guardContent: (value) => ({ guardContent: _json(value) }), + guardContent: (value) => ({ guardContent: se_GuardrailConverseContentBlock(value, context) }), image: (value) => ({ image: se_ImageBlock(value, context) }), text: (value) => ({ text: value }), toolResult: (value) => ({ toolResult: se_ToolResultBlock(value, context) }), @@ -1078,18 +1082,85 @@ const se_DocumentSource = (input: DocumentSource, context: __SerdeContext): any // se_GuardrailConfiguration omitted. -// se_GuardrailContentBlock omitted. +/** + * serializeAws_restJson1GuardrailContentBlock + */ +const se_GuardrailContentBlock = (input: GuardrailContentBlock, context: __SerdeContext): any => { + return GuardrailContentBlock.visit(input, { + image: (value) => ({ image: se_GuardrailImageBlock(value, context) }), + text: (value) => ({ text: _json(value) }), + _: (name, value) => ({ name: value } as any), + }); +}; -// se_GuardrailContentBlockList omitted. +/** + * serializeAws_restJson1GuardrailContentBlockList + */ +const se_GuardrailContentBlockList = (input: GuardrailContentBlock[], context: __SerdeContext): any => { + return input + .filter((e: any) => e != null) + .map((entry) => { + return se_GuardrailContentBlock(entry, context); + }); +}; // se_GuardrailContentQualifierList omitted. -// se_GuardrailConverseContentBlock omitted. +/** + * serializeAws_restJson1GuardrailConverseContentBlock + */ +const se_GuardrailConverseContentBlock = (input: GuardrailConverseContentBlock, context: __SerdeContext): any => { + return GuardrailConverseContentBlock.visit(input, { + image: (value) => ({ image: se_GuardrailConverseImageBlock(value, context) }), + text: (value) => ({ text: _json(value) }), + _: (name, value) => ({ name: value } as any), + }); +}; // se_GuardrailConverseContentQualifierList omitted. +/** + * serializeAws_restJson1GuardrailConverseImageBlock + */ +const se_GuardrailConverseImageBlock = (input: GuardrailConverseImageBlock, context: __SerdeContext): any => { + return take(input, { + format: [], + source: (_) => se_GuardrailConverseImageSource(_, context), + }); +}; + +/** + * serializeAws_restJson1GuardrailConverseImageSource + */ +const se_GuardrailConverseImageSource = (input: GuardrailConverseImageSource, context: __SerdeContext): any => { + return GuardrailConverseImageSource.visit(input, { + bytes: (value) => ({ bytes: context.base64Encoder(value) }), + _: (name, value) => ({ name: value } as any), + }); +}; + // se_GuardrailConverseTextBlock omitted. +/** + * serializeAws_restJson1GuardrailImageBlock + */ +const se_GuardrailImageBlock = (input: GuardrailImageBlock, context: __SerdeContext): any => { + return take(input, { + format: [], + source: (_) => se_GuardrailImageSource(_, context), + }); +}; + +/** + * serializeAws_restJson1GuardrailImageSource + */ +const se_GuardrailImageSource = (input: GuardrailImageSource, context: __SerdeContext): any => { + return GuardrailImageSource.visit(input, { + bytes: (value) => ({ bytes: context.base64Encoder(value) }), + _: (name, value) => ({ name: value } as any), + }); +}; + // se_GuardrailStreamConfiguration omitted. // se_GuardrailTextBlock omitted. @@ -1168,9 +1239,27 @@ const se_ModelInputPayload = (input: __DocumentType, context: __SerdeContext): a // se_SpecificToolChoice omitted. -// se_SystemContentBlock omitted. +/** + * serializeAws_restJson1SystemContentBlock + */ +const se_SystemContentBlock = (input: SystemContentBlock, context: __SerdeContext): any => { + return SystemContentBlock.visit(input, { + guardContent: (value) => ({ guardContent: se_GuardrailConverseContentBlock(value, context) }), + text: (value) => ({ text: value }), + _: (name, value) => ({ name: value } as any), + }); +}; -// se_SystemContentBlocks omitted. +/** + * serializeAws_restJson1SystemContentBlocks + */ +const se_SystemContentBlocks = (input: SystemContentBlock[], context: __SerdeContext): any => { + return input + .filter((e: any) => e != null) + .map((entry) => { + return se_SystemContentBlock(entry, context); + }); +}; // se_Tag omitted. @@ -1349,7 +1438,7 @@ const de_ContentBlock = (output: any, context: __SerdeContext): ContentBlock => } if (output.guardContent != null) { return { - guardContent: _json(__expectUnion(output.guardContent)), + guardContent: de_GuardrailConverseContentBlock(__expectUnion(output.guardContent), context), }; } if (output.image != null) { @@ -1434,6 +1523,7 @@ const de_ConverseStreamMetadataEvent = (output: any, context: __SerdeContext): C const de_ConverseStreamTrace = (output: any, context: __SerdeContext): ConverseStreamTrace => { return take(output, { guardrail: (_: any) => de_GuardrailTraceAssessment(_, context), + promptRouter: _json, }) as any; }; @@ -1443,6 +1533,7 @@ const de_ConverseStreamTrace = (output: any, context: __SerdeContext): ConverseS const de_ConverseTrace = (output: any, context: __SerdeContext): ConverseTrace => { return take(output, { guardrail: (_: any) => de_GuardrailTraceAssessment(_, context), + promptRouter: _json, }) as any; }; @@ -1569,10 +1660,47 @@ const de_GuardrailContextualGroundingPolicyAssessment = ( }) as any; }; -// de_GuardrailConverseContentBlock omitted. +/** + * deserializeAws_restJson1GuardrailConverseContentBlock + */ +const de_GuardrailConverseContentBlock = (output: any, context: __SerdeContext): GuardrailConverseContentBlock => { + if (output.image != null) { + return { + image: de_GuardrailConverseImageBlock(output.image, context), + }; + } + if (output.text != null) { + return { + text: _json(output.text), + }; + } + return { $unknown: Object.entries(output)[0] }; +}; // de_GuardrailConverseContentQualifierList omitted. +/** + * deserializeAws_restJson1GuardrailConverseImageBlock + */ +const de_GuardrailConverseImageBlock = (output: any, context: __SerdeContext): GuardrailConverseImageBlock => { + return take(output, { + format: __expectString, + source: (_: any) => de_GuardrailConverseImageSource(__expectUnion(_), context), + }) as any; +}; + +/** + * deserializeAws_restJson1GuardrailConverseImageSource + */ +const de_GuardrailConverseImageSource = (output: any, context: __SerdeContext): GuardrailConverseImageSource => { + if (output.bytes != null) { + return { + bytes: context.base64Decoder(output.bytes), + }; + } + return { $unknown: Object.entries(output)[0] }; +}; + // de_GuardrailConverseTextBlock omitted. // de_GuardrailCoverage omitted. @@ -1581,6 +1709,8 @@ const de_GuardrailContextualGroundingPolicyAssessment = ( // de_GuardrailCustomWordList omitted. +// de_GuardrailImageCoverage omitted. + // de_GuardrailInvocationMetrics omitted. // de_GuardrailManagedWord omitted. @@ -1681,6 +1811,8 @@ const de_PayloadPart = (output: any, context: __SerdeContext): PayloadPart => { // de_PerformanceConfiguration omitted. +// de_PromptRouterTrace omitted. + // de_S3Location omitted. // de_TokenUsage omitted. diff --git a/codegen/sdk-codegen/aws-models/bedrock-runtime.json b/codegen/sdk-codegen/aws-models/bedrock-runtime.json index 7730c11bf960..b168b4b194d9 100644 --- a/codegen/sdk-codegen/aws-models/bedrock-runtime.json +++ b/codegen/sdk-codegen/aws-models/bedrock-runtime.json @@ -1244,7 +1244,7 @@ "min": 1, "max": 2048 }, - "smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:imported-model/[a-z0-9]{12})|([0-9]{12}:provisioned-model/[a-z0-9]{12})|([0-9]{12}:(inference-profile|application-inference-profile)/[a-zA-Z0-9-:.]+)))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)|([a-zA-Z0-9-:.]+)|(^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:prompt/[0-9a-zA-Z]{10}(?::[0-9]{1,5})?))$" + "smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:imported-model/[a-z0-9]{12})|([0-9]{12}:provisioned-model/[a-z0-9]{12})|([0-9]{12}:(inference-profile|application-inference-profile)/[a-zA-Z0-9-:.]+)))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)|([a-zA-Z0-9-:.]+)|(^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:prompt/[0-9a-zA-Z]{10}(?::[0-9]{1,5})?))$|(^arn:aws:sagemaker:[a-z0-9-]+:[0-9]{12}:endpoint/[a-zA-Z0-9-]+$)|(^arn:aws(-[^:]+)?:bedrock:([0-9a-z-]{1,20}):([0-9]{12}):default-prompt-router/[a-zA-Z0-9-:.]+$)$" } }, "com.amazonaws.bedrockruntime#Converse": { @@ -1727,6 +1727,12 @@ "traits": { "smithy.api#documentation": "The guardrail trace object.
" } + }, + "promptRouter": { + "target": "com.amazonaws.bedrockruntime#PromptRouterTrace", + "traits": { + "smithy.api#documentation": "The request's prompt router.
" + } } }, "traits": { @@ -1741,6 +1747,12 @@ "traits": { "smithy.api#documentation": "The guardrail trace object.
" } + }, + "promptRouter": { + "target": "com.amazonaws.bedrockruntime#PromptRouterTrace", + "traits": { + "smithy.api#documentation": "The request's prompt router.
" + } } }, "traits": { @@ -2093,6 +2105,12 @@ "traits": { "smithy.api#documentation": "Text within content block to be evaluated by the guardrail.
" } + }, + "image": { + "target": "com.amazonaws.bedrockruntime#GuardrailImageBlock", + "traits": { + "smithy.api#documentation": "Image within guardrail content block to be evaluated by the guardrail.
" + } } }, "traits": { @@ -2429,6 +2447,12 @@ "traits": { "smithy.api#documentation": "The text to guard.
" } + }, + "image": { + "target": "com.amazonaws.bedrockruntime#GuardrailConverseImageBlock", + "traits": { + "smithy.api#documentation": "Image within converse content block to be evaluated by the guardrail.
" + } } }, "traits": { @@ -2464,6 +2488,64 @@ "target": "com.amazonaws.bedrockruntime#GuardrailConverseContentQualifier" } }, + "com.amazonaws.bedrockruntime#GuardrailConverseImageBlock": { + "type": "structure", + "members": { + "format": { + "target": "com.amazonaws.bedrockruntime#GuardrailConverseImageFormat", + "traits": { + "smithy.api#documentation": "The format details for the image type of the guardrail converse image block.
", + "smithy.api#required": {} + } + }, + "source": { + "target": "com.amazonaws.bedrockruntime#GuardrailConverseImageSource", + "traits": { + "smithy.api#documentation": "The image source (image bytes) of the guardrail converse image block.
", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "An image block that contains images that you want to assess with a guardrail.
", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockruntime#GuardrailConverseImageFormat": { + "type": "enum", + "members": { + "PNG": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "png" + } + }, + "JPEG": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "jpeg" + } + } + } + }, + "com.amazonaws.bedrockruntime#GuardrailConverseImageSource": { + "type": "union", + "members": { + "bytes": { + "target": "smithy.api#Blob", + "traits": { + "smithy.api#documentation": "The raw image bytes for the image.
", + "smithy.api#length": { + "min": 1 + } + } + } + }, + "traits": { + "smithy.api#documentation": "The image source (image bytes) of the guardrail converse image source.
", + "smithy.api#sensitive": {} + } + }, "com.amazonaws.bedrockruntime#GuardrailConverseTextBlock": { "type": "structure", "members": { @@ -2493,6 +2575,12 @@ "traits": { "smithy.api#documentation": "The text characters of the guardrail coverage details.
" } + }, + "images": { + "target": "com.amazonaws.bedrockruntime#GuardrailImageCoverage", + "traits": { + "smithy.api#documentation": "The guardrail coverage for images (the number of images that guardrails guarded).
" + } } }, "traits": { @@ -2536,6 +2624,84 @@ "smithy.api#pattern": "^(([a-z0-9]+)|(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:guardrail/[a-z0-9]+))$" } }, + "com.amazonaws.bedrockruntime#GuardrailImageBlock": { + "type": "structure", + "members": { + "format": { + "target": "com.amazonaws.bedrockruntime#GuardrailImageFormat", + "traits": { + "smithy.api#documentation": "The format details for the file type of the image blocked by the guardrail.
", + "smithy.api#required": {} + } + }, + "source": { + "target": "com.amazonaws.bedrockruntime#GuardrailImageSource", + "traits": { + "smithy.api#documentation": "The image source (image bytes) details of the image blocked by the guardrail.
", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Contain an image which user wants guarded. This block is accepted by the guardrails independent API.
", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockruntime#GuardrailImageCoverage": { + "type": "structure", + "members": { + "guarded": { + "target": "com.amazonaws.bedrockruntime#ImagesGuarded", + "traits": { + "smithy.api#documentation": "The count (integer) of images guardrails guarded.
" + } + }, + "total": { + "target": "com.amazonaws.bedrockruntime#ImagesTotal", + "traits": { + "smithy.api#documentation": "Represents the total number of images (integer) that were in the request (guarded and unguarded).
" + } + } + }, + "traits": { + "smithy.api#documentation": "The details of the guardrail image coverage.
" + } + }, + "com.amazonaws.bedrockruntime#GuardrailImageFormat": { + "type": "enum", + "members": { + "PNG": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "png" + } + }, + "JPEG": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "jpeg" + } + } + } + }, + "com.amazonaws.bedrockruntime#GuardrailImageSource": { + "type": "union", + "members": { + "bytes": { + "target": "smithy.api#Blob", + "traits": { + "smithy.api#documentation": "The bytes details of the guardrail image source. Object used in independent api.
", + "smithy.api#length": { + "min": 1 + } + } + } + }, + "traits": { + "smithy.api#documentation": "The image source (image bytes) of the guardrail image source. Object used in independent api.
", + "smithy.api#sensitive": {} + } + }, "com.amazonaws.bedrockruntime#GuardrailInvocationMetrics": { "type": "structure", "members": { @@ -3324,6 +3490,12 @@ "smithy.api#documentation": "The source for an image.
" } }, + "com.amazonaws.bedrockruntime#ImagesGuarded": { + "type": "integer" + }, + "com.amazonaws.bedrockruntime#ImagesTotal": { + "type": "integer" + }, "com.amazonaws.bedrockruntime#InferenceConfiguration": { "type": "structure", "members": { @@ -3466,7 +3638,7 @@ "min": 1, "max": 2048 }, - "smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:imported-model/[a-z0-9]{12})|([0-9]{12}:provisioned-model/[a-z0-9]{12})|([0-9]{12}:(inference-profile|application-inference-profile)/[a-zA-Z0-9-:.]+)))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)|([a-zA-Z0-9-:.]+)$|(^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:prompt/[0-9a-zA-Z]{10}(?::[0-9]{1,5})?))$" + "smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:imported-model/[a-z0-9]{12})|([0-9]{12}:provisioned-model/[a-z0-9]{12})|([0-9]{12}:(inference-profile|application-inference-profile)/[a-zA-Z0-9-:.]+)))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)|([a-zA-Z0-9-:.]+)$|(^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:prompt/[0-9a-zA-Z]{10}(?::[0-9]{1,5})?))$|(^arn:aws:sagemaker:[a-z0-9-]+:[0-9]{12}:endpoint/[a-zA-Z0-9-]+$)|(^arn:aws(-[^:]+)?:bedrock:([0-9a-z-]{1,20}):([0-9]{12}):default-prompt-router/[a-zA-Z0-9-:.]+$)$" } }, "com.amazonaws.bedrockruntime#InvokeModelRequest": { @@ -3715,6 +3887,12 @@ "smithy.api#output": {} } }, + "com.amazonaws.bedrockruntime#InvokedModelId": { + "type": "string", + "traits": { + "smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}::foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([a-z0-9-]{1,63}[.]){0,2}[a-z0-9-]{1,63}([:][a-z0-9-]{1,63}){0,2})|(arn:aws(|-us-gov|-cn|-iso|-iso-b):bedrock:(|[0-9a-z-]{1,20}):(|[0-9]{12}):inference-profile/[a-zA-Z0-9-:.]+)$" + } + }, "com.amazonaws.bedrockruntime#KmsKeyId": { "type": "string", "traits": { @@ -4101,6 +4279,20 @@ "smithy.api#documentation": "Performance settings for a model.
" } }, + "com.amazonaws.bedrockruntime#PromptRouterTrace": { + "type": "structure", + "members": { + "invokedModelId": { + "target": "com.amazonaws.bedrockruntime#InvokedModelId", + "traits": { + "smithy.api#documentation": "The ID of the invoked model.
" + } + } + }, + "traits": { + "smithy.api#documentation": "A prompt router trace.
" + } + }, "com.amazonaws.bedrockruntime#PromptVariableMap": { "type": "map", "key": {