diff --git a/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts b/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts index 081d846014c69..ce891e0cce0b3 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseCommand.ts @@ -60,6 +60,13 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") * }, * }, + * document: { // DocumentBlock + * format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required + * name: "STRING_VALUE", // required + * source: { // DocumentSource Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * toolUse: { // ToolUseBlock * toolUseId: "STRING_VALUE", // required * name: "STRING_VALUE", // required @@ -77,6 +84,13 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") * }, * }, + * document: { + * format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required + * name: "STRING_VALUE", // required + * source: {// Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * }, * ], * status: "success" || "error", @@ -153,6 +167,13 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // bytes: new Uint8Array(), * // }, * // }, + * // document: { // DocumentBlock + * // format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required + * // name: "STRING_VALUE", // required + * // source: { // DocumentSource Union: only one key present + * // bytes: new Uint8Array(), + * // }, + * // }, * // toolUse: { // ToolUseBlock * // toolUseId: "STRING_VALUE", // required * // name: "STRING_VALUE", // required @@ -170,6 +191,13 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare * // bytes: new Uint8Array(), * // }, * // }, + * // document: { + * // format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required + * // name: "STRING_VALUE", // required + * // source: {// Union: only one key present + * // bytes: new Uint8Array(), + * // }, + * // }, * // }, * // ], * // status: "success" || "error", diff --git a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts index 38abc842c97c8..f2f2c95994e88 100644 --- a/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts @@ -67,6 +67,13 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") * }, * }, + * document: { // DocumentBlock + * format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required + * name: "STRING_VALUE", // required + * source: { // DocumentSource Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * toolUse: { // ToolUseBlock * toolUseId: "STRING_VALUE", // required * name: "STRING_VALUE", // required @@ -84,6 +91,13 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") * }, * }, + * document: { + * format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required + * name: "STRING_VALUE", // required + * source: {// Union: only one key present + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") + * }, + * }, * }, * ], * status: "success" || "error", diff --git a/clients/client-bedrock-runtime/src/models/models_0.ts b/clients/client-bedrock-runtime/src/models/models_0.ts index 0f0d3aacc3594..47a4952fbfcb1 100644 --- a/clients/client-bedrock-runtime/src/models/models_0.ts +++ b/clients/client-bedrock-runtime/src/models/models_0.ts @@ -111,6 +111,89 @@ export interface InferenceConfiguration { stopSequences?: string[]; } +/** + * @public + * @enum + */ +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 type DocumentFormat = (typeof DocumentFormat)[keyof typeof DocumentFormat]; + +/** + *

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

+ * @public + */ +export type DocumentSource = DocumentSource.BytesMember | DocumentSource.$UnknownMember; + +/** + * @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; + } + + /** + * @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: DocumentSource, visitor: Visitor): T => { + if (value.bytes !== undefined) return visitor.bytes(value.bytes); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} + +/** + *

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 { + /** + *

The format of a document, or its extension.

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

A name for the document.

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

Contains the content of the document.

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

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

* @public @@ -242,6 +325,7 @@ export interface ImageBlock { * @public */ export type ToolResultContentBlock = + | ToolResultContentBlock.DocumentMember | ToolResultContentBlock.ImageMember | ToolResultContentBlock.JsonMember | ToolResultContentBlock.TextMember @@ -259,6 +343,7 @@ export namespace ToolResultContentBlock { json: __DocumentType; text?: never; image?: never; + document?: never; $unknown?: never; } @@ -270,6 +355,7 @@ export namespace ToolResultContentBlock { json?: never; text: string; image?: never; + document?: never; $unknown?: never; } @@ -284,6 +370,19 @@ export namespace ToolResultContentBlock { json?: never; text?: never; image: ImageBlock; + document?: never; + $unknown?: never; + } + + /** + *

A tool result that is a document.

+ * @public + */ + export interface DocumentMember { + json?: never; + text?: never; + image?: never; + document: DocumentBlock; $unknown?: never; } @@ -294,6 +393,7 @@ export namespace ToolResultContentBlock { json?: never; text?: never; image?: never; + document?: never; $unknown: [string, any]; } @@ -301,6 +401,7 @@ export namespace ToolResultContentBlock { json: (value: __DocumentType) => T; text: (value: string) => T; image: (value: ImageBlock) => T; + document: (value: DocumentBlock) => T; _: (name: string, value: any) => T; } @@ -308,6 +409,7 @@ export namespace ToolResultContentBlock { 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]); }; } @@ -384,6 +486,7 @@ export interface ToolUseBlock { * @public */ export type ContentBlock = + | ContentBlock.DocumentMember | ContentBlock.GuardContentMember | ContentBlock.ImageMember | ContentBlock.TextMember @@ -402,6 +505,7 @@ export namespace ContentBlock { export interface TextMember { text: string; image?: never; + document?: never; toolUse?: never; toolResult?: never; guardContent?: never; @@ -418,6 +522,21 @@ export namespace ContentBlock { 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; @@ -431,6 +550,7 @@ export namespace ContentBlock { export interface ToolUseMember { text?: never; image?: never; + document?: never; toolUse: ToolUseBlock; toolResult?: never; guardContent?: never; @@ -444,6 +564,7 @@ export namespace ContentBlock { export interface ToolResultMember { text?: never; image?: never; + document?: never; toolUse?: never; toolResult: ToolResultBlock; guardContent?: never; @@ -462,6 +583,7 @@ export namespace ContentBlock { export interface GuardContentMember { text?: never; image?: never; + document?: never; toolUse?: never; toolResult?: never; guardContent: GuardrailConverseContentBlock; @@ -474,6 +596,7 @@ export namespace ContentBlock { export interface $UnknownMember { text?: never; image?: never; + document?: never; toolUse?: never; toolResult?: never; guardContent?: never; @@ -483,6 +606,7 @@ export namespace ContentBlock { 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; @@ -492,6 +616,7 @@ export namespace ContentBlock { 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); diff --git a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts index f538b2dc1a4be..bd6ec3bedb60b 100644 --- a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts @@ -48,6 +48,8 @@ import { ConverseOutput, ConverseStreamMetadataEvent, ConverseStreamOutput, + DocumentBlock, + DocumentSource, GuardrailConfiguration, GuardrailConverseContentBlock, GuardrailConverseTextBlock, @@ -728,6 +730,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) }), image: (value) => ({ image: se_ImageBlock(value, context) }), text: (value) => ({ text: value }), @@ -748,6 +751,27 @@ const se_ContentBlocks = (input: ContentBlock[], context: __SerdeContext): any = }); }; +/** + * serializeAws_restJson1DocumentBlock + */ +const se_DocumentBlock = (input: DocumentBlock, context: __SerdeContext): any => { + return take(input, { + format: [], + name: [], + source: (_) => se_DocumentSource(_, context), + }); +}; + +/** + * serializeAws_restJson1DocumentSource + */ +const se_DocumentSource = (input: DocumentSource, context: __SerdeContext): any => { + return DocumentSource.visit(input, { + bytes: (value) => ({ bytes: context.base64Encoder(value) }), + _: (name, value) => ({ name: value } as any), + }); +}; + // se_GuardrailConfiguration omitted. // se_GuardrailConverseContentBlock omitted. @@ -865,6 +889,7 @@ const se_ToolResultBlock = (input: ToolResultBlock, context: __SerdeContext): an */ const se_ToolResultContentBlock = (input: ToolResultContentBlock, context: __SerdeContext): any => { return ToolResultContentBlock.visit(input, { + document: (value) => ({ document: se_DocumentBlock(value, context) }), image: (value) => ({ image: se_ImageBlock(value, context) }), json: (value) => ({ json: se_Document(value, context) }), text: (value) => ({ text: value }), @@ -927,6 +952,11 @@ const se_Document = (input: __DocumentType, context: __SerdeContext): any => { * deserializeAws_restJson1ContentBlock */ const de_ContentBlock = (output: any, context: __SerdeContext): ContentBlock => { + if (output.document != null) { + return { + document: de_DocumentBlock(output.document, context), + }; + } if (output.guardContent != null) { return { guardContent: _json(__expectUnion(output.guardContent)), @@ -997,6 +1027,29 @@ const de_ConverseOutput = (output: any, context: __SerdeContext): ConverseOutput // de_ConverseTrace omitted. +/** + * deserializeAws_restJson1DocumentBlock + */ +const de_DocumentBlock = (output: any, context: __SerdeContext): DocumentBlock => { + return take(output, { + format: __expectString, + name: __expectString, + source: (_: any) => de_DocumentSource(__expectUnion(_), context), + }) as any; +}; + +/** + * deserializeAws_restJson1DocumentSource + */ +const de_DocumentSource = (output: any, context: __SerdeContext): DocumentSource => { + if (output.bytes != null) { + return { + bytes: context.base64Decoder(output.bytes), + }; + } + return { $unknown: Object.entries(output)[0] }; +}; + // de_GuardrailAssessment omitted. // de_GuardrailAssessmentList omitted. @@ -1115,6 +1168,11 @@ const de_ToolResultBlock = (output: any, context: __SerdeContext): ToolResultBlo * deserializeAws_restJson1ToolResultContentBlock */ const de_ToolResultContentBlock = (output: any, context: __SerdeContext): ToolResultContentBlock => { + if (output.document != null) { + return { + document: de_DocumentBlock(output.document, context), + }; + } if (output.image != null) { return { image: de_ImageBlock(output.image, context), diff --git a/codegen/sdk-codegen/aws-models/bedrock-runtime.json b/codegen/sdk-codegen/aws-models/bedrock-runtime.json index c25558aff2810..f75983e5d62fe 100644 --- a/codegen/sdk-codegen/aws-models/bedrock-runtime.json +++ b/codegen/sdk-codegen/aws-models/bedrock-runtime.json @@ -755,6 +755,12 @@ "smithy.api#documentation": "

Image to include in the message.

\n \n

This field is only supported by Anthropic Claude 3 models.

\n
" } }, + "document": { + "target": "com.amazonaws.bedrockruntime#DocumentBlock", + "traits": { + "smithy.api#documentation": "

A document to include in the message.

" + } + }, "toolUse": { "target": "com.amazonaws.bedrockruntime#ToolUseBlock", "traits": { @@ -1346,6 +1352,115 @@ "smithy.api#documentation": "

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

" } }, + "com.amazonaws.bedrockruntime#DocumentBlock": { + "type": "structure", + "members": { + "format": { + "target": "com.amazonaws.bedrockruntime#DocumentFormat", + "traits": { + "smithy.api#documentation": "

The format of a document, or its extension.

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

A name for the document.

", + "smithy.api#length": { + "min": 1, + "max": 64 + }, + "smithy.api#required": {} + } + }, + "source": { + "target": "com.amazonaws.bedrockruntime#DocumentSource", + "traits": { + "smithy.api#documentation": "

Contains the content of the document.

", + "smithy.api#required": {} + } + } + }, + "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.

" + } + }, + "com.amazonaws.bedrockruntime#DocumentFormat": { + "type": "enum", + "members": { + "PDF": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "pdf" + } + }, + "CSV": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "csv" + } + }, + "DOC": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "doc" + } + }, + "DOCX": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "docx" + } + }, + "XLS": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "xls" + } + }, + "XLSX": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "xlsx" + } + }, + "HTML": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "html" + } + }, + "TXT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "txt" + } + }, + "MD": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "md" + } + } + } + }, + "com.amazonaws.bedrockruntime#DocumentSource": { + "type": "union", + "members": { + "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#length": { + "min": 1 + } + } + } + }, + "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.

" + } + }, "com.amazonaws.bedrockruntime#GuardrailAssessment": { "type": "structure", "members": { @@ -3153,6 +3268,12 @@ "traits": { "smithy.api#documentation": "

A tool result that is an image.

\n \n

This field is only supported by Anthropic Claude 3 models.

\n
" } + }, + "document": { + "target": "com.amazonaws.bedrockruntime#DocumentBlock", + "traits": { + "smithy.api#documentation": "

A tool result that is a document.

" + } } }, "traits": {