@aws-sdk/client-bedrock-agent-runtime 3.461.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.
- package/LICENSE +201 -0
- package/README.md +229 -0
- package/dist-cjs/BedrockAgentRuntime.js +17 -0
- package/dist-cjs/BedrockAgentRuntimeClient.js +45 -0
- package/dist-cjs/commands/InvokeAgentCommand.js +52 -0
- package/dist-cjs/commands/RetrieveAndGenerateCommand.js +52 -0
- package/dist-cjs/commands/RetrieveCommand.js +52 -0
- package/dist-cjs/commands/index.js +6 -0
- package/dist-cjs/endpoint/EndpointParameters.js +12 -0
- package/dist-cjs/endpoint/endpointResolver.js +12 -0
- package/dist-cjs/endpoint/ruleset.js +7 -0
- package/dist-cjs/extensionConfiguration.js +2 -0
- package/dist-cjs/index.js +12 -0
- package/dist-cjs/models/BedrockAgentRuntimeServiceException.js +12 -0
- package/dist-cjs/models/index.js +4 -0
- package/dist-cjs/models/models_0.js +439 -0
- package/dist-cjs/pagination/Interfaces.js +2 -0
- package/dist-cjs/pagination/RetrievePaginator.js +28 -0
- package/dist-cjs/pagination/index.js +5 -0
- package/dist-cjs/protocols/Aws_restJson1.js +689 -0
- package/dist-cjs/runtimeConfig.browser.js +41 -0
- package/dist-cjs/runtimeConfig.js +52 -0
- package/dist-cjs/runtimeConfig.native.js +15 -0
- package/dist-cjs/runtimeConfig.shared.js +24 -0
- package/dist-cjs/runtimeExtensions.js +22 -0
- package/dist-es/BedrockAgentRuntime.js +13 -0
- package/dist-es/BedrockAgentRuntimeClient.js +41 -0
- package/dist-es/commands/InvokeAgentCommand.js +48 -0
- package/dist-es/commands/RetrieveAndGenerateCommand.js +48 -0
- package/dist-es/commands/RetrieveCommand.js +48 -0
- package/dist-es/commands/index.js +3 -0
- package/dist-es/endpoint/EndpointParameters.js +8 -0
- package/dist-es/endpoint/endpointResolver.js +8 -0
- package/dist-es/endpoint/ruleset.js +4 -0
- package/dist-es/extensionConfiguration.js +1 -0
- package/dist-es/index.js +7 -0
- package/dist-es/models/BedrockAgentRuntimeServiceException.js +8 -0
- package/dist-es/models/index.js +1 -0
- package/dist-es/models/models_0.js +396 -0
- package/dist-es/pagination/Interfaces.js +1 -0
- package/dist-es/pagination/RetrievePaginator.js +24 -0
- package/dist-es/pagination/index.js +2 -0
- package/dist-es/protocols/Aws_restJson1.js +680 -0
- package/dist-es/runtimeConfig.browser.js +36 -0
- package/dist-es/runtimeConfig.js +47 -0
- package/dist-es/runtimeConfig.native.js +11 -0
- package/dist-es/runtimeConfig.shared.js +20 -0
- package/dist-es/runtimeExtensions.js +18 -0
- package/dist-types/BedrockAgentRuntime.d.ts +31 -0
- package/dist-types/BedrockAgentRuntimeClient.d.ts +177 -0
- package/dist-types/commands/InvokeAgentCommand.d.ts +321 -0
- package/dist-types/commands/RetrieveAndGenerateCommand.d.ts +142 -0
- package/dist-types/commands/RetrieveCommand.d.ts +123 -0
- package/dist-types/commands/index.d.ts +3 -0
- package/dist-types/endpoint/EndpointParameters.d.ts +22 -0
- package/dist-types/endpoint/endpointResolver.d.ts +5 -0
- package/dist-types/endpoint/ruleset.d.ts +2 -0
- package/dist-types/extensionConfiguration.d.ts +8 -0
- package/dist-types/index.d.ts +15 -0
- package/dist-types/models/BedrockAgentRuntimeServiceException.d.ts +13 -0
- package/dist-types/models/index.d.ts +1 -0
- package/dist-types/models/models_0.d.ts +1598 -0
- package/dist-types/pagination/Interfaces.d.ts +8 -0
- package/dist-types/pagination/RetrievePaginator.d.ts +7 -0
- package/dist-types/pagination/index.d.ts +2 -0
- package/dist-types/protocols/Aws_restJson1.d.ts +29 -0
- package/dist-types/runtimeConfig.browser.d.ts +47 -0
- package/dist-types/runtimeConfig.d.ts +47 -0
- package/dist-types/runtimeConfig.native.d.ts +46 -0
- package/dist-types/runtimeConfig.shared.d.ts +19 -0
- package/dist-types/runtimeExtensions.d.ts +17 -0
- package/dist-types/ts3.4/BedrockAgentRuntime.d.ts +58 -0
- package/dist-types/ts3.4/BedrockAgentRuntimeClient.d.ts +147 -0
- package/dist-types/ts3.4/commands/InvokeAgentCommand.d.ts +35 -0
- package/dist-types/ts3.4/commands/RetrieveAndGenerateCommand.d.ts +39 -0
- package/dist-types/ts3.4/commands/RetrieveCommand.d.ts +35 -0
- package/dist-types/ts3.4/commands/index.d.ts +3 -0
- package/dist-types/ts3.4/endpoint/EndpointParameters.d.ts +33 -0
- package/dist-types/ts3.4/endpoint/endpointResolver.d.ts +8 -0
- package/dist-types/ts3.4/endpoint/ruleset.d.ts +2 -0
- package/dist-types/ts3.4/extensionConfiguration.d.ts +7 -0
- package/dist-types/ts3.4/index.d.ts +10 -0
- package/dist-types/ts3.4/models/BedrockAgentRuntimeServiceException.d.ts +8 -0
- package/dist-types/ts3.4/models/index.d.ts +1 -0
- package/dist-types/ts3.4/models/models_0.d.ts +737 -0
- package/dist-types/ts3.4/pagination/Interfaces.d.ts +6 -0
- package/dist-types/ts3.4/pagination/RetrievePaginator.d.ts +11 -0
- package/dist-types/ts3.4/pagination/index.d.ts +2 -0
- package/dist-types/ts3.4/protocols/Aws_restJson1.d.ts +44 -0
- package/dist-types/ts3.4/runtimeConfig.browser.d.ts +100 -0
- package/dist-types/ts3.4/runtimeConfig.d.ts +100 -0
- package/dist-types/ts3.4/runtimeConfig.native.d.ts +91 -0
- package/dist-types/ts3.4/runtimeConfig.shared.d.ts +21 -0
- package/dist-types/ts3.4/runtimeExtensions.d.ts +13 -0
- package/package.json +105 -0
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
import { awsExpectUnion as __expectUnion } from "@aws-sdk/core";
|
|
2
|
+
import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
|
|
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, resolvedPath as __resolvedPath, take, withBaseException, } from "@smithy/smithy-client";
|
|
4
|
+
import { BedrockAgentRuntimeServiceException as __BaseException } from "../models/BedrockAgentRuntimeServiceException";
|
|
5
|
+
import { AccessDeniedException, BadGatewayException, ConflictException, DependencyFailedException, InternalServerException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException, ValidationException, } from "../models/models_0";
|
|
6
|
+
export const se_InvokeAgentCommand = async (input, context) => {
|
|
7
|
+
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
|
|
8
|
+
const headers = {
|
|
9
|
+
"content-type": "application/json",
|
|
10
|
+
};
|
|
11
|
+
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
|
|
12
|
+
"/agents/{agentId}/agentAliases/{agentAliasId}/sessions/{sessionId}/text";
|
|
13
|
+
resolvedPath = __resolvedPath(resolvedPath, input, "agentId", () => input.agentId, "{agentId}", false);
|
|
14
|
+
resolvedPath = __resolvedPath(resolvedPath, input, "agentAliasId", () => input.agentAliasId, "{agentAliasId}", false);
|
|
15
|
+
resolvedPath = __resolvedPath(resolvedPath, input, "sessionId", () => input.sessionId, "{sessionId}", false);
|
|
16
|
+
let body;
|
|
17
|
+
body = JSON.stringify(take(input, {
|
|
18
|
+
enableTrace: [],
|
|
19
|
+
endSession: [],
|
|
20
|
+
inputText: [],
|
|
21
|
+
sessionState: (_) => _json(_),
|
|
22
|
+
}));
|
|
23
|
+
return new __HttpRequest({
|
|
24
|
+
protocol,
|
|
25
|
+
hostname,
|
|
26
|
+
port,
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers,
|
|
29
|
+
path: resolvedPath,
|
|
30
|
+
body,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export const se_RetrieveCommand = async (input, context) => {
|
|
34
|
+
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
|
|
35
|
+
const headers = {
|
|
36
|
+
"content-type": "application/json",
|
|
37
|
+
};
|
|
38
|
+
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
|
|
39
|
+
"/knowledgebases/{knowledgeBaseId}/retrieve";
|
|
40
|
+
resolvedPath = __resolvedPath(resolvedPath, input, "knowledgeBaseId", () => input.knowledgeBaseId, "{knowledgeBaseId}", false);
|
|
41
|
+
let body;
|
|
42
|
+
body = JSON.stringify(take(input, {
|
|
43
|
+
nextToken: [],
|
|
44
|
+
retrievalConfiguration: (_) => _json(_),
|
|
45
|
+
retrievalQuery: (_) => _json(_),
|
|
46
|
+
}));
|
|
47
|
+
return new __HttpRequest({
|
|
48
|
+
protocol,
|
|
49
|
+
hostname,
|
|
50
|
+
port,
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers,
|
|
53
|
+
path: resolvedPath,
|
|
54
|
+
body,
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
export const se_RetrieveAndGenerateCommand = async (input, context) => {
|
|
58
|
+
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
|
|
59
|
+
const headers = {
|
|
60
|
+
"content-type": "application/json",
|
|
61
|
+
};
|
|
62
|
+
const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/retrieveAndGenerate";
|
|
63
|
+
let body;
|
|
64
|
+
body = JSON.stringify(take(input, {
|
|
65
|
+
input: (_) => _json(_),
|
|
66
|
+
retrieveAndGenerateConfiguration: (_) => _json(_),
|
|
67
|
+
sessionConfiguration: (_) => _json(_),
|
|
68
|
+
sessionId: [],
|
|
69
|
+
}));
|
|
70
|
+
return new __HttpRequest({
|
|
71
|
+
protocol,
|
|
72
|
+
hostname,
|
|
73
|
+
port,
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers,
|
|
76
|
+
path: resolvedPath,
|
|
77
|
+
body,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
export const de_InvokeAgentCommand = async (output, context) => {
|
|
81
|
+
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
82
|
+
return de_InvokeAgentCommandError(output, context);
|
|
83
|
+
}
|
|
84
|
+
const contents = map({
|
|
85
|
+
$metadata: deserializeMetadata(output),
|
|
86
|
+
contentType: [, output.headers["x-amzn-bedrock-agent-content-type"]],
|
|
87
|
+
sessionId: [, output.headers["x-amz-bedrock-agent-session-id"]],
|
|
88
|
+
});
|
|
89
|
+
const data = output.body;
|
|
90
|
+
contents.completion = de_ResponseStream(data, context);
|
|
91
|
+
return contents;
|
|
92
|
+
};
|
|
93
|
+
const de_InvokeAgentCommandError = async (output, context) => {
|
|
94
|
+
const parsedOutput = {
|
|
95
|
+
...output,
|
|
96
|
+
body: await parseErrorBody(output.body, context),
|
|
97
|
+
};
|
|
98
|
+
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
|
|
99
|
+
switch (errorCode) {
|
|
100
|
+
case "AccessDeniedException":
|
|
101
|
+
case "com.amazonaws.bedrockagentruntime#AccessDeniedException":
|
|
102
|
+
throw await de_AccessDeniedExceptionRes(parsedOutput, context);
|
|
103
|
+
case "BadGatewayException":
|
|
104
|
+
case "com.amazonaws.bedrockagentruntime#BadGatewayException":
|
|
105
|
+
throw await de_BadGatewayExceptionRes(parsedOutput, context);
|
|
106
|
+
case "ConflictException":
|
|
107
|
+
case "com.amazonaws.bedrockagentruntime#ConflictException":
|
|
108
|
+
throw await de_ConflictExceptionRes(parsedOutput, context);
|
|
109
|
+
case "DependencyFailedException":
|
|
110
|
+
case "com.amazonaws.bedrockagentruntime#DependencyFailedException":
|
|
111
|
+
throw await de_DependencyFailedExceptionRes(parsedOutput, context);
|
|
112
|
+
case "InternalServerException":
|
|
113
|
+
case "com.amazonaws.bedrockagentruntime#InternalServerException":
|
|
114
|
+
throw await de_InternalServerExceptionRes(parsedOutput, context);
|
|
115
|
+
case "ResourceNotFoundException":
|
|
116
|
+
case "com.amazonaws.bedrockagentruntime#ResourceNotFoundException":
|
|
117
|
+
throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
|
|
118
|
+
case "ServiceQuotaExceededException":
|
|
119
|
+
case "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException":
|
|
120
|
+
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
121
|
+
case "ThrottlingException":
|
|
122
|
+
case "com.amazonaws.bedrockagentruntime#ThrottlingException":
|
|
123
|
+
throw await de_ThrottlingExceptionRes(parsedOutput, context);
|
|
124
|
+
case "ValidationException":
|
|
125
|
+
case "com.amazonaws.bedrockagentruntime#ValidationException":
|
|
126
|
+
throw await de_ValidationExceptionRes(parsedOutput, context);
|
|
127
|
+
default:
|
|
128
|
+
const parsedBody = parsedOutput.body;
|
|
129
|
+
return throwDefaultError({
|
|
130
|
+
output,
|
|
131
|
+
parsedBody,
|
|
132
|
+
errorCode,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
export const de_RetrieveCommand = async (output, context) => {
|
|
137
|
+
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
138
|
+
return de_RetrieveCommandError(output, context);
|
|
139
|
+
}
|
|
140
|
+
const contents = map({
|
|
141
|
+
$metadata: deserializeMetadata(output),
|
|
142
|
+
});
|
|
143
|
+
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
|
|
144
|
+
const doc = take(data, {
|
|
145
|
+
nextToken: __expectString,
|
|
146
|
+
retrievalResults: (_) => de_KnowledgeBaseRetrievalResults(_, context),
|
|
147
|
+
});
|
|
148
|
+
Object.assign(contents, doc);
|
|
149
|
+
return contents;
|
|
150
|
+
};
|
|
151
|
+
const de_RetrieveCommandError = async (output, context) => {
|
|
152
|
+
const parsedOutput = {
|
|
153
|
+
...output,
|
|
154
|
+
body: await parseErrorBody(output.body, context),
|
|
155
|
+
};
|
|
156
|
+
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
|
|
157
|
+
switch (errorCode) {
|
|
158
|
+
case "AccessDeniedException":
|
|
159
|
+
case "com.amazonaws.bedrockagentruntime#AccessDeniedException":
|
|
160
|
+
throw await de_AccessDeniedExceptionRes(parsedOutput, context);
|
|
161
|
+
case "BadGatewayException":
|
|
162
|
+
case "com.amazonaws.bedrockagentruntime#BadGatewayException":
|
|
163
|
+
throw await de_BadGatewayExceptionRes(parsedOutput, context);
|
|
164
|
+
case "ConflictException":
|
|
165
|
+
case "com.amazonaws.bedrockagentruntime#ConflictException":
|
|
166
|
+
throw await de_ConflictExceptionRes(parsedOutput, context);
|
|
167
|
+
case "DependencyFailedException":
|
|
168
|
+
case "com.amazonaws.bedrockagentruntime#DependencyFailedException":
|
|
169
|
+
throw await de_DependencyFailedExceptionRes(parsedOutput, context);
|
|
170
|
+
case "InternalServerException":
|
|
171
|
+
case "com.amazonaws.bedrockagentruntime#InternalServerException":
|
|
172
|
+
throw await de_InternalServerExceptionRes(parsedOutput, context);
|
|
173
|
+
case "ResourceNotFoundException":
|
|
174
|
+
case "com.amazonaws.bedrockagentruntime#ResourceNotFoundException":
|
|
175
|
+
throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
|
|
176
|
+
case "ServiceQuotaExceededException":
|
|
177
|
+
case "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException":
|
|
178
|
+
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
179
|
+
case "ThrottlingException":
|
|
180
|
+
case "com.amazonaws.bedrockagentruntime#ThrottlingException":
|
|
181
|
+
throw await de_ThrottlingExceptionRes(parsedOutput, context);
|
|
182
|
+
case "ValidationException":
|
|
183
|
+
case "com.amazonaws.bedrockagentruntime#ValidationException":
|
|
184
|
+
throw await de_ValidationExceptionRes(parsedOutput, context);
|
|
185
|
+
default:
|
|
186
|
+
const parsedBody = parsedOutput.body;
|
|
187
|
+
return throwDefaultError({
|
|
188
|
+
output,
|
|
189
|
+
parsedBody,
|
|
190
|
+
errorCode,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
export const de_RetrieveAndGenerateCommand = async (output, context) => {
|
|
195
|
+
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
196
|
+
return de_RetrieveAndGenerateCommandError(output, context);
|
|
197
|
+
}
|
|
198
|
+
const contents = map({
|
|
199
|
+
$metadata: deserializeMetadata(output),
|
|
200
|
+
});
|
|
201
|
+
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
|
|
202
|
+
const doc = take(data, {
|
|
203
|
+
citations: _json,
|
|
204
|
+
output: _json,
|
|
205
|
+
sessionId: __expectString,
|
|
206
|
+
});
|
|
207
|
+
Object.assign(contents, doc);
|
|
208
|
+
return contents;
|
|
209
|
+
};
|
|
210
|
+
const de_RetrieveAndGenerateCommandError = async (output, context) => {
|
|
211
|
+
const parsedOutput = {
|
|
212
|
+
...output,
|
|
213
|
+
body: await parseErrorBody(output.body, context),
|
|
214
|
+
};
|
|
215
|
+
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
|
|
216
|
+
switch (errorCode) {
|
|
217
|
+
case "AccessDeniedException":
|
|
218
|
+
case "com.amazonaws.bedrockagentruntime#AccessDeniedException":
|
|
219
|
+
throw await de_AccessDeniedExceptionRes(parsedOutput, context);
|
|
220
|
+
case "BadGatewayException":
|
|
221
|
+
case "com.amazonaws.bedrockagentruntime#BadGatewayException":
|
|
222
|
+
throw await de_BadGatewayExceptionRes(parsedOutput, context);
|
|
223
|
+
case "ConflictException":
|
|
224
|
+
case "com.amazonaws.bedrockagentruntime#ConflictException":
|
|
225
|
+
throw await de_ConflictExceptionRes(parsedOutput, context);
|
|
226
|
+
case "DependencyFailedException":
|
|
227
|
+
case "com.amazonaws.bedrockagentruntime#DependencyFailedException":
|
|
228
|
+
throw await de_DependencyFailedExceptionRes(parsedOutput, context);
|
|
229
|
+
case "InternalServerException":
|
|
230
|
+
case "com.amazonaws.bedrockagentruntime#InternalServerException":
|
|
231
|
+
throw await de_InternalServerExceptionRes(parsedOutput, context);
|
|
232
|
+
case "ResourceNotFoundException":
|
|
233
|
+
case "com.amazonaws.bedrockagentruntime#ResourceNotFoundException":
|
|
234
|
+
throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
|
|
235
|
+
case "ServiceQuotaExceededException":
|
|
236
|
+
case "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException":
|
|
237
|
+
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
238
|
+
case "ThrottlingException":
|
|
239
|
+
case "com.amazonaws.bedrockagentruntime#ThrottlingException":
|
|
240
|
+
throw await de_ThrottlingExceptionRes(parsedOutput, context);
|
|
241
|
+
case "ValidationException":
|
|
242
|
+
case "com.amazonaws.bedrockagentruntime#ValidationException":
|
|
243
|
+
throw await de_ValidationExceptionRes(parsedOutput, context);
|
|
244
|
+
default:
|
|
245
|
+
const parsedBody = parsedOutput.body;
|
|
246
|
+
return throwDefaultError({
|
|
247
|
+
output,
|
|
248
|
+
parsedBody,
|
|
249
|
+
errorCode,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const throwDefaultError = withBaseException(__BaseException);
|
|
254
|
+
const de_AccessDeniedExceptionRes = async (parsedOutput, context) => {
|
|
255
|
+
const contents = map({});
|
|
256
|
+
const data = parsedOutput.body;
|
|
257
|
+
const doc = take(data, {
|
|
258
|
+
message: __expectString,
|
|
259
|
+
});
|
|
260
|
+
Object.assign(contents, doc);
|
|
261
|
+
const exception = new AccessDeniedException({
|
|
262
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
263
|
+
...contents,
|
|
264
|
+
});
|
|
265
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
266
|
+
};
|
|
267
|
+
const de_BadGatewayExceptionRes = async (parsedOutput, context) => {
|
|
268
|
+
const contents = map({});
|
|
269
|
+
const data = parsedOutput.body;
|
|
270
|
+
const doc = take(data, {
|
|
271
|
+
message: __expectString,
|
|
272
|
+
resourceName: __expectString,
|
|
273
|
+
});
|
|
274
|
+
Object.assign(contents, doc);
|
|
275
|
+
const exception = new BadGatewayException({
|
|
276
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
277
|
+
...contents,
|
|
278
|
+
});
|
|
279
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
280
|
+
};
|
|
281
|
+
const de_ConflictExceptionRes = async (parsedOutput, context) => {
|
|
282
|
+
const contents = map({});
|
|
283
|
+
const data = parsedOutput.body;
|
|
284
|
+
const doc = take(data, {
|
|
285
|
+
message: __expectString,
|
|
286
|
+
});
|
|
287
|
+
Object.assign(contents, doc);
|
|
288
|
+
const exception = new ConflictException({
|
|
289
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
290
|
+
...contents,
|
|
291
|
+
});
|
|
292
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
293
|
+
};
|
|
294
|
+
const de_DependencyFailedExceptionRes = async (parsedOutput, context) => {
|
|
295
|
+
const contents = map({});
|
|
296
|
+
const data = parsedOutput.body;
|
|
297
|
+
const doc = take(data, {
|
|
298
|
+
message: __expectString,
|
|
299
|
+
resourceName: __expectString,
|
|
300
|
+
});
|
|
301
|
+
Object.assign(contents, doc);
|
|
302
|
+
const exception = new DependencyFailedException({
|
|
303
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
304
|
+
...contents,
|
|
305
|
+
});
|
|
306
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
307
|
+
};
|
|
308
|
+
const de_InternalServerExceptionRes = async (parsedOutput, context) => {
|
|
309
|
+
const contents = map({});
|
|
310
|
+
const data = parsedOutput.body;
|
|
311
|
+
const doc = take(data, {
|
|
312
|
+
message: __expectString,
|
|
313
|
+
});
|
|
314
|
+
Object.assign(contents, doc);
|
|
315
|
+
const exception = new InternalServerException({
|
|
316
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
317
|
+
...contents,
|
|
318
|
+
});
|
|
319
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
320
|
+
};
|
|
321
|
+
const de_ResourceNotFoundExceptionRes = async (parsedOutput, context) => {
|
|
322
|
+
const contents = map({});
|
|
323
|
+
const data = parsedOutput.body;
|
|
324
|
+
const doc = take(data, {
|
|
325
|
+
message: __expectString,
|
|
326
|
+
});
|
|
327
|
+
Object.assign(contents, doc);
|
|
328
|
+
const exception = new ResourceNotFoundException({
|
|
329
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
330
|
+
...contents,
|
|
331
|
+
});
|
|
332
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
333
|
+
};
|
|
334
|
+
const de_ServiceQuotaExceededExceptionRes = async (parsedOutput, context) => {
|
|
335
|
+
const contents = map({});
|
|
336
|
+
const data = parsedOutput.body;
|
|
337
|
+
const doc = take(data, {
|
|
338
|
+
message: __expectString,
|
|
339
|
+
});
|
|
340
|
+
Object.assign(contents, doc);
|
|
341
|
+
const exception = new ServiceQuotaExceededException({
|
|
342
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
343
|
+
...contents,
|
|
344
|
+
});
|
|
345
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
346
|
+
};
|
|
347
|
+
const de_ThrottlingExceptionRes = async (parsedOutput, context) => {
|
|
348
|
+
const contents = map({});
|
|
349
|
+
const data = parsedOutput.body;
|
|
350
|
+
const doc = take(data, {
|
|
351
|
+
message: __expectString,
|
|
352
|
+
});
|
|
353
|
+
Object.assign(contents, doc);
|
|
354
|
+
const exception = new ThrottlingException({
|
|
355
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
356
|
+
...contents,
|
|
357
|
+
});
|
|
358
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
359
|
+
};
|
|
360
|
+
const de_ValidationExceptionRes = async (parsedOutput, context) => {
|
|
361
|
+
const contents = map({});
|
|
362
|
+
const data = parsedOutput.body;
|
|
363
|
+
const doc = take(data, {
|
|
364
|
+
message: __expectString,
|
|
365
|
+
});
|
|
366
|
+
Object.assign(contents, doc);
|
|
367
|
+
const exception = new ValidationException({
|
|
368
|
+
$metadata: deserializeMetadata(parsedOutput),
|
|
369
|
+
...contents,
|
|
370
|
+
});
|
|
371
|
+
return __decorateServiceException(exception, parsedOutput.body);
|
|
372
|
+
};
|
|
373
|
+
const de_ResponseStream = (output, context) => {
|
|
374
|
+
return context.eventStreamMarshaller.deserialize(output, async (event) => {
|
|
375
|
+
if (event["chunk"] != null) {
|
|
376
|
+
return {
|
|
377
|
+
chunk: await de_PayloadPart_event(event["chunk"], context),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
if (event["trace"] != null) {
|
|
381
|
+
return {
|
|
382
|
+
trace: await de_TracePart_event(event["trace"], context),
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (event["internalServerException"] != null) {
|
|
386
|
+
return {
|
|
387
|
+
internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
if (event["validationException"] != null) {
|
|
391
|
+
return {
|
|
392
|
+
validationException: await de_ValidationException_event(event["validationException"], context),
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
if (event["resourceNotFoundException"] != null) {
|
|
396
|
+
return {
|
|
397
|
+
resourceNotFoundException: await de_ResourceNotFoundException_event(event["resourceNotFoundException"], context),
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
if (event["serviceQuotaExceededException"] != null) {
|
|
401
|
+
return {
|
|
402
|
+
serviceQuotaExceededException: await de_ServiceQuotaExceededException_event(event["serviceQuotaExceededException"], context),
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (event["throttlingException"] != null) {
|
|
406
|
+
return {
|
|
407
|
+
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
if (event["accessDeniedException"] != null) {
|
|
411
|
+
return {
|
|
412
|
+
accessDeniedException: await de_AccessDeniedException_event(event["accessDeniedException"], context),
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if (event["conflictException"] != null) {
|
|
416
|
+
return {
|
|
417
|
+
conflictException: await de_ConflictException_event(event["conflictException"], context),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
if (event["dependencyFailedException"] != null) {
|
|
421
|
+
return {
|
|
422
|
+
dependencyFailedException: await de_DependencyFailedException_event(event["dependencyFailedException"], context),
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
if (event["badGatewayException"] != null) {
|
|
426
|
+
return {
|
|
427
|
+
badGatewayException: await de_BadGatewayException_event(event["badGatewayException"], context),
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
return { $unknown: output };
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
const de_AccessDeniedException_event = async (output, context) => {
|
|
434
|
+
const parsedOutput = {
|
|
435
|
+
...output,
|
|
436
|
+
body: await parseBody(output.body, context),
|
|
437
|
+
};
|
|
438
|
+
return de_AccessDeniedExceptionRes(parsedOutput, context);
|
|
439
|
+
};
|
|
440
|
+
const de_BadGatewayException_event = async (output, context) => {
|
|
441
|
+
const parsedOutput = {
|
|
442
|
+
...output,
|
|
443
|
+
body: await parseBody(output.body, context),
|
|
444
|
+
};
|
|
445
|
+
return de_BadGatewayExceptionRes(parsedOutput, context);
|
|
446
|
+
};
|
|
447
|
+
const de_ConflictException_event = async (output, context) => {
|
|
448
|
+
const parsedOutput = {
|
|
449
|
+
...output,
|
|
450
|
+
body: await parseBody(output.body, context),
|
|
451
|
+
};
|
|
452
|
+
return de_ConflictExceptionRes(parsedOutput, context);
|
|
453
|
+
};
|
|
454
|
+
const de_DependencyFailedException_event = async (output, context) => {
|
|
455
|
+
const parsedOutput = {
|
|
456
|
+
...output,
|
|
457
|
+
body: await parseBody(output.body, context),
|
|
458
|
+
};
|
|
459
|
+
return de_DependencyFailedExceptionRes(parsedOutput, context);
|
|
460
|
+
};
|
|
461
|
+
const de_InternalServerException_event = async (output, context) => {
|
|
462
|
+
const parsedOutput = {
|
|
463
|
+
...output,
|
|
464
|
+
body: await parseBody(output.body, context),
|
|
465
|
+
};
|
|
466
|
+
return de_InternalServerExceptionRes(parsedOutput, context);
|
|
467
|
+
};
|
|
468
|
+
const de_PayloadPart_event = async (output, context) => {
|
|
469
|
+
const contents = {};
|
|
470
|
+
const data = await parseBody(output.body, context);
|
|
471
|
+
Object.assign(contents, de_PayloadPart(data, context));
|
|
472
|
+
return contents;
|
|
473
|
+
};
|
|
474
|
+
const de_ResourceNotFoundException_event = async (output, context) => {
|
|
475
|
+
const parsedOutput = {
|
|
476
|
+
...output,
|
|
477
|
+
body: await parseBody(output.body, context),
|
|
478
|
+
};
|
|
479
|
+
return de_ResourceNotFoundExceptionRes(parsedOutput, context);
|
|
480
|
+
};
|
|
481
|
+
const de_ServiceQuotaExceededException_event = async (output, context) => {
|
|
482
|
+
const parsedOutput = {
|
|
483
|
+
...output,
|
|
484
|
+
body: await parseBody(output.body, context),
|
|
485
|
+
};
|
|
486
|
+
return de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
487
|
+
};
|
|
488
|
+
const de_ThrottlingException_event = async (output, context) => {
|
|
489
|
+
const parsedOutput = {
|
|
490
|
+
...output,
|
|
491
|
+
body: await parseBody(output.body, context),
|
|
492
|
+
};
|
|
493
|
+
return de_ThrottlingExceptionRes(parsedOutput, context);
|
|
494
|
+
};
|
|
495
|
+
const de_TracePart_event = async (output, context) => {
|
|
496
|
+
const contents = {};
|
|
497
|
+
const data = await parseBody(output.body, context);
|
|
498
|
+
Object.assign(contents, de_TracePart(data, context));
|
|
499
|
+
return contents;
|
|
500
|
+
};
|
|
501
|
+
const de_ValidationException_event = async (output, context) => {
|
|
502
|
+
const parsedOutput = {
|
|
503
|
+
...output,
|
|
504
|
+
body: await parseBody(output.body, context),
|
|
505
|
+
};
|
|
506
|
+
return de_ValidationExceptionRes(parsedOutput, context);
|
|
507
|
+
};
|
|
508
|
+
const de_InferenceConfiguration = (output, context) => {
|
|
509
|
+
return take(output, {
|
|
510
|
+
maximumLength: __expectInt32,
|
|
511
|
+
stopSequences: _json,
|
|
512
|
+
temperature: __limitedParseFloat32,
|
|
513
|
+
topK: __expectInt32,
|
|
514
|
+
topP: __limitedParseFloat32,
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
const de_KnowledgeBaseRetrievalResult = (output, context) => {
|
|
518
|
+
return take(output, {
|
|
519
|
+
content: _json,
|
|
520
|
+
location: _json,
|
|
521
|
+
score: __limitedParseDouble,
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
const de_KnowledgeBaseRetrievalResults = (output, context) => {
|
|
525
|
+
const retVal = (output || [])
|
|
526
|
+
.filter((e) => e != null)
|
|
527
|
+
.map((entry) => {
|
|
528
|
+
return de_KnowledgeBaseRetrievalResult(entry, context);
|
|
529
|
+
});
|
|
530
|
+
return retVal;
|
|
531
|
+
};
|
|
532
|
+
const de_ModelInvocationInput = (output, context) => {
|
|
533
|
+
return take(output, {
|
|
534
|
+
inferenceConfiguration: (_) => de_InferenceConfiguration(_, context),
|
|
535
|
+
overrideLambda: __expectString,
|
|
536
|
+
parserMode: __expectString,
|
|
537
|
+
promptCreationMode: __expectString,
|
|
538
|
+
text: __expectString,
|
|
539
|
+
traceId: __expectString,
|
|
540
|
+
type: __expectString,
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
const de_OrchestrationTrace = (output, context) => {
|
|
544
|
+
if (output.invocationInput != null) {
|
|
545
|
+
return {
|
|
546
|
+
invocationInput: _json(output.invocationInput),
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
if (output.modelInvocationInput != null) {
|
|
550
|
+
return {
|
|
551
|
+
modelInvocationInput: de_ModelInvocationInput(output.modelInvocationInput, context),
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
if (output.observation != null) {
|
|
555
|
+
return {
|
|
556
|
+
observation: _json(output.observation),
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
if (output.rationale != null) {
|
|
560
|
+
return {
|
|
561
|
+
rationale: _json(output.rationale),
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
return { $unknown: Object.entries(output)[0] };
|
|
565
|
+
};
|
|
566
|
+
const de_PayloadPart = (output, context) => {
|
|
567
|
+
return take(output, {
|
|
568
|
+
attribution: _json,
|
|
569
|
+
bytes: context.base64Decoder,
|
|
570
|
+
});
|
|
571
|
+
};
|
|
572
|
+
const de_PostProcessingTrace = (output, context) => {
|
|
573
|
+
if (output.modelInvocationInput != null) {
|
|
574
|
+
return {
|
|
575
|
+
modelInvocationInput: de_ModelInvocationInput(output.modelInvocationInput, context),
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
if (output.modelInvocationOutput != null) {
|
|
579
|
+
return {
|
|
580
|
+
modelInvocationOutput: _json(output.modelInvocationOutput),
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
return { $unknown: Object.entries(output)[0] };
|
|
584
|
+
};
|
|
585
|
+
const de_PreProcessingTrace = (output, context) => {
|
|
586
|
+
if (output.modelInvocationInput != null) {
|
|
587
|
+
return {
|
|
588
|
+
modelInvocationInput: de_ModelInvocationInput(output.modelInvocationInput, context),
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
if (output.modelInvocationOutput != null) {
|
|
592
|
+
return {
|
|
593
|
+
modelInvocationOutput: _json(output.modelInvocationOutput),
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
return { $unknown: Object.entries(output)[0] };
|
|
597
|
+
};
|
|
598
|
+
const de_Trace = (output, context) => {
|
|
599
|
+
if (output.failureTrace != null) {
|
|
600
|
+
return {
|
|
601
|
+
failureTrace: _json(output.failureTrace),
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
if (output.orchestrationTrace != null) {
|
|
605
|
+
return {
|
|
606
|
+
orchestrationTrace: de_OrchestrationTrace(__expectUnion(output.orchestrationTrace), context),
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (output.postProcessingTrace != null) {
|
|
610
|
+
return {
|
|
611
|
+
postProcessingTrace: de_PostProcessingTrace(__expectUnion(output.postProcessingTrace), context),
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
if (output.preProcessingTrace != null) {
|
|
615
|
+
return {
|
|
616
|
+
preProcessingTrace: de_PreProcessingTrace(__expectUnion(output.preProcessingTrace), context),
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
return { $unknown: Object.entries(output)[0] };
|
|
620
|
+
};
|
|
621
|
+
const de_TracePart = (output, context) => {
|
|
622
|
+
return take(output, {
|
|
623
|
+
agentAliasId: __expectString,
|
|
624
|
+
agentId: __expectString,
|
|
625
|
+
sessionId: __expectString,
|
|
626
|
+
trace: (_) => de_Trace(__expectUnion(_), context),
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
const deserializeMetadata = (output) => ({
|
|
630
|
+
httpStatusCode: output.statusCode,
|
|
631
|
+
requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
|
|
632
|
+
extendedRequestId: output.headers["x-amz-id-2"],
|
|
633
|
+
cfId: output.headers["x-amz-cf-id"],
|
|
634
|
+
});
|
|
635
|
+
const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
|
|
636
|
+
const isSerializableHeaderValue = (value) => value !== undefined &&
|
|
637
|
+
value !== null &&
|
|
638
|
+
value !== "" &&
|
|
639
|
+
(!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
|
|
640
|
+
(!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
|
|
641
|
+
const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
|
642
|
+
if (encoded.length) {
|
|
643
|
+
return JSON.parse(encoded);
|
|
644
|
+
}
|
|
645
|
+
return {};
|
|
646
|
+
});
|
|
647
|
+
const parseErrorBody = async (errorBody, context) => {
|
|
648
|
+
const value = await parseBody(errorBody, context);
|
|
649
|
+
value.message = value.message ?? value.Message;
|
|
650
|
+
return value;
|
|
651
|
+
};
|
|
652
|
+
const loadRestJsonErrorCode = (output, data) => {
|
|
653
|
+
const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
|
|
654
|
+
const sanitizeErrorCode = (rawValue) => {
|
|
655
|
+
let cleanValue = rawValue;
|
|
656
|
+
if (typeof cleanValue === "number") {
|
|
657
|
+
cleanValue = cleanValue.toString();
|
|
658
|
+
}
|
|
659
|
+
if (cleanValue.indexOf(",") >= 0) {
|
|
660
|
+
cleanValue = cleanValue.split(",")[0];
|
|
661
|
+
}
|
|
662
|
+
if (cleanValue.indexOf(":") >= 0) {
|
|
663
|
+
cleanValue = cleanValue.split(":")[0];
|
|
664
|
+
}
|
|
665
|
+
if (cleanValue.indexOf("#") >= 0) {
|
|
666
|
+
cleanValue = cleanValue.split("#")[1];
|
|
667
|
+
}
|
|
668
|
+
return cleanValue;
|
|
669
|
+
};
|
|
670
|
+
const headerKey = findKey(output.headers, "x-amzn-errortype");
|
|
671
|
+
if (headerKey !== undefined) {
|
|
672
|
+
return sanitizeErrorCode(output.headers[headerKey]);
|
|
673
|
+
}
|
|
674
|
+
if (data.code !== undefined) {
|
|
675
|
+
return sanitizeErrorCode(data.code);
|
|
676
|
+
}
|
|
677
|
+
if (data["__type"] !== undefined) {
|
|
678
|
+
return sanitizeErrorCode(data["__type"]);
|
|
679
|
+
}
|
|
680
|
+
};
|