Skip to content

Commit 9e49c84

Browse files
author
awstools
committed
feat(client-bedrock-agent-runtime): Releasing new Prompt Optimization to enhance your prompts for improved performance
1 parent 15509fd commit 9e49c84

File tree

9 files changed

+947
-4
lines changed

9 files changed

+947
-4
lines changed

clients/client-bedrock-agent-runtime/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ InvokeFlow
234234

235235
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/InvokeFlowCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/InvokeFlowCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/InvokeFlowCommandOutput/)
236236

237+
</details>
238+
<details>
239+
<summary>
240+
OptimizePrompt
241+
</summary>
242+
243+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/OptimizePromptCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/OptimizePromptCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/OptimizePromptCommandOutput/)
244+
237245
</details>
238246
<details>
239247
<summary>

clients/client-bedrock-agent-runtime/src/BedrockAgentRuntime.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import {
1515
} from "./commands/GetAgentMemoryCommand";
1616
import { InvokeAgentCommand, InvokeAgentCommandInput, InvokeAgentCommandOutput } from "./commands/InvokeAgentCommand";
1717
import { InvokeFlowCommand, InvokeFlowCommandInput, InvokeFlowCommandOutput } from "./commands/InvokeFlowCommand";
18+
import {
19+
OptimizePromptCommand,
20+
OptimizePromptCommandInput,
21+
OptimizePromptCommandOutput,
22+
} from "./commands/OptimizePromptCommand";
1823
import {
1924
RetrieveAndGenerateCommand,
2025
RetrieveAndGenerateCommandInput,
@@ -27,6 +32,7 @@ const commands = {
2732
GetAgentMemoryCommand,
2833
InvokeAgentCommand,
2934
InvokeFlowCommand,
35+
OptimizePromptCommand,
3036
RetrieveCommand,
3137
RetrieveAndGenerateCommand,
3238
};
@@ -85,6 +91,20 @@ export interface BedrockAgentRuntime {
8591
cb: (err: any, data?: InvokeFlowCommandOutput) => void
8692
): void;
8793

94+
/**
95+
* @see {@link OptimizePromptCommand}
96+
*/
97+
optimizePrompt(
98+
args: OptimizePromptCommandInput,
99+
options?: __HttpHandlerOptions
100+
): Promise<OptimizePromptCommandOutput>;
101+
optimizePrompt(args: OptimizePromptCommandInput, cb: (err: any, data?: OptimizePromptCommandOutput) => void): void;
102+
optimizePrompt(
103+
args: OptimizePromptCommandInput,
104+
options: __HttpHandlerOptions,
105+
cb: (err: any, data?: OptimizePromptCommandOutput) => void
106+
): void;
107+
88108
/**
89109
* @see {@link RetrieveCommand}
90110
*/

clients/client-bedrock-agent-runtime/src/BedrockAgentRuntimeClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import { DeleteAgentMemoryCommandInput, DeleteAgentMemoryCommandOutput } from ".
6363
import { GetAgentMemoryCommandInput, GetAgentMemoryCommandOutput } from "./commands/GetAgentMemoryCommand";
6464
import { InvokeAgentCommandInput, InvokeAgentCommandOutput } from "./commands/InvokeAgentCommand";
6565
import { InvokeFlowCommandInput, InvokeFlowCommandOutput } from "./commands/InvokeFlowCommand";
66+
import { OptimizePromptCommandInput, OptimizePromptCommandOutput } from "./commands/OptimizePromptCommand";
6667
import {
6768
RetrieveAndGenerateCommandInput,
6869
RetrieveAndGenerateCommandOutput,
@@ -87,6 +88,7 @@ export type ServiceInputTypes =
8788
| GetAgentMemoryCommandInput
8889
| InvokeAgentCommandInput
8990
| InvokeFlowCommandInput
91+
| OptimizePromptCommandInput
9092
| RetrieveAndGenerateCommandInput
9193
| RetrieveCommandInput;
9294

@@ -98,6 +100,7 @@ export type ServiceOutputTypes =
98100
| GetAgentMemoryCommandOutput
99101
| InvokeAgentCommandOutput
100102
| InvokeFlowCommandOutput
103+
| OptimizePromptCommandOutput
101104
| RetrieveAndGenerateCommandOutput
102105
| RetrieveCommandOutput;
103106

clients/client-bedrock-agent-runtime/src/commands/InvokeFlowCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface InvokeFlowCommandInput extends InvokeFlowRequest {}
3737
export interface InvokeFlowCommandOutput extends InvokeFlowResponse, __MetadataBearer {}
3838

3939
/**
40-
* <p>Invokes an alias of a flow to run the inputs that you specify and return the output of each node as a stream. If there's an error, the error is returned. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-test.html">Test a flow in Amazon Bedrock</a> in the Amazon Bedrock User Guide.</p>
40+
* <p>Invokes an alias of a flow to run the inputs that you specify and return the output of each node as a stream. If there's an error, the error is returned. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-test.html">Test a flow in Amazon Bedrock</a> in the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html">Amazon Bedrock User Guide</a>.</p>
4141
* <note>
4242
* <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeFlow</code>.</p>
4343
* </note>
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import {
8+
BedrockAgentRuntimeClientResolvedConfig,
9+
ServiceInputTypes,
10+
ServiceOutputTypes,
11+
} from "../BedrockAgentRuntimeClient";
12+
import { commonParams } from "../endpoint/EndpointParameters";
13+
import {
14+
OptimizePromptRequest,
15+
OptimizePromptRequestFilterSensitiveLog,
16+
OptimizePromptResponse,
17+
OptimizePromptResponseFilterSensitiveLog,
18+
} from "../models/models_0";
19+
import { de_OptimizePromptCommand, se_OptimizePromptCommand } from "../protocols/Aws_restJson1";
20+
21+
/**
22+
* @public
23+
*/
24+
export type { __MetadataBearer };
25+
export { $Command };
26+
/**
27+
* @public
28+
*
29+
* The input for {@link OptimizePromptCommand}.
30+
*/
31+
export interface OptimizePromptCommandInput extends OptimizePromptRequest {}
32+
/**
33+
* @public
34+
*
35+
* The output of {@link OptimizePromptCommand}.
36+
*/
37+
export interface OptimizePromptCommandOutput extends OptimizePromptResponse, __MetadataBearer {}
38+
39+
/**
40+
* <p>Optimizes a prompt for the task that you specify. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-optimize.html">Optimize a prompt</a> in the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html">Amazon Bedrock User Guide</a>.</p>
41+
* @example
42+
* Use a bare-bones client and the command you need to make an API call.
43+
* ```javascript
44+
* import { BedrockAgentRuntimeClient, OptimizePromptCommand } from "@aws-sdk/client-bedrock-agent-runtime"; // ES Modules import
45+
* // const { BedrockAgentRuntimeClient, OptimizePromptCommand } = require("@aws-sdk/client-bedrock-agent-runtime"); // CommonJS import
46+
* const client = new BedrockAgentRuntimeClient(config);
47+
* const input = { // OptimizePromptRequest
48+
* input: { // InputPrompt Union: only one key present
49+
* textPrompt: { // TextPrompt
50+
* text: "STRING_VALUE", // required
51+
* },
52+
* },
53+
* targetModelId: "STRING_VALUE", // required
54+
* };
55+
* const command = new OptimizePromptCommand(input);
56+
* const response = await client.send(command);
57+
* // { // OptimizePromptResponse
58+
* // optimizedPrompt: { // OptimizedPromptStream Union: only one key present
59+
* // optimizedPromptEvent: { // OptimizedPromptEvent
60+
* // optimizedPrompt: { // OptimizedPrompt Union: only one key present
61+
* // textPrompt: { // TextPrompt
62+
* // text: "STRING_VALUE", // required
63+
* // },
64+
* // },
65+
* // },
66+
* // analyzePromptEvent: { // AnalyzePromptEvent
67+
* // message: "STRING_VALUE",
68+
* // },
69+
* // internalServerException: { // InternalServerException
70+
* // message: "STRING_VALUE",
71+
* // },
72+
* // throttlingException: { // ThrottlingException
73+
* // message: "STRING_VALUE",
74+
* // },
75+
* // validationException: { // ValidationException
76+
* // message: "STRING_VALUE",
77+
* // },
78+
* // dependencyFailedException: { // DependencyFailedException
79+
* // message: "STRING_VALUE",
80+
* // resourceName: "STRING_VALUE",
81+
* // },
82+
* // accessDeniedException: { // AccessDeniedException
83+
* // message: "STRING_VALUE",
84+
* // },
85+
* // badGatewayException: { // BadGatewayException
86+
* // message: "STRING_VALUE",
87+
* // resourceName: "STRING_VALUE",
88+
* // },
89+
* // },
90+
* // };
91+
*
92+
* ```
93+
*
94+
* @param OptimizePromptCommandInput - {@link OptimizePromptCommandInput}
95+
* @returns {@link OptimizePromptCommandOutput}
96+
* @see {@link OptimizePromptCommandInput} for command's `input` shape.
97+
* @see {@link OptimizePromptCommandOutput} for command's `response` shape.
98+
* @see {@link BedrockAgentRuntimeClientResolvedConfig | config} for BedrockAgentRuntimeClient's `config` shape.
99+
*
100+
* @throws {@link AccessDeniedException} (client fault)
101+
* <p>The request is denied because of missing access permissions. Check your permissions and retry your request.</p>
102+
*
103+
* @throws {@link BadGatewayException} (server fault)
104+
* <p>There was an issue with a dependency due to a server issue. Retry your request.</p>
105+
*
106+
* @throws {@link DependencyFailedException} (client fault)
107+
* <p>There was an issue with a dependency. Check the resource configurations and retry the request.</p>
108+
*
109+
* @throws {@link InternalServerException} (server fault)
110+
* <p>An internal server error occurred. Retry your request.</p>
111+
*
112+
* @throws {@link ThrottlingException} (client fault)
113+
* <p>The number of requests exceeds the limit. Resubmit your request later.</p>
114+
*
115+
* @throws {@link ValidationException} (client fault)
116+
* <p>Input validation failed. Check your request parameters and retry the request.</p>
117+
*
118+
* @throws {@link BedrockAgentRuntimeServiceException}
119+
* <p>Base exception class for all service exceptions from BedrockAgentRuntime service.</p>
120+
*
121+
* @public
122+
*/
123+
export class OptimizePromptCommand extends $Command
124+
.classBuilder<
125+
OptimizePromptCommandInput,
126+
OptimizePromptCommandOutput,
127+
BedrockAgentRuntimeClientResolvedConfig,
128+
ServiceInputTypes,
129+
ServiceOutputTypes
130+
>()
131+
.ep(commonParams)
132+
.m(function (this: any, Command: any, cs: any, config: BedrockAgentRuntimeClientResolvedConfig, o: any) {
133+
return [
134+
getSerdePlugin(config, this.serialize, this.deserialize),
135+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
136+
];
137+
})
138+
.s("AmazonBedrockAgentRunTimeService", "OptimizePrompt", {
139+
/**
140+
* @internal
141+
*/
142+
eventStream: {
143+
output: true,
144+
},
145+
})
146+
.n("BedrockAgentRuntimeClient", "OptimizePromptCommand")
147+
.f(OptimizePromptRequestFilterSensitiveLog, OptimizePromptResponseFilterSensitiveLog)
148+
.ser(se_OptimizePromptCommand)
149+
.de(de_OptimizePromptCommand)
150+
.build() {
151+
/** @internal type navigation helper, not in runtime. */
152+
protected declare static __types: {
153+
api: {
154+
input: OptimizePromptRequest;
155+
output: OptimizePromptResponse;
156+
};
157+
sdk: {
158+
input: OptimizePromptCommandInput;
159+
output: OptimizePromptCommandOutput;
160+
};
161+
};
162+
}

clients/client-bedrock-agent-runtime/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ export * from "./DeleteAgentMemoryCommand";
33
export * from "./GetAgentMemoryCommand";
44
export * from "./InvokeAgentCommand";
55
export * from "./InvokeFlowCommand";
6+
export * from "./OptimizePromptCommand";
67
export * from "./RetrieveAndGenerateCommand";
78
export * from "./RetrieveCommand";

0 commit comments

Comments
 (0)