Skip to content

Commit 6607253

Browse files
author
awstools
committed
feat(client-bedrock-runtime): Add Prompt management support to Bedrock runtime APIs: Converse, ConverseStream, InvokeModel, InvokeModelWithStreamingResponse
1 parent 3d8d0bb commit 6607253

File tree

7 files changed

+189
-57
lines changed

7 files changed

+189
-57
lines changed

clients/client-bedrock-runtime/src/commands/ConverseCommand.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MetadataBearer as __MetadataBearer } from "@smithy/types";
66

77
import { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BedrockRuntimeClient";
88
import { commonParams } from "../endpoint/EndpointParameters";
9-
import { ConverseRequest, ConverseResponse } from "../models/models_0";
9+
import { ConverseRequest, ConverseRequestFilterSensitiveLog, ConverseResponse } from "../models/models_0";
1010
import { de_ConverseCommand, se_ConverseCommand } from "../protocols/Aws_restJson1";
1111

1212
/**
@@ -34,6 +34,8 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
3434
* If a model has unique inference parameters, you can also pass those unique parameters
3535
* to the model.</p>
3636
* <p>Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to generate the response.</p>
37+
* <p>You can submit a prompt by including it in the <code>messages</code> field, specifying the <code>modelId</code> of a foundation model or inference profile to run inference on it, and including any other fields that are relevant to your use case.</p>
38+
* <p>You can also submit a prompt from Prompt management by specifying the ARN of the prompt version and including a map of variables to values in the <code>promptVariables</code> field. You can append more messages to the prompt by using the <code>messages</code> field. If you use a prompt from Prompt management, you can't include the following fields in the request: <code>additionalModelRequestFields</code>, <code>inferenceConfig</code>, <code>system</code>, or <code>toolConfig</code>. Instead, these fields must be defined through Prompt management. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-use.html">Use a prompt from Prompt management</a>.</p>
3739
* <p>For information about the Converse API, see <i>Use the Converse API</i> in the <i>Amazon Bedrock User Guide</i>.
3840
* To use a guardrail, see <i>Use a guardrail with the Converse API</i> in the <i>Amazon Bedrock User Guide</i>.
3941
* To use a tool with a model, see <i>Tool use (Function calling)</i> in the <i>Amazon Bedrock User Guide</i>
@@ -49,7 +51,7 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
4951
* const client = new BedrockRuntimeClient(config);
5052
* const input = { // ConverseRequest
5153
* modelId: "STRING_VALUE", // required
52-
* messages: [ // Messages // required
54+
* messages: [ // Messages
5355
* { // Message
5456
* role: "user" || "assistant", // required
5557
* content: [ // ContentBlocks // required
@@ -155,6 +157,11 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
155157
* trace: "enabled" || "disabled",
156158
* },
157159
* additionalModelRequestFields: "DOCUMENT_VALUE",
160+
* promptVariables: { // PromptVariableMap
161+
* "<keys>": { // PromptVariableValues Union: only one key present
162+
* text: "STRING_VALUE",
163+
* },
164+
* },
158165
* additionalModelResponseFieldPaths: [ // AdditionalModelResponseFieldPaths
159166
* "STRING_VALUE",
160167
* ],
@@ -466,7 +473,7 @@ export class ConverseCommand extends $Command
466473
})
467474
.s("AmazonBedrockFrontendService", "Converse", {})
468475
.n("BedrockRuntimeClient", "ConverseCommand")
469-
.f(void 0, void 0)
476+
.f(ConverseRequestFilterSensitiveLog, void 0)
470477
.ser(se_ConverseCommand)
471478
.de(de_ConverseCommand)
472479
.build() {

clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTyp
88
import { commonParams } from "../endpoint/EndpointParameters";
99
import {
1010
ConverseStreamRequest,
11+
ConverseStreamRequestFilterSensitiveLog,
1112
ConverseStreamResponse,
1213
ConverseStreamResponseFilterSensitiveLog,
1314
} from "../models/models_0";
@@ -44,6 +45,8 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
4445
* <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>ConverseStream</code>.</p>
4546
* </note>
4647
* <p>Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to generate the response.</p>
48+
* <p>You can submit a prompt by including it in the <code>messages</code> field, specifying the <code>modelId</code> of a foundation model or inference profile to run inference on it, and including any other fields that are relevant to your use case.</p>
49+
* <p>You can also submit a prompt from Prompt management by specifying the ARN of the prompt version and including a map of variables to values in the <code>promptVariables</code> field. You can append more messages to the prompt by using the <code>messages</code> field. If you use a prompt from Prompt management, you can't include the following fields in the request: <code>additionalModelRequestFields</code>, <code>inferenceConfig</code>, <code>system</code>, or <code>toolConfig</code>. Instead, these fields must be defined through Prompt management. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-use.html">Use a prompt from Prompt management</a>.</p>
4750
* <p>For information about the Converse API, see <i>Use the Converse API</i> in the <i>Amazon Bedrock User Guide</i>.
4851
* To use a guardrail, see <i>Use a guardrail with the Converse API</i> in the <i>Amazon Bedrock User Guide</i>.
4952
* To use a tool with a model, see <i>Tool use (Function calling)</i> in the <i>Amazon Bedrock User Guide</i>
@@ -59,7 +62,7 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
5962
* const client = new BedrockRuntimeClient(config);
6063
* const input = { // ConverseStreamRequest
6164
* modelId: "STRING_VALUE", // required
62-
* messages: [ // Messages // required
65+
* messages: [ // Messages
6366
* { // Message
6467
* role: "user" || "assistant", // required
6568
* content: [ // ContentBlocks // required
@@ -166,6 +169,11 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
166169
* streamProcessingMode: "sync" || "async",
167170
* },
168171
* additionalModelRequestFields: "DOCUMENT_VALUE",
172+
* promptVariables: { // PromptVariableMap
173+
* "<keys>": { // PromptVariableValues Union: only one key present
174+
* text: "STRING_VALUE",
175+
* },
176+
* },
169177
* additionalModelResponseFieldPaths: [ // AdditionalModelResponseFieldPaths
170178
* "STRING_VALUE",
171179
* ],
@@ -472,7 +480,7 @@ export class ConverseStreamCommand extends $Command
472480
},
473481
})
474482
.n("BedrockRuntimeClient", "ConverseStreamCommand")
475-
.f(void 0, ConverseStreamResponseFilterSensitiveLog)
483+
.f(ConverseStreamRequestFilterSensitiveLog, ConverseStreamResponseFilterSensitiveLog)
476484
.ser(se_ConverseStreamCommand)
477485
.de(de_ConverseStreamCommand)
478486
.build() {

clients/client-bedrock-runtime/src/commands/InvokeModelCommand.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export { $Command };
2424
* @public
2525
*/
2626
export type InvokeModelCommandInputType = Omit<InvokeModelRequest, "body"> & {
27-
body: BlobPayloadInputTypes;
27+
body?: BlobPayloadInputTypes;
2828
};
2929

3030
/**
@@ -60,7 +60,7 @@ export interface InvokeModelCommandOutput extends InvokeModelCommandOutputType,
6060
* // const { BedrockRuntimeClient, InvokeModelCommand } = require("@aws-sdk/client-bedrock-runtime"); // CommonJS import
6161
* const client = new BedrockRuntimeClient(config);
6262
* const input = { // InvokeModelRequest
63-
* body: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") // required
63+
* body: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
6464
* contentType: "STRING_VALUE",
6565
* accept: "STRING_VALUE",
6666
* modelId: "STRING_VALUE", // required

clients/client-bedrock-runtime/src/commands/InvokeModelWithResponseStreamCommand.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export { $Command };
2626
* @public
2727
*/
2828
export type InvokeModelWithResponseStreamCommandInputType = Omit<InvokeModelWithResponseStreamRequest, "body"> & {
29-
body: BlobPayloadInputTypes;
29+
body?: BlobPayloadInputTypes;
3030
};
3131

3232
/**
@@ -62,7 +62,7 @@ export interface InvokeModelWithResponseStreamCommandOutput
6262
* // const { BedrockRuntimeClient, InvokeModelWithResponseStreamCommand } = require("@aws-sdk/client-bedrock-runtime"); // CommonJS import
6363
* const client = new BedrockRuntimeClient(config);
6464
* const input = { // InvokeModelWithResponseStreamRequest
65-
* body: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") // required
65+
* body: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
6666
* contentType: "STRING_VALUE",
6767
* accept: "STRING_VALUE",
6868
* modelId: "STRING_VALUE", // required

0 commit comments

Comments
 (0)