@effect/ai-amazon-bedrock 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AmazonBedrockClient/package.json +6 -0
- package/AmazonBedrockConfig/package.json +6 -0
- package/AmazonBedrockLanguageModel/package.json +6 -0
- package/AmazonBedrockSchema/package.json +6 -0
- package/EventStreamEncoding/package.json +6 -0
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/cjs/AmazonBedrockClient.js +255 -0
- package/dist/cjs/AmazonBedrockClient.js.map +1 -0
- package/dist/cjs/AmazonBedrockConfig.js +30 -0
- package/dist/cjs/AmazonBedrockConfig.js.map +1 -0
- package/dist/cjs/AmazonBedrockLanguageModel.js +507 -0
- package/dist/cjs/AmazonBedrockLanguageModel.js.map +1 -0
- package/dist/cjs/AmazonBedrockSchema.js +745 -0
- package/dist/cjs/AmazonBedrockSchema.js.map +1 -0
- package/dist/cjs/EventStreamEncoding.js +85 -0
- package/dist/cjs/EventStreamEncoding.js.map +1 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/internal/utilities.js +25 -0
- package/dist/cjs/internal/utilities.js.map +1 -0
- package/dist/dts/AmazonBedrockClient.d.ts +95 -0
- package/dist/dts/AmazonBedrockClient.d.ts.map +1 -0
- package/dist/dts/AmazonBedrockConfig.d.ts +47 -0
- package/dist/dts/AmazonBedrockConfig.d.ts.map +1 -0
- package/dist/dts/AmazonBedrockLanguageModel.d.ts +95 -0
- package/dist/dts/AmazonBedrockLanguageModel.d.ts.map +1 -0
- package/dist/dts/AmazonBedrockSchema.d.ts +1434 -0
- package/dist/dts/AmazonBedrockSchema.d.ts.map +1 -0
- package/dist/dts/EventStreamEncoding.d.ts +16 -0
- package/dist/dts/EventStreamEncoding.d.ts.map +1 -0
- package/dist/dts/index.d.ts +21 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/internal/utilities.d.ts +2 -0
- package/dist/dts/internal/utilities.d.ts.map +1 -0
- package/dist/esm/AmazonBedrockClient.js +242 -0
- package/dist/esm/AmazonBedrockClient.js.map +1 -0
- package/dist/esm/AmazonBedrockConfig.js +22 -0
- package/dist/esm/AmazonBedrockConfig.js.map +1 -0
- package/dist/esm/AmazonBedrockLanguageModel.js +495 -0
- package/dist/esm/AmazonBedrockLanguageModel.js.map +1 -0
- package/dist/esm/AmazonBedrockSchema.js +675 -0
- package/dist/esm/AmazonBedrockSchema.js.map +1 -0
- package/dist/esm/EventStreamEncoding.js +76 -0
- package/dist/esm/EventStreamEncoding.js.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/utilities.js +17 -0
- package/dist/esm/internal/utilities.js.map +1 -0
- package/dist/esm/package.json +4 -0
- package/index/package.json +6 -0
- package/package.json +91 -0
- package/src/AmazonBedrockClient.ts +409 -0
- package/src/AmazonBedrockConfig.ts +78 -0
- package/src/AmazonBedrockLanguageModel.ts +623 -0
- package/src/AmazonBedrockSchema.ts +1038 -0
- package/src/EventStreamEncoding.ts +111 -0
- package/src/index.ts +24 -0
- package/src/internal/utilities.ts +21 -0
|
@@ -0,0 +1,1038 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as Schema from "effect/Schema"
|
|
5
|
+
|
|
6
|
+
const prefix = "@effect/ai-amazon-bedrock"
|
|
7
|
+
|
|
8
|
+
const makeIdentifier = (name: string) => `${prefix}/${name}`
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The foundation models supported by Amazon Bedrock.
|
|
12
|
+
*
|
|
13
|
+
* An up-to-date list can be generated with the following command:
|
|
14
|
+
*
|
|
15
|
+
* ```sh
|
|
16
|
+
* aws bedrock list-foundation-models --output json | jq '[.modelSummaries[].modelId]'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
* @category Schemas
|
|
21
|
+
*/
|
|
22
|
+
export class BedrockFoundationModelId extends Schema.Literal(
|
|
23
|
+
"amazon.titan-tg1-large",
|
|
24
|
+
"amazon.titan-image-generator-v1:0",
|
|
25
|
+
"amazon.titan-image-generator-v1",
|
|
26
|
+
"amazon.titan-image-generator-v2:0",
|
|
27
|
+
"amazon.nova-premier-v1:0:8k",
|
|
28
|
+
"amazon.nova-premier-v1:0:20k",
|
|
29
|
+
"amazon.nova-premier-v1:0:1000k",
|
|
30
|
+
"amazon.nova-premier-v1:0:mm",
|
|
31
|
+
"amazon.nova-premier-v1:0",
|
|
32
|
+
"amazon.titan-text-premier-v1:0",
|
|
33
|
+
"amazon.nova-pro-v1:0:24k",
|
|
34
|
+
"amazon.nova-pro-v1:0:300k",
|
|
35
|
+
"amazon.nova-pro-v1:0",
|
|
36
|
+
"amazon.nova-lite-v1:0:24k",
|
|
37
|
+
"amazon.nova-lite-v1:0:300k",
|
|
38
|
+
"amazon.nova-lite-v1:0",
|
|
39
|
+
"amazon.nova-canvas-v1:0",
|
|
40
|
+
"amazon.nova-reel-v1:0",
|
|
41
|
+
"amazon.nova-reel-v1:1",
|
|
42
|
+
"amazon.nova-micro-v1:0:24k",
|
|
43
|
+
"amazon.nova-micro-v1:0:128k",
|
|
44
|
+
"amazon.nova-micro-v1:0",
|
|
45
|
+
"amazon.nova-sonic-v1:0",
|
|
46
|
+
"amazon.titan-embed-g1-text-02",
|
|
47
|
+
"amazon.titan-text-lite-v1:0:4k",
|
|
48
|
+
"amazon.titan-text-lite-v1",
|
|
49
|
+
"amazon.titan-text-express-v1:0:8k",
|
|
50
|
+
"amazon.titan-text-express-v1",
|
|
51
|
+
"amazon.titan-embed-text-v1:2:8k",
|
|
52
|
+
"amazon.titan-embed-text-v1",
|
|
53
|
+
"amazon.titan-embed-text-v2:0:8k",
|
|
54
|
+
"amazon.titan-embed-text-v2:0",
|
|
55
|
+
"amazon.titan-embed-image-v1:0",
|
|
56
|
+
"amazon.titan-embed-image-v1",
|
|
57
|
+
"stability.stable-diffusion-xl-v1:0",
|
|
58
|
+
"stability.stable-diffusion-xl-v1",
|
|
59
|
+
"ai21.jamba-instruct-v1:0",
|
|
60
|
+
"ai21.jamba-1-5-large-v1:0",
|
|
61
|
+
"ai21.jamba-1-5-mini-v1:0",
|
|
62
|
+
"anthropic.claude-instant-v1:2:100k",
|
|
63
|
+
"anthropic.claude-instant-v1",
|
|
64
|
+
"anthropic.claude-v2:0:18k",
|
|
65
|
+
"anthropic.claude-v2:0:100k",
|
|
66
|
+
"anthropic.claude-v2:1:18k",
|
|
67
|
+
"anthropic.claude-v2:1:200k",
|
|
68
|
+
"anthropic.claude-v2:1",
|
|
69
|
+
"anthropic.claude-v2",
|
|
70
|
+
"anthropic.claude-3-sonnet-20240229-v1:0:28k",
|
|
71
|
+
"anthropic.claude-3-sonnet-20240229-v1:0:200k",
|
|
72
|
+
"anthropic.claude-3-sonnet-20240229-v1:0",
|
|
73
|
+
"anthropic.claude-3-haiku-20240307-v1:0:48k",
|
|
74
|
+
"anthropic.claude-3-haiku-20240307-v1:0:200k",
|
|
75
|
+
"anthropic.claude-3-haiku-20240307-v1:0",
|
|
76
|
+
"anthropic.claude-3-opus-20240229-v1:0:12k",
|
|
77
|
+
"anthropic.claude-3-opus-20240229-v1:0:28k",
|
|
78
|
+
"anthropic.claude-3-opus-20240229-v1:0:200k",
|
|
79
|
+
"anthropic.claude-3-opus-20240229-v1:0",
|
|
80
|
+
"anthropic.claude-3-5-sonnet-20240620-v1:0",
|
|
81
|
+
"anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
82
|
+
"anthropic.claude-3-7-sonnet-20250219-v1:0",
|
|
83
|
+
"anthropic.claude-3-5-haiku-20241022-v1:0",
|
|
84
|
+
"anthropic.claude-opus-4-20250514-v1:0",
|
|
85
|
+
"anthropic.claude-sonnet-4-20250514-v1:0",
|
|
86
|
+
"cohere.command-text-v14:7:4k",
|
|
87
|
+
"cohere.command-text-v14",
|
|
88
|
+
"cohere.command-r-v1:0",
|
|
89
|
+
"cohere.command-r-plus-v1:0",
|
|
90
|
+
"cohere.command-light-text-v14:7:4k",
|
|
91
|
+
"cohere.command-light-text-v14",
|
|
92
|
+
"cohere.embed-english-v3:0:512",
|
|
93
|
+
"cohere.embed-english-v3",
|
|
94
|
+
"cohere.embed-multilingual-v3:0:512",
|
|
95
|
+
"cohere.embed-multilingual-v3",
|
|
96
|
+
"deepseek.r1-v1:0",
|
|
97
|
+
"meta.llama3-8b-instruct-v1:0",
|
|
98
|
+
"meta.llama3-70b-instruct-v1:0",
|
|
99
|
+
"meta.llama3-1-8b-instruct-v1:0",
|
|
100
|
+
"meta.llama3-1-70b-instruct-v1:0",
|
|
101
|
+
"meta.llama3-2-11b-instruct-v1:0",
|
|
102
|
+
"meta.llama3-2-90b-instruct-v1:0",
|
|
103
|
+
"meta.llama3-2-1b-instruct-v1:0",
|
|
104
|
+
"meta.llama3-2-3b-instruct-v1:0",
|
|
105
|
+
"meta.llama3-3-70b-instruct-v1:0",
|
|
106
|
+
"meta.llama4-scout-17b-instruct-v1:0",
|
|
107
|
+
"meta.llama4-maverick-17b-instruct-v1:0",
|
|
108
|
+
"mistral.mistral-7b-instruct-v0:2",
|
|
109
|
+
"mistral.mixtral-8x7b-instruct-v0:1",
|
|
110
|
+
"mistral.mistral-large-2402-v1:0",
|
|
111
|
+
"mistral.mistral-small-2402-v1:0",
|
|
112
|
+
"mistral.pixtral-large-2502-v1:0"
|
|
113
|
+
) {}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @since 1.0.0
|
|
117
|
+
* @category Schemas
|
|
118
|
+
*/
|
|
119
|
+
export class CachePointBlock extends Schema.Class<CachePointBlock>(makeIdentifier("CachePointBlock"))({
|
|
120
|
+
type: Schema.Literal("default")
|
|
121
|
+
}) {}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @since 1.0.0
|
|
125
|
+
* @category Schemas
|
|
126
|
+
*/
|
|
127
|
+
export const DocumentFormat = Schema.Literal(
|
|
128
|
+
"csv",
|
|
129
|
+
"doc",
|
|
130
|
+
"docx",
|
|
131
|
+
"html",
|
|
132
|
+
"md",
|
|
133
|
+
"pdf",
|
|
134
|
+
"txt",
|
|
135
|
+
"xls",
|
|
136
|
+
"xlsx"
|
|
137
|
+
)
|
|
138
|
+
/**
|
|
139
|
+
* @since 1.0.0
|
|
140
|
+
* @category Schemas
|
|
141
|
+
*/
|
|
142
|
+
export type DocumentFormat = typeof DocumentFormat.Type
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @since 1.0.0
|
|
146
|
+
* @category Schemas
|
|
147
|
+
*/
|
|
148
|
+
export class DocumentBlock extends Schema.Class<DocumentBlock>(makeIdentifier("DocumentBlock"))({
|
|
149
|
+
name: Schema.String.pipe(
|
|
150
|
+
Schema.pattern(/^[a-zA-Z0-9()[\]-]+(?: [a-zA-Z0-9()[\]-]+)*$/),
|
|
151
|
+
Schema.minLength(1),
|
|
152
|
+
Schema.maxLength(200)
|
|
153
|
+
),
|
|
154
|
+
format: DocumentFormat,
|
|
155
|
+
source: Schema.Struct({
|
|
156
|
+
bytes: Schema.NonEmptyString
|
|
157
|
+
})
|
|
158
|
+
}) {}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @since 1.0.0
|
|
162
|
+
* @category Schemas
|
|
163
|
+
*/
|
|
164
|
+
export class GuardrailConverseImageBlock extends Schema.Class<GuardrailConverseImageBlock>(
|
|
165
|
+
makeIdentifier("GuardrailConverseImageBlock")
|
|
166
|
+
)({
|
|
167
|
+
format: Schema.Literal("png", "jpg"),
|
|
168
|
+
source: Schema.Struct({
|
|
169
|
+
bytes: Schema.NonEmptyString
|
|
170
|
+
})
|
|
171
|
+
}) {}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @since 1.0.0
|
|
175
|
+
* @category Schemas
|
|
176
|
+
*/
|
|
177
|
+
export class GuardrailConverseTextBlock extends Schema.Class<GuardrailConverseTextBlock>(
|
|
178
|
+
makeIdentifier("GuardrailConverseTextBlock")
|
|
179
|
+
)({
|
|
180
|
+
text: Schema.String,
|
|
181
|
+
qualifiers: Schema.optional(Schema.Array(Schema.Literal("guard_content", "grounding_source", "query")))
|
|
182
|
+
}) {}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @since 1.0.0
|
|
186
|
+
* @category Schemas
|
|
187
|
+
*/
|
|
188
|
+
export class GuardrailConverseContentBlock extends Schema.Union(
|
|
189
|
+
GuardrailConverseImageBlock,
|
|
190
|
+
GuardrailConverseTextBlock
|
|
191
|
+
) {}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @since 1.0.0
|
|
195
|
+
* @category Schemas
|
|
196
|
+
*/
|
|
197
|
+
export const ImageFormat = Schema.Literal("gif", "jpeg", "png", "webp")
|
|
198
|
+
/**
|
|
199
|
+
* @since 1.0.0
|
|
200
|
+
* @category Schemas
|
|
201
|
+
*/
|
|
202
|
+
export type ImageFormat = typeof ImageFormat.Type
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @since 1.0.0
|
|
206
|
+
* @category Schemas
|
|
207
|
+
*/
|
|
208
|
+
export class ImageBlock extends Schema.Class<ImageBlock>(makeIdentifier("ImageBlock"))({
|
|
209
|
+
format: ImageFormat,
|
|
210
|
+
source: Schema.Struct({
|
|
211
|
+
bytes: Schema.NonEmptyString
|
|
212
|
+
})
|
|
213
|
+
}) {}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @since 1.0.0
|
|
217
|
+
* @category Schemas
|
|
218
|
+
*/
|
|
219
|
+
export class JsonBlock extends Schema.Class<JsonBlock>(makeIdentifier("JsonBlock"))({
|
|
220
|
+
json: Schema.Unknown
|
|
221
|
+
}) {}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @since 1.0.0
|
|
225
|
+
* @category Schemas
|
|
226
|
+
*/
|
|
227
|
+
export class ReasoningContentBlock extends Schema.Union(
|
|
228
|
+
Schema.Struct({
|
|
229
|
+
reasoningText: Schema.Struct({
|
|
230
|
+
text: Schema.String,
|
|
231
|
+
signature: Schema.optional(Schema.String)
|
|
232
|
+
})
|
|
233
|
+
}),
|
|
234
|
+
Schema.Struct({ redactedContent: Schema.Uint8ArrayFromBase64 })
|
|
235
|
+
) {}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @since 1.0.0
|
|
239
|
+
* @category Schemas
|
|
240
|
+
*/
|
|
241
|
+
export class VideoBlock extends Schema.Class<VideoBlock>(makeIdentifier("VideoBlock"))({
|
|
242
|
+
format: Schema.Literal("flv", "mkv", "mov", "mp4", "mpg", "mpeg", "three_gp", "webm"),
|
|
243
|
+
source: Schema.Union(
|
|
244
|
+
Schema.Struct({
|
|
245
|
+
bytes: Schema.NonEmptyString
|
|
246
|
+
}),
|
|
247
|
+
Schema.Struct({
|
|
248
|
+
s3Location: Schema.Struct({
|
|
249
|
+
uri: Schema.String.pipe(
|
|
250
|
+
Schema.pattern(/^s3:\/\/[a-z0-9][.\-a-z0-9]{1,61}[a-z0-9](\/.*)?$/),
|
|
251
|
+
Schema.minLength(1),
|
|
252
|
+
Schema.maxLength(1024)
|
|
253
|
+
),
|
|
254
|
+
bucketOwner: Schema.String.pipe(
|
|
255
|
+
Schema.pattern(/^[0-9]{12}$/),
|
|
256
|
+
Schema.optional
|
|
257
|
+
)
|
|
258
|
+
})
|
|
259
|
+
})
|
|
260
|
+
)
|
|
261
|
+
}) {}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @since 1.0.0
|
|
265
|
+
* @category Schemas
|
|
266
|
+
*/
|
|
267
|
+
export class ToolResultBlock extends Schema.Class<ToolResultBlock>(makeIdentifier("ToolResultBlock"))({
|
|
268
|
+
content: Schema.Array(Schema.Union(
|
|
269
|
+
Schema.Struct({ document: DocumentBlock }),
|
|
270
|
+
Schema.Struct({ image: ImageBlock }),
|
|
271
|
+
Schema.Struct({ text: Schema.String }),
|
|
272
|
+
Schema.Struct({ json: JsonBlock }),
|
|
273
|
+
Schema.Struct({ video: VideoBlock })
|
|
274
|
+
)),
|
|
275
|
+
toolUseId: Schema.String.pipe(
|
|
276
|
+
Schema.pattern(/^[a-zA-Z0-9_-]+$/),
|
|
277
|
+
Schema.minLength(1),
|
|
278
|
+
Schema.maxLength(64)
|
|
279
|
+
),
|
|
280
|
+
status: Schema.optional(Schema.Literal("success", "error"))
|
|
281
|
+
}) {}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @since 1.0.0
|
|
285
|
+
* @category Schemas
|
|
286
|
+
*/
|
|
287
|
+
export class ToolUseBlock extends Schema.Class<ToolUseBlock>(makeIdentifier("ToolUseBlock"))({
|
|
288
|
+
name: Schema.String.pipe(
|
|
289
|
+
Schema.pattern(/^[a-zA-Z0-9_-]+$/),
|
|
290
|
+
Schema.minLength(1),
|
|
291
|
+
Schema.maxLength(64)
|
|
292
|
+
),
|
|
293
|
+
input: Schema.Unknown,
|
|
294
|
+
toolUseId: Schema.String.pipe(
|
|
295
|
+
Schema.pattern(/^[a-zA-Z0-9_-]+$/),
|
|
296
|
+
Schema.minLength(1),
|
|
297
|
+
Schema.maxLength(64)
|
|
298
|
+
)
|
|
299
|
+
}) {}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* @since 1.0.0
|
|
303
|
+
* @category Schemas
|
|
304
|
+
*/
|
|
305
|
+
export class ContentBlock extends Schema.Union(
|
|
306
|
+
Schema.Struct({ cachePoint: CachePointBlock }),
|
|
307
|
+
Schema.Struct({ document: DocumentBlock }),
|
|
308
|
+
Schema.Struct({ guardContent: GuardrailConverseContentBlock }),
|
|
309
|
+
Schema.Struct({ image: ImageBlock }),
|
|
310
|
+
Schema.Struct({ reasoningContent: ReasoningContentBlock }),
|
|
311
|
+
Schema.Struct({ text: Schema.String }),
|
|
312
|
+
Schema.Struct({ toolResult: ToolResultBlock }),
|
|
313
|
+
Schema.Struct({ toolUse: ToolUseBlock }),
|
|
314
|
+
Schema.Struct({ video: VideoBlock })
|
|
315
|
+
) {}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* @since 1.0.0
|
|
319
|
+
* @category Schemas
|
|
320
|
+
*/
|
|
321
|
+
export class Message extends Schema.Class<Message>(makeIdentifier("Message"))({
|
|
322
|
+
role: Schema.Literal("user", "assistant"),
|
|
323
|
+
content: Schema.Array(ContentBlock)
|
|
324
|
+
}) {}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @since 1.0.0
|
|
328
|
+
* @category Schemas
|
|
329
|
+
*/
|
|
330
|
+
export class ConverseOutput extends Schema.Class<ConverseOutput>(makeIdentifier("ConverseOutput"))({
|
|
331
|
+
message: Message
|
|
332
|
+
}) {}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @since 1.0.0
|
|
336
|
+
* @category Schemas
|
|
337
|
+
*/
|
|
338
|
+
export class ConverseMetrics extends Schema.Class<ConverseMetrics>(makeIdentifier("ConverseMetrics"))({
|
|
339
|
+
latencyMs: Schema.DurationFromMillis
|
|
340
|
+
}) {}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @since 1.0.0
|
|
344
|
+
* @category Schemas
|
|
345
|
+
*/
|
|
346
|
+
export class GuardrailContentFilter extends Schema.Class<GuardrailContentFilter>(
|
|
347
|
+
makeIdentifier("GuardrailContentFilter")
|
|
348
|
+
)({
|
|
349
|
+
type: Schema.Literal("HATE", "INSULTS", "MISCONDUCT", "PROMPT_ATTACK", "SEXUAL", "VIOLENCE"),
|
|
350
|
+
action: Schema.Literal("BLOCKED", "NONE"),
|
|
351
|
+
confidence: Schema.Literal("NONE", "LOW", "MEDIUM", "HIGH"),
|
|
352
|
+
detected: Schema.optional(Schema.Boolean),
|
|
353
|
+
filterStrength: Schema.optional(Schema.Literal("NONE", "LOW", "MEDIUM", "HIGH"))
|
|
354
|
+
}) {}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @since 1.0.0
|
|
358
|
+
* @category Schemas
|
|
359
|
+
*/
|
|
360
|
+
export class GuardrailContentPolicyAssessment extends Schema.Class<GuardrailContentPolicyAssessment>(
|
|
361
|
+
makeIdentifier("GuardrailContentPolicyAssessment")
|
|
362
|
+
)({
|
|
363
|
+
filters: Schema.Array(GuardrailContentFilter)
|
|
364
|
+
}) {}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @since 1.0.0
|
|
368
|
+
* @category Schemas
|
|
369
|
+
*/
|
|
370
|
+
export class GuardrailContextualGroundingFilter extends Schema.Class<GuardrailContextualGroundingFilter>(
|
|
371
|
+
makeIdentifier("GuardrailContextualGroundingFilter")
|
|
372
|
+
)({
|
|
373
|
+
type: Schema.Literal("GROUNDING", "RELEVANCE"),
|
|
374
|
+
action: Schema.Literal("BLOCKED", "NONE"),
|
|
375
|
+
score: Schema.Number.pipe(Schema.between(0, 1)),
|
|
376
|
+
threshold: Schema.Number.pipe(Schema.between(0, 1)),
|
|
377
|
+
detected: Schema.optional(Schema.Boolean)
|
|
378
|
+
}) {}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* @since 1.0.0
|
|
382
|
+
* @category Schemas
|
|
383
|
+
*/
|
|
384
|
+
export class GuardrailContextualGroundingPolicyAssessment
|
|
385
|
+
extends Schema.Class<GuardrailContextualGroundingPolicyAssessment>(
|
|
386
|
+
makeIdentifier("GuardrailContextualGroundingPolicyAssessment")
|
|
387
|
+
)({
|
|
388
|
+
filters: Schema.optional(Schema.Array(GuardrailContextualGroundingFilter))
|
|
389
|
+
})
|
|
390
|
+
{}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* @since 1.0.0
|
|
394
|
+
* @category Schemas
|
|
395
|
+
*/
|
|
396
|
+
export class GuardrailImageCoverage extends Schema.Class<GuardrailImageCoverage>(
|
|
397
|
+
makeIdentifier("GuardrailImageCoverage")
|
|
398
|
+
)({
|
|
399
|
+
guarded: Schema.optional(Schema.Int),
|
|
400
|
+
total: Schema.optional(Schema.Int)
|
|
401
|
+
}) {}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @since 1.0.0
|
|
405
|
+
* @category Schemas
|
|
406
|
+
*/
|
|
407
|
+
export class GuardrailTextCharactersCoverage extends Schema.Class<GuardrailTextCharactersCoverage>(
|
|
408
|
+
makeIdentifier("GuardrailTextCharactersCoverage")
|
|
409
|
+
)({
|
|
410
|
+
guarded: Schema.optional(Schema.Int),
|
|
411
|
+
total: Schema.optional(Schema.Int)
|
|
412
|
+
}) {}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @since 1.0.0
|
|
416
|
+
* @category Schemas
|
|
417
|
+
*/
|
|
418
|
+
export class GuardrailCoverage extends Schema.Class<GuardrailCoverage>(makeIdentifier("GuardrailCoverage"))({
|
|
419
|
+
images: Schema.optional(GuardrailImageCoverage),
|
|
420
|
+
textCharacters: Schema.optional(GuardrailTextCharactersCoverage)
|
|
421
|
+
}) {}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @since 1.0.0
|
|
425
|
+
* @category Schemas
|
|
426
|
+
*/
|
|
427
|
+
export class GuardrailUsage extends Schema.Class<GuardrailUsage>(makeIdentifier("GuardrailUsage"))({
|
|
428
|
+
contentPolicyUnits: Schema.Int,
|
|
429
|
+
contextualGroundingPolicyUnits: Schema.Int,
|
|
430
|
+
sensitiveInformationPolicyFreeUnits: Schema.Int,
|
|
431
|
+
sensitiveInformationPolicyUnits: Schema.Int,
|
|
432
|
+
topicPolicyUnits: Schema.Int,
|
|
433
|
+
wordPolicyUnits: Schema.Int,
|
|
434
|
+
contentPolicyImageUnits: Schema.optional(Schema.Int)
|
|
435
|
+
}) {}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @since 1.0.0
|
|
439
|
+
* @category Schemas
|
|
440
|
+
*/
|
|
441
|
+
export class GuardrailInvocationMetrics extends Schema.Class<GuardrailInvocationMetrics>(
|
|
442
|
+
makeIdentifier("GuardrailInvocationMetrics")
|
|
443
|
+
)({
|
|
444
|
+
guardrailCoverage: Schema.optional(GuardrailCoverage),
|
|
445
|
+
guardrailProcessingLatency: Schema.optional(Schema.Number),
|
|
446
|
+
usage: Schema.optional(GuardrailUsage)
|
|
447
|
+
}) {}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @since 1.0.0
|
|
451
|
+
* @category Schemas
|
|
452
|
+
*/
|
|
453
|
+
export class GuardrailPiiEntityFilter extends Schema.Class<GuardrailPiiEntityFilter>(
|
|
454
|
+
makeIdentifier("GuardrailPiiEntityFilter")
|
|
455
|
+
)({
|
|
456
|
+
type: Schema.Literal(
|
|
457
|
+
"ADDRESS",
|
|
458
|
+
"AGE",
|
|
459
|
+
"AWS_ACCESS_KEY",
|
|
460
|
+
"AWS_SECRET_KEY",
|
|
461
|
+
"CA_HEALTH_NUMBER",
|
|
462
|
+
"CA_SOCIAL_INSURANCE_NUMBER",
|
|
463
|
+
"CREDIT_DEBIT_CARD_CVV",
|
|
464
|
+
"CREDIT_DEBIT_CARD_EXPIRY",
|
|
465
|
+
"CREDIT_DEBIT_CARD_NUMBER",
|
|
466
|
+
"DRIVER_ID",
|
|
467
|
+
"EMAIL",
|
|
468
|
+
"INTERNATIONAL_BANK_ACCOUNT_NUMBER",
|
|
469
|
+
"IP_ADDRESS",
|
|
470
|
+
"LICENSE_PLATE",
|
|
471
|
+
"MAC_ADDRESS",
|
|
472
|
+
"NAME",
|
|
473
|
+
"PASSWORD",
|
|
474
|
+
"PHONE",
|
|
475
|
+
"PIN",
|
|
476
|
+
"SWIFT_CODE",
|
|
477
|
+
"UK_NATIONAL_HEALTH_SERVICE_NUMBER",
|
|
478
|
+
"UK_NATIONAL_INSURANCE_NUMBER",
|
|
479
|
+
"UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER",
|
|
480
|
+
"URL",
|
|
481
|
+
"USERNAME",
|
|
482
|
+
"US_BANK_ACCOUNT_NUMBER",
|
|
483
|
+
"US_BANK_ROUTING_NUMBER",
|
|
484
|
+
"US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER",
|
|
485
|
+
"US_PASSPORT_NUMBER",
|
|
486
|
+
"US_SOCIAL_SECURITY_NUMBER",
|
|
487
|
+
"VEHICLE_IDENTIFICATION_NUMBER"
|
|
488
|
+
),
|
|
489
|
+
action: Schema.Literal("ANONYMIZED", "BLOCKED", "NONE"),
|
|
490
|
+
match: Schema.String,
|
|
491
|
+
detected: Schema.optional(Schema.Boolean)
|
|
492
|
+
}) {}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* @since 1.0.0
|
|
496
|
+
* @category Schemas
|
|
497
|
+
*/
|
|
498
|
+
export class GuardrailRegexFilter extends Schema.Class<GuardrailRegexFilter>(
|
|
499
|
+
makeIdentifier("GuardrailRegexFilter")
|
|
500
|
+
)({
|
|
501
|
+
action: Schema.Literal("ANONYMIZED", "BLOCKED", "NONE"),
|
|
502
|
+
name: Schema.optional(Schema.String),
|
|
503
|
+
match: Schema.optional(Schema.String),
|
|
504
|
+
regex: Schema.optional(Schema.String),
|
|
505
|
+
detected: Schema.optional(Schema.Boolean)
|
|
506
|
+
}) {}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* @since 1.0.0
|
|
510
|
+
* @category Schemas
|
|
511
|
+
*/
|
|
512
|
+
export class GuardrailSensitiveInformationPolicyAssessment
|
|
513
|
+
extends Schema.Class<GuardrailSensitiveInformationPolicyAssessment>(
|
|
514
|
+
makeIdentifier("GuardrailSensitiveInformationPolicyAssessment")
|
|
515
|
+
)({
|
|
516
|
+
piiEntities: Schema.Array(GuardrailPiiEntityFilter),
|
|
517
|
+
regexes: Schema.Array(GuardrailRegexFilter)
|
|
518
|
+
})
|
|
519
|
+
{}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* @since 1.0.0
|
|
523
|
+
* @category Schemas
|
|
524
|
+
*/
|
|
525
|
+
export class GuardrailTopic extends Schema.Class<GuardrailTopic>(makeIdentifier("GuardrailTopic"))({
|
|
526
|
+
action: Schema.Literal("BLOCKED", "NONE"),
|
|
527
|
+
name: Schema.String,
|
|
528
|
+
type: Schema.Literal("DENY"),
|
|
529
|
+
detected: Schema.optional(Schema.Boolean)
|
|
530
|
+
}) {}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* @since 1.0.0
|
|
534
|
+
* @category Schemas
|
|
535
|
+
*/
|
|
536
|
+
export class GuardrailTopicPolicyAssessment extends Schema.Class<GuardrailTopicPolicyAssessment>(
|
|
537
|
+
makeIdentifier("GuardrailTopicPolicyAssessment")
|
|
538
|
+
)({
|
|
539
|
+
topics: Schema.Array(GuardrailTopic)
|
|
540
|
+
}) {}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @since 1.0.0
|
|
544
|
+
* @category Schemas
|
|
545
|
+
*/
|
|
546
|
+
export class GuardrailCustomWord extends Schema.Class<GuardrailCustomWord>(
|
|
547
|
+
makeIdentifier("GuardrailCustomWord")
|
|
548
|
+
)({
|
|
549
|
+
action: Schema.Literal("BLOCKED", "NONE"),
|
|
550
|
+
match: Schema.String,
|
|
551
|
+
detected: Schema.optional(Schema.Boolean)
|
|
552
|
+
}) {}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* @since 1.0.0
|
|
556
|
+
* @category Schemas
|
|
557
|
+
*/
|
|
558
|
+
export class GuardrailManagedWord extends Schema.Class<GuardrailManagedWord>(
|
|
559
|
+
makeIdentifier("GuardrailManagedWord")
|
|
560
|
+
)({
|
|
561
|
+
action: Schema.Literal("BLOCKED", "NONE"),
|
|
562
|
+
match: Schema.String,
|
|
563
|
+
type: Schema.Literal("PROFANITY"),
|
|
564
|
+
detected: Schema.optional(Schema.Boolean)
|
|
565
|
+
}) {}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* @since 1.0.0
|
|
569
|
+
* @category Schemas
|
|
570
|
+
*/
|
|
571
|
+
export class GuardrailWordPolicyAssessment extends Schema.Class<GuardrailWordPolicyAssessment>(
|
|
572
|
+
makeIdentifier("GuardrailWordPolicyAssessment")
|
|
573
|
+
)({
|
|
574
|
+
customWords: GuardrailCustomWord,
|
|
575
|
+
managedWordLists: GuardrailManagedWord
|
|
576
|
+
}) {}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* @since 1.0.0
|
|
580
|
+
* @category Schemas
|
|
581
|
+
*/
|
|
582
|
+
export class GuardrailAssessment extends Schema.Class<GuardrailAssessment>(makeIdentifier("GuardrailAssessment"))({
|
|
583
|
+
contentPolicy: Schema.optional(GuardrailContentPolicyAssessment),
|
|
584
|
+
contextualGroundingPolicy: Schema.optional(GuardrailContextualGroundingPolicyAssessment),
|
|
585
|
+
invocationMetrics: Schema.optional(GuardrailInvocationMetrics),
|
|
586
|
+
sensitiveInformationPolicy: Schema.optional(GuardrailSensitiveInformationPolicyAssessment),
|
|
587
|
+
topicPolicy: Schema.optional(GuardrailTopicPolicyAssessment),
|
|
588
|
+
wordPolicy: Schema.optional(GuardrailWordPolicyAssessment)
|
|
589
|
+
}) {}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* @since 1.0.0
|
|
593
|
+
* @category Schemas
|
|
594
|
+
*/
|
|
595
|
+
export class GuardrailTraceAssessment extends Schema.Class<GuardrailTraceAssessment>(
|
|
596
|
+
makeIdentifier("GuardrailTraceAssessment")
|
|
597
|
+
)({
|
|
598
|
+
actionReason: Schema.optional(Schema.String),
|
|
599
|
+
inputAssessment: Schema.optional(Schema.Record({
|
|
600
|
+
key: Schema.String,
|
|
601
|
+
value: GuardrailAssessment
|
|
602
|
+
})),
|
|
603
|
+
modelOutput: Schema.optional(Schema.Array(Schema.String)),
|
|
604
|
+
outputAssessments: Schema.optional(Schema.Record({
|
|
605
|
+
key: Schema.String,
|
|
606
|
+
value: GuardrailAssessment
|
|
607
|
+
}))
|
|
608
|
+
}) {}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* @since 1.0.0
|
|
612
|
+
* @category Schemas
|
|
613
|
+
*/
|
|
614
|
+
export class PromptRouterTrace extends Schema.Class<PromptRouterTrace>(makeIdentifier("PromptRouterTrace"))({
|
|
615
|
+
invokedModelId: Schema.String.pipe(
|
|
616
|
+
Schema.pattern(
|
|
617
|
+
/^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}::foundation-model\/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([a-z0-9-]{1,63}[.]){0,2}[a-z0-9-]{1,63}([:][a-z0-9-]{1,63}){0,2})|(arn:aws(|-us-gov|-cn|-iso|-iso-b):bedrock:(|[0-9a-z-]{1,20}):(|[0-9]{12}):inference-profile\/[a-zA-Z0-9-:.]+)$/
|
|
618
|
+
),
|
|
619
|
+
Schema.optional
|
|
620
|
+
)
|
|
621
|
+
}) {}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* @since 1.0.0
|
|
625
|
+
* @category Schemas
|
|
626
|
+
*/
|
|
627
|
+
export class ConverseTrace extends Schema.Class<ConverseTrace>(makeIdentifier("ConverseTrace"))({
|
|
628
|
+
guardrail: Schema.optional(GuardrailTraceAssessment),
|
|
629
|
+
promptRouter: Schema.optional(PromptRouterTrace)
|
|
630
|
+
}) {}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* @since 1.0.0
|
|
634
|
+
* @category Schemas
|
|
635
|
+
*/
|
|
636
|
+
export const IntZeroOrGreater = Schema.Int.pipe(Schema.greaterThanOrEqualTo(0))
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* @since 1.0.0
|
|
640
|
+
* @category Schemas
|
|
641
|
+
*/
|
|
642
|
+
export class TokenUsage extends Schema.Class<TokenUsage>(makeIdentifier("TokenUsage"))({
|
|
643
|
+
inputTokens: IntZeroOrGreater,
|
|
644
|
+
outputTokens: IntZeroOrGreater,
|
|
645
|
+
totalTokens: IntZeroOrGreater,
|
|
646
|
+
cacheReadInputTokens: Schema.optional(IntZeroOrGreater),
|
|
647
|
+
cacheWriteInputTokens: Schema.optional(IntZeroOrGreater)
|
|
648
|
+
}) {}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* @since 1.0.0
|
|
652
|
+
* @category Schemas
|
|
653
|
+
*/
|
|
654
|
+
export class SystemContentBlock extends Schema.Union(
|
|
655
|
+
Schema.Struct({ cachePoint: CachePointBlock }),
|
|
656
|
+
Schema.Struct({ guardContent: GuardrailConverseContentBlock }),
|
|
657
|
+
Schema.Struct({ text: Schema.String.pipe(Schema.minLength(1)) })
|
|
658
|
+
) {}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* @since 1.0.0
|
|
662
|
+
* @category Schemas
|
|
663
|
+
*/
|
|
664
|
+
export class GuardrailConfiguration extends Schema.Class<GuardrailConfiguration>(
|
|
665
|
+
makeIdentifier("GuardrailConfiguration")
|
|
666
|
+
)({
|
|
667
|
+
guardrailIdentifier: Schema.String.pipe(
|
|
668
|
+
Schema.minLength(0),
|
|
669
|
+
Schema.maxLength(2048),
|
|
670
|
+
Schema.pattern(/^(([a-z0-9]+)|(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:guardrail\/[a-z0-9]+))$/)
|
|
671
|
+
),
|
|
672
|
+
guardrailVersion: Schema.String.pipe(
|
|
673
|
+
Schema.pattern(/^(([1-9][0-9]{0,7})|(DRAFT))$/)
|
|
674
|
+
),
|
|
675
|
+
trace: Schema.optional(Schema.Literal("enabled", "disabled", "enabled_full"))
|
|
676
|
+
}) {}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* @since 1.0.0
|
|
680
|
+
* @category Schemas
|
|
681
|
+
*/
|
|
682
|
+
export class InferenceConfiguration extends Schema.Class<InferenceConfiguration>(
|
|
683
|
+
makeIdentifier("InferenceConfiguration")
|
|
684
|
+
)({
|
|
685
|
+
maxTokens: Schema.optional(Schema.Int.pipe(Schema.greaterThanOrEqualTo(1))),
|
|
686
|
+
stopSequences: Schema.optional(
|
|
687
|
+
Schema.Array(Schema.String.pipe(
|
|
688
|
+
Schema.minLength(1)
|
|
689
|
+
)).pipe(
|
|
690
|
+
Schema.maxItems(4)
|
|
691
|
+
)
|
|
692
|
+
),
|
|
693
|
+
temperature: Schema.Number.pipe(Schema.between(0, 1)),
|
|
694
|
+
topP: Schema.Number.pipe(Schema.between(0, 1))
|
|
695
|
+
}) {}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* @since 1.0.0
|
|
699
|
+
* @category Schemas
|
|
700
|
+
*/
|
|
701
|
+
export class PerformanceConfiguration extends Schema.Class<PerformanceConfiguration>(
|
|
702
|
+
makeIdentifier("PerformanceConfiguration")
|
|
703
|
+
)({
|
|
704
|
+
latency: Schema.optional(Schema.Literal("standard", "optimized"))
|
|
705
|
+
}) {}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* @since 1.0.0
|
|
709
|
+
* @category Schemas
|
|
710
|
+
*/
|
|
711
|
+
export class ToolSpecification extends Schema.Class<ToolSpecification>(
|
|
712
|
+
makeIdentifier("ToolSpecification")
|
|
713
|
+
)({
|
|
714
|
+
name: Schema.String.pipe(
|
|
715
|
+
Schema.minLength(1),
|
|
716
|
+
Schema.maxLength(64),
|
|
717
|
+
Schema.pattern(/^[a-zA-Z0-9_-]+$/)
|
|
718
|
+
),
|
|
719
|
+
inputSchema: Schema.Struct({
|
|
720
|
+
json: Schema.Record({
|
|
721
|
+
key: Schema.String,
|
|
722
|
+
value: Schema.Unknown
|
|
723
|
+
})
|
|
724
|
+
}),
|
|
725
|
+
description: Schema.optional(Schema.String.pipe(
|
|
726
|
+
Schema.minLength(1)
|
|
727
|
+
))
|
|
728
|
+
}) {}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* @since 1.0.0
|
|
732
|
+
* @category Schemas
|
|
733
|
+
*/
|
|
734
|
+
export class Tool extends Schema.Class<Tool>(
|
|
735
|
+
makeIdentifier("Tool")
|
|
736
|
+
)({
|
|
737
|
+
cachePoint: Schema.optional(CachePointBlock),
|
|
738
|
+
toolSpec: Schema.optional(ToolSpecification)
|
|
739
|
+
}) {}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* @since 1.0.0
|
|
743
|
+
* @category Schemas
|
|
744
|
+
*/
|
|
745
|
+
export class ToolChoice extends Schema.Union(
|
|
746
|
+
Schema.Struct({ any: Schema.Struct({}) }),
|
|
747
|
+
Schema.Struct({ auto: Schema.Struct({}) }),
|
|
748
|
+
Schema.Struct({
|
|
749
|
+
tool: Schema.Struct({
|
|
750
|
+
name: Schema.String.pipe(
|
|
751
|
+
Schema.minLength(1),
|
|
752
|
+
Schema.maxLength(64),
|
|
753
|
+
Schema.pattern(/^[a-zA-Z0-9_-]+$/)
|
|
754
|
+
)
|
|
755
|
+
})
|
|
756
|
+
})
|
|
757
|
+
) {}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* @since 1.0.0
|
|
761
|
+
* @category Schemas
|
|
762
|
+
*/
|
|
763
|
+
export class ToolConfiguration extends Schema.Class<ToolConfiguration>(
|
|
764
|
+
makeIdentifier("ToolConfiguration")
|
|
765
|
+
)({
|
|
766
|
+
tools: Schema.Array(Tool).pipe(Schema.minItems(1)),
|
|
767
|
+
toolChoice: Schema.optional(ToolChoice)
|
|
768
|
+
}) {}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* @since 1.0.0
|
|
772
|
+
* @category Schemas
|
|
773
|
+
*/
|
|
774
|
+
export class ConverseRequest extends Schema.Class<ConverseRequest>(makeIdentifier("ConverseRequest"))({
|
|
775
|
+
modelId: Schema.String,
|
|
776
|
+
messages: Schema.Array(Message),
|
|
777
|
+
system: Schema.optional(Schema.Array(SystemContentBlock)),
|
|
778
|
+
toolConfig: Schema.optional(ToolConfiguration),
|
|
779
|
+
guardrailConfig: Schema.optional(GuardrailConfiguration),
|
|
780
|
+
inferenceConfig: Schema.optional(InferenceConfiguration),
|
|
781
|
+
performanceConfig: Schema.optional(PerformanceConfiguration),
|
|
782
|
+
promptVariables: Schema.optional(Schema.Record({
|
|
783
|
+
key: Schema.String,
|
|
784
|
+
value: Schema.Struct({ text: Schema.String })
|
|
785
|
+
})),
|
|
786
|
+
requestMetadata: Schema.optional(Schema.Record({
|
|
787
|
+
key: Schema.String.pipe(
|
|
788
|
+
Schema.minLength(1),
|
|
789
|
+
Schema.maxLength(256),
|
|
790
|
+
Schema.pattern(/^[a-zA-Z0-9\s:_@$#=/+,-.]{1,256}$/)
|
|
791
|
+
),
|
|
792
|
+
value: Schema.String.pipe(
|
|
793
|
+
Schema.minLength(0),
|
|
794
|
+
Schema.maxLength(256),
|
|
795
|
+
Schema.pattern(/^[a-zA-Z0-9\s:_@$#=/+,-.]{0,256}$/)
|
|
796
|
+
)
|
|
797
|
+
})),
|
|
798
|
+
additionalModelRequestFields: Schema.optional(Schema.Record({
|
|
799
|
+
key: Schema.String,
|
|
800
|
+
value: Schema.Unknown
|
|
801
|
+
})),
|
|
802
|
+
additionalModelResponseFieldPaths: Schema.optional(
|
|
803
|
+
Schema.Array(Schema.String.pipe(
|
|
804
|
+
Schema.minLength(1),
|
|
805
|
+
Schema.maxLength(256)
|
|
806
|
+
)).pipe(
|
|
807
|
+
Schema.maxItems(10)
|
|
808
|
+
)
|
|
809
|
+
)
|
|
810
|
+
}) {}
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* @since 1.0.0
|
|
814
|
+
* @category Schemas
|
|
815
|
+
*/
|
|
816
|
+
export class ConverseResponse extends Schema.Class<ConverseResponse>(makeIdentifier("ConverseResponse"))({
|
|
817
|
+
output: ConverseOutput,
|
|
818
|
+
metrics: ConverseMetrics,
|
|
819
|
+
usage: TokenUsage,
|
|
820
|
+
stopReason: Schema.Literal(
|
|
821
|
+
"content_filtered",
|
|
822
|
+
"end_turn",
|
|
823
|
+
"tool_use",
|
|
824
|
+
"max_tokens",
|
|
825
|
+
"stop_sequence",
|
|
826
|
+
"guardrail_intervened"
|
|
827
|
+
),
|
|
828
|
+
trace: Schema.optional(ConverseTrace),
|
|
829
|
+
performanceConfig: Schema.optional(Schema.Struct({
|
|
830
|
+
latency: Schema.Literal("standard", "optimized")
|
|
831
|
+
})),
|
|
832
|
+
additionalModelResponseFields: Schema.optional(Schema.Record({
|
|
833
|
+
key: Schema.String,
|
|
834
|
+
value: Schema.Unknown
|
|
835
|
+
}))
|
|
836
|
+
}) {}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* @since 1.0.0
|
|
840
|
+
* @category Schemas
|
|
841
|
+
*/
|
|
842
|
+
export class ReasoningContentBlockDelta extends Schema.Union(
|
|
843
|
+
Schema.Struct({ redactedContent: Schema.Uint8ArrayFromBase64 }),
|
|
844
|
+
Schema.Struct({ signature: Schema.String }),
|
|
845
|
+
Schema.Struct({ text: Schema.String })
|
|
846
|
+
) {}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* @since 1.0.0
|
|
850
|
+
* @category Schemas
|
|
851
|
+
*/
|
|
852
|
+
export class ToolUseBlockStart extends Schema.Class<ToolUseBlockStart>(
|
|
853
|
+
makeIdentifier("ToolUseBlockStart")
|
|
854
|
+
)({
|
|
855
|
+
name: Schema.String.pipe(
|
|
856
|
+
Schema.minLength(1),
|
|
857
|
+
Schema.maxLength(64),
|
|
858
|
+
Schema.pattern(/^[a-zA-Z0-9_-]+$/)
|
|
859
|
+
),
|
|
860
|
+
toolUseId: Schema.String.pipe(
|
|
861
|
+
Schema.minLength(1),
|
|
862
|
+
Schema.maxLength(64),
|
|
863
|
+
Schema.pattern(/^[a-zA-Z0-9_-]+$/)
|
|
864
|
+
)
|
|
865
|
+
}) {}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* @since 1.0.0
|
|
869
|
+
* @category Schemas
|
|
870
|
+
*/
|
|
871
|
+
export class ContentBlockStart extends Schema.Class<ContentBlockStart>(
|
|
872
|
+
makeIdentifier("ContentBlockStart")
|
|
873
|
+
)({
|
|
874
|
+
toolUse: ToolUseBlockStart
|
|
875
|
+
}) {}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* @since 1.0.0
|
|
879
|
+
* @category Schemas
|
|
880
|
+
*/
|
|
881
|
+
export class ContentBlockStartEvent extends Schema.Class<ContentBlockStartEvent>(
|
|
882
|
+
makeIdentifier("ContentBlockStartEvent")
|
|
883
|
+
)({
|
|
884
|
+
contentBlockIndex: Schema.Int.pipe(Schema.greaterThanOrEqualTo(0)),
|
|
885
|
+
start: ContentBlockStart
|
|
886
|
+
}) {}
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* @since 1.0.0
|
|
890
|
+
* @category Schemas
|
|
891
|
+
*/
|
|
892
|
+
export class ContentBlockStopEvent extends Schema.Class<ContentBlockStopEvent>(
|
|
893
|
+
makeIdentifier("ContentBlockStopEvent")
|
|
894
|
+
)({
|
|
895
|
+
contentBlockIndex: Schema.Int.pipe(Schema.greaterThanOrEqualTo(0))
|
|
896
|
+
}) {}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* @since 1.0.0
|
|
900
|
+
* @category Schemas
|
|
901
|
+
*/
|
|
902
|
+
export class ToolUseBlockDelta extends Schema.Class<ToolUseBlockDelta>(
|
|
903
|
+
makeIdentifier("ToolUseBlockDelta")
|
|
904
|
+
)({
|
|
905
|
+
input: Schema.String
|
|
906
|
+
}) {}
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* @since 1.0.0
|
|
910
|
+
* @category Schemas
|
|
911
|
+
*/
|
|
912
|
+
export class ContentBlockDelta extends Schema.Union(
|
|
913
|
+
Schema.Struct({ reasoningContent: ReasoningContentBlockDelta }),
|
|
914
|
+
Schema.Struct({ text: Schema.String }),
|
|
915
|
+
Schema.Struct({ toolUse: ToolUseBlockDelta })
|
|
916
|
+
) {}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* @since 1.0.0
|
|
920
|
+
* @category Schemas
|
|
921
|
+
*/
|
|
922
|
+
export class ContentBlockDeltaEvent extends Schema.Class<ContentBlockDeltaEvent>(
|
|
923
|
+
makeIdentifier("ContentBlockDeltaEvent")
|
|
924
|
+
)({
|
|
925
|
+
contentBlockIndex: Schema.Int.pipe(Schema.greaterThanOrEqualTo(0)),
|
|
926
|
+
delta: ContentBlockDelta
|
|
927
|
+
}) {}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* @since 1.0.0
|
|
931
|
+
* @category Schemas
|
|
932
|
+
*/
|
|
933
|
+
export class MessageStartEvent extends Schema.Class<MessageStartEvent>(
|
|
934
|
+
makeIdentifier("MessageStartEvent")
|
|
935
|
+
)({
|
|
936
|
+
role: Schema.Literal("user", "assistant")
|
|
937
|
+
}) {}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* @since 1.0.0
|
|
941
|
+
* @category Schemas
|
|
942
|
+
*/
|
|
943
|
+
export const StopReason = Schema.Literal(
|
|
944
|
+
"end_turn",
|
|
945
|
+
"tool_use",
|
|
946
|
+
"max_tokens",
|
|
947
|
+
"stop_sequence",
|
|
948
|
+
"guardrail_intervened",
|
|
949
|
+
"content_filtered"
|
|
950
|
+
)
|
|
951
|
+
/**
|
|
952
|
+
* @since 1.0.0
|
|
953
|
+
* @category Schemas
|
|
954
|
+
*/
|
|
955
|
+
export type StopReason = typeof StopReason.Type
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* @since 1.0.0
|
|
959
|
+
* @category Schemas
|
|
960
|
+
*/
|
|
961
|
+
export class MessageStopEvent extends Schema.Class<MessageStopEvent>(
|
|
962
|
+
makeIdentifier("MessageStopEvent")
|
|
963
|
+
)({
|
|
964
|
+
stopReason: StopReason,
|
|
965
|
+
additionalModelResponseFields: Schema.optional(Schema.Record({
|
|
966
|
+
key: Schema.String,
|
|
967
|
+
value: Schema.Unknown
|
|
968
|
+
}))
|
|
969
|
+
}) {}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* @since 1.0.0
|
|
973
|
+
* @category Schemas
|
|
974
|
+
*/
|
|
975
|
+
export class ConverseStreamMetrics extends Schema.Class<ConverseStreamMetrics>(
|
|
976
|
+
makeIdentifier("ConverseStreamMetrics")
|
|
977
|
+
)({
|
|
978
|
+
latencyMs: Schema.DurationFromMillis
|
|
979
|
+
}) {}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* @since 1.0.0
|
|
983
|
+
* @category Schemas
|
|
984
|
+
*/
|
|
985
|
+
export class ConverseStreamTrace extends Schema.Class<ConverseStreamTrace>(
|
|
986
|
+
makeIdentifier("ConverseStreamTrace")
|
|
987
|
+
)({
|
|
988
|
+
guardrail: Schema.optional(GuardrailTraceAssessment),
|
|
989
|
+
promptRouter: Schema.optional(PromptRouterTrace)
|
|
990
|
+
}) {}
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* @since 1.0.0
|
|
994
|
+
* @category Schemas
|
|
995
|
+
*/
|
|
996
|
+
export class ConverseStreamMetadataEvent extends Schema.Class<ConverseStreamMetadataEvent>(
|
|
997
|
+
makeIdentifier("ConverseStreamMetadataEvent")
|
|
998
|
+
)({
|
|
999
|
+
metrics: ConverseStreamMetrics,
|
|
1000
|
+
usage: TokenUsage,
|
|
1001
|
+
performanceConfig: Schema.optional(PerformanceConfiguration),
|
|
1002
|
+
trace: Schema.optional(ConverseStreamTrace)
|
|
1003
|
+
}) {}
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* @since 1.0.0
|
|
1007
|
+
* @category Schemas
|
|
1008
|
+
*/
|
|
1009
|
+
export class ConverseStreamResponse extends Schema.Class<ConverseStreamResponse>(
|
|
1010
|
+
makeIdentifier("ConverseStreamResponse")
|
|
1011
|
+
)({
|
|
1012
|
+
contentBlockStart: Schema.optional(ContentBlockStartEvent),
|
|
1013
|
+
contentBlockStop: Schema.optional(ContentBlockStopEvent),
|
|
1014
|
+
contentBlockDelta: Schema.optional(ContentBlockDeltaEvent),
|
|
1015
|
+
messageStart: Schema.optional(MessageStartEvent),
|
|
1016
|
+
messageStop: Schema.optional(MessageStopEvent),
|
|
1017
|
+
metadata: Schema.optional(ConverseStreamMetadataEvent),
|
|
1018
|
+
internalServerException: Schema.optional(Schema.Record({
|
|
1019
|
+
key: Schema.String,
|
|
1020
|
+
value: Schema.Unknown
|
|
1021
|
+
})),
|
|
1022
|
+
modelStreamErrorException: Schema.optional(Schema.Record({
|
|
1023
|
+
key: Schema.String,
|
|
1024
|
+
value: Schema.Unknown
|
|
1025
|
+
})),
|
|
1026
|
+
serviceUnavailableException: Schema.optional(Schema.Record({
|
|
1027
|
+
key: Schema.String,
|
|
1028
|
+
value: Schema.Unknown
|
|
1029
|
+
})),
|
|
1030
|
+
throttlingException: Schema.optional(Schema.Record({
|
|
1031
|
+
key: Schema.String,
|
|
1032
|
+
value: Schema.Unknown
|
|
1033
|
+
})),
|
|
1034
|
+
validationException: Schema.optional(Schema.Record({
|
|
1035
|
+
key: Schema.String,
|
|
1036
|
+
value: Schema.Unknown
|
|
1037
|
+
}))
|
|
1038
|
+
}) {}
|