Skip to content

Commit

Permalink
feat(client-bedrock-agent-runtime): Releasing new Prompt Optimization…
Browse files Browse the repository at this point in the history
… to enhance your prompts for improved performance
  • Loading branch information
awstools committed Nov 20, 2024
1 parent 15509fd commit 9e49c84
Show file tree
Hide file tree
Showing 9 changed files with 947 additions and 4 deletions.
8 changes: 8 additions & 0 deletions clients/client-bedrock-agent-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ InvokeFlow

[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/)

</details>
<details>
<summary>
OptimizePrompt
</summary>

[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/)

</details>
<details>
<summary>
Expand Down
20 changes: 20 additions & 0 deletions clients/client-bedrock-agent-runtime/src/BedrockAgentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import {
} from "./commands/GetAgentMemoryCommand";
import { InvokeAgentCommand, InvokeAgentCommandInput, InvokeAgentCommandOutput } from "./commands/InvokeAgentCommand";
import { InvokeFlowCommand, InvokeFlowCommandInput, InvokeFlowCommandOutput } from "./commands/InvokeFlowCommand";
import {
OptimizePromptCommand,
OptimizePromptCommandInput,
OptimizePromptCommandOutput,
} from "./commands/OptimizePromptCommand";
import {
RetrieveAndGenerateCommand,
RetrieveAndGenerateCommandInput,
Expand All @@ -27,6 +32,7 @@ const commands = {
GetAgentMemoryCommand,
InvokeAgentCommand,
InvokeFlowCommand,
OptimizePromptCommand,
RetrieveCommand,
RetrieveAndGenerateCommand,
};
Expand Down Expand Up @@ -85,6 +91,20 @@ export interface BedrockAgentRuntime {
cb: (err: any, data?: InvokeFlowCommandOutput) => void
): void;

/**
* @see {@link OptimizePromptCommand}
*/
optimizePrompt(
args: OptimizePromptCommandInput,
options?: __HttpHandlerOptions
): Promise<OptimizePromptCommandOutput>;
optimizePrompt(args: OptimizePromptCommandInput, cb: (err: any, data?: OptimizePromptCommandOutput) => void): void;
optimizePrompt(
args: OptimizePromptCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: OptimizePromptCommandOutput) => void
): void;

/**
* @see {@link RetrieveCommand}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { DeleteAgentMemoryCommandInput, DeleteAgentMemoryCommandOutput } from ".
import { GetAgentMemoryCommandInput, GetAgentMemoryCommandOutput } from "./commands/GetAgentMemoryCommand";
import { InvokeAgentCommandInput, InvokeAgentCommandOutput } from "./commands/InvokeAgentCommand";
import { InvokeFlowCommandInput, InvokeFlowCommandOutput } from "./commands/InvokeFlowCommand";
import { OptimizePromptCommandInput, OptimizePromptCommandOutput } from "./commands/OptimizePromptCommand";
import {
RetrieveAndGenerateCommandInput,
RetrieveAndGenerateCommandOutput,
Expand All @@ -87,6 +88,7 @@ export type ServiceInputTypes =
| GetAgentMemoryCommandInput
| InvokeAgentCommandInput
| InvokeFlowCommandInput
| OptimizePromptCommandInput
| RetrieveAndGenerateCommandInput
| RetrieveCommandInput;

Expand All @@ -98,6 +100,7 @@ export type ServiceOutputTypes =
| GetAgentMemoryCommandOutput
| InvokeAgentCommandOutput
| InvokeFlowCommandOutput
| OptimizePromptCommandOutput
| RetrieveAndGenerateCommandOutput
| RetrieveCommandOutput;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface InvokeFlowCommandInput extends InvokeFlowRequest {}
export interface InvokeFlowCommandOutput extends InvokeFlowResponse, __MetadataBearer {}

/**
* <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>
* <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>
* <note>
* <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeFlow</code>.</p>
* </note>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// 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 {
BedrockAgentRuntimeClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes,
} from "../BedrockAgentRuntimeClient";
import { commonParams } from "../endpoint/EndpointParameters";
import {
OptimizePromptRequest,
OptimizePromptRequestFilterSensitiveLog,
OptimizePromptResponse,
OptimizePromptResponseFilterSensitiveLog,
} from "../models/models_0";
import { de_OptimizePromptCommand, se_OptimizePromptCommand } from "../protocols/Aws_restJson1";

/**
* @public
*/
export type { __MetadataBearer };
export { $Command };
/**
* @public
*
* The input for {@link OptimizePromptCommand}.
*/
export interface OptimizePromptCommandInput extends OptimizePromptRequest {}
/**
* @public
*
* The output of {@link OptimizePromptCommand}.
*/
export interface OptimizePromptCommandOutput extends OptimizePromptResponse, __MetadataBearer {}

/**
* <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>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { BedrockAgentRuntimeClient, OptimizePromptCommand } from "@aws-sdk/client-bedrock-agent-runtime"; // ES Modules import
* // const { BedrockAgentRuntimeClient, OptimizePromptCommand } = require("@aws-sdk/client-bedrock-agent-runtime"); // CommonJS import
* const client = new BedrockAgentRuntimeClient(config);
* const input = { // OptimizePromptRequest
* input: { // InputPrompt Union: only one key present
* textPrompt: { // TextPrompt
* text: "STRING_VALUE", // required
* },
* },
* targetModelId: "STRING_VALUE", // required
* };
* const command = new OptimizePromptCommand(input);
* const response = await client.send(command);
* // { // OptimizePromptResponse
* // optimizedPrompt: { // OptimizedPromptStream Union: only one key present
* // optimizedPromptEvent: { // OptimizedPromptEvent
* // optimizedPrompt: { // OptimizedPrompt Union: only one key present
* // textPrompt: { // TextPrompt
* // text: "STRING_VALUE", // required
* // },
* // },
* // },
* // analyzePromptEvent: { // AnalyzePromptEvent
* // message: "STRING_VALUE",
* // },
* // internalServerException: { // InternalServerException
* // message: "STRING_VALUE",
* // },
* // throttlingException: { // ThrottlingException
* // message: "STRING_VALUE",
* // },
* // validationException: { // ValidationException
* // message: "STRING_VALUE",
* // },
* // dependencyFailedException: { // DependencyFailedException
* // message: "STRING_VALUE",
* // resourceName: "STRING_VALUE",
* // },
* // accessDeniedException: { // AccessDeniedException
* // message: "STRING_VALUE",
* // },
* // badGatewayException: { // BadGatewayException
* // message: "STRING_VALUE",
* // resourceName: "STRING_VALUE",
* // },
* // },
* // };
*
* ```
*
* @param OptimizePromptCommandInput - {@link OptimizePromptCommandInput}
* @returns {@link OptimizePromptCommandOutput}
* @see {@link OptimizePromptCommandInput} for command's `input` shape.
* @see {@link OptimizePromptCommandOutput} for command's `response` shape.
* @see {@link BedrockAgentRuntimeClientResolvedConfig | config} for BedrockAgentRuntimeClient's `config` shape.
*
* @throws {@link AccessDeniedException} (client fault)
* <p>The request is denied because of missing access permissions. Check your permissions and retry your request.</p>
*
* @throws {@link BadGatewayException} (server fault)
* <p>There was an issue with a dependency due to a server issue. Retry your request.</p>
*
* @throws {@link DependencyFailedException} (client fault)
* <p>There was an issue with a dependency. Check the resource configurations and retry the request.</p>
*
* @throws {@link InternalServerException} (server fault)
* <p>An internal server error occurred. Retry your request.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>The number of requests exceeds the limit. Resubmit your request later.</p>
*
* @throws {@link ValidationException} (client fault)
* <p>Input validation failed. Check your request parameters and retry the request.</p>
*
* @throws {@link BedrockAgentRuntimeServiceException}
* <p>Base exception class for all service exceptions from BedrockAgentRuntime service.</p>
*
* @public
*/
export class OptimizePromptCommand extends $Command
.classBuilder<
OptimizePromptCommandInput,
OptimizePromptCommandOutput,
BedrockAgentRuntimeClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: BedrockAgentRuntimeClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("AmazonBedrockAgentRunTimeService", "OptimizePrompt", {
/**
* @internal
*/
eventStream: {
output: true,
},
})
.n("BedrockAgentRuntimeClient", "OptimizePromptCommand")
.f(OptimizePromptRequestFilterSensitiveLog, OptimizePromptResponseFilterSensitiveLog)
.ser(se_OptimizePromptCommand)
.de(de_OptimizePromptCommand)
.build() {
/** @internal type navigation helper, not in runtime. */
protected declare static __types: {
api: {
input: OptimizePromptRequest;
output: OptimizePromptResponse;
};
sdk: {
input: OptimizePromptCommandInput;
output: OptimizePromptCommandOutput;
};
};
}
1 change: 1 addition & 0 deletions clients/client-bedrock-agent-runtime/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export * from "./DeleteAgentMemoryCommand";
export * from "./GetAgentMemoryCommand";
export * from "./InvokeAgentCommand";
export * from "./InvokeFlowCommand";
export * from "./OptimizePromptCommand";
export * from "./RetrieveAndGenerateCommand";
export * from "./RetrieveCommand";
Loading

0 comments on commit 9e49c84

Please sign in to comment.