Skip to content

Commit f3c2a2c

Browse files
author
awstools
committed
feat(client-bedrock-agent-runtime): Knowledge Bases for Amazon Bedrock now supports custom prompts and model parameters in the orchestrationConfiguration of the RetrieveAndGenerate API. The modelArn field accepts Custom Models and Imported Models ARNs.
1 parent 9588015 commit f3c2a2c

File tree

4 files changed

+108
-16
lines changed

4 files changed

+108
-16
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ export interface RetrieveAndGenerateCommandOutput extends RetrieveAndGenerateRes
135135
* },
136136
* },
137137
* orchestrationConfiguration: { // OrchestrationConfiguration
138+
* promptTemplate: {
139+
* textPromptTemplate: "STRING_VALUE",
140+
* },
141+
* inferenceConfig: {
142+
* textInferenceConfig: {
143+
* temperature: Number("float"),
144+
* topP: Number("float"),
145+
* maxTokens: Number("int"),
146+
* stopSequences: [
147+
* "STRING_VALUE",
148+
* ],
149+
* },
150+
* },
151+
* additionalModelRequestFields: {
152+
* "<keys>": "DOCUMENT_VALUE",
153+
* },
138154
* queryTransformationConfiguration: { // QueryTransformationConfiguration
139155
* type: "QUERY_DECOMPOSITION", // required
140156
* },

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

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,7 +2604,7 @@ export interface OrchestrationModelInvocationOutput {
26042604
rawResponse?: RawResponse;
26052605

26062606
/**
2607-
* <p>Contains information about the foundation model output.</p>
2607+
* <p>Contains information about the foundation model output from the orchestration step.</p>
26082608
* @public
26092609
*/
26102610
metadata?: Metadata;
@@ -2955,13 +2955,17 @@ export interface PostProcessingModelInvocationOutput {
29552955
parsedResponse?: PostProcessingParsedResponse;
29562956

29572957
/**
2958-
* <p>Contains the raw output from the foundation model.</p>
2958+
* <p>
2959+
* Details of the raw response from the foundation model output.
2960+
* </p>
29592961
* @public
29602962
*/
29612963
rawResponse?: RawResponse;
29622964

29632965
/**
2964-
* <p>Provides details of the foundation model.</p>
2966+
* <p>
2967+
* Contains information about the foundation model output from the post-processing step.
2968+
* </p>
29652969
* @public
29662970
*/
29672971
metadata?: Metadata;
@@ -3069,13 +3073,17 @@ export interface PreProcessingModelInvocationOutput {
30693073
parsedResponse?: PreProcessingParsedResponse;
30703074

30713075
/**
3072-
* <p>Contains the raw output from the foundation model.</p>
3076+
* <p>
3077+
* Details of the raw response from the foundation model output.
3078+
* </p>
30733079
* @public
30743080
*/
30753081
rawResponse?: RawResponse;
30763082

30773083
/**
3078-
* <p>Provides details of the foundation model.</p>
3084+
* <p>
3085+
* Contains information about the foundation model output from the pre-processing step.
3086+
* </p>
30793087
* @public
30803088
*/
30813089
metadata?: Metadata;
@@ -4178,12 +4186,30 @@ export interface QueryTransformationConfiguration {
41784186
* @public
41794187
*/
41804188
export interface OrchestrationConfiguration {
4189+
/**
4190+
* <p>Contains the template for the prompt that's sent to the model for response generation.</p>
4191+
* @public
4192+
*/
4193+
promptTemplate?: PromptTemplate;
4194+
4195+
/**
4196+
* <p> Configuration settings for inference when using RetrieveAndGenerate to generate responses while using a knowledge base as a source. </p>
4197+
* @public
4198+
*/
4199+
inferenceConfig?: InferenceConfig;
4200+
4201+
/**
4202+
* <p> Additional model parameters and corresponding values not included in the textInferenceConfig structure for a knowledge base. This allows users to provide custom model parameters specific to the language model being used. </p>
4203+
* @public
4204+
*/
4205+
additionalModelRequestFields?: Record<string, __DocumentType>;
4206+
41814207
/**
41824208
* <p>To split up the prompt and retrieve multiple sources, set the transformation type to
41834209
* <code>QUERY_DECOMPOSITION</code>.</p>
41844210
* @public
41854211
*/
4186-
queryTransformationConfiguration: QueryTransformationConfiguration | undefined;
4212+
queryTransformationConfiguration?: QueryTransformationConfiguration;
41874213
}
41884214

41894215
/**
@@ -5723,6 +5749,14 @@ export const GenerationConfigurationFilterSensitiveLog = (obj: GenerationConfigu
57235749
...(obj.promptTemplate && { promptTemplate: PromptTemplateFilterSensitiveLog(obj.promptTemplate) }),
57245750
});
57255751

5752+
/**
5753+
* @internal
5754+
*/
5755+
export const OrchestrationConfigurationFilterSensitiveLog = (obj: OrchestrationConfiguration): any => ({
5756+
...obj,
5757+
...(obj.promptTemplate && { promptTemplate: PromptTemplateFilterSensitiveLog(obj.promptTemplate) }),
5758+
});
5759+
57265760
/**
57275761
* @internal
57285762
*/
@@ -5829,6 +5863,9 @@ export const KnowledgeBaseRetrieveAndGenerateConfigurationFilterSensitiveLog = (
58295863
...(obj.generationConfiguration && {
58305864
generationConfiguration: GenerationConfigurationFilterSensitiveLog(obj.generationConfiguration),
58315865
}),
5866+
...(obj.orchestrationConfiguration && {
5867+
orchestrationConfiguration: OrchestrationConfigurationFilterSensitiveLog(obj.orchestrationConfiguration),
5868+
}),
58325869
});
58335870

58345871
/**

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ const se_KnowledgeBaseRetrieveAndGenerateConfiguration = (
11221122
generationConfiguration: (_) => se_GenerationConfiguration(_, context),
11231123
knowledgeBaseId: [],
11241124
modelArn: [],
1125-
orchestrationConfiguration: _json,
1125+
orchestrationConfiguration: (_) => se_OrchestrationConfiguration(_, context),
11261126
retrievalConfiguration: (_) => se_KnowledgeBaseRetrievalConfiguration(_, context),
11271127
});
11281128
};
@@ -1141,7 +1141,17 @@ const se_KnowledgeBaseVectorSearchConfiguration = (
11411141
});
11421142
};
11431143

1144-
// se_OrchestrationConfiguration omitted.
1144+
/**
1145+
* serializeAws_restJson1OrchestrationConfiguration
1146+
*/
1147+
const se_OrchestrationConfiguration = (input: OrchestrationConfiguration, context: __SerdeContext): any => {
1148+
return take(input, {
1149+
additionalModelRequestFields: (_) => se_AdditionalModelRequestFields(_, context),
1150+
inferenceConfig: (_) => se_InferenceConfig(_, context),
1151+
promptTemplate: _json,
1152+
queryTransformationConfiguration: _json,
1153+
});
1154+
};
11451155

11461156
// se_PromptSessionAttributesMap omitted.
11471157

codegen/sdk-codegen/aws-models/bedrock-agent-runtime.json

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@
10641064
"min": 1,
10651065
"max": 2048
10661066
},
1067-
"smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))))|(arn:aws(|-us-gov|-cn|-iso|-iso-b):bedrock:(|[0-9a-z-]{1,20}):(|[0-9]{12}):inference-profile/[a-zA-Z0-9-:.]+)|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)$"
1067+
"smithy.api#pattern": "^(arn:aws(-[^:]{1,10})?:bedrock:[a-z0-9-]{1,20}:([0-9]{12})?:([a-z-]{1,20}/)?)?([a-z0-9.-]{1,63}){0,2}(([:][a-z0-9-]{1,63}){0,2})?(/[a-z0-9]{1,12})?$"
10681068
}
10691069
},
10701070
"com.amazonaws.bedrockagentruntime#ByteContentBlob": {
@@ -4012,11 +4012,28 @@
40124012
"com.amazonaws.bedrockagentruntime#OrchestrationConfiguration": {
40134013
"type": "structure",
40144014
"members": {
4015+
"promptTemplate": {
4016+
"target": "com.amazonaws.bedrockagentruntime#PromptTemplate",
4017+
"traits": {
4018+
"smithy.api#documentation": "<p>Contains the template for the prompt that's sent to the model for response generation.</p>"
4019+
}
4020+
},
4021+
"inferenceConfig": {
4022+
"target": "com.amazonaws.bedrockagentruntime#InferenceConfig",
4023+
"traits": {
4024+
"smithy.api#documentation": "<p> Configuration settings for inference when using RetrieveAndGenerate to generate responses while using a knowledge base as a source. </p>"
4025+
}
4026+
},
4027+
"additionalModelRequestFields": {
4028+
"target": "com.amazonaws.bedrockagentruntime#AdditionalModelRequestFields",
4029+
"traits": {
4030+
"smithy.api#documentation": "<p> Additional model parameters and corresponding values not included in the textInferenceConfig structure for a knowledge base. This allows users to provide custom model parameters specific to the language model being used. </p>"
4031+
}
4032+
},
40154033
"queryTransformationConfiguration": {
40164034
"target": "com.amazonaws.bedrockagentruntime#QueryTransformationConfiguration",
40174035
"traits": {
4018-
"smithy.api#documentation": "<p>To split up the prompt and retrieve multiple sources, set the transformation type to\n <code>QUERY_DECOMPOSITION</code>.</p>",
4019-
"smithy.api#required": {}
4036+
"smithy.api#documentation": "<p>To split up the prompt and retrieve multiple sources, set the transformation type to\n <code>QUERY_DECOMPOSITION</code>.</p>"
40204037
}
40214038
}
40224039
},
@@ -4042,7 +4059,7 @@
40424059
"metadata": {
40434060
"target": "com.amazonaws.bedrockagentruntime#Metadata",
40444061
"traits": {
4045-
"smithy.api#documentation": "<p>Contains information about the foundation model output.</p>"
4062+
"smithy.api#documentation": "<p>Contains information about the foundation model output from the orchestration step.</p>"
40464063
}
40474064
}
40484065
},
@@ -4219,10 +4236,16 @@
42194236
}
42204237
},
42214238
"rawResponse": {
4222-
"target": "com.amazonaws.bedrockagentruntime#RawResponse"
4239+
"target": "com.amazonaws.bedrockagentruntime#RawResponse",
4240+
"traits": {
4241+
"smithy.api#documentation": "<p>\n Details of the raw response from the foundation model output.\n </p>"
4242+
}
42234243
},
42244244
"metadata": {
4225-
"target": "com.amazonaws.bedrockagentruntime#Metadata"
4245+
"target": "com.amazonaws.bedrockagentruntime#Metadata",
4246+
"traits": {
4247+
"smithy.api#documentation": "<p>\n Contains information about the foundation model output from the post-processing step.\n </p>"
4248+
}
42264249
}
42274250
},
42284251
"traits": {
@@ -4282,10 +4305,16 @@
42824305
}
42834306
},
42844307
"rawResponse": {
4285-
"target": "com.amazonaws.bedrockagentruntime#RawResponse"
4308+
"target": "com.amazonaws.bedrockagentruntime#RawResponse",
4309+
"traits": {
4310+
"smithy.api#documentation": "<p>\n Details of the raw response from the foundation model output.\n </p>"
4311+
}
42864312
},
42874313
"metadata": {
4288-
"target": "com.amazonaws.bedrockagentruntime#Metadata"
4314+
"target": "com.amazonaws.bedrockagentruntime#Metadata",
4315+
"traits": {
4316+
"smithy.api#documentation": "<p>\n Contains information about the foundation model output from the pre-processing step.\n </p>"
4317+
}
42894318
}
42904319
},
42914320
"traits": {

0 commit comments

Comments
 (0)