Skip to content

Commit

Permalink
feat(client-bedrock-agent-runtime): This release introduces a new Rer…
Browse files Browse the repository at this point in the history
…ank API to leverage reranking models (with integration into Knowledge Bases); APIs to upload documents directly into Knowledge Base; RetrieveAndGenerateStream API for streaming response; Guardrails on Retrieve API; and ability to automatically generate filters
  • Loading branch information
awstools committed Dec 2, 2024
1 parent ac2bf51 commit 4ed232e
Show file tree
Hide file tree
Showing 15 changed files with 3,398 additions and 87 deletions.
16 changes: 16 additions & 0 deletions clients/client-bedrock-agent-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ OptimizePrompt

[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>
Rerank
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/RerankCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RerankCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RerankCommandOutput/)

</details>
<details>
<summary>
Expand All @@ -267,3 +275,11 @@ RetrieveAndGenerate
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/RetrieveAndGenerateCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveAndGenerateCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveAndGenerateCommandOutput/)

</details>
<details>
<summary>
RetrieveAndGenerateStream
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/RetrieveAndGenerateStreamCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveAndGenerateStreamCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveAndGenerateStreamCommandOutput/)

</details>
36 changes: 36 additions & 0 deletions clients/client-bedrock-agent-runtime/src/BedrockAgentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ import {
OptimizePromptCommandInput,
OptimizePromptCommandOutput,
} from "./commands/OptimizePromptCommand";
import { RerankCommand, RerankCommandInput, RerankCommandOutput } from "./commands/RerankCommand";
import {
RetrieveAndGenerateCommand,
RetrieveAndGenerateCommandInput,
RetrieveAndGenerateCommandOutput,
} from "./commands/RetrieveAndGenerateCommand";
import {
RetrieveAndGenerateStreamCommand,
RetrieveAndGenerateStreamCommandInput,
RetrieveAndGenerateStreamCommandOutput,
} from "./commands/RetrieveAndGenerateStreamCommand";
import { RetrieveCommand, RetrieveCommandInput, RetrieveCommandOutput } from "./commands/RetrieveCommand";

const commands = {
Expand All @@ -39,8 +45,10 @@ const commands = {
InvokeFlowCommand,
InvokeInlineAgentCommand,
OptimizePromptCommand,
RerankCommand,
RetrieveCommand,
RetrieveAndGenerateCommand,
RetrieveAndGenerateStreamCommand,
};

export interface BedrockAgentRuntime {
Expand Down Expand Up @@ -128,6 +136,17 @@ export interface BedrockAgentRuntime {
cb: (err: any, data?: OptimizePromptCommandOutput) => void
): void;

/**
* @see {@link RerankCommand}
*/
rerank(args: RerankCommandInput, options?: __HttpHandlerOptions): Promise<RerankCommandOutput>;
rerank(args: RerankCommandInput, cb: (err: any, data?: RerankCommandOutput) => void): void;
rerank(
args: RerankCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: RerankCommandOutput) => void
): void;

/**
* @see {@link RetrieveCommand}
*/
Expand Down Expand Up @@ -155,6 +174,23 @@ export interface BedrockAgentRuntime {
options: __HttpHandlerOptions,
cb: (err: any, data?: RetrieveAndGenerateCommandOutput) => void
): void;

/**
* @see {@link RetrieveAndGenerateStreamCommand}
*/
retrieveAndGenerateStream(
args: RetrieveAndGenerateStreamCommandInput,
options?: __HttpHandlerOptions
): Promise<RetrieveAndGenerateStreamCommandOutput>;
retrieveAndGenerateStream(
args: RetrieveAndGenerateStreamCommandInput,
cb: (err: any, data?: RetrieveAndGenerateStreamCommandOutput) => void
): void;
retrieveAndGenerateStream(
args: RetrieveAndGenerateStreamCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: RetrieveAndGenerateStreamCommandOutput) => void
): void;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ import { InvokeAgentCommandInput, InvokeAgentCommandOutput } from "./commands/In
import { InvokeFlowCommandInput, InvokeFlowCommandOutput } from "./commands/InvokeFlowCommand";
import { InvokeInlineAgentCommandInput, InvokeInlineAgentCommandOutput } from "./commands/InvokeInlineAgentCommand";
import { OptimizePromptCommandInput, OptimizePromptCommandOutput } from "./commands/OptimizePromptCommand";
import { RerankCommandInput, RerankCommandOutput } from "./commands/RerankCommand";
import {
RetrieveAndGenerateCommandInput,
RetrieveAndGenerateCommandOutput,
} from "./commands/RetrieveAndGenerateCommand";
import {
RetrieveAndGenerateStreamCommandInput,
RetrieveAndGenerateStreamCommandOutput,
} from "./commands/RetrieveAndGenerateStreamCommand";
import { RetrieveCommandInput, RetrieveCommandOutput } from "./commands/RetrieveCommand";
import {
ClientInputEndpointParameters,
Expand All @@ -91,7 +96,9 @@ export type ServiceInputTypes =
| InvokeFlowCommandInput
| InvokeInlineAgentCommandInput
| OptimizePromptCommandInput
| RerankCommandInput
| RetrieveAndGenerateCommandInput
| RetrieveAndGenerateStreamCommandInput
| RetrieveCommandInput;

/**
Expand All @@ -104,7 +111,9 @@ export type ServiceOutputTypes =
| InvokeFlowCommandOutput
| InvokeInlineAgentCommandOutput
| OptimizePromptCommandOutput
| RerankCommandOutput
| RetrieveAndGenerateCommandOutput
| RetrieveAndGenerateStreamCommandOutput
| RetrieveCommandOutput;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,43 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
* "<RetrievalFilter>",
* ],
* },
* rerankingConfiguration: { // VectorSearchRerankingConfiguration
* type: "BEDROCK_RERANKING_MODEL", // required
* bedrockRerankingConfiguration: { // VectorSearchBedrockRerankingConfiguration
* modelConfiguration: { // VectorSearchBedrockRerankingModelConfiguration
* modelArn: "STRING_VALUE", // required
* additionalModelRequestFields: { // AdditionalModelRequestFields
* "<keys>": "DOCUMENT_VALUE",
* },
* },
* numberOfRerankedResults: Number("int"),
* metadataConfiguration: { // MetadataConfigurationForReranking
* selectionMode: "SELECTIVE" || "ALL", // required
* selectiveModeConfiguration: { // RerankingMetadataSelectiveModeConfiguration Union: only one key present
* fieldsToInclude: [ // FieldsForReranking
* { // FieldForReranking
* fieldName: "STRING_VALUE", // required
* },
* ],
* fieldsToExclude: [
* {
* fieldName: "STRING_VALUE", // required
* },
* ],
* },
* },
* },
* },
* implicitFilterConfiguration: { // ImplicitFilterConfiguration
* metadataAttributes: [ // MetadataAttributeSchemaList // required
* { // MetadataAttributeSchema
* key: "STRING_VALUE", // required
* type: "STRING" || "NUMBER" || "BOOLEAN" || "STRING_LIST", // required
* description: "STRING_VALUE", // required
* },
* ],
* modelArn: "STRING_VALUE", // required
* },
* },
* },
* },
Expand Down Expand Up @@ -229,7 +266,7 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
* // text: "STRING_VALUE", // required
* // },
* // location: { // RetrievalResultLocation
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT", // required
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT" || "CUSTOM", // required
* // s3Location: { // RetrievalResultS3Location
* // uri: "STRING_VALUE",
* // },
Expand All @@ -245,6 +282,9 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
* // sharePointLocation: { // RetrievalResultSharePointLocation
* // url: "STRING_VALUE",
* // },
* // customDocumentLocation: { // RetrievalResultCustomDocumentLocation
* // id: "STRING_VALUE",
* // },
* // },
* // metadata: { // RetrievalResultMetadata
* // "<keys>": "DOCUMENT_VALUE",
Expand Down Expand Up @@ -463,7 +503,7 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
* // text: "STRING_VALUE", // required
* // },
* // location: {
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT", // required
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT" || "CUSTOM", // required
* // s3Location: {
* // uri: "STRING_VALUE",
* // },
Expand All @@ -479,6 +519,9 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
* // sharePointLocation: {
* // url: "STRING_VALUE",
* // },
* // customDocumentLocation: {
* // id: "STRING_VALUE",
* // },
* // },
* // metadata: {
* // "<keys>": "DOCUMENT_VALUE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,43 @@ export interface InvokeInlineAgentCommandOutput extends InvokeInlineAgentRespons
* "<RetrievalFilter>",
* ],
* },
* rerankingConfiguration: { // VectorSearchRerankingConfiguration
* type: "BEDROCK_RERANKING_MODEL", // required
* bedrockRerankingConfiguration: { // VectorSearchBedrockRerankingConfiguration
* modelConfiguration: { // VectorSearchBedrockRerankingModelConfiguration
* modelArn: "STRING_VALUE", // required
* additionalModelRequestFields: { // AdditionalModelRequestFields
* "<keys>": "DOCUMENT_VALUE",
* },
* },
* numberOfRerankedResults: Number("int"),
* metadataConfiguration: { // MetadataConfigurationForReranking
* selectionMode: "SELECTIVE" || "ALL", // required
* selectiveModeConfiguration: { // RerankingMetadataSelectiveModeConfiguration Union: only one key present
* fieldsToInclude: [ // FieldsForReranking
* { // FieldForReranking
* fieldName: "STRING_VALUE", // required
* },
* ],
* fieldsToExclude: [
* {
* fieldName: "STRING_VALUE", // required
* },
* ],
* },
* },
* },
* },
* implicitFilterConfiguration: { // ImplicitFilterConfiguration
* metadataAttributes: [ // MetadataAttributeSchemaList // required
* { // MetadataAttributeSchema
* key: "STRING_VALUE", // required
* type: "STRING" || "NUMBER" || "BOOLEAN" || "STRING_LIST", // required
* description: "STRING_VALUE", // required
* },
* ],
* modelArn: "STRING_VALUE", // required
* },
* },
* },
* },
Expand Down Expand Up @@ -279,7 +316,7 @@ export interface InvokeInlineAgentCommandOutput extends InvokeInlineAgentRespons
* // text: "STRING_VALUE", // required
* // },
* // location: { // RetrievalResultLocation
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT", // required
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT" || "CUSTOM", // required
* // s3Location: { // RetrievalResultS3Location
* // uri: "STRING_VALUE",
* // },
Expand All @@ -295,6 +332,9 @@ export interface InvokeInlineAgentCommandOutput extends InvokeInlineAgentRespons
* // sharePointLocation: { // RetrievalResultSharePointLocation
* // url: "STRING_VALUE",
* // },
* // customDocumentLocation: { // RetrievalResultCustomDocumentLocation
* // id: "STRING_VALUE",
* // },
* // },
* // metadata: { // RetrievalResultMetadata
* // "<keys>": "DOCUMENT_VALUE",
Expand Down Expand Up @@ -513,7 +553,7 @@ export interface InvokeInlineAgentCommandOutput extends InvokeInlineAgentRespons
* // text: "STRING_VALUE", // required
* // },
* // location: {
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT", // required
* // type: "S3" || "WEB" || "CONFLUENCE" || "SALESFORCE" || "SHAREPOINT" || "CUSTOM", // required
* // s3Location: {
* // uri: "STRING_VALUE",
* // },
Expand All @@ -529,6 +569,9 @@ export interface InvokeInlineAgentCommandOutput extends InvokeInlineAgentRespons
* // sharePointLocation: {
* // url: "STRING_VALUE",
* // },
* // customDocumentLocation: {
* // id: "STRING_VALUE",
* // },
* // },
* // metadata: {
* // "<keys>": "DOCUMENT_VALUE",
Expand Down
Loading

0 comments on commit 4ed232e

Please sign in to comment.