@aeye/aws 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/README.md +407 -0
- package/dist/aws.d.ts +135 -0
- package/dist/aws.d.ts.map +1 -0
- package/dist/aws.js +835 -0
- package/dist/aws.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +59 -0
- package/dist/types.js.map +1 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
# @aeye/aws - AWS Bedrock Provider
|
|
2
|
+
|
|
3
|
+
AWS Bedrock integration for the [@aeye](https://github.com/ClickerMonkey/aeye) framework, providing seamless access to Claude, Llama, Mistral, Cohere, Stability AI, and Amazon Titan models.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🤖 **Multi-Model Support** - Access to all AWS Bedrock foundation models
|
|
8
|
+
- 🔐 **Automatic Authentication** - Uses AWS SDK credential chain for seamless authentication
|
|
9
|
+
- 🌊 **Streaming** - Full streaming support for real-time responses
|
|
10
|
+
- 🎨 **Image Generation** - Stability AI models for image creation
|
|
11
|
+
- 📊 **Embeddings** - Amazon Titan embeddings for semantic search
|
|
12
|
+
- 🔧 **Type-Safe** - Full TypeScript support with type inference
|
|
13
|
+
- ⚡ **Regional Flexibility** - Deploy across any AWS region with Bedrock
|
|
14
|
+
|
|
15
|
+
## Supported Models
|
|
16
|
+
|
|
17
|
+
### Chat Models
|
|
18
|
+
- **Anthropic Claude** - Claude 3 Opus, Sonnet, Haiku, and Claude 3.5 Sonnet
|
|
19
|
+
- **Meta Llama** - Llama 2, Llama 3, Llama 3.1, Llama 3.2
|
|
20
|
+
- **Mistral AI** - Mistral 7B, Mixtral 8x7B, Mistral Large
|
|
21
|
+
- **Cohere** - Command, Command Light, Command R, Command R+
|
|
22
|
+
- **AI21 Labs** - Jurassic-2 models
|
|
23
|
+
|
|
24
|
+
### Image Models
|
|
25
|
+
- **Stability AI** - Stable Diffusion XL, Stable Diffusion 3
|
|
26
|
+
|
|
27
|
+
### Embedding Models
|
|
28
|
+
- **Amazon Titan** - Titan Text Embeddings v1 and v2
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @aeye/aws @aeye/ai @aeye/core zod
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Prerequisites
|
|
37
|
+
|
|
38
|
+
### AWS Credentials
|
|
39
|
+
|
|
40
|
+
The provider uses the AWS SDK v3 credential chain to automatically discover credentials:
|
|
41
|
+
|
|
42
|
+
1. **Environment variables** - `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`
|
|
43
|
+
2. **Shared credentials file** - `~/.aws/credentials`
|
|
44
|
+
3. **IAM roles** - When running on EC2, ECS, Lambda, etc.
|
|
45
|
+
|
|
46
|
+
### AWS Bedrock Access
|
|
47
|
+
|
|
48
|
+
Ensure you have:
|
|
49
|
+
1. Access to AWS Bedrock in your target region
|
|
50
|
+
2. Permissions to invoke foundation models
|
|
51
|
+
3. Model access enabled in the AWS Bedrock console
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
### Basic Chat Completion
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { AI } from '@aeye/ai';
|
|
59
|
+
import { AWSBedrockProvider } from '@aeye/aws';
|
|
60
|
+
|
|
61
|
+
// Create provider (credentials picked up automatically)
|
|
62
|
+
const aws = new AWSBedrockProvider({
|
|
63
|
+
region: 'us-east-1',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Create AI instance
|
|
67
|
+
const ai = AI.with()
|
|
68
|
+
.providers({ aws })
|
|
69
|
+
.create();
|
|
70
|
+
|
|
71
|
+
// Chat with Claude
|
|
72
|
+
const response = await ai.chat.get([
|
|
73
|
+
{ role: 'user', content: 'What is AWS Bedrock?' }
|
|
74
|
+
], {
|
|
75
|
+
model: 'anthropic.claude-3-sonnet-20240229-v1:0'
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
console.log(response.content);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Streaming Responses
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Stream responses in real-time
|
|
85
|
+
for await (const chunk of ai.chat.stream([
|
|
86
|
+
{ role: 'user', content: 'Write a poem about AI' }
|
|
87
|
+
], {
|
|
88
|
+
model: 'anthropic.claude-3-haiku-20240307-v1:0'
|
|
89
|
+
})) {
|
|
90
|
+
if (chunk.content) {
|
|
91
|
+
process.stdout.write(chunk.content);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Image Generation
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { AWSBedrockProvider } from '@aeye/aws';
|
|
100
|
+
|
|
101
|
+
const aws = new AWSBedrockProvider({
|
|
102
|
+
region: 'us-east-1',
|
|
103
|
+
defaultModels: {
|
|
104
|
+
imageGenerate: 'stability.stable-diffusion-xl-v1',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const ai = AI.with()
|
|
109
|
+
.providers({ aws })
|
|
110
|
+
.create();
|
|
111
|
+
|
|
112
|
+
const result = await ai.image.generate({
|
|
113
|
+
prompt: 'A serene mountain landscape at sunset',
|
|
114
|
+
size: { width: 1024, height: 1024 },
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
console.log('Image URL:', result.images[0].url);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Text Embeddings
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const aws = new AWSBedrockProvider({
|
|
124
|
+
region: 'us-east-1',
|
|
125
|
+
defaultModels: {
|
|
126
|
+
embedding: 'amazon.titan-embed-text-v1',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const ai = AI.with()
|
|
131
|
+
.providers({ aws })
|
|
132
|
+
.create();
|
|
133
|
+
|
|
134
|
+
const embeddings = await ai.embed.get({
|
|
135
|
+
input: 'AWS Bedrock is a fully managed service',
|
|
136
|
+
model: 'amazon.titan-embed-text-v1',
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
console.log('Embedding dimensions:', embeddings.embeddings[0].length);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Configuration
|
|
143
|
+
|
|
144
|
+
### Provider Configuration
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { AWSBedrockProvider, type AWSBedrockConfig } from '@aeye/aws';
|
|
148
|
+
|
|
149
|
+
const config: AWSBedrockConfig = {
|
|
150
|
+
// AWS region (defaults to AWS_REGION env var or 'us-east-1')
|
|
151
|
+
region: 'us-west-2',
|
|
152
|
+
|
|
153
|
+
// Optional: Explicit credentials (if not using default chain)
|
|
154
|
+
credentials: {
|
|
155
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
|
156
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
157
|
+
sessionToken: process.env.AWS_SESSION_TOKEN, // Optional
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
// Optional: Default models for different capabilities
|
|
161
|
+
defaultModels: {
|
|
162
|
+
chat: 'anthropic.claude-3-sonnet-20240229-v1:0',
|
|
163
|
+
imageGenerate: 'stability.stable-diffusion-xl-v1',
|
|
164
|
+
embedding: 'amazon.titan-embed-text-v2:0',
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const provider = new AWSBedrockProvider(config);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Using with Multiple Providers
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { AI } from '@aeye/ai';
|
|
175
|
+
import { AWSBedrockProvider } from '@aeye/aws';
|
|
176
|
+
import { OpenAIProvider } from '@aeye/openai';
|
|
177
|
+
|
|
178
|
+
const aws = new AWSBedrockProvider({ region: 'us-east-1' });
|
|
179
|
+
const openai = new OpenAIProvider({ apiKey: process.env.OPENAI_API_KEY! });
|
|
180
|
+
|
|
181
|
+
const ai = AI.with()
|
|
182
|
+
.providers({ aws, openai })
|
|
183
|
+
.create({
|
|
184
|
+
// Automatic model selection across all providers
|
|
185
|
+
defaultMetadata: {
|
|
186
|
+
required: ['chat', 'streaming'],
|
|
187
|
+
weights: {
|
|
188
|
+
cost: 0.5,
|
|
189
|
+
speed: 0.3,
|
|
190
|
+
quality: 0.2,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// AI instance will automatically select the best model across AWS and OpenAI
|
|
196
|
+
const response = await ai.chat.get([
|
|
197
|
+
{ role: 'user', content: 'Hello!' }
|
|
198
|
+
]);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Model IDs
|
|
202
|
+
|
|
203
|
+
### Anthropic Claude Models
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// Claude 3.5
|
|
207
|
+
'anthropic.claude-3-5-sonnet-20240620-v1:0'
|
|
208
|
+
'anthropic.claude-3-5-sonnet-20241022-v2:0'
|
|
209
|
+
|
|
210
|
+
// Claude 3
|
|
211
|
+
'anthropic.claude-3-opus-20240229-v1:0'
|
|
212
|
+
'anthropic.claude-3-sonnet-20240229-v1:0'
|
|
213
|
+
'anthropic.claude-3-haiku-20240307-v1:0'
|
|
214
|
+
|
|
215
|
+
// Claude 2.x
|
|
216
|
+
'anthropic.claude-v2:1'
|
|
217
|
+
'anthropic.claude-v2'
|
|
218
|
+
'anthropic.claude-instant-v1'
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Meta Llama Models
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
'meta.llama3-2-1b-instruct-v1:0'
|
|
225
|
+
'meta.llama3-2-3b-instruct-v1:0'
|
|
226
|
+
'meta.llama3-2-11b-instruct-v1:0'
|
|
227
|
+
'meta.llama3-2-90b-instruct-v1:0'
|
|
228
|
+
'meta.llama3-1-8b-instruct-v1:0'
|
|
229
|
+
'meta.llama3-1-70b-instruct-v1:0'
|
|
230
|
+
'meta.llama3-1-405b-instruct-v1:0'
|
|
231
|
+
'meta.llama3-8b-instruct-v1:0'
|
|
232
|
+
'meta.llama3-70b-instruct-v1:0'
|
|
233
|
+
'meta.llama2-13b-chat-v1'
|
|
234
|
+
'meta.llama2-70b-chat-v1'
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Mistral AI Models
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
'mistral.mistral-7b-instruct-v0:2'
|
|
241
|
+
'mistral.mixtral-8x7b-instruct-v0:1'
|
|
242
|
+
'mistral.mistral-large-2402-v1:0'
|
|
243
|
+
'mistral.mistral-large-2407-v1:0'
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Cohere Models
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
'cohere.command-text-v14'
|
|
250
|
+
'cohere.command-light-text-v14'
|
|
251
|
+
'cohere.command-r-v1:0'
|
|
252
|
+
'cohere.command-r-plus-v1:0'
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Stability AI Models
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
'stability.stable-diffusion-xl-v1'
|
|
259
|
+
'stability.sd3-large-v1:0'
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Amazon Titan Models
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
// Embeddings
|
|
266
|
+
'amazon.titan-embed-text-v1'
|
|
267
|
+
'amazon.titan-embed-text-v2:0'
|
|
268
|
+
|
|
269
|
+
// Image Generation
|
|
270
|
+
'amazon.titan-image-generator-v1'
|
|
271
|
+
'amazon.titan-image-generator-v2:0'
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Advanced Features
|
|
275
|
+
|
|
276
|
+
### Vision with Claude 3
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const response = await ai.chat.get([
|
|
280
|
+
{
|
|
281
|
+
role: 'user',
|
|
282
|
+
content: [
|
|
283
|
+
{ type: 'text', content: 'What do you see in this image?' },
|
|
284
|
+
{ type: 'image', content: 'https://example.com/image.jpg' },
|
|
285
|
+
],
|
|
286
|
+
},
|
|
287
|
+
], {
|
|
288
|
+
model: 'anthropic.claude-3-sonnet-20240229-v1:0',
|
|
289
|
+
});
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Custom Request Parameters
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
const response = await ai.chat.get([
|
|
296
|
+
{ role: 'user', content: 'Hello!' }
|
|
297
|
+
], {
|
|
298
|
+
model: 'anthropic.claude-3-haiku-20240307-v1:0',
|
|
299
|
+
temperature: 0.7,
|
|
300
|
+
maxTokens: 2048,
|
|
301
|
+
topP: 0.9,
|
|
302
|
+
stop: ['Human:', 'Assistant:'],
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Multi-Region Setup
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// Primary region
|
|
310
|
+
const awsEast = new AWSBedrockProvider({
|
|
311
|
+
region: 'us-east-1',
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Fallback region
|
|
315
|
+
const awsWest = new AWSBedrockProvider({
|
|
316
|
+
region: 'us-west-2',
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const ai = AI.with()
|
|
320
|
+
.providers({ awsEast, awsWest })
|
|
321
|
+
.create();
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Error Handling
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import {
|
|
328
|
+
AWSError,
|
|
329
|
+
AWSAuthError,
|
|
330
|
+
AWSRateLimitError,
|
|
331
|
+
AWSQuotaError,
|
|
332
|
+
AWSContextWindowError,
|
|
333
|
+
} from '@aeye/aws';
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
const response = await ai.chat.get([
|
|
337
|
+
{ role: 'user', content: 'Hello!' }
|
|
338
|
+
]);
|
|
339
|
+
} catch (error) {
|
|
340
|
+
if (error instanceof AWSAuthError) {
|
|
341
|
+
console.error('Authentication failed. Check your AWS credentials.');
|
|
342
|
+
} else if (error instanceof AWSRateLimitError) {
|
|
343
|
+
console.error('Rate limit exceeded. Retry after:', error.retryAfter);
|
|
344
|
+
} else if (error instanceof AWSQuotaError) {
|
|
345
|
+
console.error('AWS quota exceeded. Request quota increase.');
|
|
346
|
+
} else if (error instanceof AWSContextWindowError) {
|
|
347
|
+
console.error('Input too long for model context window.');
|
|
348
|
+
} else if (error instanceof AWSError) {
|
|
349
|
+
console.error('AWS Bedrock error:', error.message);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## Health Check
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
const isHealthy = await aws.checkHealth();
|
|
358
|
+
console.log('AWS Bedrock is accessible:', isHealthy);
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## List Available Models
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
const models = await aws.listModels();
|
|
365
|
+
console.log('Available models:', models.map(m => m.id));
|
|
366
|
+
|
|
367
|
+
// Filter by capability
|
|
368
|
+
const chatModels = models.filter(m => m.capabilities.has('chat'));
|
|
369
|
+
const imageModels = models.filter(m => m.capabilities.has('image'));
|
|
370
|
+
const embeddingModels = models.filter(m => m.capabilities.has('embedding'));
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## Best Practices
|
|
374
|
+
|
|
375
|
+
1. **Use IAM Roles** - When running on AWS infrastructure (EC2, ECS, Lambda), use IAM roles instead of hardcoded credentials
|
|
376
|
+
2. **Region Selection** - Choose regions close to your users for lower latency
|
|
377
|
+
3. **Model Selection** - Use smaller models (Haiku, 7B) for faster, cheaper responses when appropriate
|
|
378
|
+
4. **Streaming** - Enable streaming for better user experience with long responses
|
|
379
|
+
5. **Error Handling** - Implement proper error handling and retry logic for production use
|
|
380
|
+
6. **Cost Management** - Monitor usage through AWS Cost Explorer and set up billing alerts
|
|
381
|
+
|
|
382
|
+
## Environment Variables
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
# AWS credentials (if not using IAM roles)
|
|
386
|
+
AWS_ACCESS_KEY_ID=your_access_key
|
|
387
|
+
AWS_SECRET_ACCESS_KEY=your_secret_key
|
|
388
|
+
AWS_SESSION_TOKEN=your_session_token # Optional
|
|
389
|
+
|
|
390
|
+
# AWS region
|
|
391
|
+
AWS_REGION=us-east-1
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## Links
|
|
395
|
+
|
|
396
|
+
- [AWS Bedrock Documentation](https://docs.aws.amazon.com/bedrock/)
|
|
397
|
+
- [Model IDs Reference](https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html)
|
|
398
|
+
- [@aeye Framework](https://github.com/ClickerMonkey/aeye)
|
|
399
|
+
- [AWS SDK for JavaScript](https://docs.aws.amazon.com/sdk-for-javascript/v3/)
|
|
400
|
+
|
|
401
|
+
## License
|
|
402
|
+
|
|
403
|
+
MIT - See [LICENSE](../../LICENSE) file for details.
|
|
404
|
+
|
|
405
|
+
## Contributing
|
|
406
|
+
|
|
407
|
+
Issues and pull requests are welcome! See the [main repository](https://github.com/ClickerMonkey/aeye) for contribution guidelines.
|
package/dist/aws.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Bedrock Provider
|
|
3
|
+
*
|
|
4
|
+
* Provider for AWS Bedrock models including Claude, Llama, Titan, Mistral, and more.
|
|
5
|
+
* Uses AWS SDK v3 to automatically pick up credentials from environment, IAM roles, or credential files.
|
|
6
|
+
*/
|
|
7
|
+
import type { AIContextAny, AIMetadataAny, ModelInfo, Provider } from '@aeye/ai';
|
|
8
|
+
import type { Executor, Streamer, ModelInput } from '@aeye/core';
|
|
9
|
+
import { type ModelFamilyConfig } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for the AWS Bedrock provider.
|
|
12
|
+
*
|
|
13
|
+
* Credentials are automatically discovered using the AWS SDK credential chain:
|
|
14
|
+
* 1. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
|
|
15
|
+
* 2. Shared credentials file (~/.aws/credentials)
|
|
16
|
+
* 3. IAM roles (when running on EC2, ECS, Lambda, etc.)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const config: AWSBedrockConfig = {
|
|
21
|
+
* region: 'us-east-1', // Optional, defaults to AWS_REGION env var
|
|
22
|
+
* // Credentials are picked up automatically from environment
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example With explicit credentials
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const config: AWSBedrockConfig = {
|
|
29
|
+
* region: 'us-west-2',
|
|
30
|
+
* credentials: {
|
|
31
|
+
* accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
|
32
|
+
* secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
33
|
+
* },
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export interface AWSBedrockConfig {
|
|
38
|
+
region?: string;
|
|
39
|
+
credentials?: {
|
|
40
|
+
accessKeyId: string;
|
|
41
|
+
secretAccessKey: string;
|
|
42
|
+
sessionToken?: string;
|
|
43
|
+
};
|
|
44
|
+
modelFamilies?: Record<string, ModelFamilyConfig>;
|
|
45
|
+
defaultModels?: {
|
|
46
|
+
chat?: ModelInput;
|
|
47
|
+
imageGenerate?: ModelInput;
|
|
48
|
+
embedding?: ModelInput;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* AWS Bedrock provider implementation for the @aeye framework.
|
|
53
|
+
*
|
|
54
|
+
* Supports the full range of AWS Bedrock capabilities including:
|
|
55
|
+
* - Chat completions with Claude, Llama, Mistral, Cohere, and more
|
|
56
|
+
* - Image generation with Stability AI models
|
|
57
|
+
* - Text embeddings with Amazon Titan
|
|
58
|
+
* - Streaming responses
|
|
59
|
+
*
|
|
60
|
+
* Uses AWS SDK v3 for automatic credential discovery and management.
|
|
61
|
+
*
|
|
62
|
+
* @example Basic usage
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { AWSBedrockProvider } from '@aeye/aws';
|
|
65
|
+
*
|
|
66
|
+
* const provider = new AWSBedrockProvider({
|
|
67
|
+
* region: 'us-east-1',
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* const executor = provider.createExecutor();
|
|
71
|
+
* const response = await executor(
|
|
72
|
+
* {
|
|
73
|
+
* messages: [
|
|
74
|
+
* { role: 'user', content: 'Hello!' }
|
|
75
|
+
* ]
|
|
76
|
+
* },
|
|
77
|
+
* {},
|
|
78
|
+
* { model: 'anthropic.claude-3-sonnet-20240229-v1:0' }
|
|
79
|
+
* );
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly config: AWSBedrockConfig;
|
|
85
|
+
defaultMetadata?: Provider['defaultMetadata'];
|
|
86
|
+
private bedrockClient;
|
|
87
|
+
private bedrockRuntimeClient;
|
|
88
|
+
constructor(config: AWSBedrockConfig);
|
|
89
|
+
/**
|
|
90
|
+
* Detect model family from model ID
|
|
91
|
+
*/
|
|
92
|
+
private detectModelFamily;
|
|
93
|
+
/**
|
|
94
|
+
* Convert AWS Bedrock model to @aeye ModelInfo format
|
|
95
|
+
*/
|
|
96
|
+
private convertModel;
|
|
97
|
+
/**
|
|
98
|
+
* List available models from AWS Bedrock
|
|
99
|
+
*/
|
|
100
|
+
listModels(config?: AWSBedrockConfig): Promise<ModelInfo[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Check if AWS Bedrock is accessible
|
|
103
|
+
*/
|
|
104
|
+
checkHealth(config?: AWSBedrockConfig): Promise<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* Create an executor for chat completion requests
|
|
107
|
+
*/
|
|
108
|
+
createExecutor(config?: AWSBedrockConfig): Executor<AIContextAny, AIMetadataAny>;
|
|
109
|
+
/**
|
|
110
|
+
* Create a streamer for streaming chat completion requests
|
|
111
|
+
*/
|
|
112
|
+
createStreamer(config?: AWSBedrockConfig): Streamer<AIContextAny, AIMetadataAny>;
|
|
113
|
+
/**
|
|
114
|
+
* Convert tools to Anthropic format
|
|
115
|
+
*/
|
|
116
|
+
private convertToolsToAnthropic;
|
|
117
|
+
/**
|
|
118
|
+
* Convert tool choice to Anthropic format
|
|
119
|
+
*/
|
|
120
|
+
private convertToolChoiceToAnthropic;
|
|
121
|
+
private executeAnthropicModel;
|
|
122
|
+
private streamAnthropicModel;
|
|
123
|
+
private convertMessagesToAnthropic;
|
|
124
|
+
private mapAnthropicStopReason;
|
|
125
|
+
private executeLlamaStyleModel;
|
|
126
|
+
private streamLlamaStyleModel;
|
|
127
|
+
private convertMessagesToLlamaPrompt;
|
|
128
|
+
private executeCohereModel;
|
|
129
|
+
private streamCohereModel;
|
|
130
|
+
private convertMessagesToCoherePrompt;
|
|
131
|
+
generateImage: Provider['generateImage'];
|
|
132
|
+
embed: Provider['embed'];
|
|
133
|
+
private handleAWSError;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=aws.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../src/aws.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAMb,SAAS,EACT,QAAQ,EACT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