@aws-sdk/client-bedrock-agent-runtime 3.542.0 → 3.549.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { awsExpectUnion as __expectUnion, loadRestJsonErrorCode, parseJsonBody a
2
2
  import { requestBuilder as rb } from "@smithy/core";
3
3
  import { _json, collectBody, decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, limitedParseDouble as __limitedParseDouble, limitedParseFloat32 as __limitedParseFloat32, map, take, withBaseException, } from "@smithy/smithy-client";
4
4
  import { BedrockAgentRuntimeServiceException as __BaseException } from "../models/BedrockAgentRuntimeServiceException";
5
- import { AccessDeniedException, BadGatewayException, ConflictException, DependencyFailedException, InternalServerException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException, ValidationException, } from "../models/models_0";
5
+ import { AccessDeniedException, BadGatewayException, ConflictException, DependencyFailedException, InternalServerException, ResourceNotFoundException, RetrievalFilter, ServiceQuotaExceededException, ThrottlingException, ValidationException, } from "../models/models_0";
6
6
  export const se_InvokeAgentCommand = async (input, context) => {
7
7
  const b = rb(input, context);
8
8
  const headers = {
@@ -32,7 +32,7 @@ export const se_RetrieveCommand = async (input, context) => {
32
32
  let body;
33
33
  body = JSON.stringify(take(input, {
34
34
  nextToken: [],
35
- retrievalConfiguration: (_) => _json(_),
35
+ retrievalConfiguration: (_) => se_KnowledgeBaseRetrievalConfiguration(_, context),
36
36
  retrievalQuery: (_) => _json(_),
37
37
  }));
38
38
  b.m("POST").h(headers).b(body);
@@ -47,7 +47,7 @@ export const se_RetrieveAndGenerateCommand = async (input, context) => {
47
47
  let body;
48
48
  body = JSON.stringify(take(input, {
49
49
  input: (_) => _json(_),
50
- retrieveAndGenerateConfiguration: (_) => _json(_),
50
+ retrieveAndGenerateConfiguration: (_) => se_RetrieveAndGenerateConfiguration(_, context),
51
51
  sessionConfiguration: (_) => _json(_),
52
52
  sessionId: [],
53
53
  }));
@@ -91,7 +91,7 @@ export const de_RetrieveAndGenerateCommand = async (output, context) => {
91
91
  });
92
92
  const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
93
93
  const doc = take(data, {
94
- citations: _json,
94
+ citations: (_) => de_Citations(_, context),
95
95
  output: _json,
96
96
  sessionId: __expectString,
97
97
  });
@@ -396,6 +396,83 @@ const de_ValidationException_event = async (output, context) => {
396
396
  };
397
397
  return de_ValidationExceptionRes(parsedOutput, context);
398
398
  };
399
+ const se_FilterAttribute = (input, context) => {
400
+ return take(input, {
401
+ key: [],
402
+ value: (_) => se_FilterValue(_, context),
403
+ });
404
+ };
405
+ const se_FilterValue = (input, context) => {
406
+ return input;
407
+ };
408
+ const se_KnowledgeBaseRetrievalConfiguration = (input, context) => {
409
+ return take(input, {
410
+ vectorSearchConfiguration: (_) => se_KnowledgeBaseVectorSearchConfiguration(_, context),
411
+ });
412
+ };
413
+ const se_KnowledgeBaseRetrieveAndGenerateConfiguration = (input, context) => {
414
+ return take(input, {
415
+ generationConfiguration: _json,
416
+ knowledgeBaseId: [],
417
+ modelArn: [],
418
+ retrievalConfiguration: (_) => se_KnowledgeBaseRetrievalConfiguration(_, context),
419
+ });
420
+ };
421
+ const se_KnowledgeBaseVectorSearchConfiguration = (input, context) => {
422
+ return take(input, {
423
+ filter: (_) => se_RetrievalFilter(_, context),
424
+ numberOfResults: [],
425
+ overrideSearchType: [],
426
+ });
427
+ };
428
+ const se_RetrievalFilter = (input, context) => {
429
+ return RetrievalFilter.visit(input, {
430
+ andAll: (value) => ({ andAll: se_RetrievalFilterList(value, context) }),
431
+ equals: (value) => ({ equals: se_FilterAttribute(value, context) }),
432
+ greaterThan: (value) => ({ greaterThan: se_FilterAttribute(value, context) }),
433
+ greaterThanOrEquals: (value) => ({ greaterThanOrEquals: se_FilterAttribute(value, context) }),
434
+ in: (value) => ({ in: se_FilterAttribute(value, context) }),
435
+ lessThan: (value) => ({ lessThan: se_FilterAttribute(value, context) }),
436
+ lessThanOrEquals: (value) => ({ lessThanOrEquals: se_FilterAttribute(value, context) }),
437
+ notEquals: (value) => ({ notEquals: se_FilterAttribute(value, context) }),
438
+ notIn: (value) => ({ notIn: se_FilterAttribute(value, context) }),
439
+ orAll: (value) => ({ orAll: se_RetrievalFilterList(value, context) }),
440
+ startsWith: (value) => ({ startsWith: se_FilterAttribute(value, context) }),
441
+ _: (name, value) => ({ name: value }),
442
+ });
443
+ };
444
+ const se_RetrievalFilterList = (input, context) => {
445
+ return input
446
+ .filter((e) => e != null)
447
+ .map((entry) => {
448
+ return se_RetrievalFilter(entry, context);
449
+ });
450
+ };
451
+ const se_RetrieveAndGenerateConfiguration = (input, context) => {
452
+ return take(input, {
453
+ knowledgeBaseConfiguration: (_) => se_KnowledgeBaseRetrieveAndGenerateConfiguration(_, context),
454
+ type: [],
455
+ });
456
+ };
457
+ const de_Attribution = (output, context) => {
458
+ return take(output, {
459
+ citations: (_) => de_Citations(_, context),
460
+ });
461
+ };
462
+ const de_Citation = (output, context) => {
463
+ return take(output, {
464
+ generatedResponsePart: _json,
465
+ retrievedReferences: (_) => de_RetrievedReferences(_, context),
466
+ });
467
+ };
468
+ const de_Citations = (output, context) => {
469
+ const retVal = (output || [])
470
+ .filter((e) => e != null)
471
+ .map((entry) => {
472
+ return de_Citation(entry, context);
473
+ });
474
+ return retVal;
475
+ };
399
476
  const de_InferenceConfiguration = (output, context) => {
400
477
  return take(output, {
401
478
  maximumLength: __expectInt32,
@@ -405,10 +482,16 @@ const de_InferenceConfiguration = (output, context) => {
405
482
  topP: __limitedParseFloat32,
406
483
  });
407
484
  };
485
+ const de_KnowledgeBaseLookupOutput = (output, context) => {
486
+ return take(output, {
487
+ retrievedReferences: (_) => de_RetrievedReferences(_, context),
488
+ });
489
+ };
408
490
  const de_KnowledgeBaseRetrievalResult = (output, context) => {
409
491
  return take(output, {
410
492
  content: _json,
411
493
  location: _json,
494
+ metadata: (_) => de_RetrievalResultMetadata(_, context),
412
495
  score: __limitedParseDouble,
413
496
  });
414
497
  };
@@ -431,6 +514,16 @@ const de_ModelInvocationInput = (output, context) => {
431
514
  type: __expectString,
432
515
  });
433
516
  };
517
+ const de_Observation = (output, context) => {
518
+ return take(output, {
519
+ actionGroupInvocationOutput: _json,
520
+ finalResponse: _json,
521
+ knowledgeBaseLookupOutput: (_) => de_KnowledgeBaseLookupOutput(_, context),
522
+ repromptResponse: _json,
523
+ traceId: __expectString,
524
+ type: __expectString,
525
+ });
526
+ };
434
527
  const de_OrchestrationTrace = (output, context) => {
435
528
  if (output.invocationInput != null) {
436
529
  return {
@@ -444,7 +537,7 @@ const de_OrchestrationTrace = (output, context) => {
444
537
  }
445
538
  if (output.observation != null) {
446
539
  return {
447
- observation: _json(output.observation),
540
+ observation: de_Observation(output.observation, context),
448
541
  };
449
542
  }
450
543
  if (output.rationale != null) {
@@ -456,7 +549,7 @@ const de_OrchestrationTrace = (output, context) => {
456
549
  };
457
550
  const de_PayloadPart = (output, context) => {
458
551
  return take(output, {
459
- attribution: _json,
552
+ attribution: (_) => de_Attribution(_, context),
460
553
  bytes: context.base64Decoder,
461
554
  });
462
555
  };
@@ -486,6 +579,33 @@ const de_PreProcessingTrace = (output, context) => {
486
579
  }
487
580
  return { $unknown: Object.entries(output)[0] };
488
581
  };
582
+ const de_RetrievalResultMetadata = (output, context) => {
583
+ return Object.entries(output).reduce((acc, [key, value]) => {
584
+ if (value === null) {
585
+ return acc;
586
+ }
587
+ acc[key] = de_RetrievalResultMetadataValue(value, context);
588
+ return acc;
589
+ }, {});
590
+ };
591
+ const de_RetrievalResultMetadataValue = (output, context) => {
592
+ return output;
593
+ };
594
+ const de_RetrievedReference = (output, context) => {
595
+ return take(output, {
596
+ content: _json,
597
+ location: _json,
598
+ metadata: (_) => de_RetrievalResultMetadata(_, context),
599
+ });
600
+ };
601
+ const de_RetrievedReferences = (output, context) => {
602
+ const retVal = (output || [])
603
+ .filter((e) => e != null)
604
+ .map((entry) => {
605
+ return de_RetrievedReference(entry, context);
606
+ });
607
+ return retVal;
608
+ };
489
609
  const de_Trace = (output, context) => {
490
610
  if (output.failureTrace != null) {
491
611
  return {
@@ -107,6 +107,9 @@ declare const InvokeAgentCommand_base: {
107
107
  * // uri: "STRING_VALUE",
108
108
  * // },
109
109
  * // },
110
+ * // metadata: { // RetrievalResultMetadata
111
+ * // "<keys>": "DOCUMENT_VALUE",
112
+ * // },
110
113
  * // },
111
114
  * // ],
112
115
  * // },
@@ -198,6 +201,9 @@ declare const InvokeAgentCommand_base: {
198
201
  * // uri: "STRING_VALUE",
199
202
  * // },
200
203
  * // },
204
+ * // metadata: {
205
+ * // "<keys>": "DOCUMENT_VALUE",
206
+ * // },
201
207
  * // },
202
208
  * // ],
203
209
  * // },
@@ -26,7 +26,7 @@ declare const RetrieveAndGenerateCommand_base: {
26
26
  getEndpointParameterInstructions(): import("@smithy/middleware-endpoint").EndpointParameterInstructions;
27
27
  };
28
28
  /**
29
- * <p>Queries a knowledge base and generates responses based on the retrieved results. The response cites up to five sources but only selects the ones that are relevant to the query.</p>
29
+ * <p>Queries a knowledge base and generates responses based on the retrieved results. The response only cites sources that are relevant to the query.</p>
30
30
  * @example
31
31
  * Use a bare-bones client and the command you need to make an API call.
32
32
  * ```javascript
@@ -47,6 +47,54 @@ declare const RetrieveAndGenerateCommand_base: {
47
47
  * vectorSearchConfiguration: { // KnowledgeBaseVectorSearchConfiguration
48
48
  * numberOfResults: Number("int"),
49
49
  * overrideSearchType: "HYBRID" || "SEMANTIC",
50
+ * filter: { // RetrievalFilter Union: only one key present
51
+ * equals: { // FilterAttribute
52
+ * key: "STRING_VALUE", // required
53
+ * value: "DOCUMENT_VALUE", // required
54
+ * },
55
+ * notEquals: {
56
+ * key: "STRING_VALUE", // required
57
+ * value: "DOCUMENT_VALUE", // required
58
+ * },
59
+ * greaterThan: {
60
+ * key: "STRING_VALUE", // required
61
+ * value: "DOCUMENT_VALUE", // required
62
+ * },
63
+ * greaterThanOrEquals: {
64
+ * key: "STRING_VALUE", // required
65
+ * value: "DOCUMENT_VALUE", // required
66
+ * },
67
+ * lessThan: {
68
+ * key: "STRING_VALUE", // required
69
+ * value: "DOCUMENT_VALUE", // required
70
+ * },
71
+ * lessThanOrEquals: "<FilterAttribute>",
72
+ * in: "<FilterAttribute>",
73
+ * notIn: "<FilterAttribute>",
74
+ * startsWith: "<FilterAttribute>",
75
+ * andAll: [ // RetrievalFilterList
76
+ * {// Union: only one key present
77
+ * equals: "<FilterAttribute>",
78
+ * notEquals: "<FilterAttribute>",
79
+ * greaterThan: "<FilterAttribute>",
80
+ * greaterThanOrEquals: "<FilterAttribute>",
81
+ * lessThan: "<FilterAttribute>",
82
+ * lessThanOrEquals: "<FilterAttribute>",
83
+ * in: "<FilterAttribute>",
84
+ * notIn: "<FilterAttribute>",
85
+ * startsWith: "<FilterAttribute>",
86
+ * andAll: [
87
+ * "<RetrievalFilter>",
88
+ * ],
89
+ * orAll: [
90
+ * "<RetrievalFilter>",
91
+ * ],
92
+ * },
93
+ * ],
94
+ * orAll: [
95
+ * "<RetrievalFilter>",
96
+ * ],
97
+ * },
50
98
  * },
51
99
  * },
52
100
  * generationConfiguration: { // GenerationConfiguration
@@ -89,6 +137,9 @@ declare const RetrieveAndGenerateCommand_base: {
89
137
  * // uri: "STRING_VALUE",
90
138
  * // },
91
139
  * // },
140
+ * // metadata: { // RetrievalResultMetadata
141
+ * // "<keys>": "DOCUMENT_VALUE",
142
+ * // },
92
143
  * // },
93
144
  * // ],
94
145
  * // },
@@ -42,6 +42,54 @@ declare const RetrieveCommand_base: {
42
42
  * vectorSearchConfiguration: { // KnowledgeBaseVectorSearchConfiguration
43
43
  * numberOfResults: Number("int"),
44
44
  * overrideSearchType: "HYBRID" || "SEMANTIC",
45
+ * filter: { // RetrievalFilter Union: only one key present
46
+ * equals: { // FilterAttribute
47
+ * key: "STRING_VALUE", // required
48
+ * value: "DOCUMENT_VALUE", // required
49
+ * },
50
+ * notEquals: {
51
+ * key: "STRING_VALUE", // required
52
+ * value: "DOCUMENT_VALUE", // required
53
+ * },
54
+ * greaterThan: {
55
+ * key: "STRING_VALUE", // required
56
+ * value: "DOCUMENT_VALUE", // required
57
+ * },
58
+ * greaterThanOrEquals: {
59
+ * key: "STRING_VALUE", // required
60
+ * value: "DOCUMENT_VALUE", // required
61
+ * },
62
+ * lessThan: {
63
+ * key: "STRING_VALUE", // required
64
+ * value: "DOCUMENT_VALUE", // required
65
+ * },
66
+ * lessThanOrEquals: "<FilterAttribute>",
67
+ * in: "<FilterAttribute>",
68
+ * notIn: "<FilterAttribute>",
69
+ * startsWith: "<FilterAttribute>",
70
+ * andAll: [ // RetrievalFilterList
71
+ * {// Union: only one key present
72
+ * equals: "<FilterAttribute>",
73
+ * notEquals: "<FilterAttribute>",
74
+ * greaterThan: "<FilterAttribute>",
75
+ * greaterThanOrEquals: "<FilterAttribute>",
76
+ * lessThan: "<FilterAttribute>",
77
+ * lessThanOrEquals: "<FilterAttribute>",
78
+ * in: "<FilterAttribute>",
79
+ * notIn: "<FilterAttribute>",
80
+ * startsWith: "<FilterAttribute>",
81
+ * andAll: [
82
+ * "<RetrievalFilter>",
83
+ * ],
84
+ * orAll: [
85
+ * "<RetrievalFilter>",
86
+ * ],
87
+ * },
88
+ * ],
89
+ * orAll: [
90
+ * "<RetrievalFilter>",
91
+ * ],
92
+ * },
45
93
  * },
46
94
  * },
47
95
  * nextToken: "STRING_VALUE",
@@ -61,6 +109,9 @@ declare const RetrieveCommand_base: {
61
109
  * // },
62
110
  * // },
63
111
  * // score: Number("double"),
112
+ * // metadata: { // RetrievalResultMetadata
113
+ * // "<keys>": "DOCUMENT_VALUE",
114
+ * // },
64
115
  * // },
65
116
  * // ],
66
117
  * // nextToken: "STRING_VALUE",