@aeye/aws 0.3.8 → 0.4.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/README.md +73 -1
- package/aeye-aws.md +171 -0
- package/dist/aws.d.ts +56 -16
- package/dist/aws.d.ts.map +1 -1
- package/dist/aws.js +255 -321
- package/dist/aws.js.map +1 -1
- package/dist/converse.d.ts +143 -0
- package/dist/converse.d.ts.map +1 -0
- package/dist/converse.js +483 -0
- package/dist/converse.js.map +1 -0
- package/package.json +74 -73
package/README.md
CHANGED
|
@@ -7,6 +7,10 @@ AWS Bedrock integration for the [@aeye](https://github.com/ClickerMonkey/aeye) f
|
|
|
7
7
|
- 🤖 **Multi-Model Support** - Access to all AWS Bedrock foundation models
|
|
8
8
|
- 🔐 **Automatic Authentication** - Uses AWS SDK credential chain for seamless authentication
|
|
9
9
|
- 🌊 **Streaming** - Full streaming support for real-time responses
|
|
10
|
+
- 🧠 **Reasoning** - Claude adaptive and budgeted thinking, Nova and gpt-oss reasoning, with reasoning blocks replayed across turns
|
|
11
|
+
- 📐 **Structured Output** - Converse JSON-schema output and strict tools
|
|
12
|
+
- 💾 **Prompt Caching** - Cache points from `cacheBreakpoint`, with cache read/write usage
|
|
13
|
+
- 📄 **Documents, Images, Video** - Bytes or S3 locations
|
|
10
14
|
- 🎨 **Image Generation** - Stability AI models for image creation
|
|
11
15
|
- 📊 **Embeddings** - Amazon Titan embeddings for semantic search
|
|
12
16
|
- 🔧 **Type-Safe** - Full TypeScript support with type inference
|
|
@@ -15,7 +19,10 @@ AWS Bedrock integration for the [@aeye](https://github.com/ClickerMonkey/aeye) f
|
|
|
15
19
|
## Supported Models
|
|
16
20
|
|
|
17
21
|
### Chat Models
|
|
18
|
-
- **Anthropic Claude** - Claude 3
|
|
22
|
+
- **Anthropic Claude** - Claude 3.x through 5.x
|
|
23
|
+
- **Amazon Nova** - Nova and Nova 2
|
|
24
|
+
- **OpenAI** - gpt-oss
|
|
25
|
+
- **Open-weight models** - DeepSeek, Qwen, Kimi, MiniMax, and more
|
|
19
26
|
- **Meta Llama** - Llama 2, Llama 3, Llama 3.1, Llama 3.2
|
|
20
27
|
- **Mistral AI** - Mistral 7B, Mixtral 8x7B, Mistral Large
|
|
21
28
|
- **Cohere** - Command, Command Light, Command R, Command R+
|
|
@@ -157,6 +164,16 @@ const config: AWSBedrockConfig = {
|
|
|
157
164
|
sessionToken: process.env.AWS_SESSION_TOKEN, // Optional
|
|
158
165
|
},
|
|
159
166
|
|
|
167
|
+
// Optional: Inference profile prefix. Without one, models served only
|
|
168
|
+
// through inference profiles use the region's geography (or global) profile
|
|
169
|
+
modelPrefix: 'us.',
|
|
170
|
+
|
|
171
|
+
// Optional: Latency-optimized inference, where the model offers it
|
|
172
|
+
latency: 'optimized',
|
|
173
|
+
|
|
174
|
+
// Optional: Guardrail applied to every chat request
|
|
175
|
+
guardrail: { guardrailIdentifier: 'gr-abc123', guardrailVersion: '1' },
|
|
176
|
+
|
|
160
177
|
// Optional: Default models for different capabilities
|
|
161
178
|
defaultModels: {
|
|
162
179
|
chat: 'anthropic.claude-3-sonnet-20240229-v1:0',
|
|
@@ -289,6 +306,58 @@ const response = await ai.chat.get([
|
|
|
289
306
|
});
|
|
290
307
|
```
|
|
291
308
|
|
|
309
|
+
### Documents, Video, and S3
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
const response = await ai.chat.get([
|
|
313
|
+
{
|
|
314
|
+
role: 'user',
|
|
315
|
+
content: [
|
|
316
|
+
{ type: 'text', content: 'Summarize the report and the clip.' },
|
|
317
|
+
{ type: 'file', content: 's3://my-bucket/q3-report.pdf', name: 'Q3 report.pdf' },
|
|
318
|
+
{ type: 'video', content: 's3://my-bucket/clip.mp4' },
|
|
319
|
+
],
|
|
320
|
+
},
|
|
321
|
+
], {
|
|
322
|
+
model: 'amazon.nova-pro-v1:0',
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
`s3://` URIs are sent as S3 locations; other content is sent as bytes. The
|
|
327
|
+
format comes from `format`, the MIME type, or the file extension.
|
|
328
|
+
|
|
329
|
+
### Reasoning
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
const response = await ai.chat.get([
|
|
333
|
+
{ role: 'user', content: 'Prove that there are infinitely many primes.' },
|
|
334
|
+
], {
|
|
335
|
+
model: 'anthropic.claude-opus-4-7',
|
|
336
|
+
reason: { effort: 'high' },
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
console.log(response.reasoning?.content);
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Claude 4.6+ thinks adaptively (`thinking.type: 'adaptive'` with
|
|
343
|
+
`outputConfig.effort`), earlier Claude takes a thinking budget, Nova 2 takes
|
|
344
|
+
`reasoningConfig`, and gpt-oss takes `reasoning_effort`. Reasoning blocks keep
|
|
345
|
+
their signatures and redacted content, and are sent back with the assistant
|
|
346
|
+
message on later turns, as Claude requires while it uses tools.
|
|
347
|
+
|
|
348
|
+
### Prompt Caching
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
const response = await ai.chat.get([
|
|
352
|
+
{ role: 'system', content: [{ type: 'text', content: longInstructions, cacheBreakpoint: true }] },
|
|
353
|
+
{ role: 'user', content: 'First question' },
|
|
354
|
+
], {
|
|
355
|
+
model: 'anthropic.claude-sonnet-4-5-20250929-v1:0',
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
console.log(response.usage?.text?.cached, response.usage?.text?.cacheWrite);
|
|
359
|
+
```
|
|
360
|
+
|
|
292
361
|
### Custom Request Parameters
|
|
293
362
|
|
|
294
363
|
```typescript
|
|
@@ -300,6 +369,9 @@ const response = await ai.chat.get([
|
|
|
300
369
|
maxTokens: 2048,
|
|
301
370
|
topP: 0.9,
|
|
302
371
|
stop: ['Human:', 'Assistant:'],
|
|
372
|
+
serviceTier: 'flex', // Converse serviceTier (fast → priority)
|
|
373
|
+
metadata: { team: 'search' }, // Converse requestMetadata
|
|
374
|
+
extra: { top_k: 50 }, // additionalModelRequestFields
|
|
303
375
|
});
|
|
304
376
|
```
|
|
305
377
|
|
package/aeye-aws.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @aeye/aws
|
|
2
|
+
|
|
3
|
+
One-line purpose: AWS Bedrock provider for `@aeye/ai` — chat (Claude, Llama, Mistral, Cohere, etc.) through the unified **Converse API**, plus Stability AI image generation and Amazon Titan embeddings, using AWS SDK v3 credential discovery.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
- You want Bedrock-hosted foundation models behind the `@aeye/ai` interface.
|
|
8
|
+
- You need AWS-native auth (IAM roles, SSO, env credentials) rather than a single API key.
|
|
9
|
+
- You want one request/response shape across model families (the Converse API handles this).
|
|
10
|
+
|
|
11
|
+
## Install / import
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @aeye/aws
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The AWS SDK v3 clients (`@aws-sdk/client-bedrock`, `@aws-sdk/client-bedrock-runtime`) ship as dependencies — no separate peer install.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import {
|
|
21
|
+
AWSBedrockProvider,
|
|
22
|
+
type AWSBedrockConfig,
|
|
23
|
+
// errors
|
|
24
|
+
AWSError,
|
|
25
|
+
AWSAuthError,
|
|
26
|
+
AWSRateLimitError,
|
|
27
|
+
AWSQuotaError,
|
|
28
|
+
AWSContextWindowError,
|
|
29
|
+
// model family typing
|
|
30
|
+
type BedrockModelFamily,
|
|
31
|
+
type ModelFamilyConfig,
|
|
32
|
+
} from '@aeye/aws';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The provider's registry name is `aws-bedrock`.
|
|
36
|
+
|
|
37
|
+
## Register with an `@aeye/ai` instance
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { AI } from '@aeye/ai';
|
|
41
|
+
import { AWSBedrockProvider } from '@aeye/aws';
|
|
42
|
+
|
|
43
|
+
const aws = new AWSBedrockProvider({
|
|
44
|
+
region: 'us-east-1', // optional; falls back to AWS_REGION env, then 'us-east-1'
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const ai = AI.with()
|
|
48
|
+
.providers({ aws })
|
|
49
|
+
.create({ /* ... */ });
|
|
50
|
+
|
|
51
|
+
// Chat with Claude on Bedrock (model id selected via metadata)
|
|
52
|
+
const response = await ai.chat.get(
|
|
53
|
+
{ messages: [{ role: 'user', content: 'Hello' }] },
|
|
54
|
+
{ metadata: { model: 'anthropic.claude-3-5-sonnet-20241022-v2:0' } }
|
|
55
|
+
);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Direct (no facade):
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const executor = aws.createExecutor();
|
|
62
|
+
await executor(
|
|
63
|
+
{ messages: [{ role: 'user', content: 'Hi' }] },
|
|
64
|
+
{},
|
|
65
|
+
{ model: 'anthropic.claude-3-sonnet-20240229-v1:0' }
|
|
66
|
+
);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Authentication / credentials
|
|
70
|
+
|
|
71
|
+
The provider builds AWS SDK clients and relies on the **default AWS credential chain**. Explicit credentials are only applied when both `accessKeyId` **and** `secretAccessKey` are present in config; otherwise the SDK resolves credentials automatically:
|
|
72
|
+
|
|
73
|
+
1. Explicit `config.credentials` (requires both access key + secret key).
|
|
74
|
+
2. Environment variables `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` (+ optional `AWS_SESSION_TOKEN`).
|
|
75
|
+
3. Shared credentials file `~/.aws/credentials`.
|
|
76
|
+
4. IAM roles (EC2 / ECS / Lambda).
|
|
77
|
+
5. SSO (`aws sso login`).
|
|
78
|
+
|
|
79
|
+
Region resolution: `config.region` → `process.env.AWS_REGION` → `'us-east-1'`.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Explicit (temporary) credentials
|
|
83
|
+
const aws = new AWSBedrockProvider({
|
|
84
|
+
region: 'us-west-2',
|
|
85
|
+
credentials: {
|
|
86
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
|
87
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
88
|
+
sessionToken: process.env.AWS_SESSION_TOKEN, // optional
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Configuration (`AWSBedrockConfig`)
|
|
94
|
+
|
|
95
|
+
| Field | Type | Notes |
|
|
96
|
+
|-------|------|-------|
|
|
97
|
+
| `region` | `string` | AWS region; defaults to `AWS_REGION` then `us-east-1` |
|
|
98
|
+
| `credentials` | `{ accessKeyId?, secretAccessKey?, sessionToken? }` | Only used when access key + secret are both set |
|
|
99
|
+
| `modelPrefix` | `string` | Prepended to every model id — for cross-region inference (`'us.'`, `'eu.'`, `'apac.'`) |
|
|
100
|
+
| `modelFamilies` | `Record<string, ModelFamilyConfig>` | Per-family enable/disable and model-id mapping |
|
|
101
|
+
| `defaultModels` | `{ chat?, imageGenerate?, embedding? }` | Fallback model per capability |
|
|
102
|
+
| `hooks` | `AWSBedrockHooks` | `chat` / `imageGenerate` / `embed` with `beforeRequest` / `afterRequest` |
|
|
103
|
+
|
|
104
|
+
Hooks receive the AWS SDK command object (e.g. `ConverseCommand`, `InvokeModelCommand`), so you can inspect/log the exact request.
|
|
105
|
+
|
|
106
|
+
## Cross-region inference
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const aws = new AWSBedrockProvider({ region: 'us-east-1', modelPrefix: 'us.' });
|
|
110
|
+
// model 'anthropic.claude-...' is sent as 'us.anthropic.claude-...'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Supported capabilities
|
|
114
|
+
|
|
115
|
+
| Capability | Implementation | Models |
|
|
116
|
+
|-----------|----------------|--------|
|
|
117
|
+
| Chat (+ streaming) | `ConverseCommand` / `ConverseStreamCommand` | Anthropic Claude, Meta Llama, Mistral, Cohere, AI21, Amazon Titan, etc. |
|
|
118
|
+
| Tools / function calling | Converse `toolConfig` | Claude and other tool-capable families |
|
|
119
|
+
| Vision | Converse image content blocks | Claude 3+ (see gotcha — base64 only) |
|
|
120
|
+
| Reasoning | Converse `reasoningContent` | Reasoning-capable Claude models |
|
|
121
|
+
| Image generation | `InvokeModelCommand` | Stability AI (SDXL / SD3) |
|
|
122
|
+
| Embeddings | `InvokeModelCommand` | Amazon Titan text embeddings |
|
|
123
|
+
|
|
124
|
+
There is **no** transcription or speech support in this provider.
|
|
125
|
+
|
|
126
|
+
Strict-schema families supported: `openai`, `anthropic`, `google`. Strict mode engages only when the resolved model's family is supported and the model declares `toolsStrict` / `structured`; otherwise it silently degrades to lenient schemas under a shared `SchemaBudget` (which respects Anthropic-style per-request limits).
|
|
127
|
+
|
|
128
|
+
## Usage examples
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// Streaming chat
|
|
132
|
+
for await (const chunk of ai.chat.stream(
|
|
133
|
+
{ messages: [{ role: 'user', content: 'Write a haiku' }] },
|
|
134
|
+
{ metadata: { model: 'anthropic.claude-3-5-sonnet-20241022-v2:0' } }
|
|
135
|
+
)) {
|
|
136
|
+
process.stdout.write(chunk.content ?? '');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Image generation (Stability AI)
|
|
140
|
+
const image = await ai.image.generate.get(
|
|
141
|
+
{ prompt: 'A mountain landscape', size: '1024x1024' },
|
|
142
|
+
{ metadata: { model: 'stability.stable-diffusion-xl-v1' } }
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// Embeddings (Titan)
|
|
146
|
+
const embeddings = await ai.embed.get(
|
|
147
|
+
{ texts: ['Hello world'] },
|
|
148
|
+
{ metadata: { model: 'amazon.titan-embed-text-v1' } }
|
|
149
|
+
);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Error types
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import {
|
|
156
|
+
AWSError, // base
|
|
157
|
+
AWSAuthError, // UnrecognizedClientException / InvalidSignatureException
|
|
158
|
+
AWSRateLimitError, // ThrottlingException / TooManyRequestsException
|
|
159
|
+
AWSQuotaError, // ServiceQuotaExceededException
|
|
160
|
+
AWSContextWindowError, // "context length" / "token limit" in message
|
|
161
|
+
} from '@aeye/aws';
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Gotchas
|
|
165
|
+
|
|
166
|
+
- **Vision is base64-only.** The Converse conversion only accepts `data:<type>;base64,...` image content (png/jpeg/gif/webp). Plain image URLs are dropped — fetch the bytes yourself and pass a data URI.
|
|
167
|
+
- **Titan embeddings only embed the first text.** The provider sends `request.texts[0]` and returns that single embedding duplicated once per input text. Call once per text if you need distinct vectors.
|
|
168
|
+
- **Model is always required** (no implicit default unless you set `defaultModels`); missing model throws `AWSError`.
|
|
169
|
+
- Consecutive same-role messages are merged automatically (Converse requirement); an empty conversation gets a synthetic user message.
|
|
170
|
+
- Image generation/embeddings use fixed defaults in the Stability payload (`cfg_scale: 7`, `steps: 30`); only `prompt`, `size`, and `seed` flow through.
|
|
171
|
+
- Model access must be enabled in your AWS account/region (some families, e.g. Anthropic, require a use-case submission in the Bedrock console).
|
package/dist/aws.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* All chat LLM calls use the Bedrock Converse API for a unified request/response format across models.
|
|
7
7
|
*/
|
|
8
8
|
import type { AIContextAny, AIMetadataAny, EmbeddingRequest, EmbeddingResponse, ImageGenerationRequest, ImageGenerationResponse, ModelInfo, Provider } from '@aeye/ai';
|
|
9
|
-
import { Executor, ModelInput, Request, Response, Streamer } from '@aeye/core';
|
|
10
|
-
import { ConverseCommand, ConverseStreamCommand, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime';
|
|
9
|
+
import { type DescriptorFamily, Executor, ModelInput, Request, Response, Streamer } from '@aeye/core';
|
|
10
|
+
import { ConverseCommand, ConverseStreamCommand, type GuardrailStreamConfiguration, InvokeModelCommand, type PerformanceConfigLatency } from '@aws-sdk/client-bedrock-runtime';
|
|
11
11
|
import { type ModelFamilyConfig } from './types';
|
|
12
12
|
/**
|
|
13
13
|
* Hook called before a request is made to the provider.
|
|
@@ -83,6 +83,8 @@ export interface AWSBedrockConfig {
|
|
|
83
83
|
sessionToken?: string;
|
|
84
84
|
};
|
|
85
85
|
modelPrefix?: string;
|
|
86
|
+
latency?: PerformanceConfigLatency;
|
|
87
|
+
guardrail?: GuardrailStreamConfiguration;
|
|
86
88
|
modelFamilies?: Record<string, ModelFamilyConfig>;
|
|
87
89
|
defaultModels?: {
|
|
88
90
|
chat?: ModelInput;
|
|
@@ -128,6 +130,7 @@ export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
|
|
|
128
130
|
defaultMetadata?: Provider['defaultMetadata'];
|
|
129
131
|
private bedrockClient;
|
|
130
132
|
private bedrockRuntimeClient;
|
|
133
|
+
private profileOnly;
|
|
131
134
|
constructor(config: AWSBedrockConfig);
|
|
132
135
|
/**
|
|
133
136
|
* Convert AWSBedrockConfig to BedrockClientConfig
|
|
@@ -160,7 +163,22 @@ export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
|
|
|
160
163
|
*/
|
|
161
164
|
createStreamer(config?: AWSBedrockConfig): Streamer<AIContextAny, AIMetadataAny>;
|
|
162
165
|
/**
|
|
163
|
-
*
|
|
166
|
+
* The id to call a chat model by. A configured `modelPrefix` picks a
|
|
167
|
+
* cross-region inference profile; otherwise a model Bedrock serves only
|
|
168
|
+
* through inference profiles (per the registry, or as Bedrock answered an
|
|
169
|
+
* earlier call in this region) uses the profile for the client region's
|
|
170
|
+
* geography, or the global one when only that is listed.
|
|
171
|
+
*/
|
|
172
|
+
private resolveModelId;
|
|
173
|
+
/**
|
|
174
|
+
* Make a chat call, and when Bedrock answers that the model needs an
|
|
175
|
+
* inference profile in this region (the registry's `inRegion` holds for
|
|
176
|
+
* the region it was gathered in), make it again by profile.
|
|
177
|
+
*/
|
|
178
|
+
private byProfileWhenRequired;
|
|
179
|
+
/**
|
|
180
|
+
* Build the Converse input from a generic @aeye/core Request, without the
|
|
181
|
+
* guardrail, whose shape differs between Converse and ConverseStream.
|
|
164
182
|
*/
|
|
165
183
|
private convertRequestToConverse;
|
|
166
184
|
/**
|
|
@@ -171,30 +189,52 @@ export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
|
|
|
171
189
|
* Execute a streaming chat completion using the Converse Stream API.
|
|
172
190
|
*/
|
|
173
191
|
private streamWithConverse;
|
|
174
|
-
/**
|
|
175
|
-
* Convert system messages to the Converse API system format.
|
|
176
|
-
*/
|
|
177
|
-
private convertSystemToConverse;
|
|
178
192
|
/**
|
|
179
193
|
* Convert @aeye/core messages to AWS Bedrock Converse API message format.
|
|
180
|
-
* Filters out system messages (handled via
|
|
194
|
+
* Filters out system messages (handled via toSystemBlocks).
|
|
181
195
|
* Merges consecutive messages with the same role as required by the API.
|
|
182
196
|
*/
|
|
183
197
|
private convertMessagesToConverse;
|
|
184
|
-
/**
|
|
185
|
-
* Convert an image content value to a Converse API ContentBlock.
|
|
186
|
-
* Only base64 data URIs are natively supported; URL images are not supported
|
|
187
|
-
* by the Converse API without fetching the bytes first.
|
|
188
|
-
*/
|
|
189
|
-
private convertImageContent;
|
|
190
198
|
/**
|
|
191
199
|
* Convert @aeye/core tool definitions to AWS Bedrock Converse API tool format.
|
|
200
|
+
*
|
|
201
|
+
* Strict-tool support is best-effort and per-model: the budget's
|
|
202
|
+
* descriptor comes from `buildSchemaBudget` (see `@aeye/ai`). Bedrock
|
|
203
|
+
* surfaces both Anthropic-family Claude models and (in some regions)
|
|
204
|
+
* OpenAI-shaped tools. Models without strict support use their family's
|
|
205
|
+
* non-strict descriptor, and models without a family Bedrock speaks fall
|
|
206
|
+
* back to LENIENT — silent degradation. Tools with a strict descriptor are
|
|
207
|
+
* sent with Converse's `strict` flag, which constrains the model's calls to
|
|
208
|
+
* the schema. The chosen descriptor is pinned on each
|
|
209
|
+
* `ToolDefinition.descriptor` so the Prompt loop can apply the matching
|
|
210
|
+
* strictify when validating tool arguments.
|
|
211
|
+
*
|
|
212
|
+
* Anthropic enforces per-request limits (20 strict tools, 24 optional
|
|
213
|
+
* params, 16 union types across the whole request) — those are tracked
|
|
214
|
+
* by the shared `SchemaBudget` so over-budget tools degrade to LENIENT
|
|
215
|
+
* silently rather than failing the API call.
|
|
216
|
+
*
|
|
217
|
+
* Converse has no free-text tools, so those go as their one-field function
|
|
218
|
+
* with any grammar in the description. It has no `none` choice either, so
|
|
219
|
+
* tools are left out then, unless the conversation already used them
|
|
220
|
+
* (Converse rejects tool blocks without a tool config).
|
|
192
221
|
*/
|
|
193
222
|
private convertToolsToConverse;
|
|
194
223
|
/**
|
|
195
|
-
*
|
|
224
|
+
* Convert a schema response format to Converse structured output. Converse
|
|
225
|
+
* rejects schemas outside its strict subset, so a schema goes only when the
|
|
226
|
+
* model's strict descriptor can shape it; the descriptor is pinned on the
|
|
227
|
+
* format so the Prompt validator can apply the matching strictify. Plain
|
|
228
|
+
* JSON has no Converse mode.
|
|
229
|
+
*/
|
|
230
|
+
private convertResponseFormat;
|
|
231
|
+
/**
|
|
232
|
+
* The set of strict descriptor families this provider can speak through
|
|
233
|
+
* Bedrock. Defaults to `['openai', 'anthropic', 'google']` — Bedrock
|
|
234
|
+
* surfaces all three. Subclasses can extend to accept custom registered
|
|
235
|
+
* families.
|
|
196
236
|
*/
|
|
197
|
-
|
|
237
|
+
protected supportedStrictFamilies: ReadonlySet<DescriptorFamily>;
|
|
198
238
|
generateImage: Provider['generateImage'];
|
|
199
239
|
embed: Provider['embed'];
|
|
200
240
|
private handleAWSError;
|
package/dist/aws.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../src/aws.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,i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