Skip to content

Commit

Permalink
feat(client-bedrock-agent-runtime): This release introduces zero-setu…
Browse files Browse the repository at this point in the history
…p file upload support for the RetrieveAndGenerate API. This allows you to chat with your data without setting up a Knowledge Base.
  • Loading branch information
awstools committed Apr 23, 2024
1 parent 215c945 commit 39a8983
Show file tree
Hide file tree
Showing 4 changed files with 431 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface RetrieveAndGenerateCommandOutput extends RetrieveAndGenerateRes
* text: "STRING_VALUE", // required
* },
* retrieveAndGenerateConfiguration: { // RetrieveAndGenerateConfiguration
* type: "KNOWLEDGE_BASE", // required
* type: "KNOWLEDGE_BASE" || "EXTERNAL_SOURCES", // required
* knowledgeBaseConfiguration: { // KnowledgeBaseRetrieveAndGenerateConfiguration
* knowledgeBaseId: "STRING_VALUE", // required
* modelArn: "STRING_VALUE", // required
Expand Down Expand Up @@ -113,6 +113,27 @@ export interface RetrieveAndGenerateCommandOutput extends RetrieveAndGenerateRes
* },
* },
* },
* externalSourcesConfiguration: { // ExternalSourcesRetrieveAndGenerateConfiguration
* modelArn: "STRING_VALUE", // required
* sources: [ // ExternalSources // required
* { // ExternalSource
* sourceType: "S3" || "BYTE_CONTENT", // required
* s3Location: { // S3ObjectDoc
* uri: "STRING_VALUE", // required
* },
* byteContent: { // ByteContentDoc
* identifier: "STRING_VALUE", // required
* contentType: "STRING_VALUE", // required
* data: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") // required
* },
* },
* ],
* generationConfiguration: { // ExternalSourcesGenerationConfiguration
* promptTemplate: {
* textPromptTemplate: "STRING_VALUE",
* },
* },
* },
* },
* sessionConfiguration: { // RetrieveAndGenerateSessionConfiguration
* kmsKeyArn: "STRING_VALUE", // required
Expand Down
162 changes: 162 additions & 0 deletions clients/client-bedrock-agent-runtime/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,116 @@ export interface PromptTemplate {
textPromptTemplate?: string;
}

/**
* <p>Contains the generation configuration of the external source wrapper object.</p>
* @public
*/
export interface ExternalSourcesGenerationConfiguration {
/**
* <p>Contain the textPromptTemplate string for the external source wrapper object.</p>
* @public
*/
promptTemplate?: PromptTemplate;
}

/**
* <p>This property contains the document to chat with, along with its attributes.</p>
* @public
*/
export interface ByteContentDoc {
/**
* <p>The file name of the document contained in the wrapper object.</p>
* @public
*/
identifier: string | undefined;

/**
* <p>The MIME type of the document contained in the wrapper object.</p>
* @public
*/
contentType: string | undefined;

/**
* <p>The byte value of the file to upload, encoded as a Base-64 string.</p>
* @public
*/
data: Uint8Array | undefined;
}

/**
* <p>The unique wrapper object of the document from the S3 location.</p>
* @public
*/
export interface S3ObjectDoc {
/**
* <p>The file location of the S3 wrapper object.</p>
* @public
*/
uri: string | undefined;
}

/**
* @public
* @enum
*/
export const ExternalSourceType = {
BYTE_CONTENT: "BYTE_CONTENT",
S3: "S3",
} as const;

/**
* @public
*/
export type ExternalSourceType = (typeof ExternalSourceType)[keyof typeof ExternalSourceType];

/**
* <p>The unique external source of the content contained in the wrapper object.</p>
* @public
*/
export interface ExternalSource {
/**
* <p>The source type of the external source wrapper object.</p>
* @public
*/
sourceType: ExternalSourceType | undefined;

/**
* <p>The S3 location of the external source wrapper object.</p>
* @public
*/
s3Location?: S3ObjectDoc;

/**
* <p>The identifier, contentType, and data of the external source wrapper object.</p>
* @public
*/
byteContent?: ByteContentDoc;
}

/**
* <p>The configurations of the external source wrapper object in the retrieveAndGenerate function.</p>
* @public
*/
export interface ExternalSourcesRetrieveAndGenerateConfiguration {
/**
* <p>The modelArn used with the external source wrapper object in the retrieveAndGenerate function.</p>
* @public
*/
modelArn: string | undefined;

/**
* <p>The document used with the external source wrapper object in the retrieveAndGenerate function.</p>
* @public
*/
sources: ExternalSource[] | undefined;

/**
* <p>The prompt used with the external source wrapper object with the retrieveAndGenerate function.</p>
* @public
*/
generationConfiguration?: ExternalSourcesGenerationConfiguration;
}

/**
* <p>Contains configurations for response generation based on the knowledge base query results.</p>
* <p>This data type is used in the following API operations:</p>
Expand Down Expand Up @@ -2329,6 +2439,7 @@ export type SearchType = (typeof SearchType)[keyof typeof SearchType];
* @enum
*/
export const RetrieveAndGenerateType = {
EXTERNAL_SOURCES: "EXTERNAL_SOURCES",
KNOWLEDGE_BASE: "KNOWLEDGE_BASE",
} as const;

Expand Down Expand Up @@ -2913,6 +3024,12 @@ export interface RetrieveAndGenerateConfiguration {
* @public
*/
knowledgeBaseConfiguration?: KnowledgeBaseRetrieveAndGenerateConfiguration;

/**
* <p>The configuration used with the external source wrapper object in the retrieveAndGenerate function.</p>
* @public
*/
externalSourcesConfiguration?: ExternalSourcesRetrieveAndGenerateConfiguration;
}

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

/**
* @internal
*/
export const ExternalSourcesGenerationConfigurationFilterSensitiveLog = (
obj: ExternalSourcesGenerationConfiguration
): any => ({
...obj,
...(obj.promptTemplate && { promptTemplate: PromptTemplateFilterSensitiveLog(obj.promptTemplate) }),
});

/**
* @internal
*/
export const ByteContentDocFilterSensitiveLog = (obj: ByteContentDoc): any => ({
...obj,
...(obj.identifier && { identifier: SENSITIVE_STRING }),
...(obj.data && { data: SENSITIVE_STRING }),
});

/**
* @internal
*/
export const ExternalSourceFilterSensitiveLog = (obj: ExternalSource): any => ({
...obj,
...(obj.byteContent && { byteContent: ByteContentDocFilterSensitiveLog(obj.byteContent) }),
});

/**
* @internal
*/
export const ExternalSourcesRetrieveAndGenerateConfigurationFilterSensitiveLog = (
obj: ExternalSourcesRetrieveAndGenerateConfiguration
): any => ({
...obj,
...(obj.sources && { sources: obj.sources.map((item) => ExternalSourceFilterSensitiveLog(item)) }),
...(obj.generationConfiguration && {
generationConfiguration: ExternalSourcesGenerationConfigurationFilterSensitiveLog(obj.generationConfiguration),
}),
});

/**
* @internal
*/
Expand Down Expand Up @@ -3435,6 +3592,11 @@ export const RetrieveAndGenerateConfigurationFilterSensitiveLog = (obj: Retrieve
obj.knowledgeBaseConfiguration
),
}),
...(obj.externalSourcesConfiguration && {
externalSourcesConfiguration: ExternalSourcesRetrieveAndGenerateConfigurationFilterSensitiveLog(
obj.externalSourcesConfiguration
),
}),
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ import {
ApiResult,
Attribution,
BadGatewayException,
ByteContentDoc,
Citation,
ConflictException,
ContentBody,
DependencyFailedException,
ExternalSource,
ExternalSourcesGenerationConfiguration,
ExternalSourcesRetrieveAndGenerateConfiguration,
FilterAttribute,
FunctionResult,
GenerationConfiguration,
Expand Down Expand Up @@ -73,6 +77,7 @@ import {
RetrieveAndGenerateSessionConfiguration,
RetrievedReference,
ReturnControlPayload,
S3ObjectDoc,
ServiceQuotaExceededException,
SessionState,
ThrottlingException,
Expand Down Expand Up @@ -617,8 +622,57 @@ const de_ValidationException_event = async (output: any, context: __SerdeContext
};
// se_ApiResult omitted.

/**
* serializeAws_restJson1ByteContentDoc
*/
const se_ByteContentDoc = (input: ByteContentDoc, context: __SerdeContext): any => {
return take(input, {
contentType: [],
data: context.base64Encoder,
identifier: [],
});
};

// se_ContentBody omitted.

/**
* serializeAws_restJson1ExternalSource
*/
const se_ExternalSource = (input: ExternalSource, context: __SerdeContext): any => {
return take(input, {
byteContent: (_) => se_ByteContentDoc(_, context),
s3Location: _json,
sourceType: [],
});
};

/**
* serializeAws_restJson1ExternalSources
*/
const se_ExternalSources = (input: ExternalSource[], context: __SerdeContext): any => {
return input
.filter((e: any) => e != null)
.map((entry) => {
return se_ExternalSource(entry, context);
});
};

// se_ExternalSourcesGenerationConfiguration omitted.

/**
* serializeAws_restJson1ExternalSourcesRetrieveAndGenerateConfiguration
*/
const se_ExternalSourcesRetrieveAndGenerateConfiguration = (
input: ExternalSourcesRetrieveAndGenerateConfiguration,
context: __SerdeContext
): any => {
return take(input, {
generationConfiguration: _json,
modelArn: [],
sources: (_) => se_ExternalSources(_, context),
});
};

/**
* serializeAws_restJson1FilterAttribute
*/
Expand Down Expand Up @@ -727,6 +781,7 @@ const se_RetrievalFilterList = (input: RetrievalFilter[], context: __SerdeContex
*/
const se_RetrieveAndGenerateConfiguration = (input: RetrieveAndGenerateConfiguration, context: __SerdeContext): any => {
return take(input, {
externalSourcesConfiguration: (_) => se_ExternalSourcesRetrieveAndGenerateConfiguration(_, context),
knowledgeBaseConfiguration: (_) => se_KnowledgeBaseRetrieveAndGenerateConfiguration(_, context),
type: [],
});
Expand All @@ -738,6 +793,8 @@ const se_RetrieveAndGenerateConfiguration = (input: RetrieveAndGenerateConfigura

// se_ReturnControlInvocationResults omitted.

// se_S3ObjectDoc omitted.

// se_SessionAttributesMap omitted.

// se_SessionState omitted.
Expand Down
Loading

0 comments on commit 39a8983

Please sign in to comment.