Skip to content

Commit 39a8983

Browse files
author
awstools
committed
feat(client-bedrock-agent-runtime): This release introduces zero-setup file upload support for the RetrieveAndGenerate API. This allows you to chat with your data without setting up a Knowledge Base.
1 parent 215c945 commit 39a8983

File tree

4 files changed

+431
-1
lines changed

4 files changed

+431
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface RetrieveAndGenerateCommandOutput extends RetrieveAndGenerateRes
4949
* text: "STRING_VALUE", // required
5050
* },
5151
* retrieveAndGenerateConfiguration: { // RetrieveAndGenerateConfiguration
52-
* type: "KNOWLEDGE_BASE", // required
52+
* type: "KNOWLEDGE_BASE" || "EXTERNAL_SOURCES", // required
5353
* knowledgeBaseConfiguration: { // KnowledgeBaseRetrieveAndGenerateConfiguration
5454
* knowledgeBaseId: "STRING_VALUE", // required
5555
* modelArn: "STRING_VALUE", // required
@@ -113,6 +113,27 @@ export interface RetrieveAndGenerateCommandOutput extends RetrieveAndGenerateRes
113113
* },
114114
* },
115115
* },
116+
* externalSourcesConfiguration: { // ExternalSourcesRetrieveAndGenerateConfiguration
117+
* modelArn: "STRING_VALUE", // required
118+
* sources: [ // ExternalSources // required
119+
* { // ExternalSource
120+
* sourceType: "S3" || "BYTE_CONTENT", // required
121+
* s3Location: { // S3ObjectDoc
122+
* uri: "STRING_VALUE", // required
123+
* },
124+
* byteContent: { // ByteContentDoc
125+
* identifier: "STRING_VALUE", // required
126+
* contentType: "STRING_VALUE", // required
127+
* data: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") // required
128+
* },
129+
* },
130+
* ],
131+
* generationConfiguration: { // ExternalSourcesGenerationConfiguration
132+
* promptTemplate: {
133+
* textPromptTemplate: "STRING_VALUE",
134+
* },
135+
* },
136+
* },
116137
* },
117138
* sessionConfiguration: { // RetrieveAndGenerateSessionConfiguration
118139
* kmsKeyArn: "STRING_VALUE", // required

clients/client-bedrock-agent-runtime/src/models/models_0.ts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,116 @@ export interface PromptTemplate {
22642264
textPromptTemplate?: string;
22652265
}
22662266

2267+
/**
2268+
* <p>Contains the generation configuration of the external source wrapper object.</p>
2269+
* @public
2270+
*/
2271+
export interface ExternalSourcesGenerationConfiguration {
2272+
/**
2273+
* <p>Contain the textPromptTemplate string for the external source wrapper object.</p>
2274+
* @public
2275+
*/
2276+
promptTemplate?: PromptTemplate;
2277+
}
2278+
2279+
/**
2280+
* <p>This property contains the document to chat with, along with its attributes.</p>
2281+
* @public
2282+
*/
2283+
export interface ByteContentDoc {
2284+
/**
2285+
* <p>The file name of the document contained in the wrapper object.</p>
2286+
* @public
2287+
*/
2288+
identifier: string | undefined;
2289+
2290+
/**
2291+
* <p>The MIME type of the document contained in the wrapper object.</p>
2292+
* @public
2293+
*/
2294+
contentType: string | undefined;
2295+
2296+
/**
2297+
* <p>The byte value of the file to upload, encoded as a Base-64 string.</p>
2298+
* @public
2299+
*/
2300+
data: Uint8Array | undefined;
2301+
}
2302+
2303+
/**
2304+
* <p>The unique wrapper object of the document from the S3 location.</p>
2305+
* @public
2306+
*/
2307+
export interface S3ObjectDoc {
2308+
/**
2309+
* <p>The file location of the S3 wrapper object.</p>
2310+
* @public
2311+
*/
2312+
uri: string | undefined;
2313+
}
2314+
2315+
/**
2316+
* @public
2317+
* @enum
2318+
*/
2319+
export const ExternalSourceType = {
2320+
BYTE_CONTENT: "BYTE_CONTENT",
2321+
S3: "S3",
2322+
} as const;
2323+
2324+
/**
2325+
* @public
2326+
*/
2327+
export type ExternalSourceType = (typeof ExternalSourceType)[keyof typeof ExternalSourceType];
2328+
2329+
/**
2330+
* <p>The unique external source of the content contained in the wrapper object.</p>
2331+
* @public
2332+
*/
2333+
export interface ExternalSource {
2334+
/**
2335+
* <p>The source type of the external source wrapper object.</p>
2336+
* @public
2337+
*/
2338+
sourceType: ExternalSourceType | undefined;
2339+
2340+
/**
2341+
* <p>The S3 location of the external source wrapper object.</p>
2342+
* @public
2343+
*/
2344+
s3Location?: S3ObjectDoc;
2345+
2346+
/**
2347+
* <p>The identifier, contentType, and data of the external source wrapper object.</p>
2348+
* @public
2349+
*/
2350+
byteContent?: ByteContentDoc;
2351+
}
2352+
2353+
/**
2354+
* <p>The configurations of the external source wrapper object in the retrieveAndGenerate function.</p>
2355+
* @public
2356+
*/
2357+
export interface ExternalSourcesRetrieveAndGenerateConfiguration {
2358+
/**
2359+
* <p>The modelArn used with the external source wrapper object in the retrieveAndGenerate function.</p>
2360+
* @public
2361+
*/
2362+
modelArn: string | undefined;
2363+
2364+
/**
2365+
* <p>The document used with the external source wrapper object in the retrieveAndGenerate function.</p>
2366+
* @public
2367+
*/
2368+
sources: ExternalSource[] | undefined;
2369+
2370+
/**
2371+
* <p>The prompt used with the external source wrapper object with the retrieveAndGenerate function.</p>
2372+
* @public
2373+
*/
2374+
generationConfiguration?: ExternalSourcesGenerationConfiguration;
2375+
}
2376+
22672377
/**
22682378
* <p>Contains configurations for response generation based on the knowledge base query results.</p>
22692379
* <p>This data type is used in the following API operations:</p>
@@ -2329,6 +2439,7 @@ export type SearchType = (typeof SearchType)[keyof typeof SearchType];
23292439
* @enum
23302440
*/
23312441
export const RetrieveAndGenerateType = {
2442+
EXTERNAL_SOURCES: "EXTERNAL_SOURCES",
23322443
KNOWLEDGE_BASE: "KNOWLEDGE_BASE",
23332444
} as const;
23342445

@@ -2913,6 +3024,12 @@ export interface RetrieveAndGenerateConfiguration {
29133024
* @public
29143025
*/
29153026
knowledgeBaseConfiguration?: KnowledgeBaseRetrieveAndGenerateConfiguration;
3027+
3028+
/**
3029+
* <p>The configuration used with the external source wrapper object in the retrieveAndGenerate function.</p>
3030+
* @public
3031+
*/
3032+
externalSourcesConfiguration?: ExternalSourcesRetrieveAndGenerateConfiguration;
29163033
}
29173034

29183035
/**
@@ -3310,6 +3427,46 @@ export const PromptTemplateFilterSensitiveLog = (obj: PromptTemplate): any => ({
33103427
...(obj.textPromptTemplate && { textPromptTemplate: SENSITIVE_STRING }),
33113428
});
33123429

3430+
/**
3431+
* @internal
3432+
*/
3433+
export const ExternalSourcesGenerationConfigurationFilterSensitiveLog = (
3434+
obj: ExternalSourcesGenerationConfiguration
3435+
): any => ({
3436+
...obj,
3437+
...(obj.promptTemplate && { promptTemplate: PromptTemplateFilterSensitiveLog(obj.promptTemplate) }),
3438+
});
3439+
3440+
/**
3441+
* @internal
3442+
*/
3443+
export const ByteContentDocFilterSensitiveLog = (obj: ByteContentDoc): any => ({
3444+
...obj,
3445+
...(obj.identifier && { identifier: SENSITIVE_STRING }),
3446+
...(obj.data && { data: SENSITIVE_STRING }),
3447+
});
3448+
3449+
/**
3450+
* @internal
3451+
*/
3452+
export const ExternalSourceFilterSensitiveLog = (obj: ExternalSource): any => ({
3453+
...obj,
3454+
...(obj.byteContent && { byteContent: ByteContentDocFilterSensitiveLog(obj.byteContent) }),
3455+
});
3456+
3457+
/**
3458+
* @internal
3459+
*/
3460+
export const ExternalSourcesRetrieveAndGenerateConfigurationFilterSensitiveLog = (
3461+
obj: ExternalSourcesRetrieveAndGenerateConfiguration
3462+
): any => ({
3463+
...obj,
3464+
...(obj.sources && { sources: obj.sources.map((item) => ExternalSourceFilterSensitiveLog(item)) }),
3465+
...(obj.generationConfiguration && {
3466+
generationConfiguration: ExternalSourcesGenerationConfigurationFilterSensitiveLog(obj.generationConfiguration),
3467+
}),
3468+
});
3469+
33133470
/**
33143471
* @internal
33153472
*/
@@ -3435,6 +3592,11 @@ export const RetrieveAndGenerateConfigurationFilterSensitiveLog = (obj: Retrieve
34353592
obj.knowledgeBaseConfiguration
34363593
),
34373594
}),
3595+
...(obj.externalSourcesConfiguration && {
3596+
externalSourcesConfiguration: ExternalSourcesRetrieveAndGenerateConfigurationFilterSensitiveLog(
3597+
obj.externalSourcesConfiguration
3598+
),
3599+
}),
34383600
});
34393601

34403602
/**

clients/client-bedrock-agent-runtime/src/protocols/Aws_restJson1.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ import {
4242
ApiResult,
4343
Attribution,
4444
BadGatewayException,
45+
ByteContentDoc,
4546
Citation,
4647
ConflictException,
4748
ContentBody,
4849
DependencyFailedException,
50+
ExternalSource,
51+
ExternalSourcesGenerationConfiguration,
52+
ExternalSourcesRetrieveAndGenerateConfiguration,
4953
FilterAttribute,
5054
FunctionResult,
5155
GenerationConfiguration,
@@ -73,6 +77,7 @@ import {
7377
RetrieveAndGenerateSessionConfiguration,
7478
RetrievedReference,
7579
ReturnControlPayload,
80+
S3ObjectDoc,
7681
ServiceQuotaExceededException,
7782
SessionState,
7883
ThrottlingException,
@@ -617,8 +622,57 @@ const de_ValidationException_event = async (output: any, context: __SerdeContext
617622
};
618623
// se_ApiResult omitted.
619624

625+
/**
626+
* serializeAws_restJson1ByteContentDoc
627+
*/
628+
const se_ByteContentDoc = (input: ByteContentDoc, context: __SerdeContext): any => {
629+
return take(input, {
630+
contentType: [],
631+
data: context.base64Encoder,
632+
identifier: [],
633+
});
634+
};
635+
620636
// se_ContentBody omitted.
621637

638+
/**
639+
* serializeAws_restJson1ExternalSource
640+
*/
641+
const se_ExternalSource = (input: ExternalSource, context: __SerdeContext): any => {
642+
return take(input, {
643+
byteContent: (_) => se_ByteContentDoc(_, context),
644+
s3Location: _json,
645+
sourceType: [],
646+
});
647+
};
648+
649+
/**
650+
* serializeAws_restJson1ExternalSources
651+
*/
652+
const se_ExternalSources = (input: ExternalSource[], context: __SerdeContext): any => {
653+
return input
654+
.filter((e: any) => e != null)
655+
.map((entry) => {
656+
return se_ExternalSource(entry, context);
657+
});
658+
};
659+
660+
// se_ExternalSourcesGenerationConfiguration omitted.
661+
662+
/**
663+
* serializeAws_restJson1ExternalSourcesRetrieveAndGenerateConfiguration
664+
*/
665+
const se_ExternalSourcesRetrieveAndGenerateConfiguration = (
666+
input: ExternalSourcesRetrieveAndGenerateConfiguration,
667+
context: __SerdeContext
668+
): any => {
669+
return take(input, {
670+
generationConfiguration: _json,
671+
modelArn: [],
672+
sources: (_) => se_ExternalSources(_, context),
673+
});
674+
};
675+
622676
/**
623677
* serializeAws_restJson1FilterAttribute
624678
*/
@@ -727,6 +781,7 @@ const se_RetrievalFilterList = (input: RetrievalFilter[], context: __SerdeContex
727781
*/
728782
const se_RetrieveAndGenerateConfiguration = (input: RetrieveAndGenerateConfiguration, context: __SerdeContext): any => {
729783
return take(input, {
784+
externalSourcesConfiguration: (_) => se_ExternalSourcesRetrieveAndGenerateConfiguration(_, context),
730785
knowledgeBaseConfiguration: (_) => se_KnowledgeBaseRetrieveAndGenerateConfiguration(_, context),
731786
type: [],
732787
});
@@ -738,6 +793,8 @@ const se_RetrieveAndGenerateConfiguration = (input: RetrieveAndGenerateConfigura
738793

739794
// se_ReturnControlInvocationResults omitted.
740795

796+
// se_S3ObjectDoc omitted.
797+
741798
// se_SessionAttributesMap omitted.
742799

743800
// se_SessionState omitted.

0 commit comments

Comments
 (0)