Skip to content

Commit 9326e19

Browse files
author
awstools
committed
feat(client-bedrock-agent-runtime): Added raw model response and usage metrics to PreProcessing and PostProcessing Trace
1 parent cf6979c commit 9326e19

File tree

3 files changed

+76
-17
lines changed

3 files changed

+76
-17
lines changed

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

+21-3
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,15 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
393393
* // rationale: "STRING_VALUE",
394394
* // isValid: true || false,
395395
* // },
396+
* // rawResponse: { // RawResponse
397+
* // content: "STRING_VALUE",
398+
* // },
399+
* // metadata: { // Metadata
400+
* // usage: { // Usage
401+
* // inputTokens: Number("int"),
402+
* // outputTokens: Number("int"),
403+
* // },
404+
* // },
396405
* // },
397406
* // },
398407
* // orchestrationTrace: { // OrchestrationTrace Union: only one key present
@@ -511,11 +520,11 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
511520
* // },
512521
* // modelInvocationOutput: { // OrchestrationModelInvocationOutput
513522
* // traceId: "STRING_VALUE",
514-
* // rawResponse: { // RawResponse
523+
* // rawResponse: {
515524
* // content: "STRING_VALUE",
516525
* // },
517-
* // metadata: { // Metadata
518-
* // usage: { // Usage
526+
* // metadata: {
527+
* // usage: {
519528
* // inputTokens: Number("int"),
520529
* // outputTokens: Number("int"),
521530
* // },
@@ -545,6 +554,15 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
545554
* // parsedResponse: { // PostProcessingParsedResponse
546555
* // text: "STRING_VALUE",
547556
* // },
557+
* // rawResponse: {
558+
* // content: "STRING_VALUE",
559+
* // },
560+
* // metadata: {
561+
* // usage: {
562+
* // inputTokens: Number("int"),
563+
* // outputTokens: Number("int"),
564+
* // },
565+
* // },
548566
* // },
549567
* // },
550568
* // failureTrace: { // FailureTrace

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

+36-7
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,18 @@ export interface PostProcessingModelInvocationOutput {
29532953
* @public
29542954
*/
29552955
parsedResponse?: PostProcessingParsedResponse;
2956+
2957+
/**
2958+
* <p>Contains the raw output from the foundation model.</p>
2959+
* @public
2960+
*/
2961+
rawResponse?: RawResponse;
2962+
2963+
/**
2964+
* <p>Provides details of the foundation model.</p>
2965+
* @public
2966+
*/
2967+
metadata?: Metadata;
29562968
}
29572969

29582970
/**
@@ -3055,6 +3067,18 @@ export interface PreProcessingModelInvocationOutput {
30553067
* @public
30563068
*/
30573069
parsedResponse?: PreProcessingParsedResponse;
3070+
3071+
/**
3072+
* <p>Contains the raw output from the foundation model.</p>
3073+
* @public
3074+
*/
3075+
rawResponse?: RawResponse;
3076+
3077+
/**
3078+
* <p>Provides details of the foundation model.</p>
3079+
* @public
3080+
*/
3081+
metadata?: Metadata;
30583082
}
30593083

30603084
/**
@@ -4062,24 +4086,24 @@ export interface ExternalSource {
40624086
}
40634087

40644088
/**
4065-
* <p>The configurations of the external source wrapper object in the retrieveAndGenerate function.</p>
4089+
* <p>The configurations of the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>
40664090
* @public
40674091
*/
40684092
export interface ExternalSourcesRetrieveAndGenerateConfiguration {
40694093
/**
4070-
* <p>The modelArn used with the external source wrapper object in the retrieveAndGenerate function.</p>
4094+
* <p>The model Amazon Resource Name (ARN) for the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>
40714095
* @public
40724096
*/
40734097
modelArn: string | undefined;
40744098

40754099
/**
4076-
* <p>The document used with the external source wrapper object in the retrieveAndGenerate function.</p>
4100+
* <p>The document for the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>
40774101
* @public
40784102
*/
40794103
sources: ExternalSource[] | undefined;
40804104

40814105
/**
4082-
* <p>The prompt used with the external source wrapper object with the retrieveAndGenerate function.</p>
4106+
* <p>The prompt used with the external source wrapper object with the <code>retrieveAndGenerate</code> function.</p>
40834107
* @public
40844108
*/
40854109
generationConfiguration?: ExternalSourcesGenerationConfiguration;
@@ -4912,19 +4936,20 @@ export interface RetrieveRequest {
49124936
*/
49134937
export interface RetrieveAndGenerateConfiguration {
49144938
/**
4915-
* <p>The type of resource that is queried by the request.</p>
4939+
* <p>The type of resource that contains your data for retrieving information and generating responses.</p>
4940+
* <p>If you choose ot use <code>EXTERNAL_SOURCES</code>, then currently only Claude 3 Sonnet models for knowledge bases are supported.</p>
49164941
* @public
49174942
*/
49184943
type: RetrieveAndGenerateType | undefined;
49194944

49204945
/**
4921-
* <p>Contains details about the resource being queried.</p>
4946+
* <p>Contains details about the knowledge base for retrieving information and generating responses.</p>
49224947
* @public
49234948
*/
49244949
knowledgeBaseConfiguration?: KnowledgeBaseRetrieveAndGenerateConfiguration;
49254950

49264951
/**
4927-
* <p>The configuration used with the external source wrapper object in the retrieveAndGenerate function.</p>
4952+
* <p>The configuration for the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>
49284953
* @public
49294954
*/
49304955
externalSourcesConfiguration?: ExternalSourcesRetrieveAndGenerateConfiguration;
@@ -5546,6 +5571,8 @@ export const PostProcessingModelInvocationOutputFilterSensitiveLog = (
55465571
): any => ({
55475572
...obj,
55485573
...(obj.parsedResponse && { parsedResponse: SENSITIVE_STRING }),
5574+
...(obj.rawResponse && { rawResponse: SENSITIVE_STRING }),
5575+
...(obj.metadata && { metadata: SENSITIVE_STRING }),
55495576
});
55505577

55515578
/**
@@ -5571,6 +5598,8 @@ export const PreProcessingParsedResponseFilterSensitiveLog = (obj: PreProcessing
55715598
export const PreProcessingModelInvocationOutputFilterSensitiveLog = (obj: PreProcessingModelInvocationOutput): any => ({
55725599
...obj,
55735600
...(obj.parsedResponse && { parsedResponse: SENSITIVE_STRING }),
5601+
...(obj.rawResponse && { rawResponse: SENSITIVE_STRING }),
5602+
...(obj.metadata && { metadata: SENSITIVE_STRING }),
55745603
});
55755604

55765605
/**

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

+19-7
Original file line numberDiff line numberDiff line change
@@ -1504,26 +1504,26 @@
15041504
"modelArn": {
15051505
"target": "com.amazonaws.bedrockagentruntime#BedrockModelArn",
15061506
"traits": {
1507-
"smithy.api#documentation": "<p>The modelArn used with the external source wrapper object in the retrieveAndGenerate function.</p>",
1507+
"smithy.api#documentation": "<p>The model Amazon Resource Name (ARN) for the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>",
15081508
"smithy.api#required": {}
15091509
}
15101510
},
15111511
"sources": {
15121512
"target": "com.amazonaws.bedrockagentruntime#ExternalSources",
15131513
"traits": {
1514-
"smithy.api#documentation": "<p>The document used with the external source wrapper object in the retrieveAndGenerate function.</p>",
1514+
"smithy.api#documentation": "<p>The document for the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>",
15151515
"smithy.api#required": {}
15161516
}
15171517
},
15181518
"generationConfiguration": {
15191519
"target": "com.amazonaws.bedrockagentruntime#ExternalSourcesGenerationConfiguration",
15201520
"traits": {
1521-
"smithy.api#documentation": "<p>The prompt used with the external source wrapper object with the retrieveAndGenerate function.</p>"
1521+
"smithy.api#documentation": "<p>The prompt used with the external source wrapper object with the <code>retrieveAndGenerate</code> function.</p>"
15221522
}
15231523
}
15241524
},
15251525
"traits": {
1526-
"smithy.api#documentation": "<p>The configurations of the external source wrapper object in the retrieveAndGenerate function.</p>"
1526+
"smithy.api#documentation": "<p>The configurations of the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>"
15271527
}
15281528
},
15291529
"com.amazonaws.bedrockagentruntime#FailureReasonString": {
@@ -4217,6 +4217,12 @@
42174217
"traits": {
42184218
"smithy.api#documentation": "<p>Details about the response from the Lambda parsing of the output of the post-processing step.</p>"
42194219
}
4220+
},
4221+
"rawResponse": {
4222+
"target": "com.amazonaws.bedrockagentruntime#RawResponse"
4223+
},
4224+
"metadata": {
4225+
"target": "com.amazonaws.bedrockagentruntime#Metadata"
42204226
}
42214227
},
42224228
"traits": {
@@ -4274,6 +4280,12 @@
42744280
"traits": {
42754281
"smithy.api#documentation": "<p>Details about the response from the Lambda parsing of the output of the pre-processing step.</p>"
42764282
}
4283+
},
4284+
"rawResponse": {
4285+
"target": "com.amazonaws.bedrockagentruntime#RawResponse"
4286+
},
4287+
"metadata": {
4288+
"target": "com.amazonaws.bedrockagentruntime#Metadata"
42774289
}
42784290
},
42794291
"traits": {
@@ -5038,20 +5050,20 @@
50385050
"type": {
50395051
"target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateType",
50405052
"traits": {
5041-
"smithy.api#documentation": "<p>The type of resource that is queried by the request.</p>",
5053+
"smithy.api#documentation": "<p>The type of resource that contains your data for retrieving information and generating responses.</p>\n <p>If you choose ot use <code>EXTERNAL_SOURCES</code>, then currently only Claude 3 Sonnet models for knowledge bases are supported.</p>",
50425054
"smithy.api#required": {}
50435055
}
50445056
},
50455057
"knowledgeBaseConfiguration": {
50465058
"target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrieveAndGenerateConfiguration",
50475059
"traits": {
5048-
"smithy.api#documentation": "<p>Contains details about the resource being queried.</p>"
5060+
"smithy.api#documentation": "<p>Contains details about the knowledge base for retrieving information and generating responses.</p>"
50495061
}
50505062
},
50515063
"externalSourcesConfiguration": {
50525064
"target": "com.amazonaws.bedrockagentruntime#ExternalSourcesRetrieveAndGenerateConfiguration",
50535065
"traits": {
5054-
"smithy.api#documentation": "<p>The configuration used with the external source wrapper object in the retrieveAndGenerate function.</p>"
5066+
"smithy.api#documentation": "<p>The configuration for the external source wrapper object in the <code>retrieveAndGenerate</code> function.</p>"
50555067
}
50565068
}
50575069
},

0 commit comments

Comments
 (0)