@stacksjs/ts-cloud 0.1.2 → 0.1.5
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/README.md +98 -13
- package/dist/aws/acm.d.ts +129 -0
- package/dist/aws/application-autoscaling.d.ts +282 -0
- package/dist/aws/bedrock.d.ts +2292 -0
- package/dist/aws/client.d.ts +79 -0
- package/dist/aws/cloudformation.d.ts +105 -0
- package/dist/aws/cloudfront.d.ts +265 -0
- package/dist/aws/cloudwatch-logs.d.ts +48 -0
- package/dist/aws/comprehend.d.ts +505 -0
- package/dist/aws/connect.d.ts +377 -0
- package/dist/aws/deploy-imap.d.ts +14 -0
- package/dist/aws/dynamodb.d.ts +176 -0
- package/dist/aws/ec2.d.ts +272 -0
- package/dist/aws/ecr.d.ts +149 -0
- package/dist/aws/ecs.d.ts +162 -0
- package/dist/aws/elasticache.d.ts +71 -0
- package/dist/aws/elbv2.d.ts +248 -0
- package/dist/aws/email.d.ts +175 -0
- package/dist/aws/eventbridge.d.ts +142 -0
- package/dist/aws/iam.d.ts +638 -0
- package/dist/aws/imap-server.d.ts +119 -0
- package/{src/aws/index.ts → dist/aws/index.d.ts} +62 -83
- package/{src/aws/kendra.ts → dist/aws/kendra.d.ts} +71 -386
- package/dist/aws/lambda.d.ts +232 -0
- package/dist/aws/opensearch.d.ts +87 -0
- package/dist/aws/personalize.d.ts +516 -0
- package/dist/aws/polly.d.ts +214 -0
- package/dist/aws/rds.d.ts +240 -0
- package/dist/aws/rekognition.d.ts +543 -0
- package/dist/aws/route53-domains.d.ts +113 -0
- package/dist/aws/route53.d.ts +215 -0
- package/dist/aws/s3.d.ts +212 -0
- package/dist/aws/scheduler.d.ts +140 -0
- package/dist/aws/secrets-manager.d.ts +170 -0
- package/dist/aws/ses.d.ts +288 -0
- package/dist/aws/setup-phone.d.ts +0 -0
- package/dist/aws/setup-sms.d.ts +115 -0
- package/dist/aws/sms.d.ts +304 -0
- package/dist/aws/smtp-server.d.ts +61 -0
- package/dist/aws/sns.d.ts +117 -0
- package/dist/aws/sqs.d.ts +65 -0
- package/dist/aws/ssm.d.ts +179 -0
- package/dist/aws/sts.d.ts +15 -0
- package/dist/aws/support.d.ts +104 -0
- package/dist/aws/test-imap.d.ts +0 -0
- package/dist/aws/textract.d.ts +403 -0
- package/dist/aws/transcribe.d.ts +60 -0
- package/dist/aws/translate.d.ts +358 -0
- package/dist/aws/voice.d.ts +219 -0
- package/dist/bin/cli.js +1724 -0
- package/dist/config.d.ts +7 -0
- package/dist/deploy/index.d.ts +2 -0
- package/dist/deploy/static-site-external-dns.d.ts +51 -0
- package/dist/deploy/static-site.d.ts +71 -0
- package/dist/dns/cloudflare.d.ts +52 -0
- package/dist/dns/godaddy.d.ts +38 -0
- package/dist/dns/index.d.ts +45 -0
- package/dist/dns/porkbun.d.ts +18 -0
- package/dist/dns/route53-adapter.d.ts +38 -0
- package/{src/dns/types.ts → dist/dns/types.d.ts} +26 -63
- package/dist/dns/validator.d.ts +78 -0
- package/dist/generators/index.d.ts +1 -0
- package/dist/generators/infrastructure.d.ts +30 -0
- package/{src/index.ts → dist/index.d.ts} +70 -93
- package/dist/index.js +7881 -0
- package/dist/push/apns.d.ts +60 -0
- package/dist/push/fcm.d.ts +117 -0
- package/dist/push/index.d.ts +14 -0
- package/dist/security/pre-deploy-scanner.d.ts +69 -0
- package/dist/ssl/acme-client.d.ts +67 -0
- package/dist/ssl/index.d.ts +2 -0
- package/dist/ssl/letsencrypt.d.ts +48 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/cli.d.ts +123 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/template.d.ts +23 -0
- package/package.json +8 -8
- package/bin/cli.ts +0 -133
- package/bin/commands/analytics.ts +0 -328
- package/bin/commands/api.ts +0 -379
- package/bin/commands/assets.ts +0 -221
- package/bin/commands/audit.ts +0 -501
- package/bin/commands/backup.ts +0 -682
- package/bin/commands/cache.ts +0 -294
- package/bin/commands/cdn.ts +0 -281
- package/bin/commands/config.ts +0 -202
- package/bin/commands/container.ts +0 -105
- package/bin/commands/cost.ts +0 -208
- package/bin/commands/database.ts +0 -401
- package/bin/commands/deploy.ts +0 -674
- package/bin/commands/domain.ts +0 -397
- package/bin/commands/email.ts +0 -423
- package/bin/commands/environment.ts +0 -285
- package/bin/commands/events.ts +0 -424
- package/bin/commands/firewall.ts +0 -145
- package/bin/commands/function.ts +0 -116
- package/bin/commands/generate.ts +0 -280
- package/bin/commands/git.ts +0 -139
- package/bin/commands/iam.ts +0 -464
- package/bin/commands/index.ts +0 -48
- package/bin/commands/init.ts +0 -120
- package/bin/commands/logs.ts +0 -148
- package/bin/commands/network.ts +0 -579
- package/bin/commands/notify.ts +0 -489
- package/bin/commands/queue.ts +0 -407
- package/bin/commands/scheduler.ts +0 -370
- package/bin/commands/secrets.ts +0 -54
- package/bin/commands/server.ts +0 -629
- package/bin/commands/shared.ts +0 -97
- package/bin/commands/ssl.ts +0 -138
- package/bin/commands/stack.ts +0 -325
- package/bin/commands/status.ts +0 -385
- package/bin/commands/storage.ts +0 -450
- package/bin/commands/team.ts +0 -96
- package/bin/commands/tunnel.ts +0 -489
- package/bin/commands/utils.ts +0 -202
- package/build.ts +0 -15
- package/cloud +0 -2
- package/src/aws/acm.ts +0 -768
- package/src/aws/application-autoscaling.ts +0 -845
- package/src/aws/bedrock.ts +0 -4074
- package/src/aws/client.ts +0 -878
- package/src/aws/cloudformation.ts +0 -896
- package/src/aws/cloudfront.ts +0 -1531
- package/src/aws/cloudwatch-logs.ts +0 -154
- package/src/aws/comprehend.ts +0 -839
- package/src/aws/connect.ts +0 -1056
- package/src/aws/deploy-imap.ts +0 -384
- package/src/aws/dynamodb.ts +0 -340
- package/src/aws/ec2.ts +0 -1385
- package/src/aws/ecr.ts +0 -621
- package/src/aws/ecs.ts +0 -615
- package/src/aws/elasticache.ts +0 -301
- package/src/aws/elbv2.ts +0 -942
- package/src/aws/email.ts +0 -928
- package/src/aws/eventbridge.ts +0 -248
- package/src/aws/iam.ts +0 -1689
- package/src/aws/imap-server.ts +0 -2100
- package/src/aws/lambda.ts +0 -786
- package/src/aws/opensearch.ts +0 -158
- package/src/aws/personalize.ts +0 -977
- package/src/aws/polly.ts +0 -559
- package/src/aws/rds.ts +0 -888
- package/src/aws/rekognition.ts +0 -846
- package/src/aws/route53-domains.ts +0 -359
- package/src/aws/route53.ts +0 -1046
- package/src/aws/s3.ts +0 -2318
- package/src/aws/scheduler.ts +0 -571
- package/src/aws/secrets-manager.ts +0 -769
- package/src/aws/ses.ts +0 -1081
- package/src/aws/setup-phone.ts +0 -104
- package/src/aws/setup-sms.ts +0 -580
- package/src/aws/sms.ts +0 -1735
- package/src/aws/smtp-server.ts +0 -531
- package/src/aws/sns.ts +0 -758
- package/src/aws/sqs.ts +0 -382
- package/src/aws/ssm.ts +0 -807
- package/src/aws/sts.ts +0 -92
- package/src/aws/support.ts +0 -391
- package/src/aws/test-imap.ts +0 -86
- package/src/aws/textract.ts +0 -780
- package/src/aws/transcribe.ts +0 -108
- package/src/aws/translate.ts +0 -641
- package/src/aws/voice.ts +0 -1379
- package/src/config.ts +0 -35
- package/src/deploy/index.ts +0 -7
- package/src/deploy/static-site-external-dns.ts +0 -906
- package/src/deploy/static-site.ts +0 -1125
- package/src/dns/godaddy.ts +0 -412
- package/src/dns/index.ts +0 -183
- package/src/dns/porkbun.ts +0 -362
- package/src/dns/route53-adapter.ts +0 -414
- package/src/dns/validator.ts +0 -369
- package/src/generators/index.ts +0 -5
- package/src/generators/infrastructure.ts +0 -1660
- package/src/push/apns.ts +0 -452
- package/src/push/fcm.ts +0 -506
- package/src/push/index.ts +0 -58
- package/src/ssl/acme-client.ts +0 -478
- package/src/ssl/index.ts +0 -7
- package/src/ssl/letsencrypt.ts +0 -747
- package/src/types.ts +0 -2
- package/src/utils/cli.ts +0 -398
- package/src/validation/index.ts +0 -5
- package/src/validation/template.ts +0 -405
- package/test/index.test.ts +0 -128
- package/tsconfig.json +0 -18
package/src/aws/bedrock.ts
DELETED
|
@@ -1,4074 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AWS Bedrock Client
|
|
3
|
-
* Direct API calls for Bedrock AI model invocations and management
|
|
4
|
-
* No external SDK dependencies - implements AWS Signature V4 directly
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { AWSClient } from './client'
|
|
8
|
-
|
|
9
|
-
// ============================================================================
|
|
10
|
-
// Bedrock Runtime Types
|
|
11
|
-
// ============================================================================
|
|
12
|
-
|
|
13
|
-
export interface BedrockMessage {
|
|
14
|
-
role: 'user' | 'assistant'
|
|
15
|
-
content: string | BedrockContentBlock[]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type BedrockContentBlock =
|
|
19
|
-
| { type: 'text'; text: string }
|
|
20
|
-
| { type: 'image'; source: BedrockImageSource }
|
|
21
|
-
| { type: 'document'; source: BedrockDocumentSource }
|
|
22
|
-
| { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> }
|
|
23
|
-
| { type: 'tool_result'; tool_use_id: string; content: string | BedrockContentBlock[] }
|
|
24
|
-
|
|
25
|
-
export interface BedrockImageSource {
|
|
26
|
-
type: 'base64'
|
|
27
|
-
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'
|
|
28
|
-
data: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface BedrockDocumentSource {
|
|
32
|
-
type: 'base64'
|
|
33
|
-
media_type: 'application/pdf'
|
|
34
|
-
data: string
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface BedrockToolDefinition {
|
|
38
|
-
name: string
|
|
39
|
-
description?: string
|
|
40
|
-
input_schema: {
|
|
41
|
-
type: 'object'
|
|
42
|
-
properties: Record<string, unknown>
|
|
43
|
-
required?: string[]
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface BedrockResponse {
|
|
48
|
-
id: string
|
|
49
|
-
type: string
|
|
50
|
-
role: string
|
|
51
|
-
content: Array<{ type: 'text'; text: string } | { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> }>
|
|
52
|
-
model: string
|
|
53
|
-
stop_reason: 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence'
|
|
54
|
-
usage: {
|
|
55
|
-
input_tokens: number
|
|
56
|
-
output_tokens: number
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface InvokeModelCommandInput {
|
|
61
|
-
modelId: string
|
|
62
|
-
body: string | Uint8Array | Record<string, unknown>
|
|
63
|
-
contentType?: string
|
|
64
|
-
accept?: string
|
|
65
|
-
trace?: 'ENABLED' | 'DISABLED'
|
|
66
|
-
guardrailIdentifier?: string
|
|
67
|
-
guardrailVersion?: string
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface InvokeModelCommandOutput {
|
|
71
|
-
body: Uint8Array
|
|
72
|
-
contentType: string
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface InvokeModelWithResponseStreamCommandInput {
|
|
76
|
-
modelId: string
|
|
77
|
-
body: string | Uint8Array | Record<string, unknown>
|
|
78
|
-
contentType?: string
|
|
79
|
-
accept?: string
|
|
80
|
-
trace?: 'ENABLED' | 'DISABLED'
|
|
81
|
-
guardrailIdentifier?: string
|
|
82
|
-
guardrailVersion?: string
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface InvokeModelWithResponseStreamCommandOutput {
|
|
86
|
-
body: AsyncIterable<BedrockStreamChunk>
|
|
87
|
-
contentType: string
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface BedrockStreamChunk {
|
|
91
|
-
chunk?: {
|
|
92
|
-
bytes: Uint8Array
|
|
93
|
-
}
|
|
94
|
-
internalServerException?: {
|
|
95
|
-
message: string
|
|
96
|
-
}
|
|
97
|
-
modelStreamErrorException?: {
|
|
98
|
-
message: string
|
|
99
|
-
originalStatusCode?: number
|
|
100
|
-
originalMessage?: string
|
|
101
|
-
}
|
|
102
|
-
modelTimeoutException?: {
|
|
103
|
-
message: string
|
|
104
|
-
}
|
|
105
|
-
throttlingException?: {
|
|
106
|
-
message: string
|
|
107
|
-
}
|
|
108
|
-
validationException?: {
|
|
109
|
-
message: string
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface ConverseCommandInput {
|
|
114
|
-
modelId: string
|
|
115
|
-
messages: BedrockMessage[]
|
|
116
|
-
system?: Array<{ text: string }>
|
|
117
|
-
inferenceConfig?: {
|
|
118
|
-
maxTokens?: number
|
|
119
|
-
temperature?: number
|
|
120
|
-
topP?: number
|
|
121
|
-
stopSequences?: string[]
|
|
122
|
-
}
|
|
123
|
-
toolConfig?: {
|
|
124
|
-
tools: Array<{ toolSpec: BedrockToolDefinition }>
|
|
125
|
-
toolChoice?: { auto: Record<string, never> } | { any: Record<string, never> } | { tool: { name: string } }
|
|
126
|
-
}
|
|
127
|
-
guardrailConfig?: {
|
|
128
|
-
guardrailIdentifier: string
|
|
129
|
-
guardrailVersion: string
|
|
130
|
-
trace?: 'enabled' | 'disabled'
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface ConverseCommandOutput {
|
|
135
|
-
output: {
|
|
136
|
-
message?: BedrockMessage
|
|
137
|
-
}
|
|
138
|
-
stopReason: 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'guardrail_intervened' | 'content_filtered'
|
|
139
|
-
usage: {
|
|
140
|
-
inputTokens: number
|
|
141
|
-
outputTokens: number
|
|
142
|
-
totalTokens: number
|
|
143
|
-
}
|
|
144
|
-
metrics?: {
|
|
145
|
-
latencyMs: number
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// ============================================================================
|
|
150
|
-
// Bedrock Management Types
|
|
151
|
-
// ============================================================================
|
|
152
|
-
|
|
153
|
-
export interface CreateModelCustomizationJobCommandInput {
|
|
154
|
-
jobName: string
|
|
155
|
-
customModelName: string
|
|
156
|
-
roleArn: string
|
|
157
|
-
baseModelIdentifier: string
|
|
158
|
-
trainingDataConfig: {
|
|
159
|
-
s3Uri: string
|
|
160
|
-
}
|
|
161
|
-
validationDataConfig?: {
|
|
162
|
-
validators: Array<{
|
|
163
|
-
s3Uri: string
|
|
164
|
-
}>
|
|
165
|
-
}
|
|
166
|
-
outputDataConfig: {
|
|
167
|
-
s3Uri: string
|
|
168
|
-
}
|
|
169
|
-
hyperParameters?: Record<string, string>
|
|
170
|
-
vpcConfig?: {
|
|
171
|
-
subnetIds: string[]
|
|
172
|
-
securityGroupIds: string[]
|
|
173
|
-
}
|
|
174
|
-
customModelKmsKeyId?: string
|
|
175
|
-
customModelTags?: Array<{ key: string; value: string }>
|
|
176
|
-
customizationType?: 'FINE_TUNING' | 'CONTINUED_PRE_TRAINING'
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface CreateModelCustomizationJobCommandOutput {
|
|
180
|
-
jobArn: string
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface GetModelCustomizationJobCommandInput {
|
|
184
|
-
jobIdentifier: string
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export interface GetModelCustomizationJobCommandOutput {
|
|
188
|
-
jobArn: string
|
|
189
|
-
jobName: string
|
|
190
|
-
outputModelName: string
|
|
191
|
-
outputModelArn?: string
|
|
192
|
-
clientRequestToken?: string
|
|
193
|
-
roleArn: string
|
|
194
|
-
status: 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped'
|
|
195
|
-
failureMessage?: string
|
|
196
|
-
creationTime: string
|
|
197
|
-
lastModifiedTime?: string
|
|
198
|
-
endTime?: string
|
|
199
|
-
baseModelArn: string
|
|
200
|
-
hyperParameters?: Record<string, string>
|
|
201
|
-
trainingDataConfig: {
|
|
202
|
-
s3Uri: string
|
|
203
|
-
}
|
|
204
|
-
validationDataConfig?: {
|
|
205
|
-
validators: Array<{
|
|
206
|
-
s3Uri: string
|
|
207
|
-
}>
|
|
208
|
-
}
|
|
209
|
-
outputDataConfig: {
|
|
210
|
-
s3Uri: string
|
|
211
|
-
}
|
|
212
|
-
customizationType?: 'FINE_TUNING' | 'CONTINUED_PRE_TRAINING'
|
|
213
|
-
outputModelKmsKeyArn?: string
|
|
214
|
-
trainingMetrics?: {
|
|
215
|
-
trainingLoss?: number
|
|
216
|
-
}
|
|
217
|
-
validationMetrics?: Array<{
|
|
218
|
-
validationLoss?: number
|
|
219
|
-
}>
|
|
220
|
-
vpcConfig?: {
|
|
221
|
-
subnetIds: string[]
|
|
222
|
-
securityGroupIds: string[]
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export interface ListModelCustomizationJobsCommandInput {
|
|
227
|
-
creationTimeAfter?: string
|
|
228
|
-
creationTimeBefore?: string
|
|
229
|
-
statusEquals?: 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped'
|
|
230
|
-
nameContains?: string
|
|
231
|
-
maxResults?: number
|
|
232
|
-
nextToken?: string
|
|
233
|
-
sortBy?: 'CreationTime'
|
|
234
|
-
sortOrder?: 'Ascending' | 'Descending'
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export interface ListModelCustomizationJobsCommandOutput {
|
|
238
|
-
nextToken?: string
|
|
239
|
-
modelCustomizationJobSummaries?: Array<{
|
|
240
|
-
jobArn: string
|
|
241
|
-
jobName: string
|
|
242
|
-
status: 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped'
|
|
243
|
-
lastModifiedTime?: string
|
|
244
|
-
creationTime: string
|
|
245
|
-
endTime?: string
|
|
246
|
-
baseModelArn: string
|
|
247
|
-
customModelArn?: string
|
|
248
|
-
customModelName?: string
|
|
249
|
-
customizationType?: 'FINE_TUNING' | 'CONTINUED_PRE_TRAINING'
|
|
250
|
-
}>
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export interface StopModelCustomizationJobCommandInput {
|
|
254
|
-
jobIdentifier: string
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export interface StopModelCustomizationJobCommandOutput {
|
|
258
|
-
// Empty response
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export interface ListFoundationModelsCommandInput {
|
|
262
|
-
byProvider?: string
|
|
263
|
-
byCustomizationType?: 'FINE_TUNING' | 'CONTINUED_PRE_TRAINING'
|
|
264
|
-
byOutputModality?: 'TEXT' | 'IMAGE' | 'EMBEDDING'
|
|
265
|
-
byInferenceType?: 'ON_DEMAND' | 'PROVISIONED'
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export interface ListFoundationModelsCommandOutput {
|
|
269
|
-
modelSummaries?: FoundationModelSummary[]
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export interface FoundationModelSummary {
|
|
273
|
-
modelArn: string
|
|
274
|
-
modelId: string
|
|
275
|
-
modelName: string
|
|
276
|
-
providerName: string
|
|
277
|
-
inputModalities: string[]
|
|
278
|
-
outputModalities: string[]
|
|
279
|
-
responseStreamingSupported: boolean
|
|
280
|
-
customizationsSupported?: string[]
|
|
281
|
-
inferenceTypesSupported?: string[]
|
|
282
|
-
modelLifecycle?: {
|
|
283
|
-
status: 'ACTIVE' | 'LEGACY'
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export interface GetFoundationModelCommandInput {
|
|
288
|
-
modelIdentifier: string
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export interface GetFoundationModelCommandOutput {
|
|
292
|
-
modelDetails: {
|
|
293
|
-
modelArn: string
|
|
294
|
-
modelId: string
|
|
295
|
-
modelName: string
|
|
296
|
-
providerName: string
|
|
297
|
-
inputModalities: string[]
|
|
298
|
-
outputModalities: string[]
|
|
299
|
-
responseStreamingSupported?: boolean
|
|
300
|
-
customizationsSupported?: string[]
|
|
301
|
-
inferenceTypesSupported?: string[]
|
|
302
|
-
modelLifecycle?: {
|
|
303
|
-
status: 'ACTIVE' | 'LEGACY'
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export interface ListCustomModelsCommandInput {
|
|
309
|
-
creationTimeBefore?: string
|
|
310
|
-
creationTimeAfter?: string
|
|
311
|
-
nameContains?: string
|
|
312
|
-
baseModelArnEquals?: string
|
|
313
|
-
foundationModelArnEquals?: string
|
|
314
|
-
maxResults?: number
|
|
315
|
-
nextToken?: string
|
|
316
|
-
sortBy?: 'CreationTime'
|
|
317
|
-
sortOrder?: 'Ascending' | 'Descending'
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export interface ListCustomModelsCommandOutput {
|
|
321
|
-
nextToken?: string
|
|
322
|
-
modelSummaries?: Array<{
|
|
323
|
-
modelArn: string
|
|
324
|
-
modelName: string
|
|
325
|
-
creationTime: string
|
|
326
|
-
baseModelArn: string
|
|
327
|
-
baseModelName: string
|
|
328
|
-
customizationType?: 'FINE_TUNING' | 'CONTINUED_PRE_TRAINING'
|
|
329
|
-
}>
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export interface DeleteCustomModelCommandInput {
|
|
333
|
-
modelIdentifier: string
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export interface DeleteCustomModelCommandOutput {
|
|
337
|
-
// Empty response
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export interface GetCustomModelCommandInput {
|
|
341
|
-
modelIdentifier: string
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
export interface GetCustomModelCommandOutput {
|
|
345
|
-
modelArn: string
|
|
346
|
-
modelName: string
|
|
347
|
-
jobName?: string
|
|
348
|
-
jobArn?: string
|
|
349
|
-
baseModelArn: string
|
|
350
|
-
customizationType?: 'FINE_TUNING' | 'CONTINUED_PRE_TRAINING'
|
|
351
|
-
modelKmsKeyArn?: string
|
|
352
|
-
hyperParameters?: Record<string, string>
|
|
353
|
-
trainingDataConfig?: {
|
|
354
|
-
s3Uri: string
|
|
355
|
-
}
|
|
356
|
-
validationDataConfig?: {
|
|
357
|
-
validators: Array<{
|
|
358
|
-
s3Uri: string
|
|
359
|
-
}>
|
|
360
|
-
}
|
|
361
|
-
outputDataConfig?: {
|
|
362
|
-
s3Uri: string
|
|
363
|
-
}
|
|
364
|
-
trainingMetrics?: {
|
|
365
|
-
trainingLoss?: number
|
|
366
|
-
}
|
|
367
|
-
validationMetrics?: Array<{
|
|
368
|
-
validationLoss?: number
|
|
369
|
-
}>
|
|
370
|
-
creationTime: string
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// Model entitlement / access request types
|
|
374
|
-
export interface CreateFoundationModelEntitlementCommandInput {
|
|
375
|
-
modelId: string
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
export interface CreateFoundationModelEntitlementCommandOutput {
|
|
379
|
-
status: 'PENDING' | 'APPROVED' | 'DENIED'
|
|
380
|
-
modelId: string
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
export interface ListModelInvocationJobsCommandInput {
|
|
384
|
-
submitTimeAfter?: string
|
|
385
|
-
submitTimeBefore?: string
|
|
386
|
-
statusEquals?: 'Submitted' | 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped' | 'PartiallyCompleted' | 'Expired' | 'Validating' | 'Scheduled'
|
|
387
|
-
nameContains?: string
|
|
388
|
-
maxResults?: number
|
|
389
|
-
nextToken?: string
|
|
390
|
-
sortBy?: 'CreationTime'
|
|
391
|
-
sortOrder?: 'Ascending' | 'Descending'
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
export interface ListModelInvocationJobsCommandOutput {
|
|
395
|
-
nextToken?: string
|
|
396
|
-
invocationJobSummaries?: Array<{
|
|
397
|
-
jobArn: string
|
|
398
|
-
jobName: string
|
|
399
|
-
modelId: string
|
|
400
|
-
clientRequestToken?: string
|
|
401
|
-
roleArn: string
|
|
402
|
-
status: string
|
|
403
|
-
message?: string
|
|
404
|
-
submitTime: string
|
|
405
|
-
lastModifiedTime?: string
|
|
406
|
-
endTime?: string
|
|
407
|
-
inputDataConfig: {
|
|
408
|
-
s3InputDataConfig: {
|
|
409
|
-
s3Uri: string
|
|
410
|
-
s3InputFormat?: string
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
outputDataConfig: {
|
|
414
|
-
s3OutputDataConfig: {
|
|
415
|
-
s3Uri: string
|
|
416
|
-
s3EncryptionKeyId?: string
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
timeoutDurationInHours?: number
|
|
420
|
-
jobExpirationTime?: string
|
|
421
|
-
}>
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// Guardrails types
|
|
425
|
-
export interface CreateGuardrailCommandInput {
|
|
426
|
-
name: string
|
|
427
|
-
description?: string
|
|
428
|
-
topicPolicyConfig?: {
|
|
429
|
-
topicsConfig: Array<{
|
|
430
|
-
name: string
|
|
431
|
-
definition: string
|
|
432
|
-
examples?: string[]
|
|
433
|
-
type: 'DENY'
|
|
434
|
-
}>
|
|
435
|
-
}
|
|
436
|
-
contentPolicyConfig?: {
|
|
437
|
-
filtersConfig: Array<{
|
|
438
|
-
type: 'SEXUAL' | 'VIOLENCE' | 'HATE' | 'INSULTS' | 'MISCONDUCT' | 'PROMPT_ATTACK'
|
|
439
|
-
inputStrength: 'NONE' | 'LOW' | 'MEDIUM' | 'HIGH'
|
|
440
|
-
outputStrength: 'NONE' | 'LOW' | 'MEDIUM' | 'HIGH'
|
|
441
|
-
}>
|
|
442
|
-
}
|
|
443
|
-
wordPolicyConfig?: {
|
|
444
|
-
wordsConfig?: Array<{
|
|
445
|
-
text: string
|
|
446
|
-
}>
|
|
447
|
-
managedWordListsConfig?: Array<{
|
|
448
|
-
type: 'PROFANITY'
|
|
449
|
-
}>
|
|
450
|
-
}
|
|
451
|
-
sensitiveInformationPolicyConfig?: {
|
|
452
|
-
piiEntitiesConfig?: Array<{
|
|
453
|
-
type: string
|
|
454
|
-
action: 'BLOCK' | 'ANONYMIZE'
|
|
455
|
-
}>
|
|
456
|
-
regexesConfig?: Array<{
|
|
457
|
-
name: string
|
|
458
|
-
description?: string
|
|
459
|
-
pattern: string
|
|
460
|
-
action: 'BLOCK' | 'ANONYMIZE'
|
|
461
|
-
}>
|
|
462
|
-
}
|
|
463
|
-
contextualGroundingPolicyConfig?: {
|
|
464
|
-
filtersConfig: Array<{
|
|
465
|
-
type: 'GROUNDING' | 'RELEVANCE'
|
|
466
|
-
threshold: number
|
|
467
|
-
}>
|
|
468
|
-
}
|
|
469
|
-
blockedInputMessaging: string
|
|
470
|
-
blockedOutputsMessaging: string
|
|
471
|
-
kmsKeyId?: string
|
|
472
|
-
tags?: Array<{ key: string; value: string }>
|
|
473
|
-
clientRequestToken?: string
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
export interface CreateGuardrailCommandOutput {
|
|
477
|
-
guardrailId: string
|
|
478
|
-
guardrailArn: string
|
|
479
|
-
version: string
|
|
480
|
-
createdAt: string
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
export interface GetGuardrailCommandInput {
|
|
484
|
-
guardrailIdentifier: string
|
|
485
|
-
guardrailVersion?: string
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
export interface GetGuardrailCommandOutput {
|
|
489
|
-
name: string
|
|
490
|
-
description?: string
|
|
491
|
-
guardrailId: string
|
|
492
|
-
guardrailArn: string
|
|
493
|
-
version: string
|
|
494
|
-
status: 'CREATING' | 'UPDATING' | 'VERSIONING' | 'READY' | 'FAILED' | 'DELETING'
|
|
495
|
-
topicPolicy?: {
|
|
496
|
-
topics: Array<{
|
|
497
|
-
name: string
|
|
498
|
-
definition: string
|
|
499
|
-
examples?: string[]
|
|
500
|
-
type: 'DENY'
|
|
501
|
-
}>
|
|
502
|
-
}
|
|
503
|
-
contentPolicy?: {
|
|
504
|
-
filters: Array<{
|
|
505
|
-
type: string
|
|
506
|
-
inputStrength: string
|
|
507
|
-
outputStrength: string
|
|
508
|
-
}>
|
|
509
|
-
}
|
|
510
|
-
wordPolicy?: {
|
|
511
|
-
words?: Array<{
|
|
512
|
-
text: string
|
|
513
|
-
}>
|
|
514
|
-
managedWordLists?: Array<{
|
|
515
|
-
type: string
|
|
516
|
-
}>
|
|
517
|
-
}
|
|
518
|
-
sensitiveInformationPolicy?: {
|
|
519
|
-
piiEntities?: Array<{
|
|
520
|
-
type: string
|
|
521
|
-
action: string
|
|
522
|
-
}>
|
|
523
|
-
regexes?: Array<{
|
|
524
|
-
name: string
|
|
525
|
-
description?: string
|
|
526
|
-
pattern: string
|
|
527
|
-
action: string
|
|
528
|
-
}>
|
|
529
|
-
}
|
|
530
|
-
contextualGroundingPolicy?: {
|
|
531
|
-
filters: Array<{
|
|
532
|
-
type: string
|
|
533
|
-
threshold: number
|
|
534
|
-
}>
|
|
535
|
-
}
|
|
536
|
-
createdAt: string
|
|
537
|
-
updatedAt: string
|
|
538
|
-
statusReasons?: string[]
|
|
539
|
-
failureRecommendations?: string[]
|
|
540
|
-
blockedInputMessaging: string
|
|
541
|
-
blockedOutputsMessaging: string
|
|
542
|
-
kmsKeyArn?: string
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
export interface ListGuardrailsCommandInput {
|
|
546
|
-
guardrailIdentifier?: string
|
|
547
|
-
maxResults?: number
|
|
548
|
-
nextToken?: string
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
export interface ListGuardrailsCommandOutput {
|
|
552
|
-
guardrails: Array<{
|
|
553
|
-
id: string
|
|
554
|
-
arn: string
|
|
555
|
-
status: string
|
|
556
|
-
name: string
|
|
557
|
-
description?: string
|
|
558
|
-
version: string
|
|
559
|
-
createdAt: string
|
|
560
|
-
updatedAt: string
|
|
561
|
-
}>
|
|
562
|
-
nextToken?: string
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
export interface DeleteGuardrailCommandInput {
|
|
566
|
-
guardrailIdentifier: string
|
|
567
|
-
guardrailVersion?: string
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
export interface DeleteGuardrailCommandOutput {
|
|
571
|
-
// Empty response
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// Knowledge Base types
|
|
575
|
-
export interface CreateKnowledgeBaseCommandInput {
|
|
576
|
-
clientToken?: string
|
|
577
|
-
name: string
|
|
578
|
-
description?: string
|
|
579
|
-
roleArn: string
|
|
580
|
-
knowledgeBaseConfiguration: {
|
|
581
|
-
type: 'VECTOR'
|
|
582
|
-
vectorKnowledgeBaseConfiguration?: {
|
|
583
|
-
embeddingModelArn: string
|
|
584
|
-
embeddingModelConfiguration?: {
|
|
585
|
-
bedrockEmbeddingModelConfiguration?: {
|
|
586
|
-
dimensions?: number
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
storageConfiguration: {
|
|
592
|
-
type: 'OPENSEARCH_SERVERLESS' | 'PINECONE' | 'REDIS_ENTERPRISE_CLOUD' | 'RDS' | 'MONGO_DB_ATLAS'
|
|
593
|
-
opensearchServerlessConfiguration?: {
|
|
594
|
-
collectionArn: string
|
|
595
|
-
vectorIndexName: string
|
|
596
|
-
fieldMapping: {
|
|
597
|
-
vectorField: string
|
|
598
|
-
textField: string
|
|
599
|
-
metadataField: string
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
pineconeConfiguration?: {
|
|
603
|
-
connectionString: string
|
|
604
|
-
credentialsSecretArn: string
|
|
605
|
-
namespace?: string
|
|
606
|
-
fieldMapping: {
|
|
607
|
-
textField: string
|
|
608
|
-
metadataField: string
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
redisEnterpriseCloudConfiguration?: {
|
|
612
|
-
endpoint: string
|
|
613
|
-
vectorIndexName: string
|
|
614
|
-
credentialsSecretArn: string
|
|
615
|
-
fieldMapping: {
|
|
616
|
-
vectorField: string
|
|
617
|
-
textField: string
|
|
618
|
-
metadataField: string
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
rdsConfiguration?: {
|
|
622
|
-
resourceArn: string
|
|
623
|
-
credentialsSecretArn: string
|
|
624
|
-
databaseName: string
|
|
625
|
-
tableName: string
|
|
626
|
-
fieldMapping: {
|
|
627
|
-
primaryKeyField: string
|
|
628
|
-
vectorField: string
|
|
629
|
-
textField: string
|
|
630
|
-
metadataField: string
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
mongoDbAtlasConfiguration?: {
|
|
634
|
-
endpoint: string
|
|
635
|
-
databaseName: string
|
|
636
|
-
collectionName: string
|
|
637
|
-
vectorIndexName: string
|
|
638
|
-
credentialsSecretArn: string
|
|
639
|
-
fieldMapping: {
|
|
640
|
-
vectorField: string
|
|
641
|
-
textField: string
|
|
642
|
-
metadataField: string
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
tags?: Record<string, string>
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
export interface CreateKnowledgeBaseCommandOutput {
|
|
650
|
-
knowledgeBase: {
|
|
651
|
-
knowledgeBaseId: string
|
|
652
|
-
name: string
|
|
653
|
-
knowledgeBaseArn: string
|
|
654
|
-
description?: string
|
|
655
|
-
roleArn: string
|
|
656
|
-
knowledgeBaseConfiguration: {
|
|
657
|
-
type: string
|
|
658
|
-
vectorKnowledgeBaseConfiguration?: {
|
|
659
|
-
embeddingModelArn: string
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
storageConfiguration: {
|
|
663
|
-
type: string
|
|
664
|
-
}
|
|
665
|
-
status: 'CREATING' | 'ACTIVE' | 'DELETING' | 'UPDATING' | 'FAILED' | 'DELETE_UNSUCCESSFUL'
|
|
666
|
-
createdAt: string
|
|
667
|
-
updatedAt: string
|
|
668
|
-
failureReasons?: string[]
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
// Agent types
|
|
673
|
-
export interface CreateAgentCommandInput {
|
|
674
|
-
agentName: string
|
|
675
|
-
clientToken?: string
|
|
676
|
-
instruction?: string
|
|
677
|
-
foundationModel?: string
|
|
678
|
-
description?: string
|
|
679
|
-
idleSessionTTLInSeconds?: number
|
|
680
|
-
agentResourceRoleArn: string
|
|
681
|
-
customerEncryptionKeyArn?: string
|
|
682
|
-
tags?: Record<string, string>
|
|
683
|
-
promptOverrideConfiguration?: {
|
|
684
|
-
promptConfigurations: Array<{
|
|
685
|
-
promptType: 'PRE_PROCESSING' | 'ORCHESTRATION' | 'POST_PROCESSING' | 'KNOWLEDGE_BASE_RESPONSE_GENERATION'
|
|
686
|
-
promptCreationMode: 'DEFAULT' | 'OVERRIDDEN'
|
|
687
|
-
promptState?: 'ENABLED' | 'DISABLED'
|
|
688
|
-
basePromptTemplate?: string
|
|
689
|
-
inferenceConfiguration?: {
|
|
690
|
-
temperature?: number
|
|
691
|
-
topP?: number
|
|
692
|
-
topK?: number
|
|
693
|
-
maximumLength?: number
|
|
694
|
-
stopSequences?: string[]
|
|
695
|
-
}
|
|
696
|
-
parserMode?: 'DEFAULT' | 'OVERRIDDEN'
|
|
697
|
-
}>
|
|
698
|
-
overrideLambda?: string
|
|
699
|
-
}
|
|
700
|
-
guardrailConfiguration?: {
|
|
701
|
-
guardrailIdentifier?: string
|
|
702
|
-
guardrailVersion?: string
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
export interface CreateAgentCommandOutput {
|
|
707
|
-
agent: {
|
|
708
|
-
agentId: string
|
|
709
|
-
agentName: string
|
|
710
|
-
agentArn: string
|
|
711
|
-
agentVersion: string
|
|
712
|
-
clientToken?: string
|
|
713
|
-
instruction?: string
|
|
714
|
-
agentStatus: 'CREATING' | 'PREPARING' | 'PREPARED' | 'NOT_PREPARED' | 'DELETING' | 'FAILED' | 'VERSIONING' | 'UPDATING'
|
|
715
|
-
foundationModel?: string
|
|
716
|
-
description?: string
|
|
717
|
-
idleSessionTTLInSeconds: number
|
|
718
|
-
agentResourceRoleArn: string
|
|
719
|
-
customerEncryptionKeyArn?: string
|
|
720
|
-
createdAt: string
|
|
721
|
-
updatedAt: string
|
|
722
|
-
preparedAt?: string
|
|
723
|
-
failureReasons?: string[]
|
|
724
|
-
recommendedActions?: string[]
|
|
725
|
-
promptOverrideConfiguration?: {
|
|
726
|
-
promptConfigurations: Array<{
|
|
727
|
-
promptType: string
|
|
728
|
-
promptCreationMode: string
|
|
729
|
-
promptState?: string
|
|
730
|
-
basePromptTemplate?: string
|
|
731
|
-
inferenceConfiguration?: {
|
|
732
|
-
temperature?: number
|
|
733
|
-
topP?: number
|
|
734
|
-
topK?: number
|
|
735
|
-
maximumLength?: number
|
|
736
|
-
stopSequences?: string[]
|
|
737
|
-
}
|
|
738
|
-
parserMode?: string
|
|
739
|
-
}>
|
|
740
|
-
overrideLambda?: string
|
|
741
|
-
}
|
|
742
|
-
guardrailConfiguration?: {
|
|
743
|
-
guardrailIdentifier?: string
|
|
744
|
-
guardrailVersion?: string
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
export interface InvokeAgentCommandInput {
|
|
750
|
-
agentId: string
|
|
751
|
-
agentAliasId: string
|
|
752
|
-
sessionId: string
|
|
753
|
-
endSession?: boolean
|
|
754
|
-
enableTrace?: boolean
|
|
755
|
-
inputText?: string
|
|
756
|
-
memoryId?: string
|
|
757
|
-
sessionState?: {
|
|
758
|
-
sessionAttributes?: Record<string, string>
|
|
759
|
-
promptSessionAttributes?: Record<string, string>
|
|
760
|
-
returnControlInvocationResults?: Array<{
|
|
761
|
-
functionResult?: {
|
|
762
|
-
actionGroup: string
|
|
763
|
-
function: string
|
|
764
|
-
responseBody?: Record<string, { body: string }>
|
|
765
|
-
}
|
|
766
|
-
}>
|
|
767
|
-
invocationId?: string
|
|
768
|
-
files?: Array<{
|
|
769
|
-
name: string
|
|
770
|
-
source: {
|
|
771
|
-
sourceType: 'S3' | 'BYTE_CONTENT'
|
|
772
|
-
s3Location?: {
|
|
773
|
-
uri: string
|
|
774
|
-
}
|
|
775
|
-
byteContent?: {
|
|
776
|
-
mediaType: string
|
|
777
|
-
data: Uint8Array
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
useCase: 'CODE_INTERPRETER' | 'CHAT'
|
|
781
|
-
}>
|
|
782
|
-
knowledgeBaseConfigurations?: Array<{
|
|
783
|
-
knowledgeBaseId: string
|
|
784
|
-
retrievalConfiguration: {
|
|
785
|
-
vectorSearchConfiguration: {
|
|
786
|
-
numberOfResults?: number
|
|
787
|
-
overrideSearchType?: 'HYBRID' | 'SEMANTIC'
|
|
788
|
-
filter?: Record<string, unknown>
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}>
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
export interface InvokeAgentCommandOutput {
|
|
796
|
-
completion: AsyncIterable<{
|
|
797
|
-
chunk?: {
|
|
798
|
-
bytes: Uint8Array
|
|
799
|
-
attribution?: {
|
|
800
|
-
citations: Array<{
|
|
801
|
-
generatedResponsePart?: {
|
|
802
|
-
textResponsePart?: {
|
|
803
|
-
text: string
|
|
804
|
-
span?: {
|
|
805
|
-
start: number
|
|
806
|
-
end: number
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
retrievedReferences?: Array<{
|
|
811
|
-
content?: {
|
|
812
|
-
text: string
|
|
813
|
-
}
|
|
814
|
-
location?: {
|
|
815
|
-
type: string
|
|
816
|
-
s3Location?: {
|
|
817
|
-
uri: string
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
metadata?: Record<string, unknown>
|
|
821
|
-
}>
|
|
822
|
-
}>
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
trace?: {
|
|
826
|
-
agentId?: string
|
|
827
|
-
agentAliasId?: string
|
|
828
|
-
sessionId?: string
|
|
829
|
-
agentVersion?: string
|
|
830
|
-
trace?: Record<string, unknown>
|
|
831
|
-
}
|
|
832
|
-
returnControl?: {
|
|
833
|
-
invocationId: string
|
|
834
|
-
invocationInputs: Array<{
|
|
835
|
-
functionInvocationInput?: {
|
|
836
|
-
actionGroup: string
|
|
837
|
-
function: string
|
|
838
|
-
parameters: Array<{
|
|
839
|
-
name: string
|
|
840
|
-
type: string
|
|
841
|
-
value: string
|
|
842
|
-
}>
|
|
843
|
-
}
|
|
844
|
-
}>
|
|
845
|
-
}
|
|
846
|
-
files?: {
|
|
847
|
-
files: Array<{
|
|
848
|
-
name: string
|
|
849
|
-
type: string
|
|
850
|
-
bytes: Uint8Array
|
|
851
|
-
}>
|
|
852
|
-
}
|
|
853
|
-
}>
|
|
854
|
-
contentType: string
|
|
855
|
-
sessionId: string
|
|
856
|
-
memoryId?: string
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
// ============================================================================
|
|
860
|
-
// Bedrock Runtime Client
|
|
861
|
-
// ============================================================================
|
|
862
|
-
|
|
863
|
-
/**
|
|
864
|
-
* Bedrock Runtime client for AI model invocations
|
|
865
|
-
*/
|
|
866
|
-
export class BedrockRuntimeClient {
|
|
867
|
-
private client: AWSClient
|
|
868
|
-
private region: string
|
|
869
|
-
|
|
870
|
-
constructor(region: string = 'us-east-1') {
|
|
871
|
-
this.region = region
|
|
872
|
-
this.client = new AWSClient()
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* Invoke a Bedrock model (matches AWS SDK InvokeModelCommand)
|
|
877
|
-
*/
|
|
878
|
-
async invokeModel(params: InvokeModelCommandInput): Promise<InvokeModelCommandOutput> {
|
|
879
|
-
const body = typeof params.body === 'string'
|
|
880
|
-
? params.body
|
|
881
|
-
: params.body instanceof Uint8Array
|
|
882
|
-
? new TextDecoder().decode(params.body)
|
|
883
|
-
: JSON.stringify(params.body)
|
|
884
|
-
|
|
885
|
-
const headers: Record<string, string> = {
|
|
886
|
-
'Content-Type': params.contentType || 'application/json',
|
|
887
|
-
'Accept': params.accept || 'application/json',
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
if (params.trace) {
|
|
891
|
-
headers['X-Amzn-Bedrock-Trace'] = params.trace
|
|
892
|
-
}
|
|
893
|
-
if (params.guardrailIdentifier) {
|
|
894
|
-
headers['X-Amzn-Bedrock-GuardrailIdentifier'] = params.guardrailIdentifier
|
|
895
|
-
}
|
|
896
|
-
if (params.guardrailVersion) {
|
|
897
|
-
headers['X-Amzn-Bedrock-GuardrailVersion'] = params.guardrailVersion
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
const result = await this.client.request({
|
|
901
|
-
service: 'bedrock-runtime',
|
|
902
|
-
region: this.region,
|
|
903
|
-
method: 'POST',
|
|
904
|
-
path: `/model/${encodeURIComponent(params.modelId)}/invoke`,
|
|
905
|
-
headers,
|
|
906
|
-
body,
|
|
907
|
-
rawResponse: true,
|
|
908
|
-
returnHeaders: true,
|
|
909
|
-
})
|
|
910
|
-
|
|
911
|
-
return {
|
|
912
|
-
body: new TextEncoder().encode(result.body),
|
|
913
|
-
contentType: result.headers?.['content-type'] || 'application/json',
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
/**
|
|
918
|
-
* Invoke model with streaming response (matches AWS SDK InvokeModelWithResponseStreamCommand)
|
|
919
|
-
*/
|
|
920
|
-
async invokeModelWithResponseStream(params: InvokeModelWithResponseStreamCommandInput): Promise<InvokeModelWithResponseStreamCommandOutput> {
|
|
921
|
-
const body = typeof params.body === 'string'
|
|
922
|
-
? params.body
|
|
923
|
-
: params.body instanceof Uint8Array
|
|
924
|
-
? new TextDecoder().decode(params.body)
|
|
925
|
-
: JSON.stringify(params.body)
|
|
926
|
-
|
|
927
|
-
const headers: Record<string, string> = {
|
|
928
|
-
'Content-Type': params.contentType || 'application/json',
|
|
929
|
-
'Accept': params.accept || 'application/vnd.amazon.eventstream',
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
if (params.trace) {
|
|
933
|
-
headers['X-Amzn-Bedrock-Trace'] = params.trace
|
|
934
|
-
}
|
|
935
|
-
if (params.guardrailIdentifier) {
|
|
936
|
-
headers['X-Amzn-Bedrock-GuardrailIdentifier'] = params.guardrailIdentifier
|
|
937
|
-
}
|
|
938
|
-
if (params.guardrailVersion) {
|
|
939
|
-
headers['X-Amzn-Bedrock-GuardrailVersion'] = params.guardrailVersion
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
// For streaming, we need to make a raw fetch request and handle the event stream
|
|
943
|
-
const stream = await this.makeStreamRequest(params.modelId, headers, body)
|
|
944
|
-
|
|
945
|
-
return {
|
|
946
|
-
body: stream,
|
|
947
|
-
contentType: 'application/vnd.amazon.eventstream',
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
/**
|
|
952
|
-
* Internal method to make streaming request
|
|
953
|
-
*/
|
|
954
|
-
private async makeStreamRequest(
|
|
955
|
-
modelId: string,
|
|
956
|
-
headers: Record<string, string>,
|
|
957
|
-
body: string,
|
|
958
|
-
): Promise<AsyncIterable<BedrockStreamChunk>> {
|
|
959
|
-
// Get credentials and sign request manually for streaming
|
|
960
|
-
const credentials = this.getCredentialsFromEnv()
|
|
961
|
-
const url = `https://bedrock-runtime.${this.region}.amazonaws.com/model/${encodeURIComponent(modelId)}/invoke-with-response-stream`
|
|
962
|
-
|
|
963
|
-
const signedHeaders = this.signStreamRequest(
|
|
964
|
-
'POST',
|
|
965
|
-
`/model/${encodeURIComponent(modelId)}/invoke-with-response-stream`,
|
|
966
|
-
headers,
|
|
967
|
-
body,
|
|
968
|
-
credentials,
|
|
969
|
-
)
|
|
970
|
-
|
|
971
|
-
const response = await fetch(url, {
|
|
972
|
-
method: 'POST',
|
|
973
|
-
headers: signedHeaders,
|
|
974
|
-
body,
|
|
975
|
-
})
|
|
976
|
-
|
|
977
|
-
if (!response.ok) {
|
|
978
|
-
const errorText = await response.text()
|
|
979
|
-
throw new Error(`Bedrock streaming error (${response.status}): ${errorText}`)
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
const reader = response.body?.getReader()
|
|
983
|
-
if (!reader) {
|
|
984
|
-
throw new Error('No response body for streaming')
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
return this.parseEventStream(reader as any)
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* Parse AWS event stream format
|
|
992
|
-
*/
|
|
993
|
-
private async *parseEventStream(reader: ReadableStreamDefaultReader<Uint8Array>): AsyncIterable<BedrockStreamChunk> {
|
|
994
|
-
const decoder = new TextDecoder()
|
|
995
|
-
let buffer = ''
|
|
996
|
-
|
|
997
|
-
try {
|
|
998
|
-
while (true) {
|
|
999
|
-
const { done, value } = await reader.read()
|
|
1000
|
-
if (done) break
|
|
1001
|
-
|
|
1002
|
-
buffer += decoder.decode(value, { stream: true })
|
|
1003
|
-
|
|
1004
|
-
// Parse event stream messages
|
|
1005
|
-
// AWS event stream format has binary headers followed by payload
|
|
1006
|
-
// For simplicity, we'll look for JSON chunks in the stream
|
|
1007
|
-
const chunks = this.extractJsonChunks(buffer)
|
|
1008
|
-
for (const chunk of chunks.parsed) {
|
|
1009
|
-
yield { chunk: { bytes: new TextEncoder().encode(JSON.stringify(chunk)) } }
|
|
1010
|
-
}
|
|
1011
|
-
buffer = chunks.remaining
|
|
1012
|
-
}
|
|
1013
|
-
} finally {
|
|
1014
|
-
reader.releaseLock()
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
* Extract JSON chunks from event stream buffer
|
|
1020
|
-
*/
|
|
1021
|
-
private extractJsonChunks(buffer: string): { parsed: unknown[]; remaining: string } {
|
|
1022
|
-
const parsed: unknown[] = []
|
|
1023
|
-
let remaining = buffer
|
|
1024
|
-
|
|
1025
|
-
// Look for complete JSON objects
|
|
1026
|
-
// This is a simplified parser - the actual AWS event stream format is more complex
|
|
1027
|
-
let braceCount = 0
|
|
1028
|
-
let start = -1
|
|
1029
|
-
|
|
1030
|
-
for (let i = 0; i < remaining.length; i++) {
|
|
1031
|
-
if (remaining[i] === '{') {
|
|
1032
|
-
if (braceCount === 0) start = i
|
|
1033
|
-
braceCount++
|
|
1034
|
-
} else if (remaining[i] === '}') {
|
|
1035
|
-
braceCount--
|
|
1036
|
-
if (braceCount === 0 && start !== -1) {
|
|
1037
|
-
try {
|
|
1038
|
-
const json = JSON.parse(remaining.slice(start, i + 1))
|
|
1039
|
-
parsed.push(json)
|
|
1040
|
-
remaining = remaining.slice(i + 1)
|
|
1041
|
-
i = -1 // Reset to search from beginning of new remaining
|
|
1042
|
-
start = -1
|
|
1043
|
-
} catch {
|
|
1044
|
-
// Not valid JSON, continue
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
return { parsed, remaining }
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* Get credentials from environment
|
|
1055
|
-
*/
|
|
1056
|
-
private getCredentialsFromEnv(): { accessKeyId: string; secretAccessKey: string; sessionToken?: string } {
|
|
1057
|
-
const accessKeyId = process.env.AWS_ACCESS_KEY_ID
|
|
1058
|
-
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
|
|
1059
|
-
const sessionToken = process.env.AWS_SESSION_TOKEN
|
|
1060
|
-
|
|
1061
|
-
if (!accessKeyId || !secretAccessKey) {
|
|
1062
|
-
throw new Error('AWS credentials not found in environment variables')
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
return { accessKeyId, secretAccessKey, sessionToken }
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
/**
|
|
1069
|
-
* Sign request for streaming (simplified SigV4)
|
|
1070
|
-
*/
|
|
1071
|
-
private signStreamRequest(
|
|
1072
|
-
method: string,
|
|
1073
|
-
path: string,
|
|
1074
|
-
headers: Record<string, string>,
|
|
1075
|
-
body: string,
|
|
1076
|
-
credentials: { accessKeyId: string; secretAccessKey: string; sessionToken?: string },
|
|
1077
|
-
): Record<string, string> {
|
|
1078
|
-
const crypto = require('node:crypto')
|
|
1079
|
-
const service = 'bedrock-runtime'
|
|
1080
|
-
const region = this.region
|
|
1081
|
-
const host = `${service}.${region}.amazonaws.com`
|
|
1082
|
-
|
|
1083
|
-
const now = new Date()
|
|
1084
|
-
const amzDate = now.toISOString().replace(/[:-]|\.\d{3}/g, '')
|
|
1085
|
-
const dateStamp = now.toISOString().slice(0, 10).replace(/-/g, '')
|
|
1086
|
-
|
|
1087
|
-
const allHeaders: Record<string, string> = {
|
|
1088
|
-
'host': host,
|
|
1089
|
-
'x-amz-date': amzDate,
|
|
1090
|
-
...headers,
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
if (credentials.sessionToken) {
|
|
1094
|
-
allHeaders['x-amz-security-token'] = credentials.sessionToken
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
const payloadHash = crypto.createHash('sha256').update(body, 'utf8').digest('hex')
|
|
1098
|
-
allHeaders['x-amz-content-sha256'] = payloadHash
|
|
1099
|
-
allHeaders['content-length'] = Buffer.byteLength(body).toString()
|
|
1100
|
-
|
|
1101
|
-
const sortedHeaderKeys = Object.keys(allHeaders).sort((a, b) =>
|
|
1102
|
-
a.toLowerCase().localeCompare(b.toLowerCase())
|
|
1103
|
-
)
|
|
1104
|
-
|
|
1105
|
-
const canonicalHeaders = sortedHeaderKeys
|
|
1106
|
-
.map(key => `${key.toLowerCase()}:${allHeaders[key].trim()}\n`)
|
|
1107
|
-
.join('')
|
|
1108
|
-
|
|
1109
|
-
const signedHeaders = sortedHeaderKeys
|
|
1110
|
-
.map(key => key.toLowerCase())
|
|
1111
|
-
.join(';')
|
|
1112
|
-
|
|
1113
|
-
const canonicalRequest = [
|
|
1114
|
-
method,
|
|
1115
|
-
path,
|
|
1116
|
-
'',
|
|
1117
|
-
canonicalHeaders,
|
|
1118
|
-
signedHeaders,
|
|
1119
|
-
payloadHash,
|
|
1120
|
-
].join('\n')
|
|
1121
|
-
|
|
1122
|
-
const algorithm = 'AWS4-HMAC-SHA256'
|
|
1123
|
-
const credentialScope = `${dateStamp}/${region}/${service}/aws4_request`
|
|
1124
|
-
const stringToSign = [
|
|
1125
|
-
algorithm,
|
|
1126
|
-
amzDate,
|
|
1127
|
-
credentialScope,
|
|
1128
|
-
crypto.createHash('sha256').update(canonicalRequest).digest('hex'),
|
|
1129
|
-
].join('\n')
|
|
1130
|
-
|
|
1131
|
-
const kDate = crypto.createHmac('sha256', `AWS4${credentials.secretAccessKey}`).update(dateStamp).digest()
|
|
1132
|
-
const kRegion = crypto.createHmac('sha256', kDate).update(region).digest()
|
|
1133
|
-
const kService = crypto.createHmac('sha256', kRegion).update(service).digest()
|
|
1134
|
-
const kSigning = crypto.createHmac('sha256', kService).update('aws4_request').digest()
|
|
1135
|
-
const signature = crypto.createHmac('sha256', kSigning).update(stringToSign).digest('hex')
|
|
1136
|
-
|
|
1137
|
-
const authorizationHeader = `${algorithm} Credential=${credentials.accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
1138
|
-
|
|
1139
|
-
return {
|
|
1140
|
-
...allHeaders,
|
|
1141
|
-
'Authorization': authorizationHeader,
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
/**
|
|
1146
|
-
* Invoke Claude model with messages API (convenience method)
|
|
1147
|
-
*/
|
|
1148
|
-
async invokeClaudeMessages(params: {
|
|
1149
|
-
modelId?: string
|
|
1150
|
-
messages: BedrockMessage[]
|
|
1151
|
-
maxTokens?: number
|
|
1152
|
-
temperature?: number
|
|
1153
|
-
topP?: number
|
|
1154
|
-
topK?: number
|
|
1155
|
-
stopSequences?: string[]
|
|
1156
|
-
system?: string
|
|
1157
|
-
tools?: BedrockToolDefinition[]
|
|
1158
|
-
toolChoice?: { type: 'auto' } | { type: 'any' } | { type: 'tool'; name: string }
|
|
1159
|
-
}): Promise<BedrockResponse> {
|
|
1160
|
-
const modelId = params.modelId || 'anthropic.claude-3-haiku-20240307-v1:0'
|
|
1161
|
-
|
|
1162
|
-
const requestBody: Record<string, unknown> = {
|
|
1163
|
-
anthropic_version: 'bedrock-2023-05-31',
|
|
1164
|
-
max_tokens: params.maxTokens || 1024,
|
|
1165
|
-
messages: params.messages,
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
if (params.temperature !== undefined) requestBody.temperature = params.temperature
|
|
1169
|
-
if (params.topP !== undefined) requestBody.top_p = params.topP
|
|
1170
|
-
if (params.topK !== undefined) requestBody.top_k = params.topK
|
|
1171
|
-
if (params.stopSequences) requestBody.stop_sequences = params.stopSequences
|
|
1172
|
-
if (params.system) requestBody.system = params.system
|
|
1173
|
-
if (params.tools) requestBody.tools = params.tools
|
|
1174
|
-
if (params.toolChoice) requestBody.tool_choice = params.toolChoice
|
|
1175
|
-
|
|
1176
|
-
const result = await this.client.request({
|
|
1177
|
-
service: 'bedrock-runtime',
|
|
1178
|
-
region: this.region,
|
|
1179
|
-
method: 'POST',
|
|
1180
|
-
path: `/model/${encodeURIComponent(modelId)}/invoke`,
|
|
1181
|
-
headers: {
|
|
1182
|
-
'Content-Type': 'application/json',
|
|
1183
|
-
'Accept': 'application/json',
|
|
1184
|
-
},
|
|
1185
|
-
body: JSON.stringify(requestBody),
|
|
1186
|
-
})
|
|
1187
|
-
|
|
1188
|
-
return result
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* Converse API - unified conversation interface for all models
|
|
1193
|
-
*/
|
|
1194
|
-
async converse(params: ConverseCommandInput): Promise<ConverseCommandOutput> {
|
|
1195
|
-
const requestBody: Record<string, unknown> = {
|
|
1196
|
-
modelId: params.modelId,
|
|
1197
|
-
messages: params.messages,
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
if (params.system) requestBody.system = params.system
|
|
1201
|
-
if (params.inferenceConfig) requestBody.inferenceConfig = params.inferenceConfig
|
|
1202
|
-
if (params.toolConfig) requestBody.toolConfig = params.toolConfig
|
|
1203
|
-
if (params.guardrailConfig) requestBody.guardrailConfig = params.guardrailConfig
|
|
1204
|
-
|
|
1205
|
-
const result = await this.client.request({
|
|
1206
|
-
service: 'bedrock-runtime',
|
|
1207
|
-
region: this.region,
|
|
1208
|
-
method: 'POST',
|
|
1209
|
-
path: `/model/${encodeURIComponent(params.modelId)}/converse`,
|
|
1210
|
-
headers: {
|
|
1211
|
-
'Content-Type': 'application/json',
|
|
1212
|
-
'Accept': 'application/json',
|
|
1213
|
-
},
|
|
1214
|
-
body: JSON.stringify(requestBody),
|
|
1215
|
-
})
|
|
1216
|
-
|
|
1217
|
-
return result
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
/**
|
|
1221
|
-
* Generate embeddings using a Bedrock model
|
|
1222
|
-
*/
|
|
1223
|
-
async generateEmbeddings(params: {
|
|
1224
|
-
modelId?: string
|
|
1225
|
-
inputText: string | string[]
|
|
1226
|
-
dimensions?: number
|
|
1227
|
-
normalize?: boolean
|
|
1228
|
-
}): Promise<{ embedding?: number[]; embeddings?: number[][] }> {
|
|
1229
|
-
const modelId = params.modelId || 'amazon.titan-embed-text-v1'
|
|
1230
|
-
|
|
1231
|
-
let requestBody: Record<string, unknown>
|
|
1232
|
-
|
|
1233
|
-
// Different models have different input formats
|
|
1234
|
-
if (modelId.includes('cohere')) {
|
|
1235
|
-
requestBody = {
|
|
1236
|
-
texts: Array.isArray(params.inputText) ? params.inputText : [params.inputText],
|
|
1237
|
-
input_type: 'search_document',
|
|
1238
|
-
}
|
|
1239
|
-
} else if (modelId.includes('titan')) {
|
|
1240
|
-
requestBody = {
|
|
1241
|
-
inputText: Array.isArray(params.inputText) ? params.inputText[0] : params.inputText,
|
|
1242
|
-
}
|
|
1243
|
-
if (params.dimensions) requestBody.dimensions = params.dimensions
|
|
1244
|
-
if (params.normalize !== undefined) requestBody.normalize = params.normalize
|
|
1245
|
-
} else {
|
|
1246
|
-
// Default format
|
|
1247
|
-
requestBody = {
|
|
1248
|
-
inputText: Array.isArray(params.inputText) ? params.inputText[0] : params.inputText,
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
const result = await this.client.request({
|
|
1253
|
-
service: 'bedrock-runtime',
|
|
1254
|
-
region: this.region,
|
|
1255
|
-
method: 'POST',
|
|
1256
|
-
path: `/model/${encodeURIComponent(modelId)}/invoke`,
|
|
1257
|
-
headers: {
|
|
1258
|
-
'Content-Type': 'application/json',
|
|
1259
|
-
'Accept': 'application/json',
|
|
1260
|
-
},
|
|
1261
|
-
body: JSON.stringify(requestBody),
|
|
1262
|
-
})
|
|
1263
|
-
|
|
1264
|
-
return result
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
/**
|
|
1268
|
-
* Apply guardrail to content
|
|
1269
|
-
*/
|
|
1270
|
-
async applyGuardrail(params: {
|
|
1271
|
-
guardrailIdentifier: string
|
|
1272
|
-
guardrailVersion: string
|
|
1273
|
-
source: 'INPUT' | 'OUTPUT'
|
|
1274
|
-
content: Array<{ text: { text: string } }>
|
|
1275
|
-
}): Promise<{
|
|
1276
|
-
action: 'NONE' | 'GUARDRAIL_INTERVENED'
|
|
1277
|
-
outputs: Array<{ text: string }>
|
|
1278
|
-
assessments: Array<{
|
|
1279
|
-
topicPolicy?: { topics: Array<{ name: string; type: string; action: string }> }
|
|
1280
|
-
contentPolicy?: { filters: Array<{ type: string; confidence: string; action: string }> }
|
|
1281
|
-
wordPolicy?: { customWords: Array<{ match: string; action: string }>; managedWordLists: Array<{ match: string; type: string; action: string }> }
|
|
1282
|
-
sensitiveInformationPolicy?: { piiEntities: Array<{ type: string; match: string; action: string }>; regexes: Array<{ name: string; match: string; action: string }> }
|
|
1283
|
-
}>
|
|
1284
|
-
}> {
|
|
1285
|
-
const result = await this.client.request({
|
|
1286
|
-
service: 'bedrock-runtime',
|
|
1287
|
-
region: this.region,
|
|
1288
|
-
method: 'POST',
|
|
1289
|
-
path: `/guardrail/${encodeURIComponent(params.guardrailIdentifier)}/version/${encodeURIComponent(params.guardrailVersion)}/apply`,
|
|
1290
|
-
headers: {
|
|
1291
|
-
'Content-Type': 'application/json',
|
|
1292
|
-
'Accept': 'application/json',
|
|
1293
|
-
},
|
|
1294
|
-
body: JSON.stringify({
|
|
1295
|
-
source: params.source,
|
|
1296
|
-
content: params.content,
|
|
1297
|
-
}),
|
|
1298
|
-
})
|
|
1299
|
-
|
|
1300
|
-
return result
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
// ============================================================================
|
|
1305
|
-
// Bedrock Client (Management API)
|
|
1306
|
-
// ============================================================================
|
|
1307
|
-
|
|
1308
|
-
/**
|
|
1309
|
-
* Bedrock client for model management (not runtime)
|
|
1310
|
-
*/
|
|
1311
|
-
export class BedrockClient {
|
|
1312
|
-
private client: AWSClient
|
|
1313
|
-
private region: string
|
|
1314
|
-
|
|
1315
|
-
constructor(region: string = 'us-east-1') {
|
|
1316
|
-
this.region = region
|
|
1317
|
-
this.client = new AWSClient()
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
// -------------------------------------------------------------------------
|
|
1321
|
-
// Foundation Models
|
|
1322
|
-
// -------------------------------------------------------------------------
|
|
1323
|
-
|
|
1324
|
-
/**
|
|
1325
|
-
* List available foundation models
|
|
1326
|
-
*/
|
|
1327
|
-
async listFoundationModels(params?: ListFoundationModelsCommandInput): Promise<ListFoundationModelsCommandOutput> {
|
|
1328
|
-
const queryParams: Record<string, string> = {}
|
|
1329
|
-
if (params?.byProvider) queryParams.byProvider = params.byProvider
|
|
1330
|
-
if (params?.byCustomizationType) queryParams.byCustomizationType = params.byCustomizationType
|
|
1331
|
-
if (params?.byOutputModality) queryParams.byOutputModality = params.byOutputModality
|
|
1332
|
-
if (params?.byInferenceType) queryParams.byInferenceType = params.byInferenceType
|
|
1333
|
-
|
|
1334
|
-
return this.client.request({
|
|
1335
|
-
service: 'bedrock',
|
|
1336
|
-
region: this.region,
|
|
1337
|
-
method: 'GET',
|
|
1338
|
-
path: '/foundation-models',
|
|
1339
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1340
|
-
})
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
/**
|
|
1344
|
-
* Get details about a foundation model
|
|
1345
|
-
*/
|
|
1346
|
-
async getFoundationModel(params: GetFoundationModelCommandInput): Promise<GetFoundationModelCommandOutput> {
|
|
1347
|
-
return this.client.request({
|
|
1348
|
-
service: 'bedrock',
|
|
1349
|
-
region: this.region,
|
|
1350
|
-
method: 'GET',
|
|
1351
|
-
path: `/foundation-models/${encodeURIComponent(params.modelIdentifier)}`,
|
|
1352
|
-
})
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
// -------------------------------------------------------------------------
|
|
1356
|
-
// Model Customization Jobs
|
|
1357
|
-
// -------------------------------------------------------------------------
|
|
1358
|
-
|
|
1359
|
-
/**
|
|
1360
|
-
* Create a model customization job (fine-tuning)
|
|
1361
|
-
*/
|
|
1362
|
-
async createModelCustomizationJob(params: CreateModelCustomizationJobCommandInput): Promise<CreateModelCustomizationJobCommandOutput> {
|
|
1363
|
-
return this.client.request({
|
|
1364
|
-
service: 'bedrock',
|
|
1365
|
-
region: this.region,
|
|
1366
|
-
method: 'POST',
|
|
1367
|
-
path: '/model-customization-jobs',
|
|
1368
|
-
headers: {
|
|
1369
|
-
'Content-Type': 'application/json',
|
|
1370
|
-
},
|
|
1371
|
-
body: JSON.stringify(params),
|
|
1372
|
-
})
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
/**
|
|
1376
|
-
* Get model customization job details
|
|
1377
|
-
*/
|
|
1378
|
-
async getModelCustomizationJob(params: GetModelCustomizationJobCommandInput): Promise<GetModelCustomizationJobCommandOutput> {
|
|
1379
|
-
return this.client.request({
|
|
1380
|
-
service: 'bedrock',
|
|
1381
|
-
region: this.region,
|
|
1382
|
-
method: 'GET',
|
|
1383
|
-
path: `/model-customization-jobs/${encodeURIComponent(params.jobIdentifier)}`,
|
|
1384
|
-
})
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
/**
|
|
1388
|
-
* List model customization jobs
|
|
1389
|
-
*/
|
|
1390
|
-
async listModelCustomizationJobs(params?: ListModelCustomizationJobsCommandInput): Promise<ListModelCustomizationJobsCommandOutput> {
|
|
1391
|
-
const queryParams: Record<string, string> = {}
|
|
1392
|
-
if (params?.creationTimeAfter) queryParams.creationTimeAfter = params.creationTimeAfter
|
|
1393
|
-
if (params?.creationTimeBefore) queryParams.creationTimeBefore = params.creationTimeBefore
|
|
1394
|
-
if (params?.statusEquals) queryParams.statusEquals = params.statusEquals
|
|
1395
|
-
if (params?.nameContains) queryParams.nameContains = params.nameContains
|
|
1396
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1397
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1398
|
-
if (params?.sortBy) queryParams.sortBy = params.sortBy
|
|
1399
|
-
if (params?.sortOrder) queryParams.sortOrder = params.sortOrder
|
|
1400
|
-
|
|
1401
|
-
return this.client.request({
|
|
1402
|
-
service: 'bedrock',
|
|
1403
|
-
region: this.region,
|
|
1404
|
-
method: 'GET',
|
|
1405
|
-
path: '/model-customization-jobs',
|
|
1406
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1407
|
-
})
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
/**
|
|
1411
|
-
* Stop a model customization job
|
|
1412
|
-
*/
|
|
1413
|
-
async stopModelCustomizationJob(params: StopModelCustomizationJobCommandInput): Promise<StopModelCustomizationJobCommandOutput> {
|
|
1414
|
-
return this.client.request({
|
|
1415
|
-
service: 'bedrock',
|
|
1416
|
-
region: this.region,
|
|
1417
|
-
method: 'POST',
|
|
1418
|
-
path: `/model-customization-jobs/${encodeURIComponent(params.jobIdentifier)}/stop`,
|
|
1419
|
-
headers: {
|
|
1420
|
-
'Content-Type': 'application/json',
|
|
1421
|
-
},
|
|
1422
|
-
})
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
// -------------------------------------------------------------------------
|
|
1426
|
-
// Custom Models
|
|
1427
|
-
// -------------------------------------------------------------------------
|
|
1428
|
-
|
|
1429
|
-
/**
|
|
1430
|
-
* List custom models
|
|
1431
|
-
*/
|
|
1432
|
-
async listCustomModels(params?: ListCustomModelsCommandInput): Promise<ListCustomModelsCommandOutput> {
|
|
1433
|
-
const queryParams: Record<string, string> = {}
|
|
1434
|
-
if (params?.creationTimeBefore) queryParams.creationTimeBefore = params.creationTimeBefore
|
|
1435
|
-
if (params?.creationTimeAfter) queryParams.creationTimeAfter = params.creationTimeAfter
|
|
1436
|
-
if (params?.nameContains) queryParams.nameContains = params.nameContains
|
|
1437
|
-
if (params?.baseModelArnEquals) queryParams.baseModelArnEquals = params.baseModelArnEquals
|
|
1438
|
-
if (params?.foundationModelArnEquals) queryParams.foundationModelArnEquals = params.foundationModelArnEquals
|
|
1439
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1440
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1441
|
-
if (params?.sortBy) queryParams.sortBy = params.sortBy
|
|
1442
|
-
if (params?.sortOrder) queryParams.sortOrder = params.sortOrder
|
|
1443
|
-
|
|
1444
|
-
return this.client.request({
|
|
1445
|
-
service: 'bedrock',
|
|
1446
|
-
region: this.region,
|
|
1447
|
-
method: 'GET',
|
|
1448
|
-
path: '/custom-models',
|
|
1449
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1450
|
-
})
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
/**
|
|
1454
|
-
* Get custom model details
|
|
1455
|
-
*/
|
|
1456
|
-
async getCustomModel(params: GetCustomModelCommandInput): Promise<GetCustomModelCommandOutput> {
|
|
1457
|
-
return this.client.request({
|
|
1458
|
-
service: 'bedrock',
|
|
1459
|
-
region: this.region,
|
|
1460
|
-
method: 'GET',
|
|
1461
|
-
path: `/custom-models/${encodeURIComponent(params.modelIdentifier)}`,
|
|
1462
|
-
})
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
/**
|
|
1466
|
-
* Delete a custom model
|
|
1467
|
-
*/
|
|
1468
|
-
async deleteCustomModel(params: DeleteCustomModelCommandInput): Promise<DeleteCustomModelCommandOutput> {
|
|
1469
|
-
return this.client.request({
|
|
1470
|
-
service: 'bedrock',
|
|
1471
|
-
region: this.region,
|
|
1472
|
-
method: 'DELETE',
|
|
1473
|
-
path: `/custom-models/${encodeURIComponent(params.modelIdentifier)}`,
|
|
1474
|
-
})
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
// -------------------------------------------------------------------------
|
|
1478
|
-
// Model Access / Entitlements
|
|
1479
|
-
// -------------------------------------------------------------------------
|
|
1480
|
-
|
|
1481
|
-
/**
|
|
1482
|
-
* Request access to a foundation model
|
|
1483
|
-
*/
|
|
1484
|
-
async requestModelAccess(params: CreateFoundationModelEntitlementCommandInput): Promise<CreateFoundationModelEntitlementCommandOutput> {
|
|
1485
|
-
return this.client.request({
|
|
1486
|
-
service: 'bedrock',
|
|
1487
|
-
region: this.region,
|
|
1488
|
-
method: 'POST',
|
|
1489
|
-
path: '/foundation-model-entitlement',
|
|
1490
|
-
headers: {
|
|
1491
|
-
'Content-Type': 'application/json',
|
|
1492
|
-
},
|
|
1493
|
-
body: JSON.stringify({ modelId: params.modelId }),
|
|
1494
|
-
})
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
// -------------------------------------------------------------------------
|
|
1498
|
-
// Guardrails
|
|
1499
|
-
// -------------------------------------------------------------------------
|
|
1500
|
-
|
|
1501
|
-
/**
|
|
1502
|
-
* Create a guardrail
|
|
1503
|
-
*/
|
|
1504
|
-
async createGuardrail(params: CreateGuardrailCommandInput): Promise<CreateGuardrailCommandOutput> {
|
|
1505
|
-
return this.client.request({
|
|
1506
|
-
service: 'bedrock',
|
|
1507
|
-
region: this.region,
|
|
1508
|
-
method: 'POST',
|
|
1509
|
-
path: '/guardrails',
|
|
1510
|
-
headers: {
|
|
1511
|
-
'Content-Type': 'application/json',
|
|
1512
|
-
},
|
|
1513
|
-
body: JSON.stringify(params),
|
|
1514
|
-
})
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
/**
|
|
1518
|
-
* Get guardrail details
|
|
1519
|
-
*/
|
|
1520
|
-
async getGuardrail(params: GetGuardrailCommandInput): Promise<GetGuardrailCommandOutput> {
|
|
1521
|
-
let path = `/guardrails/${encodeURIComponent(params.guardrailIdentifier)}`
|
|
1522
|
-
if (params.guardrailVersion) {
|
|
1523
|
-
path += `?guardrailVersion=${encodeURIComponent(params.guardrailVersion)}`
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
return this.client.request({
|
|
1527
|
-
service: 'bedrock',
|
|
1528
|
-
region: this.region,
|
|
1529
|
-
method: 'GET',
|
|
1530
|
-
path,
|
|
1531
|
-
})
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
/**
|
|
1535
|
-
* List guardrails
|
|
1536
|
-
*/
|
|
1537
|
-
async listGuardrails(params?: ListGuardrailsCommandInput): Promise<ListGuardrailsCommandOutput> {
|
|
1538
|
-
const queryParams: Record<string, string> = {}
|
|
1539
|
-
if (params?.guardrailIdentifier) queryParams.guardrailIdentifier = params.guardrailIdentifier
|
|
1540
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1541
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1542
|
-
|
|
1543
|
-
return this.client.request({
|
|
1544
|
-
service: 'bedrock',
|
|
1545
|
-
region: this.region,
|
|
1546
|
-
method: 'GET',
|
|
1547
|
-
path: '/guardrails',
|
|
1548
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1549
|
-
})
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
* Delete a guardrail
|
|
1554
|
-
*/
|
|
1555
|
-
async deleteGuardrail(params: DeleteGuardrailCommandInput): Promise<DeleteGuardrailCommandOutput> {
|
|
1556
|
-
let path = `/guardrails/${encodeURIComponent(params.guardrailIdentifier)}`
|
|
1557
|
-
if (params.guardrailVersion) {
|
|
1558
|
-
path += `?guardrailVersion=${encodeURIComponent(params.guardrailVersion)}`
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
return this.client.request({
|
|
1562
|
-
service: 'bedrock',
|
|
1563
|
-
region: this.region,
|
|
1564
|
-
method: 'DELETE',
|
|
1565
|
-
path,
|
|
1566
|
-
})
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
// -------------------------------------------------------------------------
|
|
1570
|
-
// Batch Inference Jobs
|
|
1571
|
-
// -------------------------------------------------------------------------
|
|
1572
|
-
|
|
1573
|
-
/**
|
|
1574
|
-
* List model invocation jobs (batch inference)
|
|
1575
|
-
*/
|
|
1576
|
-
async listModelInvocationJobs(params?: ListModelInvocationJobsCommandInput): Promise<ListModelInvocationJobsCommandOutput> {
|
|
1577
|
-
const queryParams: Record<string, string> = {}
|
|
1578
|
-
if (params?.submitTimeAfter) queryParams.submitTimeAfter = params.submitTimeAfter
|
|
1579
|
-
if (params?.submitTimeBefore) queryParams.submitTimeBefore = params.submitTimeBefore
|
|
1580
|
-
if (params?.statusEquals) queryParams.statusEquals = params.statusEquals
|
|
1581
|
-
if (params?.nameContains) queryParams.nameContains = params.nameContains
|
|
1582
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1583
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1584
|
-
if (params?.sortBy) queryParams.sortBy = params.sortBy
|
|
1585
|
-
if (params?.sortOrder) queryParams.sortOrder = params.sortOrder
|
|
1586
|
-
|
|
1587
|
-
return this.client.request({
|
|
1588
|
-
service: 'bedrock',
|
|
1589
|
-
region: this.region,
|
|
1590
|
-
method: 'GET',
|
|
1591
|
-
path: '/model-invocation-jobs',
|
|
1592
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1593
|
-
})
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
// -------------------------------------------------------------------------
|
|
1597
|
-
// Convenience Methods
|
|
1598
|
-
// -------------------------------------------------------------------------
|
|
1599
|
-
|
|
1600
|
-
/**
|
|
1601
|
-
* Wait for a model customization job to complete
|
|
1602
|
-
*/
|
|
1603
|
-
async waitForModelCustomizationJob(
|
|
1604
|
-
jobIdentifier: string,
|
|
1605
|
-
options?: { maxWaitMs?: number; pollIntervalMs?: number },
|
|
1606
|
-
): Promise<GetModelCustomizationJobCommandOutput> {
|
|
1607
|
-
const maxWaitMs = options?.maxWaitMs ?? 3600000 // 1 hour default
|
|
1608
|
-
const pollIntervalMs = options?.pollIntervalMs ?? 30000 // 30 seconds default
|
|
1609
|
-
const startTime = Date.now()
|
|
1610
|
-
|
|
1611
|
-
while (Date.now() - startTime < maxWaitMs) {
|
|
1612
|
-
const job = await this.getModelCustomizationJob({ jobIdentifier })
|
|
1613
|
-
|
|
1614
|
-
if (job.status === 'Completed' || job.status === 'Failed' || job.status === 'Stopped') {
|
|
1615
|
-
return job
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
await new Promise(resolve => setTimeout(resolve, pollIntervalMs))
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
throw new Error(`Timeout waiting for model customization job ${jobIdentifier}`)
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
/**
|
|
1625
|
-
* Request access to multiple models
|
|
1626
|
-
*/
|
|
1627
|
-
async requestAccessToModels(modelIds: string[]): Promise<Array<{ modelId: string; status: string; error?: string }>> {
|
|
1628
|
-
const results: Array<{ modelId: string; status: string; error?: string }> = []
|
|
1629
|
-
|
|
1630
|
-
for (const modelId of modelIds) {
|
|
1631
|
-
try {
|
|
1632
|
-
const result = await this.requestModelAccess({ modelId })
|
|
1633
|
-
results.push({ modelId, status: result.status })
|
|
1634
|
-
} catch (error: unknown) {
|
|
1635
|
-
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
1636
|
-
results.push({ modelId, status: 'ERROR', error: errorMessage })
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
return results
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
/**
|
|
1644
|
-
* List all foundation models from a specific provider
|
|
1645
|
-
*/
|
|
1646
|
-
async listModelsByProvider(provider: string): Promise<FoundationModelSummary[]> {
|
|
1647
|
-
const result = await this.listFoundationModels({ byProvider: provider })
|
|
1648
|
-
return result.modelSummaries || []
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
/**
|
|
1652
|
-
* List all Claude models
|
|
1653
|
-
*/
|
|
1654
|
-
async listClaudeModels(): Promise<FoundationModelSummary[]> {
|
|
1655
|
-
return this.listModelsByProvider('Anthropic')
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
/**
|
|
1659
|
-
* List all embedding models
|
|
1660
|
-
*/
|
|
1661
|
-
async listEmbeddingModels(): Promise<FoundationModelSummary[]> {
|
|
1662
|
-
const result = await this.listFoundationModels({ byOutputModality: 'EMBEDDING' })
|
|
1663
|
-
return result.modelSummaries || []
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
// -------------------------------------------------------------------------
|
|
1667
|
-
// Batch Inference (Create/Get/Stop)
|
|
1668
|
-
// -------------------------------------------------------------------------
|
|
1669
|
-
|
|
1670
|
-
/**
|
|
1671
|
-
* Create a batch inference job
|
|
1672
|
-
*/
|
|
1673
|
-
async createModelInvocationJob(params: CreateModelInvocationJobCommandInput): Promise<CreateModelInvocationJobCommandOutput> {
|
|
1674
|
-
return this.client.request({
|
|
1675
|
-
service: 'bedrock',
|
|
1676
|
-
region: this.region,
|
|
1677
|
-
method: 'POST',
|
|
1678
|
-
path: '/model-invocation-jobs',
|
|
1679
|
-
headers: {
|
|
1680
|
-
'Content-Type': 'application/json',
|
|
1681
|
-
},
|
|
1682
|
-
body: JSON.stringify(params),
|
|
1683
|
-
})
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
/**
|
|
1687
|
-
* Get batch inference job details
|
|
1688
|
-
*/
|
|
1689
|
-
async getModelInvocationJob(params: GetModelInvocationJobCommandInput): Promise<GetModelInvocationJobCommandOutput> {
|
|
1690
|
-
return this.client.request({
|
|
1691
|
-
service: 'bedrock',
|
|
1692
|
-
region: this.region,
|
|
1693
|
-
method: 'GET',
|
|
1694
|
-
path: `/model-invocation-jobs/${encodeURIComponent(params.jobIdentifier)}`,
|
|
1695
|
-
})
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
/**
|
|
1699
|
-
* Stop a batch inference job
|
|
1700
|
-
*/
|
|
1701
|
-
async stopModelInvocationJob(params: StopModelInvocationJobCommandInput): Promise<StopModelInvocationJobCommandOutput> {
|
|
1702
|
-
return this.client.request({
|
|
1703
|
-
service: 'bedrock',
|
|
1704
|
-
region: this.region,
|
|
1705
|
-
method: 'POST',
|
|
1706
|
-
path: `/model-invocation-jobs/${encodeURIComponent(params.jobIdentifier)}/stop`,
|
|
1707
|
-
headers: {
|
|
1708
|
-
'Content-Type': 'application/json',
|
|
1709
|
-
},
|
|
1710
|
-
})
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
|
-
// -------------------------------------------------------------------------
|
|
1714
|
-
// Provisioned Throughput
|
|
1715
|
-
// -------------------------------------------------------------------------
|
|
1716
|
-
|
|
1717
|
-
/**
|
|
1718
|
-
* Create provisioned throughput for a model
|
|
1719
|
-
*/
|
|
1720
|
-
async createProvisionedModelThroughput(params: CreateProvisionedModelThroughputCommandInput): Promise<CreateProvisionedModelThroughputCommandOutput> {
|
|
1721
|
-
return this.client.request({
|
|
1722
|
-
service: 'bedrock',
|
|
1723
|
-
region: this.region,
|
|
1724
|
-
method: 'POST',
|
|
1725
|
-
path: '/provisioned-model-throughput',
|
|
1726
|
-
headers: {
|
|
1727
|
-
'Content-Type': 'application/json',
|
|
1728
|
-
},
|
|
1729
|
-
body: JSON.stringify(params),
|
|
1730
|
-
})
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
/**
|
|
1734
|
-
* Get provisioned throughput details
|
|
1735
|
-
*/
|
|
1736
|
-
async getProvisionedModelThroughput(params: GetProvisionedModelThroughputCommandInput): Promise<GetProvisionedModelThroughputCommandOutput> {
|
|
1737
|
-
return this.client.request({
|
|
1738
|
-
service: 'bedrock',
|
|
1739
|
-
region: this.region,
|
|
1740
|
-
method: 'GET',
|
|
1741
|
-
path: `/provisioned-model-throughput/${encodeURIComponent(params.provisionedModelId)}`,
|
|
1742
|
-
})
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
/**
|
|
1746
|
-
* List provisioned throughputs
|
|
1747
|
-
*/
|
|
1748
|
-
async listProvisionedModelThroughputs(params?: ListProvisionedModelThroughputsCommandInput): Promise<ListProvisionedModelThroughputsCommandOutput> {
|
|
1749
|
-
const queryParams: Record<string, string> = {}
|
|
1750
|
-
if (params?.creationTimeAfter) queryParams.creationTimeAfter = params.creationTimeAfter
|
|
1751
|
-
if (params?.creationTimeBefore) queryParams.creationTimeBefore = params.creationTimeBefore
|
|
1752
|
-
if (params?.statusEquals) queryParams.statusEquals = params.statusEquals
|
|
1753
|
-
if (params?.modelArnEquals) queryParams.modelArnEquals = params.modelArnEquals
|
|
1754
|
-
if (params?.nameContains) queryParams.nameContains = params.nameContains
|
|
1755
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1756
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1757
|
-
if (params?.sortBy) queryParams.sortBy = params.sortBy
|
|
1758
|
-
if (params?.sortOrder) queryParams.sortOrder = params.sortOrder
|
|
1759
|
-
|
|
1760
|
-
return this.client.request({
|
|
1761
|
-
service: 'bedrock',
|
|
1762
|
-
region: this.region,
|
|
1763
|
-
method: 'GET',
|
|
1764
|
-
path: '/provisioned-model-throughput',
|
|
1765
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1766
|
-
})
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
/**
|
|
1770
|
-
* Update provisioned throughput
|
|
1771
|
-
*/
|
|
1772
|
-
async updateProvisionedModelThroughput(params: UpdateProvisionedModelThroughputCommandInput): Promise<UpdateProvisionedModelThroughputCommandOutput> {
|
|
1773
|
-
return this.client.request({
|
|
1774
|
-
service: 'bedrock',
|
|
1775
|
-
region: this.region,
|
|
1776
|
-
method: 'PATCH',
|
|
1777
|
-
path: `/provisioned-model-throughput/${encodeURIComponent(params.provisionedModelId)}`,
|
|
1778
|
-
headers: {
|
|
1779
|
-
'Content-Type': 'application/json',
|
|
1780
|
-
},
|
|
1781
|
-
body: JSON.stringify({
|
|
1782
|
-
desiredProvisionedModelName: params.desiredProvisionedModelName,
|
|
1783
|
-
desiredModelId: params.desiredModelId,
|
|
1784
|
-
}),
|
|
1785
|
-
})
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
/**
|
|
1789
|
-
* Delete provisioned throughput
|
|
1790
|
-
*/
|
|
1791
|
-
async deleteProvisionedModelThroughput(params: DeleteProvisionedModelThroughputCommandInput): Promise<DeleteProvisionedModelThroughputCommandOutput> {
|
|
1792
|
-
return this.client.request({
|
|
1793
|
-
service: 'bedrock',
|
|
1794
|
-
region: this.region,
|
|
1795
|
-
method: 'DELETE',
|
|
1796
|
-
path: `/provisioned-model-throughput/${encodeURIComponent(params.provisionedModelId)}`,
|
|
1797
|
-
})
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
// -------------------------------------------------------------------------
|
|
1801
|
-
// Model Evaluation
|
|
1802
|
-
// -------------------------------------------------------------------------
|
|
1803
|
-
|
|
1804
|
-
/**
|
|
1805
|
-
* Create a model evaluation job
|
|
1806
|
-
*/
|
|
1807
|
-
async createEvaluationJob(params: CreateEvaluationJobCommandInput): Promise<CreateEvaluationJobCommandOutput> {
|
|
1808
|
-
return this.client.request({
|
|
1809
|
-
service: 'bedrock',
|
|
1810
|
-
region: this.region,
|
|
1811
|
-
method: 'POST',
|
|
1812
|
-
path: '/evaluation-jobs',
|
|
1813
|
-
headers: {
|
|
1814
|
-
'Content-Type': 'application/json',
|
|
1815
|
-
},
|
|
1816
|
-
body: JSON.stringify(params),
|
|
1817
|
-
})
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
/**
|
|
1821
|
-
* Get evaluation job details
|
|
1822
|
-
*/
|
|
1823
|
-
async getEvaluationJob(params: GetEvaluationJobCommandInput): Promise<GetEvaluationJobCommandOutput> {
|
|
1824
|
-
return this.client.request({
|
|
1825
|
-
service: 'bedrock',
|
|
1826
|
-
region: this.region,
|
|
1827
|
-
method: 'GET',
|
|
1828
|
-
path: `/evaluation-jobs/${encodeURIComponent(params.jobIdentifier)}`,
|
|
1829
|
-
})
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
/**
|
|
1833
|
-
* List evaluation jobs
|
|
1834
|
-
*/
|
|
1835
|
-
async listEvaluationJobs(params?: ListEvaluationJobsCommandInput): Promise<ListEvaluationJobsCommandOutput> {
|
|
1836
|
-
const queryParams: Record<string, string> = {}
|
|
1837
|
-
if (params?.creationTimeAfter) queryParams.creationTimeAfter = params.creationTimeAfter
|
|
1838
|
-
if (params?.creationTimeBefore) queryParams.creationTimeBefore = params.creationTimeBefore
|
|
1839
|
-
if (params?.statusEquals) queryParams.statusEquals = params.statusEquals
|
|
1840
|
-
if (params?.nameContains) queryParams.nameContains = params.nameContains
|
|
1841
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1842
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1843
|
-
if (params?.sortBy) queryParams.sortBy = params.sortBy
|
|
1844
|
-
if (params?.sortOrder) queryParams.sortOrder = params.sortOrder
|
|
1845
|
-
|
|
1846
|
-
return this.client.request({
|
|
1847
|
-
service: 'bedrock',
|
|
1848
|
-
region: this.region,
|
|
1849
|
-
method: 'GET',
|
|
1850
|
-
path: '/evaluation-jobs',
|
|
1851
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1852
|
-
})
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
/**
|
|
1856
|
-
* Stop an evaluation job
|
|
1857
|
-
*/
|
|
1858
|
-
async stopEvaluationJob(params: StopEvaluationJobCommandInput): Promise<StopEvaluationJobCommandOutput> {
|
|
1859
|
-
return this.client.request({
|
|
1860
|
-
service: 'bedrock',
|
|
1861
|
-
region: this.region,
|
|
1862
|
-
method: 'POST',
|
|
1863
|
-
path: `/evaluation-jobs/${encodeURIComponent(params.jobIdentifier)}/stop`,
|
|
1864
|
-
headers: {
|
|
1865
|
-
'Content-Type': 'application/json',
|
|
1866
|
-
},
|
|
1867
|
-
})
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
// -------------------------------------------------------------------------
|
|
1871
|
-
// Inference Profiles
|
|
1872
|
-
// -------------------------------------------------------------------------
|
|
1873
|
-
|
|
1874
|
-
/**
|
|
1875
|
-
* Get inference profile details
|
|
1876
|
-
*/
|
|
1877
|
-
async getInferenceProfile(params: GetInferenceProfileCommandInput): Promise<GetInferenceProfileCommandOutput> {
|
|
1878
|
-
return this.client.request({
|
|
1879
|
-
service: 'bedrock',
|
|
1880
|
-
region: this.region,
|
|
1881
|
-
method: 'GET',
|
|
1882
|
-
path: `/inference-profiles/${encodeURIComponent(params.inferenceProfileIdentifier)}`,
|
|
1883
|
-
})
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
|
-
/**
|
|
1887
|
-
* List inference profiles
|
|
1888
|
-
*/
|
|
1889
|
-
async listInferenceProfiles(params?: ListInferenceProfilesCommandInput): Promise<ListInferenceProfilesCommandOutput> {
|
|
1890
|
-
const queryParams: Record<string, string> = {}
|
|
1891
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1892
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1893
|
-
if (params?.typeEquals) queryParams.typeEquals = params.typeEquals
|
|
1894
|
-
|
|
1895
|
-
return this.client.request({
|
|
1896
|
-
service: 'bedrock',
|
|
1897
|
-
region: this.region,
|
|
1898
|
-
method: 'GET',
|
|
1899
|
-
path: '/inference-profiles',
|
|
1900
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1901
|
-
})
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
/**
|
|
1905
|
-
* Create an inference profile
|
|
1906
|
-
*/
|
|
1907
|
-
async createInferenceProfile(params: CreateInferenceProfileCommandInput): Promise<CreateInferenceProfileCommandOutput> {
|
|
1908
|
-
return this.client.request({
|
|
1909
|
-
service: 'bedrock',
|
|
1910
|
-
region: this.region,
|
|
1911
|
-
method: 'POST',
|
|
1912
|
-
path: '/inference-profiles',
|
|
1913
|
-
headers: {
|
|
1914
|
-
'Content-Type': 'application/json',
|
|
1915
|
-
},
|
|
1916
|
-
body: JSON.stringify(params),
|
|
1917
|
-
})
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
|
-
/**
|
|
1921
|
-
* Delete an inference profile
|
|
1922
|
-
*/
|
|
1923
|
-
async deleteInferenceProfile(params: DeleteInferenceProfileCommandInput): Promise<DeleteInferenceProfileCommandOutput> {
|
|
1924
|
-
return this.client.request({
|
|
1925
|
-
service: 'bedrock',
|
|
1926
|
-
region: this.region,
|
|
1927
|
-
method: 'DELETE',
|
|
1928
|
-
path: `/inference-profiles/${encodeURIComponent(params.inferenceProfileIdentifier)}`,
|
|
1929
|
-
})
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
// -------------------------------------------------------------------------
|
|
1933
|
-
// Model Copy
|
|
1934
|
-
// -------------------------------------------------------------------------
|
|
1935
|
-
|
|
1936
|
-
/**
|
|
1937
|
-
* Create a model copy job
|
|
1938
|
-
*/
|
|
1939
|
-
async createModelCopyJob(params: CreateModelCopyJobCommandInput): Promise<CreateModelCopyJobCommandOutput> {
|
|
1940
|
-
return this.client.request({
|
|
1941
|
-
service: 'bedrock',
|
|
1942
|
-
region: this.region,
|
|
1943
|
-
method: 'POST',
|
|
1944
|
-
path: '/model-copy-jobs',
|
|
1945
|
-
headers: {
|
|
1946
|
-
'Content-Type': 'application/json',
|
|
1947
|
-
},
|
|
1948
|
-
body: JSON.stringify(params),
|
|
1949
|
-
})
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
|
-
/**
|
|
1953
|
-
* Get model copy job details
|
|
1954
|
-
*/
|
|
1955
|
-
async getModelCopyJob(params: GetModelCopyJobCommandInput): Promise<GetModelCopyJobCommandOutput> {
|
|
1956
|
-
return this.client.request({
|
|
1957
|
-
service: 'bedrock',
|
|
1958
|
-
region: this.region,
|
|
1959
|
-
method: 'GET',
|
|
1960
|
-
path: `/model-copy-jobs/${encodeURIComponent(params.jobArn)}`,
|
|
1961
|
-
})
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
/**
|
|
1965
|
-
* List model copy jobs
|
|
1966
|
-
*/
|
|
1967
|
-
async listModelCopyJobs(params?: ListModelCopyJobsCommandInput): Promise<ListModelCopyJobsCommandOutput> {
|
|
1968
|
-
const queryParams: Record<string, string> = {}
|
|
1969
|
-
if (params?.creationTimeAfter) queryParams.creationTimeAfter = params.creationTimeAfter
|
|
1970
|
-
if (params?.creationTimeBefore) queryParams.creationTimeBefore = params.creationTimeBefore
|
|
1971
|
-
if (params?.statusEquals) queryParams.statusEquals = params.statusEquals
|
|
1972
|
-
if (params?.sourceAccountEquals) queryParams.sourceAccountEquals = params.sourceAccountEquals
|
|
1973
|
-
if (params?.sourceModelArnEquals) queryParams.sourceModelArnEquals = params.sourceModelArnEquals
|
|
1974
|
-
if (params?.targetModelNameContains) queryParams.targetModelNameContains = params.targetModelNameContains
|
|
1975
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
1976
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
1977
|
-
if (params?.sortBy) queryParams.sortBy = params.sortBy
|
|
1978
|
-
if (params?.sortOrder) queryParams.sortOrder = params.sortOrder
|
|
1979
|
-
|
|
1980
|
-
return this.client.request({
|
|
1981
|
-
service: 'bedrock',
|
|
1982
|
-
region: this.region,
|
|
1983
|
-
method: 'GET',
|
|
1984
|
-
path: '/model-copy-jobs',
|
|
1985
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
1986
|
-
})
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
// ============================================================================
|
|
1991
|
-
// Bedrock Agent Runtime Client
|
|
1992
|
-
// ============================================================================
|
|
1993
|
-
|
|
1994
|
-
/**
|
|
1995
|
-
* Bedrock Agent Runtime client for invoking agents
|
|
1996
|
-
*/
|
|
1997
|
-
export class BedrockAgentRuntimeClient {
|
|
1998
|
-
private client: AWSClient
|
|
1999
|
-
private region: string
|
|
2000
|
-
|
|
2001
|
-
constructor(region: string = 'us-east-1') {
|
|
2002
|
-
this.region = region
|
|
2003
|
-
this.client = new AWSClient()
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
/**
|
|
2007
|
-
* Invoke a Bedrock agent
|
|
2008
|
-
*/
|
|
2009
|
-
async invokeAgent(params: InvokeAgentCommandInput): Promise<{
|
|
2010
|
-
completion: string
|
|
2011
|
-
sessionId: string
|
|
2012
|
-
memoryId?: string
|
|
2013
|
-
citations?: Array<{
|
|
2014
|
-
generatedResponsePart?: { textResponsePart?: { text: string } }
|
|
2015
|
-
retrievedReferences?: Array<{ content?: { text: string }; location?: { s3Location?: { uri: string } } }>
|
|
2016
|
-
}>
|
|
2017
|
-
}> {
|
|
2018
|
-
const requestBody: Record<string, unknown> = {
|
|
2019
|
-
inputText: params.inputText,
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
if (params.endSession !== undefined) requestBody.endSession = params.endSession
|
|
2023
|
-
if (params.enableTrace !== undefined) requestBody.enableTrace = params.enableTrace
|
|
2024
|
-
if (params.memoryId) requestBody.memoryId = params.memoryId
|
|
2025
|
-
if (params.sessionState) requestBody.sessionState = params.sessionState
|
|
2026
|
-
|
|
2027
|
-
const result = await this.client.request({
|
|
2028
|
-
service: 'bedrock-agent-runtime',
|
|
2029
|
-
region: this.region,
|
|
2030
|
-
method: 'POST',
|
|
2031
|
-
path: `/agents/${encodeURIComponent(params.agentId)}/agentAliases/${encodeURIComponent(params.agentAliasId)}/sessions/${encodeURIComponent(params.sessionId)}/text`,
|
|
2032
|
-
headers: {
|
|
2033
|
-
'Content-Type': 'application/json',
|
|
2034
|
-
'Accept': 'application/json',
|
|
2035
|
-
},
|
|
2036
|
-
body: JSON.stringify(requestBody),
|
|
2037
|
-
})
|
|
2038
|
-
|
|
2039
|
-
return result
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2042
|
-
/**
|
|
2043
|
-
* Retrieve from a knowledge base
|
|
2044
|
-
*/
|
|
2045
|
-
async retrieve(params: {
|
|
2046
|
-
knowledgeBaseId: string
|
|
2047
|
-
retrievalQuery: {
|
|
2048
|
-
text: string
|
|
2049
|
-
}
|
|
2050
|
-
retrievalConfiguration?: {
|
|
2051
|
-
vectorSearchConfiguration: {
|
|
2052
|
-
numberOfResults?: number
|
|
2053
|
-
overrideSearchType?: 'HYBRID' | 'SEMANTIC'
|
|
2054
|
-
filter?: Record<string, unknown>
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
nextToken?: string
|
|
2058
|
-
}): Promise<{
|
|
2059
|
-
retrievalResults: Array<{
|
|
2060
|
-
content: { text: string }
|
|
2061
|
-
location?: {
|
|
2062
|
-
type: string
|
|
2063
|
-
s3Location?: { uri: string }
|
|
2064
|
-
}
|
|
2065
|
-
score?: number
|
|
2066
|
-
metadata?: Record<string, unknown>
|
|
2067
|
-
}>
|
|
2068
|
-
nextToken?: string
|
|
2069
|
-
}> {
|
|
2070
|
-
return this.client.request({
|
|
2071
|
-
service: 'bedrock-agent-runtime',
|
|
2072
|
-
region: this.region,
|
|
2073
|
-
method: 'POST',
|
|
2074
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/retrieve`,
|
|
2075
|
-
headers: {
|
|
2076
|
-
'Content-Type': 'application/json',
|
|
2077
|
-
'Accept': 'application/json',
|
|
2078
|
-
},
|
|
2079
|
-
body: JSON.stringify({
|
|
2080
|
-
retrievalQuery: params.retrievalQuery,
|
|
2081
|
-
retrievalConfiguration: params.retrievalConfiguration,
|
|
2082
|
-
nextToken: params.nextToken,
|
|
2083
|
-
}),
|
|
2084
|
-
})
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
/**
|
|
2088
|
-
* Retrieve and generate using a knowledge base
|
|
2089
|
-
*/
|
|
2090
|
-
async retrieveAndGenerate(params: {
|
|
2091
|
-
input: {
|
|
2092
|
-
text: string
|
|
2093
|
-
}
|
|
2094
|
-
retrieveAndGenerateConfiguration: {
|
|
2095
|
-
type: 'KNOWLEDGE_BASE'
|
|
2096
|
-
knowledgeBaseConfiguration: {
|
|
2097
|
-
knowledgeBaseId: string
|
|
2098
|
-
modelArn: string
|
|
2099
|
-
retrievalConfiguration?: {
|
|
2100
|
-
vectorSearchConfiguration: {
|
|
2101
|
-
numberOfResults?: number
|
|
2102
|
-
overrideSearchType?: 'HYBRID' | 'SEMANTIC'
|
|
2103
|
-
filter?: Record<string, unknown>
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
generationConfiguration?: {
|
|
2107
|
-
promptTemplate?: {
|
|
2108
|
-
textPromptTemplate: string
|
|
2109
|
-
}
|
|
2110
|
-
inferenceConfig?: {
|
|
2111
|
-
textInferenceConfig?: {
|
|
2112
|
-
temperature?: number
|
|
2113
|
-
topP?: number
|
|
2114
|
-
maxTokens?: number
|
|
2115
|
-
stopSequences?: string[]
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
guardrailConfiguration?: {
|
|
2119
|
-
guardrailId: string
|
|
2120
|
-
guardrailVersion: string
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
sessionConfiguration?: {
|
|
2126
|
-
kmsKeyArn?: string
|
|
2127
|
-
}
|
|
2128
|
-
sessionId?: string
|
|
2129
|
-
}): Promise<{
|
|
2130
|
-
sessionId: string
|
|
2131
|
-
output: {
|
|
2132
|
-
text: string
|
|
2133
|
-
}
|
|
2134
|
-
citations?: Array<{
|
|
2135
|
-
generatedResponsePart?: {
|
|
2136
|
-
textResponsePart?: {
|
|
2137
|
-
text: string
|
|
2138
|
-
span?: { start: number; end: number }
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
retrievedReferences?: Array<{
|
|
2142
|
-
content: { text: string }
|
|
2143
|
-
location?: {
|
|
2144
|
-
type: string
|
|
2145
|
-
s3Location?: { uri: string }
|
|
2146
|
-
}
|
|
2147
|
-
metadata?: Record<string, unknown>
|
|
2148
|
-
}>
|
|
2149
|
-
}>
|
|
2150
|
-
guardrailAction?: 'INTERVENED' | 'NONE'
|
|
2151
|
-
}> {
|
|
2152
|
-
return this.client.request({
|
|
2153
|
-
service: 'bedrock-agent-runtime',
|
|
2154
|
-
region: this.region,
|
|
2155
|
-
method: 'POST',
|
|
2156
|
-
path: '/retrieveAndGenerate',
|
|
2157
|
-
headers: {
|
|
2158
|
-
'Content-Type': 'application/json',
|
|
2159
|
-
'Accept': 'application/json',
|
|
2160
|
-
},
|
|
2161
|
-
body: JSON.stringify(params),
|
|
2162
|
-
})
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
|
-
// ============================================================================
|
|
2167
|
-
// Bedrock Agent Client (Management)
|
|
2168
|
-
// ============================================================================
|
|
2169
|
-
|
|
2170
|
-
/**
|
|
2171
|
-
* Bedrock Agent client for agent management
|
|
2172
|
-
*/
|
|
2173
|
-
export class BedrockAgentClient {
|
|
2174
|
-
private client: AWSClient
|
|
2175
|
-
private region: string
|
|
2176
|
-
|
|
2177
|
-
constructor(region: string = 'us-east-1') {
|
|
2178
|
-
this.region = region
|
|
2179
|
-
this.client = new AWSClient()
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
/**
|
|
2183
|
-
* Create an agent
|
|
2184
|
-
*/
|
|
2185
|
-
async createAgent(params: CreateAgentCommandInput): Promise<CreateAgentCommandOutput> {
|
|
2186
|
-
return this.client.request({
|
|
2187
|
-
service: 'bedrock-agent',
|
|
2188
|
-
region: this.region,
|
|
2189
|
-
method: 'PUT',
|
|
2190
|
-
path: '/agents/',
|
|
2191
|
-
headers: {
|
|
2192
|
-
'Content-Type': 'application/json',
|
|
2193
|
-
},
|
|
2194
|
-
body: JSON.stringify(params),
|
|
2195
|
-
})
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2198
|
-
/**
|
|
2199
|
-
* Get agent details
|
|
2200
|
-
*/
|
|
2201
|
-
async getAgent(params: { agentId: string }): Promise<{ agent: CreateAgentCommandOutput['agent'] }> {
|
|
2202
|
-
return this.client.request({
|
|
2203
|
-
service: 'bedrock-agent',
|
|
2204
|
-
region: this.region,
|
|
2205
|
-
method: 'GET',
|
|
2206
|
-
path: `/agents/${encodeURIComponent(params.agentId)}/`,
|
|
2207
|
-
})
|
|
2208
|
-
}
|
|
2209
|
-
|
|
2210
|
-
/**
|
|
2211
|
-
* List agents
|
|
2212
|
-
*/
|
|
2213
|
-
async listAgents(params?: {
|
|
2214
|
-
maxResults?: number
|
|
2215
|
-
nextToken?: string
|
|
2216
|
-
}): Promise<{
|
|
2217
|
-
agentSummaries: Array<{
|
|
2218
|
-
agentId: string
|
|
2219
|
-
agentName: string
|
|
2220
|
-
agentStatus: string
|
|
2221
|
-
description?: string
|
|
2222
|
-
updatedAt: string
|
|
2223
|
-
latestAgentVersion: string
|
|
2224
|
-
}>
|
|
2225
|
-
nextToken?: string
|
|
2226
|
-
}> {
|
|
2227
|
-
const queryParams: Record<string, string> = {}
|
|
2228
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
2229
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
2230
|
-
|
|
2231
|
-
return this.client.request({
|
|
2232
|
-
service: 'bedrock-agent',
|
|
2233
|
-
region: this.region,
|
|
2234
|
-
method: 'GET',
|
|
2235
|
-
path: '/agents/',
|
|
2236
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2237
|
-
})
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
/**
|
|
2241
|
-
* Delete an agent
|
|
2242
|
-
*/
|
|
2243
|
-
async deleteAgent(params: { agentId: string; skipResourceInUseCheck?: boolean }): Promise<{ agentId: string; agentStatus: string }> {
|
|
2244
|
-
const queryParams: Record<string, string> = {}
|
|
2245
|
-
if (params.skipResourceInUseCheck !== undefined) {
|
|
2246
|
-
queryParams.skipResourceInUseCheck = params.skipResourceInUseCheck.toString()
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
return this.client.request({
|
|
2250
|
-
service: 'bedrock-agent',
|
|
2251
|
-
region: this.region,
|
|
2252
|
-
method: 'DELETE',
|
|
2253
|
-
path: `/agents/${encodeURIComponent(params.agentId)}/`,
|
|
2254
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2255
|
-
})
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
/**
|
|
2259
|
-
* Prepare an agent for invocation
|
|
2260
|
-
*/
|
|
2261
|
-
async prepareAgent(params: { agentId: string }): Promise<{
|
|
2262
|
-
agentId: string
|
|
2263
|
-
agentStatus: string
|
|
2264
|
-
agentVersion: string
|
|
2265
|
-
preparedAt: string
|
|
2266
|
-
}> {
|
|
2267
|
-
return this.client.request({
|
|
2268
|
-
service: 'bedrock-agent',
|
|
2269
|
-
region: this.region,
|
|
2270
|
-
method: 'POST',
|
|
2271
|
-
path: `/agents/${encodeURIComponent(params.agentId)}/`,
|
|
2272
|
-
headers: {
|
|
2273
|
-
'Content-Type': 'application/json',
|
|
2274
|
-
},
|
|
2275
|
-
})
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
/**
|
|
2279
|
-
* Create a knowledge base
|
|
2280
|
-
*/
|
|
2281
|
-
async createKnowledgeBase(params: CreateKnowledgeBaseCommandInput): Promise<CreateKnowledgeBaseCommandOutput> {
|
|
2282
|
-
return this.client.request({
|
|
2283
|
-
service: 'bedrock-agent',
|
|
2284
|
-
region: this.region,
|
|
2285
|
-
method: 'PUT',
|
|
2286
|
-
path: '/knowledgebases/',
|
|
2287
|
-
headers: {
|
|
2288
|
-
'Content-Type': 'application/json',
|
|
2289
|
-
},
|
|
2290
|
-
body: JSON.stringify(params),
|
|
2291
|
-
})
|
|
2292
|
-
}
|
|
2293
|
-
|
|
2294
|
-
/**
|
|
2295
|
-
* Get knowledge base details
|
|
2296
|
-
*/
|
|
2297
|
-
async getKnowledgeBase(params: { knowledgeBaseId: string }): Promise<{ knowledgeBase: CreateKnowledgeBaseCommandOutput['knowledgeBase'] }> {
|
|
2298
|
-
return this.client.request({
|
|
2299
|
-
service: 'bedrock-agent',
|
|
2300
|
-
region: this.region,
|
|
2301
|
-
method: 'GET',
|
|
2302
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}`,
|
|
2303
|
-
})
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
|
-
/**
|
|
2307
|
-
* List knowledge bases
|
|
2308
|
-
*/
|
|
2309
|
-
async listKnowledgeBases(params?: {
|
|
2310
|
-
maxResults?: number
|
|
2311
|
-
nextToken?: string
|
|
2312
|
-
}): Promise<{
|
|
2313
|
-
knowledgeBaseSummaries: Array<{
|
|
2314
|
-
knowledgeBaseId: string
|
|
2315
|
-
name: string
|
|
2316
|
-
description?: string
|
|
2317
|
-
status: string
|
|
2318
|
-
updatedAt: string
|
|
2319
|
-
}>
|
|
2320
|
-
nextToken?: string
|
|
2321
|
-
}> {
|
|
2322
|
-
const queryParams: Record<string, string> = {}
|
|
2323
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
2324
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
2325
|
-
|
|
2326
|
-
return this.client.request({
|
|
2327
|
-
service: 'bedrock-agent',
|
|
2328
|
-
region: this.region,
|
|
2329
|
-
method: 'GET',
|
|
2330
|
-
path: '/knowledgebases/',
|
|
2331
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2332
|
-
})
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
/**
|
|
2336
|
-
* Delete a knowledge base
|
|
2337
|
-
*/
|
|
2338
|
-
async deleteKnowledgeBase(params: { knowledgeBaseId: string }): Promise<{ knowledgeBaseId: string; status: string }> {
|
|
2339
|
-
return this.client.request({
|
|
2340
|
-
service: 'bedrock-agent',
|
|
2341
|
-
region: this.region,
|
|
2342
|
-
method: 'DELETE',
|
|
2343
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}`,
|
|
2344
|
-
})
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
|
-
// -------------------------------------------------------------------------
|
|
2348
|
-
// Data Sources
|
|
2349
|
-
// -------------------------------------------------------------------------
|
|
2350
|
-
|
|
2351
|
-
/**
|
|
2352
|
-
* Create a data source for a knowledge base
|
|
2353
|
-
*/
|
|
2354
|
-
async createDataSource(params: CreateDataSourceCommandInput): Promise<CreateDataSourceCommandOutput> {
|
|
2355
|
-
return this.client.request({
|
|
2356
|
-
service: 'bedrock-agent',
|
|
2357
|
-
region: this.region,
|
|
2358
|
-
method: 'PUT',
|
|
2359
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/`,
|
|
2360
|
-
headers: {
|
|
2361
|
-
'Content-Type': 'application/json',
|
|
2362
|
-
},
|
|
2363
|
-
body: JSON.stringify(params),
|
|
2364
|
-
})
|
|
2365
|
-
}
|
|
2366
|
-
|
|
2367
|
-
/**
|
|
2368
|
-
* Get data source details
|
|
2369
|
-
*/
|
|
2370
|
-
async getDataSource(params: GetDataSourceCommandInput): Promise<GetDataSourceCommandOutput> {
|
|
2371
|
-
return this.client.request({
|
|
2372
|
-
service: 'bedrock-agent',
|
|
2373
|
-
region: this.region,
|
|
2374
|
-
method: 'GET',
|
|
2375
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/${encodeURIComponent(params.dataSourceId)}`,
|
|
2376
|
-
})
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
/**
|
|
2380
|
-
* List data sources for a knowledge base
|
|
2381
|
-
*/
|
|
2382
|
-
async listDataSources(params: ListDataSourcesCommandInput): Promise<ListDataSourcesCommandOutput> {
|
|
2383
|
-
const queryParams: Record<string, string> = {}
|
|
2384
|
-
if (params.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
2385
|
-
if (params.nextToken) queryParams.nextToken = params.nextToken
|
|
2386
|
-
|
|
2387
|
-
return this.client.request({
|
|
2388
|
-
service: 'bedrock-agent',
|
|
2389
|
-
region: this.region,
|
|
2390
|
-
method: 'GET',
|
|
2391
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/`,
|
|
2392
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2393
|
-
})
|
|
2394
|
-
}
|
|
2395
|
-
|
|
2396
|
-
/**
|
|
2397
|
-
* Update a data source
|
|
2398
|
-
*/
|
|
2399
|
-
async updateDataSource(params: UpdateDataSourceCommandInput): Promise<UpdateDataSourceCommandOutput> {
|
|
2400
|
-
return this.client.request({
|
|
2401
|
-
service: 'bedrock-agent',
|
|
2402
|
-
region: this.region,
|
|
2403
|
-
method: 'PUT',
|
|
2404
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/${encodeURIComponent(params.dataSourceId)}`,
|
|
2405
|
-
headers: {
|
|
2406
|
-
'Content-Type': 'application/json',
|
|
2407
|
-
},
|
|
2408
|
-
body: JSON.stringify(params),
|
|
2409
|
-
})
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
/**
|
|
2413
|
-
* Delete a data source
|
|
2414
|
-
*/
|
|
2415
|
-
async deleteDataSource(params: DeleteDataSourceCommandInput): Promise<DeleteDataSourceCommandOutput> {
|
|
2416
|
-
return this.client.request({
|
|
2417
|
-
service: 'bedrock-agent',
|
|
2418
|
-
region: this.region,
|
|
2419
|
-
method: 'DELETE',
|
|
2420
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/${encodeURIComponent(params.dataSourceId)}`,
|
|
2421
|
-
})
|
|
2422
|
-
}
|
|
2423
|
-
|
|
2424
|
-
// -------------------------------------------------------------------------
|
|
2425
|
-
// Ingestion Jobs
|
|
2426
|
-
// -------------------------------------------------------------------------
|
|
2427
|
-
|
|
2428
|
-
/**
|
|
2429
|
-
* Start an ingestion job to sync data source with knowledge base
|
|
2430
|
-
*/
|
|
2431
|
-
async startIngestionJob(params: StartIngestionJobCommandInput): Promise<StartIngestionJobCommandOutput> {
|
|
2432
|
-
return this.client.request({
|
|
2433
|
-
service: 'bedrock-agent',
|
|
2434
|
-
region: this.region,
|
|
2435
|
-
method: 'PUT',
|
|
2436
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/${encodeURIComponent(params.dataSourceId)}/ingestionjobs/`,
|
|
2437
|
-
headers: {
|
|
2438
|
-
'Content-Type': 'application/json',
|
|
2439
|
-
},
|
|
2440
|
-
body: JSON.stringify({
|
|
2441
|
-
clientToken: params.clientToken,
|
|
2442
|
-
description: params.description,
|
|
2443
|
-
}),
|
|
2444
|
-
})
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
/**
|
|
2448
|
-
* Get ingestion job details
|
|
2449
|
-
*/
|
|
2450
|
-
async getIngestionJob(params: GetIngestionJobCommandInput): Promise<GetIngestionJobCommandOutput> {
|
|
2451
|
-
return this.client.request({
|
|
2452
|
-
service: 'bedrock-agent',
|
|
2453
|
-
region: this.region,
|
|
2454
|
-
method: 'GET',
|
|
2455
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/${encodeURIComponent(params.dataSourceId)}/ingestionjobs/${encodeURIComponent(params.ingestionJobId)}`,
|
|
2456
|
-
})
|
|
2457
|
-
}
|
|
2458
|
-
|
|
2459
|
-
/**
|
|
2460
|
-
* List ingestion jobs
|
|
2461
|
-
*/
|
|
2462
|
-
async listIngestionJobs(params: ListIngestionJobsCommandInput): Promise<ListIngestionJobsCommandOutput> {
|
|
2463
|
-
const queryParams: Record<string, string> = {}
|
|
2464
|
-
if (params.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
2465
|
-
if (params.nextToken) queryParams.nextToken = params.nextToken
|
|
2466
|
-
|
|
2467
|
-
return this.client.request({
|
|
2468
|
-
service: 'bedrock-agent',
|
|
2469
|
-
region: this.region,
|
|
2470
|
-
method: 'POST',
|
|
2471
|
-
path: `/knowledgebases/${encodeURIComponent(params.knowledgeBaseId)}/datasources/${encodeURIComponent(params.dataSourceId)}/ingestionjobs/`,
|
|
2472
|
-
headers: {
|
|
2473
|
-
'Content-Type': 'application/json',
|
|
2474
|
-
},
|
|
2475
|
-
body: JSON.stringify({
|
|
2476
|
-
filters: params.filters,
|
|
2477
|
-
sortBy: params.sortBy,
|
|
2478
|
-
maxResults: params.maxResults,
|
|
2479
|
-
nextToken: params.nextToken,
|
|
2480
|
-
}),
|
|
2481
|
-
})
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
|
-
// -------------------------------------------------------------------------
|
|
2485
|
-
// Prompts
|
|
2486
|
-
// -------------------------------------------------------------------------
|
|
2487
|
-
|
|
2488
|
-
/**
|
|
2489
|
-
* Create a prompt
|
|
2490
|
-
*/
|
|
2491
|
-
async createPrompt(params: CreatePromptCommandInput): Promise<CreatePromptCommandOutput> {
|
|
2492
|
-
return this.client.request({
|
|
2493
|
-
service: 'bedrock-agent',
|
|
2494
|
-
region: this.region,
|
|
2495
|
-
method: 'POST',
|
|
2496
|
-
path: '/prompts/',
|
|
2497
|
-
headers: {
|
|
2498
|
-
'Content-Type': 'application/json',
|
|
2499
|
-
},
|
|
2500
|
-
body: JSON.stringify(params),
|
|
2501
|
-
})
|
|
2502
|
-
}
|
|
2503
|
-
|
|
2504
|
-
/**
|
|
2505
|
-
* Get prompt details
|
|
2506
|
-
*/
|
|
2507
|
-
async getPrompt(params: GetPromptCommandInput): Promise<GetPromptCommandOutput> {
|
|
2508
|
-
const queryParams: Record<string, string> = {}
|
|
2509
|
-
if (params.promptVersion) queryParams.promptVersion = params.promptVersion
|
|
2510
|
-
|
|
2511
|
-
return this.client.request({
|
|
2512
|
-
service: 'bedrock-agent',
|
|
2513
|
-
region: this.region,
|
|
2514
|
-
method: 'GET',
|
|
2515
|
-
path: `/prompts/${encodeURIComponent(params.promptIdentifier)}/`,
|
|
2516
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2517
|
-
})
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
/**
|
|
2521
|
-
* List prompts
|
|
2522
|
-
*/
|
|
2523
|
-
async listPrompts(params?: ListPromptsCommandInput): Promise<ListPromptsCommandOutput> {
|
|
2524
|
-
const queryParams: Record<string, string> = {}
|
|
2525
|
-
if (params?.promptIdentifier) queryParams.promptIdentifier = params.promptIdentifier
|
|
2526
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
2527
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
2528
|
-
|
|
2529
|
-
return this.client.request({
|
|
2530
|
-
service: 'bedrock-agent',
|
|
2531
|
-
region: this.region,
|
|
2532
|
-
method: 'GET',
|
|
2533
|
-
path: '/prompts/',
|
|
2534
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2535
|
-
})
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
|
-
/**
|
|
2539
|
-
* Delete a prompt
|
|
2540
|
-
*/
|
|
2541
|
-
async deletePrompt(params: DeletePromptCommandInput): Promise<DeletePromptCommandOutput> {
|
|
2542
|
-
const queryParams: Record<string, string> = {}
|
|
2543
|
-
if (params.promptVersion) queryParams.promptVersion = params.promptVersion
|
|
2544
|
-
|
|
2545
|
-
return this.client.request({
|
|
2546
|
-
service: 'bedrock-agent',
|
|
2547
|
-
region: this.region,
|
|
2548
|
-
method: 'DELETE',
|
|
2549
|
-
path: `/prompts/${encodeURIComponent(params.promptIdentifier)}/`,
|
|
2550
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2551
|
-
})
|
|
2552
|
-
}
|
|
2553
|
-
|
|
2554
|
-
/**
|
|
2555
|
-
* Create a new version of a prompt
|
|
2556
|
-
*/
|
|
2557
|
-
async createPromptVersion(params: CreatePromptVersionCommandInput): Promise<CreatePromptVersionCommandOutput> {
|
|
2558
|
-
return this.client.request({
|
|
2559
|
-
service: 'bedrock-agent',
|
|
2560
|
-
region: this.region,
|
|
2561
|
-
method: 'POST',
|
|
2562
|
-
path: `/prompts/${encodeURIComponent(params.promptIdentifier)}/versions/`,
|
|
2563
|
-
headers: {
|
|
2564
|
-
'Content-Type': 'application/json',
|
|
2565
|
-
},
|
|
2566
|
-
body: JSON.stringify({
|
|
2567
|
-
description: params.description,
|
|
2568
|
-
clientToken: params.clientToken,
|
|
2569
|
-
tags: params.tags,
|
|
2570
|
-
}),
|
|
2571
|
-
})
|
|
2572
|
-
}
|
|
2573
|
-
|
|
2574
|
-
// -------------------------------------------------------------------------
|
|
2575
|
-
// Flows
|
|
2576
|
-
// -------------------------------------------------------------------------
|
|
2577
|
-
|
|
2578
|
-
/**
|
|
2579
|
-
* Create a flow
|
|
2580
|
-
*/
|
|
2581
|
-
async createFlow(params: CreateFlowCommandInput): Promise<CreateFlowCommandOutput> {
|
|
2582
|
-
return this.client.request({
|
|
2583
|
-
service: 'bedrock-agent',
|
|
2584
|
-
region: this.region,
|
|
2585
|
-
method: 'POST',
|
|
2586
|
-
path: '/flows/',
|
|
2587
|
-
headers: {
|
|
2588
|
-
'Content-Type': 'application/json',
|
|
2589
|
-
},
|
|
2590
|
-
body: JSON.stringify(params),
|
|
2591
|
-
})
|
|
2592
|
-
}
|
|
2593
|
-
|
|
2594
|
-
/**
|
|
2595
|
-
* Get flow details
|
|
2596
|
-
*/
|
|
2597
|
-
async getFlow(params: GetFlowCommandInput): Promise<GetFlowCommandOutput> {
|
|
2598
|
-
return this.client.request({
|
|
2599
|
-
service: 'bedrock-agent',
|
|
2600
|
-
region: this.region,
|
|
2601
|
-
method: 'GET',
|
|
2602
|
-
path: `/flows/${encodeURIComponent(params.flowIdentifier)}/`,
|
|
2603
|
-
})
|
|
2604
|
-
}
|
|
2605
|
-
|
|
2606
|
-
/**
|
|
2607
|
-
* List flows
|
|
2608
|
-
*/
|
|
2609
|
-
async listFlows(params?: ListFlowsCommandInput): Promise<ListFlowsCommandOutput> {
|
|
2610
|
-
const queryParams: Record<string, string> = {}
|
|
2611
|
-
if (params?.maxResults) queryParams.maxResults = params.maxResults.toString()
|
|
2612
|
-
if (params?.nextToken) queryParams.nextToken = params.nextToken
|
|
2613
|
-
|
|
2614
|
-
return this.client.request({
|
|
2615
|
-
service: 'bedrock-agent',
|
|
2616
|
-
region: this.region,
|
|
2617
|
-
method: 'GET',
|
|
2618
|
-
path: '/flows/',
|
|
2619
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2620
|
-
})
|
|
2621
|
-
}
|
|
2622
|
-
|
|
2623
|
-
/**
|
|
2624
|
-
* Update a flow
|
|
2625
|
-
*/
|
|
2626
|
-
async updateFlow(params: UpdateFlowCommandInput): Promise<UpdateFlowCommandOutput> {
|
|
2627
|
-
return this.client.request({
|
|
2628
|
-
service: 'bedrock-agent',
|
|
2629
|
-
region: this.region,
|
|
2630
|
-
method: 'PUT',
|
|
2631
|
-
path: `/flows/${encodeURIComponent(params.flowIdentifier)}/`,
|
|
2632
|
-
headers: {
|
|
2633
|
-
'Content-Type': 'application/json',
|
|
2634
|
-
},
|
|
2635
|
-
body: JSON.stringify(params),
|
|
2636
|
-
})
|
|
2637
|
-
}
|
|
2638
|
-
|
|
2639
|
-
/**
|
|
2640
|
-
* Delete a flow
|
|
2641
|
-
*/
|
|
2642
|
-
async deleteFlow(params: DeleteFlowCommandInput): Promise<DeleteFlowCommandOutput> {
|
|
2643
|
-
const queryParams: Record<string, string> = {}
|
|
2644
|
-
if (params.skipResourceInUseCheck !== undefined) {
|
|
2645
|
-
queryParams.skipResourceInUseCheck = params.skipResourceInUseCheck.toString()
|
|
2646
|
-
}
|
|
2647
|
-
|
|
2648
|
-
return this.client.request({
|
|
2649
|
-
service: 'bedrock-agent',
|
|
2650
|
-
region: this.region,
|
|
2651
|
-
method: 'DELETE',
|
|
2652
|
-
path: `/flows/${encodeURIComponent(params.flowIdentifier)}/`,
|
|
2653
|
-
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
2654
|
-
})
|
|
2655
|
-
}
|
|
2656
|
-
|
|
2657
|
-
/**
|
|
2658
|
-
* Prepare a flow for execution
|
|
2659
|
-
*/
|
|
2660
|
-
async prepareFlow(params: PrepareFlowCommandInput): Promise<PrepareFlowCommandOutput> {
|
|
2661
|
-
return this.client.request({
|
|
2662
|
-
service: 'bedrock-agent',
|
|
2663
|
-
region: this.region,
|
|
2664
|
-
method: 'POST',
|
|
2665
|
-
path: `/flows/${encodeURIComponent(params.flowIdentifier)}/`,
|
|
2666
|
-
headers: {
|
|
2667
|
-
'Content-Type': 'application/json',
|
|
2668
|
-
},
|
|
2669
|
-
})
|
|
2670
|
-
}
|
|
2671
|
-
|
|
2672
|
-
/**
|
|
2673
|
-
* Create a new version of a flow
|
|
2674
|
-
*/
|
|
2675
|
-
async createFlowVersion(params: CreateFlowVersionCommandInput): Promise<CreateFlowVersionCommandOutput> {
|
|
2676
|
-
return this.client.request({
|
|
2677
|
-
service: 'bedrock-agent',
|
|
2678
|
-
region: this.region,
|
|
2679
|
-
method: 'POST',
|
|
2680
|
-
path: `/flows/${encodeURIComponent(params.flowIdentifier)}/versions/`,
|
|
2681
|
-
headers: {
|
|
2682
|
-
'Content-Type': 'application/json',
|
|
2683
|
-
},
|
|
2684
|
-
body: JSON.stringify({
|
|
2685
|
-
description: params.description,
|
|
2686
|
-
clientToken: params.clientToken,
|
|
2687
|
-
}),
|
|
2688
|
-
})
|
|
2689
|
-
}
|
|
2690
|
-
|
|
2691
|
-
/**
|
|
2692
|
-
* Create a flow alias
|
|
2693
|
-
*/
|
|
2694
|
-
async createFlowAlias(params: CreateFlowAliasCommandInput): Promise<CreateFlowAliasCommandOutput> {
|
|
2695
|
-
return this.client.request({
|
|
2696
|
-
service: 'bedrock-agent',
|
|
2697
|
-
region: this.region,
|
|
2698
|
-
method: 'POST',
|
|
2699
|
-
path: `/flows/${encodeURIComponent(params.flowIdentifier)}/aliases/`,
|
|
2700
|
-
headers: {
|
|
2701
|
-
'Content-Type': 'application/json',
|
|
2702
|
-
},
|
|
2703
|
-
body: JSON.stringify(params),
|
|
2704
|
-
})
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
// ============================================================================
|
|
2709
|
-
// Batch Inference Types
|
|
2710
|
-
// ============================================================================
|
|
2711
|
-
|
|
2712
|
-
export interface CreateModelInvocationJobCommandInput {
|
|
2713
|
-
jobName: string
|
|
2714
|
-
modelId: string
|
|
2715
|
-
roleArn: string
|
|
2716
|
-
inputDataConfig: {
|
|
2717
|
-
s3InputDataConfig: {
|
|
2718
|
-
s3Uri: string
|
|
2719
|
-
s3InputFormat?: 'JSONL'
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
outputDataConfig: {
|
|
2723
|
-
s3OutputDataConfig: {
|
|
2724
|
-
s3Uri: string
|
|
2725
|
-
s3EncryptionKeyId?: string
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
clientRequestToken?: string
|
|
2729
|
-
timeoutDurationInHours?: number
|
|
2730
|
-
tags?: Array<{ key: string; value: string }>
|
|
2731
|
-
vpcConfig?: {
|
|
2732
|
-
subnetIds: string[]
|
|
2733
|
-
securityGroupIds: string[]
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
|
|
2737
|
-
export interface CreateModelInvocationJobCommandOutput {
|
|
2738
|
-
jobArn: string
|
|
2739
|
-
}
|
|
2740
|
-
|
|
2741
|
-
export interface GetModelInvocationJobCommandInput {
|
|
2742
|
-
jobIdentifier: string
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
export interface GetModelInvocationJobCommandOutput {
|
|
2746
|
-
jobArn: string
|
|
2747
|
-
jobName: string
|
|
2748
|
-
modelId: string
|
|
2749
|
-
clientRequestToken?: string
|
|
2750
|
-
roleArn: string
|
|
2751
|
-
status: 'Submitted' | 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped' | 'PartiallyCompleted' | 'Expired' | 'Validating' | 'Scheduled'
|
|
2752
|
-
message?: string
|
|
2753
|
-
submitTime: string
|
|
2754
|
-
lastModifiedTime?: string
|
|
2755
|
-
endTime?: string
|
|
2756
|
-
inputDataConfig: {
|
|
2757
|
-
s3InputDataConfig: {
|
|
2758
|
-
s3Uri: string
|
|
2759
|
-
s3InputFormat?: string
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
outputDataConfig: {
|
|
2763
|
-
s3OutputDataConfig: {
|
|
2764
|
-
s3Uri: string
|
|
2765
|
-
s3EncryptionKeyId?: string
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
|
-
vpcConfig?: {
|
|
2769
|
-
subnetIds: string[]
|
|
2770
|
-
securityGroupIds: string[]
|
|
2771
|
-
}
|
|
2772
|
-
timeoutDurationInHours?: number
|
|
2773
|
-
jobExpirationTime?: string
|
|
2774
|
-
}
|
|
2775
|
-
|
|
2776
|
-
export interface StopModelInvocationJobCommandInput {
|
|
2777
|
-
jobIdentifier: string
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
|
-
export interface StopModelInvocationJobCommandOutput {
|
|
2781
|
-
// Empty response
|
|
2782
|
-
}
|
|
2783
|
-
|
|
2784
|
-
// ============================================================================
|
|
2785
|
-
// Provisioned Throughput Types
|
|
2786
|
-
// ============================================================================
|
|
2787
|
-
|
|
2788
|
-
export interface CreateProvisionedModelThroughputCommandInput {
|
|
2789
|
-
modelUnits: number
|
|
2790
|
-
provisionedModelName: string
|
|
2791
|
-
modelId: string
|
|
2792
|
-
clientRequestToken?: string
|
|
2793
|
-
commitmentDuration?: 'ONE_MONTH' | 'SIX_MONTHS'
|
|
2794
|
-
tags?: Array<{ key: string; value: string }>
|
|
2795
|
-
}
|
|
2796
|
-
|
|
2797
|
-
export interface CreateProvisionedModelThroughputCommandOutput {
|
|
2798
|
-
provisionedModelArn: string
|
|
2799
|
-
}
|
|
2800
|
-
|
|
2801
|
-
export interface GetProvisionedModelThroughputCommandInput {
|
|
2802
|
-
provisionedModelId: string
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
export interface GetProvisionedModelThroughputCommandOutput {
|
|
2806
|
-
modelUnits: number
|
|
2807
|
-
desiredModelUnits: number
|
|
2808
|
-
provisionedModelName: string
|
|
2809
|
-
provisionedModelArn: string
|
|
2810
|
-
modelArn: string
|
|
2811
|
-
desiredModelArn: string
|
|
2812
|
-
foundationModelArn: string
|
|
2813
|
-
status: 'Creating' | 'InService' | 'Updating' | 'Failed'
|
|
2814
|
-
creationTime: string
|
|
2815
|
-
lastModifiedTime: string
|
|
2816
|
-
failureMessage?: string
|
|
2817
|
-
commitmentDuration?: 'ONE_MONTH' | 'SIX_MONTHS'
|
|
2818
|
-
commitmentExpirationTime?: string
|
|
2819
|
-
}
|
|
2820
|
-
|
|
2821
|
-
export interface ListProvisionedModelThroughputsCommandInput {
|
|
2822
|
-
creationTimeAfter?: string
|
|
2823
|
-
creationTimeBefore?: string
|
|
2824
|
-
statusEquals?: 'Creating' | 'InService' | 'Updating' | 'Failed'
|
|
2825
|
-
modelArnEquals?: string
|
|
2826
|
-
nameContains?: string
|
|
2827
|
-
maxResults?: number
|
|
2828
|
-
nextToken?: string
|
|
2829
|
-
sortBy?: 'CreationTime'
|
|
2830
|
-
sortOrder?: 'Ascending' | 'Descending'
|
|
2831
|
-
}
|
|
2832
|
-
|
|
2833
|
-
export interface ListProvisionedModelThroughputsCommandOutput {
|
|
2834
|
-
nextToken?: string
|
|
2835
|
-
provisionedModelSummaries?: Array<{
|
|
2836
|
-
provisionedModelName: string
|
|
2837
|
-
provisionedModelArn: string
|
|
2838
|
-
modelArn: string
|
|
2839
|
-
desiredModelArn: string
|
|
2840
|
-
foundationModelArn: string
|
|
2841
|
-
modelUnits: number
|
|
2842
|
-
desiredModelUnits: number
|
|
2843
|
-
status: 'Creating' | 'InService' | 'Updating' | 'Failed'
|
|
2844
|
-
commitmentDuration?: 'ONE_MONTH' | 'SIX_MONTHS'
|
|
2845
|
-
commitmentExpirationTime?: string
|
|
2846
|
-
creationTime: string
|
|
2847
|
-
lastModifiedTime: string
|
|
2848
|
-
}>
|
|
2849
|
-
}
|
|
2850
|
-
|
|
2851
|
-
export interface UpdateProvisionedModelThroughputCommandInput {
|
|
2852
|
-
provisionedModelId: string
|
|
2853
|
-
desiredProvisionedModelName?: string
|
|
2854
|
-
desiredModelId?: string
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
export interface UpdateProvisionedModelThroughputCommandOutput {
|
|
2858
|
-
// Empty response
|
|
2859
|
-
}
|
|
2860
|
-
|
|
2861
|
-
export interface DeleteProvisionedModelThroughputCommandInput {
|
|
2862
|
-
provisionedModelId: string
|
|
2863
|
-
}
|
|
2864
|
-
|
|
2865
|
-
export interface DeleteProvisionedModelThroughputCommandOutput {
|
|
2866
|
-
// Empty response
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
// ============================================================================
|
|
2870
|
-
// Model Evaluation Types
|
|
2871
|
-
// ============================================================================
|
|
2872
|
-
|
|
2873
|
-
export interface CreateEvaluationJobCommandInput {
|
|
2874
|
-
jobName: string
|
|
2875
|
-
jobDescription?: string
|
|
2876
|
-
clientRequestToken?: string
|
|
2877
|
-
roleArn: string
|
|
2878
|
-
customerEncryptionKeyId?: string
|
|
2879
|
-
jobTags?: Array<{ key: string; value: string }>
|
|
2880
|
-
evaluationConfig: {
|
|
2881
|
-
automated?: {
|
|
2882
|
-
datasetMetricConfigs: Array<{
|
|
2883
|
-
taskType: 'Summarization' | 'Classification' | 'QuestionAndAnswer' | 'Generation' | 'Custom'
|
|
2884
|
-
dataset: {
|
|
2885
|
-
name: string
|
|
2886
|
-
datasetLocation?: {
|
|
2887
|
-
s3Uri: string
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
metricNames: string[]
|
|
2891
|
-
}>
|
|
2892
|
-
}
|
|
2893
|
-
human?: {
|
|
2894
|
-
humanWorkflowConfig: {
|
|
2895
|
-
flowDefinitionArn: string
|
|
2896
|
-
instructions?: string
|
|
2897
|
-
}
|
|
2898
|
-
customMetrics?: Array<{
|
|
2899
|
-
name: string
|
|
2900
|
-
description?: string
|
|
2901
|
-
ratingMethod: 'ThumbsUpDown' | 'IndividualLikertScale' | 'ComparisonLikertScale' | 'ComparisonChoice' | 'ComparisonRank' | 'FreeformFeedback'
|
|
2902
|
-
}>
|
|
2903
|
-
datasetMetricConfigs: Array<{
|
|
2904
|
-
taskType: 'Summarization' | 'Classification' | 'QuestionAndAnswer' | 'Generation' | 'Custom'
|
|
2905
|
-
dataset: {
|
|
2906
|
-
name: string
|
|
2907
|
-
datasetLocation?: {
|
|
2908
|
-
s3Uri: string
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
metricNames: string[]
|
|
2912
|
-
}>
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
inferenceConfig: {
|
|
2916
|
-
models: Array<{
|
|
2917
|
-
bedrockModel?: {
|
|
2918
|
-
modelIdentifier: string
|
|
2919
|
-
inferenceParams: string
|
|
2920
|
-
}
|
|
2921
|
-
}>
|
|
2922
|
-
}
|
|
2923
|
-
outputDataConfig: {
|
|
2924
|
-
s3Uri: string
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2928
|
-
export interface CreateEvaluationJobCommandOutput {
|
|
2929
|
-
jobArn: string
|
|
2930
|
-
}
|
|
2931
|
-
|
|
2932
|
-
export interface GetEvaluationJobCommandInput {
|
|
2933
|
-
jobIdentifier: string
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
|
-
export interface GetEvaluationJobCommandOutput {
|
|
2937
|
-
jobName: string
|
|
2938
|
-
status: 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped'
|
|
2939
|
-
jobArn: string
|
|
2940
|
-
jobDescription?: string
|
|
2941
|
-
roleArn: string
|
|
2942
|
-
customerEncryptionKeyId?: string
|
|
2943
|
-
jobType: 'Human' | 'Automated'
|
|
2944
|
-
evaluationConfig: {
|
|
2945
|
-
automated?: {
|
|
2946
|
-
datasetMetricConfigs: Array<{
|
|
2947
|
-
taskType: string
|
|
2948
|
-
dataset: {
|
|
2949
|
-
name: string
|
|
2950
|
-
datasetLocation?: {
|
|
2951
|
-
s3Uri: string
|
|
2952
|
-
}
|
|
2953
|
-
}
|
|
2954
|
-
metricNames: string[]
|
|
2955
|
-
}>
|
|
2956
|
-
}
|
|
2957
|
-
human?: {
|
|
2958
|
-
humanWorkflowConfig: {
|
|
2959
|
-
flowDefinitionArn: string
|
|
2960
|
-
instructions?: string
|
|
2961
|
-
}
|
|
2962
|
-
customMetrics?: Array<{
|
|
2963
|
-
name: string
|
|
2964
|
-
description?: string
|
|
2965
|
-
ratingMethod: string
|
|
2966
|
-
}>
|
|
2967
|
-
datasetMetricConfigs: Array<{
|
|
2968
|
-
taskType: string
|
|
2969
|
-
dataset: {
|
|
2970
|
-
name: string
|
|
2971
|
-
datasetLocation?: {
|
|
2972
|
-
s3Uri: string
|
|
2973
|
-
}
|
|
2974
|
-
}
|
|
2975
|
-
metricNames: string[]
|
|
2976
|
-
}>
|
|
2977
|
-
}
|
|
2978
|
-
}
|
|
2979
|
-
inferenceConfig: {
|
|
2980
|
-
models: Array<{
|
|
2981
|
-
bedrockModel?: {
|
|
2982
|
-
modelIdentifier: string
|
|
2983
|
-
inferenceParams: string
|
|
2984
|
-
}
|
|
2985
|
-
}>
|
|
2986
|
-
}
|
|
2987
|
-
outputDataConfig: {
|
|
2988
|
-
s3Uri: string
|
|
2989
|
-
}
|
|
2990
|
-
creationTime: string
|
|
2991
|
-
lastModifiedTime?: string
|
|
2992
|
-
failureMessages?: string[]
|
|
2993
|
-
}
|
|
2994
|
-
|
|
2995
|
-
export interface ListEvaluationJobsCommandInput {
|
|
2996
|
-
creationTimeAfter?: string
|
|
2997
|
-
creationTimeBefore?: string
|
|
2998
|
-
statusEquals?: 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped'
|
|
2999
|
-
nameContains?: string
|
|
3000
|
-
maxResults?: number
|
|
3001
|
-
nextToken?: string
|
|
3002
|
-
sortBy?: 'CreationTime'
|
|
3003
|
-
sortOrder?: 'Ascending' | 'Descending'
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
|
-
export interface ListEvaluationJobsCommandOutput {
|
|
3007
|
-
nextToken?: string
|
|
3008
|
-
jobSummaries?: Array<{
|
|
3009
|
-
jobArn: string
|
|
3010
|
-
jobName: string
|
|
3011
|
-
status: 'InProgress' | 'Completed' | 'Failed' | 'Stopping' | 'Stopped'
|
|
3012
|
-
creationTime: string
|
|
3013
|
-
jobType: 'Human' | 'Automated'
|
|
3014
|
-
evaluationTaskTypes: string[]
|
|
3015
|
-
modelIdentifiers: string[]
|
|
3016
|
-
}>
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3019
|
-
export interface StopEvaluationJobCommandInput {
|
|
3020
|
-
jobIdentifier: string
|
|
3021
|
-
}
|
|
3022
|
-
|
|
3023
|
-
export interface StopEvaluationJobCommandOutput {
|
|
3024
|
-
// Empty response
|
|
3025
|
-
}
|
|
3026
|
-
|
|
3027
|
-
// ============================================================================
|
|
3028
|
-
// Inference Profiles Types
|
|
3029
|
-
// ============================================================================
|
|
3030
|
-
|
|
3031
|
-
export interface GetInferenceProfileCommandInput {
|
|
3032
|
-
inferenceProfileIdentifier: string
|
|
3033
|
-
}
|
|
3034
|
-
|
|
3035
|
-
export interface GetInferenceProfileCommandOutput {
|
|
3036
|
-
inferenceProfileName: string
|
|
3037
|
-
inferenceProfileArn: string
|
|
3038
|
-
inferenceProfileId: string
|
|
3039
|
-
description?: string
|
|
3040
|
-
createdAt?: string
|
|
3041
|
-
updatedAt?: string
|
|
3042
|
-
models: Array<{
|
|
3043
|
-
modelArn: string
|
|
3044
|
-
}>
|
|
3045
|
-
status: 'ACTIVE'
|
|
3046
|
-
type: 'SYSTEM_DEFINED' | 'APPLICATION'
|
|
3047
|
-
}
|
|
3048
|
-
|
|
3049
|
-
export interface ListInferenceProfilesCommandInput {
|
|
3050
|
-
maxResults?: number
|
|
3051
|
-
nextToken?: string
|
|
3052
|
-
typeEquals?: 'SYSTEM_DEFINED' | 'APPLICATION'
|
|
3053
|
-
}
|
|
3054
|
-
|
|
3055
|
-
export interface ListInferenceProfilesCommandOutput {
|
|
3056
|
-
inferenceProfileSummaries?: Array<{
|
|
3057
|
-
inferenceProfileName: string
|
|
3058
|
-
inferenceProfileArn: string
|
|
3059
|
-
inferenceProfileId: string
|
|
3060
|
-
description?: string
|
|
3061
|
-
createdAt?: string
|
|
3062
|
-
updatedAt?: string
|
|
3063
|
-
models: Array<{
|
|
3064
|
-
modelArn: string
|
|
3065
|
-
}>
|
|
3066
|
-
status: 'ACTIVE'
|
|
3067
|
-
type: 'SYSTEM_DEFINED' | 'APPLICATION'
|
|
3068
|
-
}>
|
|
3069
|
-
nextToken?: string
|
|
3070
|
-
}
|
|
3071
|
-
|
|
3072
|
-
export interface CreateInferenceProfileCommandInput {
|
|
3073
|
-
inferenceProfileName: string
|
|
3074
|
-
description?: string
|
|
3075
|
-
clientRequestToken?: string
|
|
3076
|
-
modelSource: {
|
|
3077
|
-
copyFrom: string
|
|
3078
|
-
}
|
|
3079
|
-
tags?: Array<{ key: string; value: string }>
|
|
3080
|
-
}
|
|
3081
|
-
|
|
3082
|
-
export interface CreateInferenceProfileCommandOutput {
|
|
3083
|
-
inferenceProfileArn: string
|
|
3084
|
-
status?: 'ACTIVE'
|
|
3085
|
-
}
|
|
3086
|
-
|
|
3087
|
-
export interface DeleteInferenceProfileCommandInput {
|
|
3088
|
-
inferenceProfileIdentifier: string
|
|
3089
|
-
}
|
|
3090
|
-
|
|
3091
|
-
export interface DeleteInferenceProfileCommandOutput {
|
|
3092
|
-
// Empty response
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3095
|
-
// ============================================================================
|
|
3096
|
-
// Prompt Management Types
|
|
3097
|
-
// ============================================================================
|
|
3098
|
-
|
|
3099
|
-
export interface CreatePromptCommandInput {
|
|
3100
|
-
name: string
|
|
3101
|
-
description?: string
|
|
3102
|
-
customerEncryptionKeyArn?: string
|
|
3103
|
-
defaultVariant?: string
|
|
3104
|
-
variants?: Array<{
|
|
3105
|
-
name: string
|
|
3106
|
-
modelId?: string
|
|
3107
|
-
templateType: 'TEXT'
|
|
3108
|
-
templateConfiguration: {
|
|
3109
|
-
text: {
|
|
3110
|
-
text: string
|
|
3111
|
-
inputVariables?: Array<{
|
|
3112
|
-
name: string
|
|
3113
|
-
}>
|
|
3114
|
-
}
|
|
3115
|
-
}
|
|
3116
|
-
inferenceConfiguration?: {
|
|
3117
|
-
text?: {
|
|
3118
|
-
temperature?: number
|
|
3119
|
-
topP?: number
|
|
3120
|
-
maxTokens?: number
|
|
3121
|
-
stopSequences?: string[]
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
}>
|
|
3125
|
-
clientToken?: string
|
|
3126
|
-
tags?: Record<string, string>
|
|
3127
|
-
}
|
|
3128
|
-
|
|
3129
|
-
export interface CreatePromptCommandOutput {
|
|
3130
|
-
name: string
|
|
3131
|
-
description?: string
|
|
3132
|
-
customerEncryptionKeyArn?: string
|
|
3133
|
-
defaultVariant?: string
|
|
3134
|
-
variants?: Array<{
|
|
3135
|
-
name: string
|
|
3136
|
-
modelId?: string
|
|
3137
|
-
templateType: string
|
|
3138
|
-
templateConfiguration: {
|
|
3139
|
-
text?: {
|
|
3140
|
-
text: string
|
|
3141
|
-
inputVariables?: Array<{
|
|
3142
|
-
name: string
|
|
3143
|
-
}>
|
|
3144
|
-
}
|
|
3145
|
-
}
|
|
3146
|
-
inferenceConfiguration?: {
|
|
3147
|
-
text?: {
|
|
3148
|
-
temperature?: number
|
|
3149
|
-
topP?: number
|
|
3150
|
-
maxTokens?: number
|
|
3151
|
-
stopSequences?: string[]
|
|
3152
|
-
}
|
|
3153
|
-
}
|
|
3154
|
-
}>
|
|
3155
|
-
id: string
|
|
3156
|
-
arn: string
|
|
3157
|
-
version: string
|
|
3158
|
-
createdAt: string
|
|
3159
|
-
updatedAt: string
|
|
3160
|
-
}
|
|
3161
|
-
|
|
3162
|
-
export interface GetPromptCommandInput {
|
|
3163
|
-
promptIdentifier: string
|
|
3164
|
-
promptVersion?: string
|
|
3165
|
-
}
|
|
3166
|
-
|
|
3167
|
-
export interface GetPromptCommandOutput {
|
|
3168
|
-
name: string
|
|
3169
|
-
description?: string
|
|
3170
|
-
customerEncryptionKeyArn?: string
|
|
3171
|
-
defaultVariant?: string
|
|
3172
|
-
variants?: Array<{
|
|
3173
|
-
name: string
|
|
3174
|
-
modelId?: string
|
|
3175
|
-
templateType: string
|
|
3176
|
-
templateConfiguration: {
|
|
3177
|
-
text?: {
|
|
3178
|
-
text: string
|
|
3179
|
-
inputVariables?: Array<{
|
|
3180
|
-
name: string
|
|
3181
|
-
}>
|
|
3182
|
-
}
|
|
3183
|
-
}
|
|
3184
|
-
inferenceConfiguration?: {
|
|
3185
|
-
text?: {
|
|
3186
|
-
temperature?: number
|
|
3187
|
-
topP?: number
|
|
3188
|
-
maxTokens?: number
|
|
3189
|
-
stopSequences?: string[]
|
|
3190
|
-
}
|
|
3191
|
-
}
|
|
3192
|
-
}>
|
|
3193
|
-
id: string
|
|
3194
|
-
arn: string
|
|
3195
|
-
version: string
|
|
3196
|
-
createdAt: string
|
|
3197
|
-
updatedAt: string
|
|
3198
|
-
}
|
|
3199
|
-
|
|
3200
|
-
export interface ListPromptsCommandInput {
|
|
3201
|
-
promptIdentifier?: string
|
|
3202
|
-
maxResults?: number
|
|
3203
|
-
nextToken?: string
|
|
3204
|
-
}
|
|
3205
|
-
|
|
3206
|
-
export interface ListPromptsCommandOutput {
|
|
3207
|
-
promptSummaries: Array<{
|
|
3208
|
-
name: string
|
|
3209
|
-
description?: string
|
|
3210
|
-
id: string
|
|
3211
|
-
arn: string
|
|
3212
|
-
version: string
|
|
3213
|
-
createdAt: string
|
|
3214
|
-
updatedAt: string
|
|
3215
|
-
}>
|
|
3216
|
-
nextToken?: string
|
|
3217
|
-
}
|
|
3218
|
-
|
|
3219
|
-
export interface DeletePromptCommandInput {
|
|
3220
|
-
promptIdentifier: string
|
|
3221
|
-
promptVersion?: string
|
|
3222
|
-
}
|
|
3223
|
-
|
|
3224
|
-
export interface DeletePromptCommandOutput {
|
|
3225
|
-
id: string
|
|
3226
|
-
version?: string
|
|
3227
|
-
}
|
|
3228
|
-
|
|
3229
|
-
export interface CreatePromptVersionCommandInput {
|
|
3230
|
-
promptIdentifier: string
|
|
3231
|
-
description?: string
|
|
3232
|
-
clientToken?: string
|
|
3233
|
-
tags?: Record<string, string>
|
|
3234
|
-
}
|
|
3235
|
-
|
|
3236
|
-
export interface CreatePromptVersionCommandOutput {
|
|
3237
|
-
name: string
|
|
3238
|
-
description?: string
|
|
3239
|
-
customerEncryptionKeyArn?: string
|
|
3240
|
-
defaultVariant?: string
|
|
3241
|
-
variants?: Array<{
|
|
3242
|
-
name: string
|
|
3243
|
-
modelId?: string
|
|
3244
|
-
templateType: string
|
|
3245
|
-
templateConfiguration: {
|
|
3246
|
-
text?: {
|
|
3247
|
-
text: string
|
|
3248
|
-
inputVariables?: Array<{
|
|
3249
|
-
name: string
|
|
3250
|
-
}>
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
inferenceConfiguration?: {
|
|
3254
|
-
text?: {
|
|
3255
|
-
temperature?: number
|
|
3256
|
-
topP?: number
|
|
3257
|
-
maxTokens?: number
|
|
3258
|
-
stopSequences?: string[]
|
|
3259
|
-
}
|
|
3260
|
-
}
|
|
3261
|
-
}>
|
|
3262
|
-
id: string
|
|
3263
|
-
arn: string
|
|
3264
|
-
version: string
|
|
3265
|
-
createdAt: string
|
|
3266
|
-
updatedAt: string
|
|
3267
|
-
}
|
|
3268
|
-
|
|
3269
|
-
// ============================================================================
|
|
3270
|
-
// Flows Types
|
|
3271
|
-
// ============================================================================
|
|
3272
|
-
|
|
3273
|
-
export interface FlowNodeConfiguration {
|
|
3274
|
-
input?: Record<string, never>
|
|
3275
|
-
output?: Record<string, never>
|
|
3276
|
-
knowledgeBase?: {
|
|
3277
|
-
knowledgeBaseId: string
|
|
3278
|
-
modelId?: string
|
|
3279
|
-
}
|
|
3280
|
-
condition?: {
|
|
3281
|
-
conditions: Array<{
|
|
3282
|
-
name: string
|
|
3283
|
-
expression: string
|
|
3284
|
-
}>
|
|
3285
|
-
}
|
|
3286
|
-
lex?: {
|
|
3287
|
-
botAliasArn: string
|
|
3288
|
-
localeId: string
|
|
3289
|
-
}
|
|
3290
|
-
prompt?: {
|
|
3291
|
-
sourceConfiguration: {
|
|
3292
|
-
resource?: {
|
|
3293
|
-
promptArn: string
|
|
3294
|
-
}
|
|
3295
|
-
inline?: {
|
|
3296
|
-
modelId: string
|
|
3297
|
-
templateType: 'TEXT'
|
|
3298
|
-
templateConfiguration: {
|
|
3299
|
-
text: {
|
|
3300
|
-
text: string
|
|
3301
|
-
inputVariables?: Array<{ name: string }>
|
|
3302
|
-
}
|
|
3303
|
-
}
|
|
3304
|
-
inferenceConfiguration?: {
|
|
3305
|
-
text?: {
|
|
3306
|
-
temperature?: number
|
|
3307
|
-
topP?: number
|
|
3308
|
-
maxTokens?: number
|
|
3309
|
-
stopSequences?: string[]
|
|
3310
|
-
}
|
|
3311
|
-
}
|
|
3312
|
-
}
|
|
3313
|
-
}
|
|
3314
|
-
}
|
|
3315
|
-
lambdaFunction?: {
|
|
3316
|
-
lambdaArn: string
|
|
3317
|
-
}
|
|
3318
|
-
agent?: {
|
|
3319
|
-
agentAliasArn: string
|
|
3320
|
-
}
|
|
3321
|
-
storage?: {
|
|
3322
|
-
serviceConfiguration: {
|
|
3323
|
-
s3?: {
|
|
3324
|
-
bucketName: string
|
|
3325
|
-
}
|
|
3326
|
-
}
|
|
3327
|
-
}
|
|
3328
|
-
retrieval?: {
|
|
3329
|
-
serviceConfiguration: {
|
|
3330
|
-
s3?: {
|
|
3331
|
-
bucketName: string
|
|
3332
|
-
}
|
|
3333
|
-
}
|
|
3334
|
-
}
|
|
3335
|
-
iterator?: Record<string, never>
|
|
3336
|
-
collector?: Record<string, never>
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
|
-
export interface FlowNode {
|
|
3340
|
-
name: string
|
|
3341
|
-
type: 'Input' | 'Output' | 'KnowledgeBase' | 'Condition' | 'Lex' | 'Prompt' | 'LambdaFunction' | 'Agent' | 'Storage' | 'Retrieval' | 'Iterator' | 'Collector'
|
|
3342
|
-
configuration?: FlowNodeConfiguration
|
|
3343
|
-
inputs?: Array<{
|
|
3344
|
-
name: string
|
|
3345
|
-
type: 'String' | 'Number' | 'Boolean' | 'Object' | 'Array'
|
|
3346
|
-
expression: string
|
|
3347
|
-
}>
|
|
3348
|
-
outputs?: Array<{
|
|
3349
|
-
name: string
|
|
3350
|
-
type: 'String' | 'Number' | 'Boolean' | 'Object' | 'Array'
|
|
3351
|
-
}>
|
|
3352
|
-
}
|
|
3353
|
-
|
|
3354
|
-
export interface FlowConnection {
|
|
3355
|
-
name: string
|
|
3356
|
-
source: string
|
|
3357
|
-
target: string
|
|
3358
|
-
type: 'Data' | 'Conditional'
|
|
3359
|
-
configuration?: {
|
|
3360
|
-
data?: {
|
|
3361
|
-
sourceOutput: string
|
|
3362
|
-
targetInput: string
|
|
3363
|
-
}
|
|
3364
|
-
conditional?: {
|
|
3365
|
-
condition: string
|
|
3366
|
-
}
|
|
3367
|
-
}
|
|
3368
|
-
}
|
|
3369
|
-
|
|
3370
|
-
export interface CreateFlowCommandInput {
|
|
3371
|
-
name: string
|
|
3372
|
-
description?: string
|
|
3373
|
-
executionRoleArn: string
|
|
3374
|
-
customerEncryptionKeyArn?: string
|
|
3375
|
-
definition?: {
|
|
3376
|
-
nodes?: FlowNode[]
|
|
3377
|
-
connections?: FlowConnection[]
|
|
3378
|
-
}
|
|
3379
|
-
clientToken?: string
|
|
3380
|
-
tags?: Record<string, string>
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
|
-
export interface CreateFlowCommandOutput {
|
|
3384
|
-
name: string
|
|
3385
|
-
description?: string
|
|
3386
|
-
executionRoleArn: string
|
|
3387
|
-
customerEncryptionKeyArn?: string
|
|
3388
|
-
id: string
|
|
3389
|
-
arn: string
|
|
3390
|
-
status: 'NotPrepared' | 'Preparing' | 'Prepared' | 'Failed'
|
|
3391
|
-
createdAt: string
|
|
3392
|
-
updatedAt: string
|
|
3393
|
-
version: string
|
|
3394
|
-
definition?: {
|
|
3395
|
-
nodes?: FlowNode[]
|
|
3396
|
-
connections?: FlowConnection[]
|
|
3397
|
-
}
|
|
3398
|
-
}
|
|
3399
|
-
|
|
3400
|
-
export interface GetFlowCommandInput {
|
|
3401
|
-
flowIdentifier: string
|
|
3402
|
-
}
|
|
3403
|
-
|
|
3404
|
-
export interface GetFlowCommandOutput {
|
|
3405
|
-
name: string
|
|
3406
|
-
description?: string
|
|
3407
|
-
executionRoleArn: string
|
|
3408
|
-
customerEncryptionKeyArn?: string
|
|
3409
|
-
id: string
|
|
3410
|
-
arn: string
|
|
3411
|
-
status: 'NotPrepared' | 'Preparing' | 'Prepared' | 'Failed'
|
|
3412
|
-
createdAt: string
|
|
3413
|
-
updatedAt: string
|
|
3414
|
-
version: string
|
|
3415
|
-
definition?: {
|
|
3416
|
-
nodes?: FlowNode[]
|
|
3417
|
-
connections?: FlowConnection[]
|
|
3418
|
-
}
|
|
3419
|
-
validations?: Array<{
|
|
3420
|
-
message: string
|
|
3421
|
-
severity: 'Warning' | 'Error'
|
|
3422
|
-
}>
|
|
3423
|
-
}
|
|
3424
|
-
|
|
3425
|
-
export interface ListFlowsCommandInput {
|
|
3426
|
-
maxResults?: number
|
|
3427
|
-
nextToken?: string
|
|
3428
|
-
}
|
|
3429
|
-
|
|
3430
|
-
export interface ListFlowsCommandOutput {
|
|
3431
|
-
flowSummaries: Array<{
|
|
3432
|
-
name: string
|
|
3433
|
-
description?: string
|
|
3434
|
-
id: string
|
|
3435
|
-
arn: string
|
|
3436
|
-
status: 'NotPrepared' | 'Preparing' | 'Prepared' | 'Failed'
|
|
3437
|
-
createdAt: string
|
|
3438
|
-
updatedAt: string
|
|
3439
|
-
version: string
|
|
3440
|
-
}>
|
|
3441
|
-
nextToken?: string
|
|
3442
|
-
}
|
|
3443
|
-
|
|
3444
|
-
export interface UpdateFlowCommandInput {
|
|
3445
|
-
flowIdentifier: string
|
|
3446
|
-
name: string
|
|
3447
|
-
description?: string
|
|
3448
|
-
executionRoleArn: string
|
|
3449
|
-
customerEncryptionKeyArn?: string
|
|
3450
|
-
definition?: {
|
|
3451
|
-
nodes?: FlowNode[]
|
|
3452
|
-
connections?: FlowConnection[]
|
|
3453
|
-
}
|
|
3454
|
-
}
|
|
3455
|
-
|
|
3456
|
-
export interface UpdateFlowCommandOutput {
|
|
3457
|
-
name: string
|
|
3458
|
-
description?: string
|
|
3459
|
-
executionRoleArn: string
|
|
3460
|
-
customerEncryptionKeyArn?: string
|
|
3461
|
-
id: string
|
|
3462
|
-
arn: string
|
|
3463
|
-
status: 'NotPrepared' | 'Preparing' | 'Prepared' | 'Failed'
|
|
3464
|
-
createdAt: string
|
|
3465
|
-
updatedAt: string
|
|
3466
|
-
version: string
|
|
3467
|
-
definition?: {
|
|
3468
|
-
nodes?: FlowNode[]
|
|
3469
|
-
connections?: FlowConnection[]
|
|
3470
|
-
}
|
|
3471
|
-
}
|
|
3472
|
-
|
|
3473
|
-
export interface DeleteFlowCommandInput {
|
|
3474
|
-
flowIdentifier: string
|
|
3475
|
-
skipResourceInUseCheck?: boolean
|
|
3476
|
-
}
|
|
3477
|
-
|
|
3478
|
-
export interface DeleteFlowCommandOutput {
|
|
3479
|
-
id: string
|
|
3480
|
-
}
|
|
3481
|
-
|
|
3482
|
-
export interface PrepareFlowCommandInput {
|
|
3483
|
-
flowIdentifier: string
|
|
3484
|
-
}
|
|
3485
|
-
|
|
3486
|
-
export interface PrepareFlowCommandOutput {
|
|
3487
|
-
id: string
|
|
3488
|
-
status: 'NotPrepared' | 'Preparing' | 'Prepared' | 'Failed'
|
|
3489
|
-
}
|
|
3490
|
-
|
|
3491
|
-
export interface CreateFlowVersionCommandInput {
|
|
3492
|
-
flowIdentifier: string
|
|
3493
|
-
description?: string
|
|
3494
|
-
clientToken?: string
|
|
3495
|
-
}
|
|
3496
|
-
|
|
3497
|
-
export interface CreateFlowVersionCommandOutput {
|
|
3498
|
-
name: string
|
|
3499
|
-
description?: string
|
|
3500
|
-
executionRoleArn: string
|
|
3501
|
-
customerEncryptionKeyArn?: string
|
|
3502
|
-
id: string
|
|
3503
|
-
arn: string
|
|
3504
|
-
status: 'NotPrepared' | 'Preparing' | 'Prepared' | 'Failed'
|
|
3505
|
-
createdAt: string
|
|
3506
|
-
version: string
|
|
3507
|
-
definition?: {
|
|
3508
|
-
nodes?: FlowNode[]
|
|
3509
|
-
connections?: FlowConnection[]
|
|
3510
|
-
}
|
|
3511
|
-
}
|
|
3512
|
-
|
|
3513
|
-
export interface CreateFlowAliasCommandInput {
|
|
3514
|
-
flowIdentifier: string
|
|
3515
|
-
name: string
|
|
3516
|
-
description?: string
|
|
3517
|
-
routingConfiguration: Array<{
|
|
3518
|
-
flowVersion: string
|
|
3519
|
-
}>
|
|
3520
|
-
clientToken?: string
|
|
3521
|
-
tags?: Record<string, string>
|
|
3522
|
-
}
|
|
3523
|
-
|
|
3524
|
-
export interface CreateFlowAliasCommandOutput {
|
|
3525
|
-
name: string
|
|
3526
|
-
description?: string
|
|
3527
|
-
routingConfiguration: Array<{
|
|
3528
|
-
flowVersion: string
|
|
3529
|
-
}>
|
|
3530
|
-
flowId: string
|
|
3531
|
-
id: string
|
|
3532
|
-
arn: string
|
|
3533
|
-
createdAt: string
|
|
3534
|
-
updatedAt: string
|
|
3535
|
-
}
|
|
3536
|
-
|
|
3537
|
-
export interface InvokeFlowCommandInput {
|
|
3538
|
-
flowIdentifier: string
|
|
3539
|
-
flowAliasIdentifier: string
|
|
3540
|
-
inputs: Array<{
|
|
3541
|
-
nodeName: string
|
|
3542
|
-
nodeOutputName: string
|
|
3543
|
-
content: {
|
|
3544
|
-
document?: unknown
|
|
3545
|
-
}
|
|
3546
|
-
}>
|
|
3547
|
-
}
|
|
3548
|
-
|
|
3549
|
-
export interface InvokeFlowCommandOutput {
|
|
3550
|
-
responseStream: AsyncIterable<{
|
|
3551
|
-
flowOutputEvent?: {
|
|
3552
|
-
nodeName: string
|
|
3553
|
-
nodeType: string
|
|
3554
|
-
content: {
|
|
3555
|
-
document?: unknown
|
|
3556
|
-
}
|
|
3557
|
-
}
|
|
3558
|
-
flowCompletionEvent?: {
|
|
3559
|
-
completionReason: 'SUCCESS'
|
|
3560
|
-
}
|
|
3561
|
-
}>
|
|
3562
|
-
}
|
|
3563
|
-
|
|
3564
|
-
// ============================================================================
|
|
3565
|
-
// Data Sources Types
|
|
3566
|
-
// ============================================================================
|
|
3567
|
-
|
|
3568
|
-
export interface S3DataSourceConfiguration {
|
|
3569
|
-
bucketArn: string
|
|
3570
|
-
inclusionPrefixes?: string[]
|
|
3571
|
-
bucketOwnerAccountId?: string
|
|
3572
|
-
}
|
|
3573
|
-
|
|
3574
|
-
export interface ConfluenceDataSourceConfiguration {
|
|
3575
|
-
sourceConfiguration: {
|
|
3576
|
-
hostUrl: string
|
|
3577
|
-
hostType: 'SAAS'
|
|
3578
|
-
authType: 'BASIC' | 'OAUTH2_CLIENT_CREDENTIALS'
|
|
3579
|
-
credentialsSecretArn: string
|
|
3580
|
-
}
|
|
3581
|
-
crawlerConfiguration?: {
|
|
3582
|
-
filterConfiguration?: {
|
|
3583
|
-
type: 'PATTERN'
|
|
3584
|
-
patternObjectFilter?: {
|
|
3585
|
-
filters: Array<{
|
|
3586
|
-
objectType: 'Attachment' | 'Blog' | 'Comment' | 'Page' | 'Space'
|
|
3587
|
-
inclusionFilters?: string[]
|
|
3588
|
-
exclusionFilters?: string[]
|
|
3589
|
-
}>
|
|
3590
|
-
}
|
|
3591
|
-
}
|
|
3592
|
-
}
|
|
3593
|
-
}
|
|
3594
|
-
|
|
3595
|
-
export interface SalesforceDataSourceConfiguration {
|
|
3596
|
-
sourceConfiguration: {
|
|
3597
|
-
hostUrl: string
|
|
3598
|
-
authType: 'OAUTH2_CLIENT_CREDENTIALS'
|
|
3599
|
-
credentialsSecretArn: string
|
|
3600
|
-
}
|
|
3601
|
-
crawlerConfiguration?: {
|
|
3602
|
-
filterConfiguration?: {
|
|
3603
|
-
type: 'PATTERN'
|
|
3604
|
-
patternObjectFilter?: {
|
|
3605
|
-
filters: Array<{
|
|
3606
|
-
objectType: 'Account' | 'Case' | 'Campaign' | 'Contact' | 'Contract' | 'Document' | 'Lead' | 'Opportunity' | 'Partner' | 'PricebookEntry' | 'Product2' | 'Solution' | 'Task'
|
|
3607
|
-
inclusionFilters?: string[]
|
|
3608
|
-
exclusionFilters?: string[]
|
|
3609
|
-
}>
|
|
3610
|
-
}
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
|
|
3615
|
-
export interface SharePointDataSourceConfiguration {
|
|
3616
|
-
sourceConfiguration: {
|
|
3617
|
-
siteUrls: string[]
|
|
3618
|
-
hostType: 'ONLINE'
|
|
3619
|
-
authType: 'OAUTH2_CLIENT_CREDENTIALS'
|
|
3620
|
-
credentialsSecretArn: string
|
|
3621
|
-
tenantId?: string
|
|
3622
|
-
domain: string
|
|
3623
|
-
}
|
|
3624
|
-
crawlerConfiguration?: {
|
|
3625
|
-
filterConfiguration?: {
|
|
3626
|
-
type: 'PATTERN'
|
|
3627
|
-
patternObjectFilter?: {
|
|
3628
|
-
filters: Array<{
|
|
3629
|
-
objectType: 'Page' | 'File' | 'Event' | 'Attachment'
|
|
3630
|
-
inclusionFilters?: string[]
|
|
3631
|
-
exclusionFilters?: string[]
|
|
3632
|
-
}>
|
|
3633
|
-
}
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
|
|
3638
|
-
export interface WebDataSourceConfiguration {
|
|
3639
|
-
sourceConfiguration: {
|
|
3640
|
-
urlConfiguration: {
|
|
3641
|
-
seedUrls: Array<{ url: string }>
|
|
3642
|
-
}
|
|
3643
|
-
}
|
|
3644
|
-
crawlerConfiguration?: {
|
|
3645
|
-
crawlerLimits?: {
|
|
3646
|
-
rateLimit?: number
|
|
3647
|
-
}
|
|
3648
|
-
inclusionFilters?: string[]
|
|
3649
|
-
exclusionFilters?: string[]
|
|
3650
|
-
scope?: 'HOST_ONLY' | 'SUBDOMAINS'
|
|
3651
|
-
}
|
|
3652
|
-
}
|
|
3653
|
-
|
|
3654
|
-
export interface CreateDataSourceCommandInput {
|
|
3655
|
-
knowledgeBaseId: string
|
|
3656
|
-
clientToken?: string
|
|
3657
|
-
name: string
|
|
3658
|
-
description?: string
|
|
3659
|
-
dataSourceConfiguration: {
|
|
3660
|
-
type: 'S3' | 'CONFLUENCE' | 'SALESFORCE' | 'SHAREPOINT' | 'WEB'
|
|
3661
|
-
s3Configuration?: S3DataSourceConfiguration
|
|
3662
|
-
confluenceConfiguration?: ConfluenceDataSourceConfiguration
|
|
3663
|
-
salesforceConfiguration?: SalesforceDataSourceConfiguration
|
|
3664
|
-
sharePointConfiguration?: SharePointDataSourceConfiguration
|
|
3665
|
-
webConfiguration?: WebDataSourceConfiguration
|
|
3666
|
-
}
|
|
3667
|
-
dataDeletionPolicy?: 'RETAIN' | 'DELETE'
|
|
3668
|
-
serverSideEncryptionConfiguration?: {
|
|
3669
|
-
kmsKeyArn?: string
|
|
3670
|
-
}
|
|
3671
|
-
vectorIngestionConfiguration?: {
|
|
3672
|
-
chunkingConfiguration?: {
|
|
3673
|
-
chunkingStrategy: 'FIXED_SIZE' | 'NONE' | 'HIERARCHICAL' | 'SEMANTIC'
|
|
3674
|
-
fixedSizeChunkingConfiguration?: {
|
|
3675
|
-
maxTokens: number
|
|
3676
|
-
overlapPercentage: number
|
|
3677
|
-
}
|
|
3678
|
-
hierarchicalChunkingConfiguration?: {
|
|
3679
|
-
levelConfigurations: Array<{
|
|
3680
|
-
maxTokens: number
|
|
3681
|
-
}>
|
|
3682
|
-
overlapTokens: number
|
|
3683
|
-
}
|
|
3684
|
-
semanticChunkingConfiguration?: {
|
|
3685
|
-
maxTokens: number
|
|
3686
|
-
bufferSize: number
|
|
3687
|
-
breakpointPercentileThreshold: number
|
|
3688
|
-
}
|
|
3689
|
-
}
|
|
3690
|
-
parsingConfiguration?: {
|
|
3691
|
-
parsingStrategy: 'BEDROCK_FOUNDATION_MODEL'
|
|
3692
|
-
bedrockFoundationModelConfiguration?: {
|
|
3693
|
-
modelArn: string
|
|
3694
|
-
parsingPrompt?: {
|
|
3695
|
-
parsingPromptText: string
|
|
3696
|
-
}
|
|
3697
|
-
}
|
|
3698
|
-
}
|
|
3699
|
-
customTransformationConfiguration?: {
|
|
3700
|
-
intermediateStorage: {
|
|
3701
|
-
s3Location: {
|
|
3702
|
-
uri: string
|
|
3703
|
-
}
|
|
3704
|
-
}
|
|
3705
|
-
transformations: Array<{
|
|
3706
|
-
stepToApply: 'POST_CHUNKING'
|
|
3707
|
-
transformationFunction: {
|
|
3708
|
-
transformationLambdaConfiguration: {
|
|
3709
|
-
lambdaArn: string
|
|
3710
|
-
}
|
|
3711
|
-
}
|
|
3712
|
-
}>
|
|
3713
|
-
}
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
|
|
3717
|
-
export interface CreateDataSourceCommandOutput {
|
|
3718
|
-
dataSource: {
|
|
3719
|
-
knowledgeBaseId: string
|
|
3720
|
-
dataSourceId: string
|
|
3721
|
-
name: string
|
|
3722
|
-
description?: string
|
|
3723
|
-
status: 'AVAILABLE' | 'DELETING' | 'DELETE_UNSUCCESSFUL'
|
|
3724
|
-
dataSourceConfiguration: {
|
|
3725
|
-
type: string
|
|
3726
|
-
s3Configuration?: S3DataSourceConfiguration
|
|
3727
|
-
}
|
|
3728
|
-
dataDeletionPolicy?: string
|
|
3729
|
-
serverSideEncryptionConfiguration?: {
|
|
3730
|
-
kmsKeyArn?: string
|
|
3731
|
-
}
|
|
3732
|
-
vectorIngestionConfiguration?: {
|
|
3733
|
-
chunkingConfiguration?: {
|
|
3734
|
-
chunkingStrategy: string
|
|
3735
|
-
}
|
|
3736
|
-
}
|
|
3737
|
-
createdAt: string
|
|
3738
|
-
updatedAt: string
|
|
3739
|
-
failureReasons?: string[]
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3742
|
-
|
|
3743
|
-
export interface GetDataSourceCommandInput {
|
|
3744
|
-
knowledgeBaseId: string
|
|
3745
|
-
dataSourceId: string
|
|
3746
|
-
}
|
|
3747
|
-
|
|
3748
|
-
export interface GetDataSourceCommandOutput {
|
|
3749
|
-
dataSource: {
|
|
3750
|
-
knowledgeBaseId: string
|
|
3751
|
-
dataSourceId: string
|
|
3752
|
-
name: string
|
|
3753
|
-
description?: string
|
|
3754
|
-
status: 'AVAILABLE' | 'DELETING' | 'DELETE_UNSUCCESSFUL'
|
|
3755
|
-
dataSourceConfiguration: {
|
|
3756
|
-
type: string
|
|
3757
|
-
s3Configuration?: S3DataSourceConfiguration
|
|
3758
|
-
}
|
|
3759
|
-
dataDeletionPolicy?: string
|
|
3760
|
-
serverSideEncryptionConfiguration?: {
|
|
3761
|
-
kmsKeyArn?: string
|
|
3762
|
-
}
|
|
3763
|
-
vectorIngestionConfiguration?: {
|
|
3764
|
-
chunkingConfiguration?: {
|
|
3765
|
-
chunkingStrategy: string
|
|
3766
|
-
}
|
|
3767
|
-
}
|
|
3768
|
-
createdAt: string
|
|
3769
|
-
updatedAt: string
|
|
3770
|
-
failureReasons?: string[]
|
|
3771
|
-
}
|
|
3772
|
-
}
|
|
3773
|
-
|
|
3774
|
-
export interface ListDataSourcesCommandInput {
|
|
3775
|
-
knowledgeBaseId: string
|
|
3776
|
-
maxResults?: number
|
|
3777
|
-
nextToken?: string
|
|
3778
|
-
}
|
|
3779
|
-
|
|
3780
|
-
export interface ListDataSourcesCommandOutput {
|
|
3781
|
-
dataSourceSummaries: Array<{
|
|
3782
|
-
knowledgeBaseId: string
|
|
3783
|
-
dataSourceId: string
|
|
3784
|
-
name: string
|
|
3785
|
-
description?: string
|
|
3786
|
-
status: 'AVAILABLE' | 'DELETING' | 'DELETE_UNSUCCESSFUL'
|
|
3787
|
-
updatedAt: string
|
|
3788
|
-
}>
|
|
3789
|
-
nextToken?: string
|
|
3790
|
-
}
|
|
3791
|
-
|
|
3792
|
-
export interface UpdateDataSourceCommandInput {
|
|
3793
|
-
knowledgeBaseId: string
|
|
3794
|
-
dataSourceId: string
|
|
3795
|
-
name: string
|
|
3796
|
-
description?: string
|
|
3797
|
-
dataSourceConfiguration: {
|
|
3798
|
-
type: 'S3' | 'CONFLUENCE' | 'SALESFORCE' | 'SHAREPOINT' | 'WEB'
|
|
3799
|
-
s3Configuration?: S3DataSourceConfiguration
|
|
3800
|
-
confluenceConfiguration?: ConfluenceDataSourceConfiguration
|
|
3801
|
-
salesforceConfiguration?: SalesforceDataSourceConfiguration
|
|
3802
|
-
sharePointConfiguration?: SharePointDataSourceConfiguration
|
|
3803
|
-
webConfiguration?: WebDataSourceConfiguration
|
|
3804
|
-
}
|
|
3805
|
-
dataDeletionPolicy?: 'RETAIN' | 'DELETE'
|
|
3806
|
-
serverSideEncryptionConfiguration?: {
|
|
3807
|
-
kmsKeyArn?: string
|
|
3808
|
-
}
|
|
3809
|
-
vectorIngestionConfiguration?: {
|
|
3810
|
-
chunkingConfiguration?: {
|
|
3811
|
-
chunkingStrategy: 'FIXED_SIZE' | 'NONE' | 'HIERARCHICAL' | 'SEMANTIC'
|
|
3812
|
-
fixedSizeChunkingConfiguration?: {
|
|
3813
|
-
maxTokens: number
|
|
3814
|
-
overlapPercentage: number
|
|
3815
|
-
}
|
|
3816
|
-
}
|
|
3817
|
-
}
|
|
3818
|
-
}
|
|
3819
|
-
|
|
3820
|
-
export interface UpdateDataSourceCommandOutput {
|
|
3821
|
-
dataSource: {
|
|
3822
|
-
knowledgeBaseId: string
|
|
3823
|
-
dataSourceId: string
|
|
3824
|
-
name: string
|
|
3825
|
-
description?: string
|
|
3826
|
-
status: 'AVAILABLE' | 'DELETING' | 'DELETE_UNSUCCESSFUL'
|
|
3827
|
-
dataSourceConfiguration: {
|
|
3828
|
-
type: string
|
|
3829
|
-
s3Configuration?: S3DataSourceConfiguration
|
|
3830
|
-
}
|
|
3831
|
-
dataDeletionPolicy?: string
|
|
3832
|
-
serverSideEncryptionConfiguration?: {
|
|
3833
|
-
kmsKeyArn?: string
|
|
3834
|
-
}
|
|
3835
|
-
vectorIngestionConfiguration?: {
|
|
3836
|
-
chunkingConfiguration?: {
|
|
3837
|
-
chunkingStrategy: string
|
|
3838
|
-
}
|
|
3839
|
-
}
|
|
3840
|
-
createdAt: string
|
|
3841
|
-
updatedAt: string
|
|
3842
|
-
failureReasons?: string[]
|
|
3843
|
-
}
|
|
3844
|
-
}
|
|
3845
|
-
|
|
3846
|
-
export interface DeleteDataSourceCommandInput {
|
|
3847
|
-
knowledgeBaseId: string
|
|
3848
|
-
dataSourceId: string
|
|
3849
|
-
}
|
|
3850
|
-
|
|
3851
|
-
export interface DeleteDataSourceCommandOutput {
|
|
3852
|
-
knowledgeBaseId: string
|
|
3853
|
-
dataSourceId: string
|
|
3854
|
-
status: string
|
|
3855
|
-
}
|
|
3856
|
-
|
|
3857
|
-
export interface StartIngestionJobCommandInput {
|
|
3858
|
-
knowledgeBaseId: string
|
|
3859
|
-
dataSourceId: string
|
|
3860
|
-
clientToken?: string
|
|
3861
|
-
description?: string
|
|
3862
|
-
}
|
|
3863
|
-
|
|
3864
|
-
export interface StartIngestionJobCommandOutput {
|
|
3865
|
-
ingestionJob: {
|
|
3866
|
-
knowledgeBaseId: string
|
|
3867
|
-
dataSourceId: string
|
|
3868
|
-
ingestionJobId: string
|
|
3869
|
-
description?: string
|
|
3870
|
-
status: 'STARTING' | 'IN_PROGRESS' | 'COMPLETE' | 'FAILED' | 'STOPPING' | 'STOPPED'
|
|
3871
|
-
statistics?: {
|
|
3872
|
-
numberOfDocumentsScanned?: number
|
|
3873
|
-
numberOfNewDocumentsIndexed?: number
|
|
3874
|
-
numberOfModifiedDocumentsIndexed?: number
|
|
3875
|
-
numberOfDocumentsDeleted?: number
|
|
3876
|
-
numberOfDocumentsFailed?: number
|
|
3877
|
-
}
|
|
3878
|
-
failureReasons?: string[]
|
|
3879
|
-
startedAt: string
|
|
3880
|
-
updatedAt: string
|
|
3881
|
-
}
|
|
3882
|
-
}
|
|
3883
|
-
|
|
3884
|
-
export interface GetIngestionJobCommandInput {
|
|
3885
|
-
knowledgeBaseId: string
|
|
3886
|
-
dataSourceId: string
|
|
3887
|
-
ingestionJobId: string
|
|
3888
|
-
}
|
|
3889
|
-
|
|
3890
|
-
export interface GetIngestionJobCommandOutput {
|
|
3891
|
-
ingestionJob: {
|
|
3892
|
-
knowledgeBaseId: string
|
|
3893
|
-
dataSourceId: string
|
|
3894
|
-
ingestionJobId: string
|
|
3895
|
-
description?: string
|
|
3896
|
-
status: 'STARTING' | 'IN_PROGRESS' | 'COMPLETE' | 'FAILED' | 'STOPPING' | 'STOPPED'
|
|
3897
|
-
statistics?: {
|
|
3898
|
-
numberOfDocumentsScanned?: number
|
|
3899
|
-
numberOfNewDocumentsIndexed?: number
|
|
3900
|
-
numberOfModifiedDocumentsIndexed?: number
|
|
3901
|
-
numberOfDocumentsDeleted?: number
|
|
3902
|
-
numberOfDocumentsFailed?: number
|
|
3903
|
-
}
|
|
3904
|
-
failureReasons?: string[]
|
|
3905
|
-
startedAt: string
|
|
3906
|
-
updatedAt: string
|
|
3907
|
-
}
|
|
3908
|
-
}
|
|
3909
|
-
|
|
3910
|
-
export interface ListIngestionJobsCommandInput {
|
|
3911
|
-
knowledgeBaseId: string
|
|
3912
|
-
dataSourceId: string
|
|
3913
|
-
filters?: Array<{
|
|
3914
|
-
attribute: 'STATUS'
|
|
3915
|
-
operator: 'EQ'
|
|
3916
|
-
values: string[]
|
|
3917
|
-
}>
|
|
3918
|
-
sortBy?: {
|
|
3919
|
-
attribute: 'STARTED_AT' | 'STATUS'
|
|
3920
|
-
order: 'ASCENDING' | 'DESCENDING'
|
|
3921
|
-
}
|
|
3922
|
-
maxResults?: number
|
|
3923
|
-
nextToken?: string
|
|
3924
|
-
}
|
|
3925
|
-
|
|
3926
|
-
export interface ListIngestionJobsCommandOutput {
|
|
3927
|
-
ingestionJobSummaries: Array<{
|
|
3928
|
-
knowledgeBaseId: string
|
|
3929
|
-
dataSourceId: string
|
|
3930
|
-
ingestionJobId: string
|
|
3931
|
-
description?: string
|
|
3932
|
-
status: 'STARTING' | 'IN_PROGRESS' | 'COMPLETE' | 'FAILED' | 'STOPPING' | 'STOPPED'
|
|
3933
|
-
startedAt: string
|
|
3934
|
-
updatedAt: string
|
|
3935
|
-
statistics?: {
|
|
3936
|
-
numberOfDocumentsScanned?: number
|
|
3937
|
-
numberOfNewDocumentsIndexed?: number
|
|
3938
|
-
numberOfModifiedDocumentsIndexed?: number
|
|
3939
|
-
numberOfDocumentsDeleted?: number
|
|
3940
|
-
numberOfDocumentsFailed?: number
|
|
3941
|
-
}
|
|
3942
|
-
}>
|
|
3943
|
-
nextToken?: string
|
|
3944
|
-
}
|
|
3945
|
-
|
|
3946
|
-
// ============================================================================
|
|
3947
|
-
// Model Copy Types
|
|
3948
|
-
// ============================================================================
|
|
3949
|
-
|
|
3950
|
-
export interface CreateModelCopyJobCommandInput {
|
|
3951
|
-
sourceModelArn: string
|
|
3952
|
-
targetModelName: string
|
|
3953
|
-
modelKmsKeyId?: string
|
|
3954
|
-
targetModelTags?: Array<{ key: string; value: string }>
|
|
3955
|
-
clientRequestToken?: string
|
|
3956
|
-
}
|
|
3957
|
-
|
|
3958
|
-
export interface CreateModelCopyJobCommandOutput {
|
|
3959
|
-
jobArn: string
|
|
3960
|
-
}
|
|
3961
|
-
|
|
3962
|
-
export interface GetModelCopyJobCommandInput {
|
|
3963
|
-
jobArn: string
|
|
3964
|
-
}
|
|
3965
|
-
|
|
3966
|
-
export interface GetModelCopyJobCommandOutput {
|
|
3967
|
-
jobArn: string
|
|
3968
|
-
status: 'InProgress' | 'Completed' | 'Failed'
|
|
3969
|
-
creationTime: string
|
|
3970
|
-
targetModelArn?: string
|
|
3971
|
-
targetModelName: string
|
|
3972
|
-
sourceAccountId: string
|
|
3973
|
-
sourceModelArn: string
|
|
3974
|
-
targetModelKmsKeyArn?: string
|
|
3975
|
-
targetModelTags?: Array<{ key: string; value: string }>
|
|
3976
|
-
failureMessage?: string
|
|
3977
|
-
}
|
|
3978
|
-
|
|
3979
|
-
export interface ListModelCopyJobsCommandInput {
|
|
3980
|
-
creationTimeAfter?: string
|
|
3981
|
-
creationTimeBefore?: string
|
|
3982
|
-
statusEquals?: 'InProgress' | 'Completed' | 'Failed'
|
|
3983
|
-
sourceAccountEquals?: string
|
|
3984
|
-
sourceModelArnEquals?: string
|
|
3985
|
-
targetModelNameContains?: string
|
|
3986
|
-
maxResults?: number
|
|
3987
|
-
nextToken?: string
|
|
3988
|
-
sortBy?: 'CreationTime'
|
|
3989
|
-
sortOrder?: 'Ascending' | 'Descending'
|
|
3990
|
-
}
|
|
3991
|
-
|
|
3992
|
-
export interface ListModelCopyJobsCommandOutput {
|
|
3993
|
-
nextToken?: string
|
|
3994
|
-
modelCopyJobSummaries?: Array<{
|
|
3995
|
-
jobArn: string
|
|
3996
|
-
status: 'InProgress' | 'Completed' | 'Failed'
|
|
3997
|
-
creationTime: string
|
|
3998
|
-
targetModelArn?: string
|
|
3999
|
-
targetModelName: string
|
|
4000
|
-
sourceAccountId: string
|
|
4001
|
-
sourceModelArn: string
|
|
4002
|
-
targetModelKmsKeyArn?: string
|
|
4003
|
-
failureMessage?: string
|
|
4004
|
-
}>
|
|
4005
|
-
}
|
|
4006
|
-
|
|
4007
|
-
// ============================================================================
|
|
4008
|
-
// Helper Functions
|
|
4009
|
-
// ============================================================================
|
|
4010
|
-
|
|
4011
|
-
/**
|
|
4012
|
-
* Request access to multiple Bedrock models
|
|
4013
|
-
* Convenience function matching the pattern from the user's example
|
|
4014
|
-
*/
|
|
4015
|
-
export async function requestModelAccess(
|
|
4016
|
-
models: string[],
|
|
4017
|
-
region: string = 'us-east-1',
|
|
4018
|
-
): Promise<Array<{ modelId: string; status: string; error?: string }>> {
|
|
4019
|
-
const client = new BedrockClient(region)
|
|
4020
|
-
return client.requestAccessToModels(models)
|
|
4021
|
-
}
|
|
4022
|
-
|
|
4023
|
-
/**
|
|
4024
|
-
* List all available Claude models in the region
|
|
4025
|
-
*/
|
|
4026
|
-
export async function listClaudeModels(region: string = 'us-east-1'): Promise<FoundationModelSummary[]> {
|
|
4027
|
-
const client = new BedrockClient(region)
|
|
4028
|
-
return client.listClaudeModels()
|
|
4029
|
-
}
|
|
4030
|
-
|
|
4031
|
-
/**
|
|
4032
|
-
* Create a simple text completion using Claude
|
|
4033
|
-
*/
|
|
4034
|
-
export async function completeWithClaude(
|
|
4035
|
-
prompt: string,
|
|
4036
|
-
options?: {
|
|
4037
|
-
modelId?: string
|
|
4038
|
-
maxTokens?: number
|
|
4039
|
-
temperature?: number
|
|
4040
|
-
region?: string
|
|
4041
|
-
},
|
|
4042
|
-
): Promise<string> {
|
|
4043
|
-
const client = new BedrockRuntimeClient(options?.region || 'us-east-1')
|
|
4044
|
-
|
|
4045
|
-
const response = await client.invokeClaudeMessages({
|
|
4046
|
-
modelId: options?.modelId || 'anthropic.claude-3-haiku-20240307-v1:0',
|
|
4047
|
-
messages: [{ role: 'user', content: prompt }],
|
|
4048
|
-
maxTokens: options?.maxTokens || 1024,
|
|
4049
|
-
temperature: options?.temperature,
|
|
4050
|
-
})
|
|
4051
|
-
|
|
4052
|
-
const textContent = response.content.find(c => c.type === 'text')
|
|
4053
|
-
return textContent?.type === 'text' ? textContent.text : ''
|
|
4054
|
-
}
|
|
4055
|
-
|
|
4056
|
-
/**
|
|
4057
|
-
* Generate embeddings for text
|
|
4058
|
-
*/
|
|
4059
|
-
export async function generateEmbeddings(
|
|
4060
|
-
text: string | string[],
|
|
4061
|
-
options?: {
|
|
4062
|
-
modelId?: string
|
|
4063
|
-
region?: string
|
|
4064
|
-
},
|
|
4065
|
-
): Promise<number[] | number[][]> {
|
|
4066
|
-
const client = new BedrockRuntimeClient(options?.region || 'us-east-1')
|
|
4067
|
-
|
|
4068
|
-
const result = await client.generateEmbeddings({
|
|
4069
|
-
modelId: options?.modelId || 'amazon.titan-embed-text-v1',
|
|
4070
|
-
inputText: text,
|
|
4071
|
-
})
|
|
4072
|
-
|
|
4073
|
-
return result.embeddings || result.embedding || []
|
|
4074
|
-
}
|