@aeye/aws 0.3.6 → 0.3.8
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/dist/aws.d.ts +63 -53
- package/dist/aws.d.ts.map +1 -1
- package/dist/aws.js +277 -533
- package/dist/aws.js.map +1 -1
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +5 -2
- package/dist/common.js.map +1 -1
- package/package.json +3 -4
package/dist/aws.d.ts
CHANGED
|
@@ -3,39 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provider for AWS Bedrock models including Claude, Llama, Titan, Mistral, and more.
|
|
5
5
|
* Uses AWS SDK v3 to automatically pick up credentials from environment, IAM roles, or credential files.
|
|
6
|
+
* All chat LLM calls use the Bedrock Converse API for a unified request/response format across models.
|
|
6
7
|
*/
|
|
7
8
|
import type { AIContextAny, AIMetadataAny, EmbeddingRequest, EmbeddingResponse, ImageGenerationRequest, ImageGenerationResponse, ModelInfo, Provider } from '@aeye/ai';
|
|
8
9
|
import { Executor, ModelInput, Request, Response, Streamer } from '@aeye/core';
|
|
9
|
-
import
|
|
10
|
-
import { InvokeModelCommand, InvokeModelWithResponseStreamCommand } from '@aws-sdk/client-bedrock-runtime';
|
|
10
|
+
import { ConverseCommand, ConverseStreamCommand, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime';
|
|
11
11
|
import { type ModelFamilyConfig } from './types';
|
|
12
|
-
/**
|
|
13
|
-
* Configuration options for the AWS Bedrock provider.
|
|
14
|
-
*
|
|
15
|
-
* Credentials are automatically discovered using the AWS SDK credential chain:
|
|
16
|
-
* 1. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
|
|
17
|
-
* 2. Shared credentials file (~/.aws/credentials)
|
|
18
|
-
* 3. IAM roles (when running on EC2, ECS, Lambda, etc.)
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const config: AWSBedrockConfig = {
|
|
23
|
-
* region: 'us-east-1', // Optional, defaults to AWS_REGION env var
|
|
24
|
-
* // Credentials are picked up automatically from environment
|
|
25
|
-
* };
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example With explicit credentials
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const config: AWSBedrockConfig = {
|
|
31
|
-
* region: 'us-west-2',
|
|
32
|
-
* credentials: {
|
|
33
|
-
* accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
|
34
|
-
* secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
35
|
-
* },
|
|
36
|
-
* };
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
12
|
/**
|
|
40
13
|
* Hook called before a request is made to the provider.
|
|
41
14
|
*
|
|
@@ -63,8 +36,8 @@ export type PostRequestHook<TRequest = any, TCommand = any, TResponse = any> = (
|
|
|
63
36
|
*/
|
|
64
37
|
export interface AWSBedrockHooks {
|
|
65
38
|
chat?: {
|
|
66
|
-
beforeRequest?: PreRequestHook<Request,
|
|
67
|
-
afterRequest?: PostRequestHook<Request,
|
|
39
|
+
beforeRequest?: PreRequestHook<Request, ConverseCommand | ConverseStreamCommand>;
|
|
40
|
+
afterRequest?: PostRequestHook<Request, ConverseCommand | ConverseStreamCommand, Response>;
|
|
68
41
|
};
|
|
69
42
|
imageGenerate?: {
|
|
70
43
|
beforeRequest?: PreRequestHook<ImageGenerationRequest, InvokeModelCommand>;
|
|
@@ -75,6 +48,33 @@ export interface AWSBedrockHooks {
|
|
|
75
48
|
afterRequest?: PostRequestHook<EmbeddingRequest, InvokeModelCommand, EmbeddingResponse>;
|
|
76
49
|
};
|
|
77
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Configuration options for the AWS Bedrock provider.
|
|
53
|
+
*
|
|
54
|
+
* Credentials are automatically discovered using the AWS SDK credential chain:
|
|
55
|
+
* 1. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
|
|
56
|
+
* 2. Shared credentials file (~/.aws/credentials)
|
|
57
|
+
* 3. IAM roles (when running on EC2, ECS, Lambda, etc.)
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const config: AWSBedrockConfig = {
|
|
62
|
+
* region: 'us-east-1', // Optional, defaults to AWS_REGION env var
|
|
63
|
+
* // Credentials are picked up automatically from environment
|
|
64
|
+
* };
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example With explicit credentials
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const config: AWSBedrockConfig = {
|
|
70
|
+
* region: 'us-west-2',
|
|
71
|
+
* credentials: {
|
|
72
|
+
* accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
|
73
|
+
* secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
74
|
+
* },
|
|
75
|
+
* };
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
78
|
export interface AWSBedrockConfig {
|
|
79
79
|
region?: string;
|
|
80
80
|
credentials?: {
|
|
@@ -89,14 +89,8 @@ export interface AWSBedrockConfig {
|
|
|
89
89
|
imageGenerate?: ModelInput;
|
|
90
90
|
embedding?: ModelInput;
|
|
91
91
|
};
|
|
92
|
-
anthropic?: {
|
|
93
|
-
version?: string;
|
|
94
|
-
beta?: AnthropicBeta[];
|
|
95
|
-
emptyMessage?: Anthropic.MessageParam;
|
|
96
|
-
};
|
|
97
92
|
hooks?: AWSBedrockHooks;
|
|
98
93
|
}
|
|
99
|
-
type AnthropicBeta = 'computer-use-2025-01-24' | 'token-efficient-tools-2025-02-19' | 'Interleaved-thinking-2025-05-14' | 'output-128k-2025-02-19' | 'dev-full-thinking-2025-05-14' | 'context-1m-2025-08-07' | 'context-management-2025-06-27';
|
|
100
94
|
/**
|
|
101
95
|
* AWS Bedrock provider implementation for the @aeye framework.
|
|
102
96
|
*
|
|
@@ -166,27 +160,43 @@ export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
|
|
|
166
160
|
*/
|
|
167
161
|
createStreamer(config?: AWSBedrockConfig): Streamer<AIContextAny, AIMetadataAny>;
|
|
168
162
|
/**
|
|
169
|
-
*
|
|
163
|
+
* Build a ConverseCommandInput from a generic @aeye/core Request.
|
|
164
|
+
*/
|
|
165
|
+
private convertRequestToConverse;
|
|
166
|
+
/**
|
|
167
|
+
* Execute a non-streaming chat completion using the Converse API.
|
|
168
|
+
*/
|
|
169
|
+
private executeWithConverse;
|
|
170
|
+
/**
|
|
171
|
+
* Execute a streaming chat completion using the Converse Stream API.
|
|
172
|
+
*/
|
|
173
|
+
private streamWithConverse;
|
|
174
|
+
/**
|
|
175
|
+
* Convert system messages to the Converse API system format.
|
|
176
|
+
*/
|
|
177
|
+
private convertSystemToConverse;
|
|
178
|
+
/**
|
|
179
|
+
* Convert @aeye/core messages to AWS Bedrock Converse API message format.
|
|
180
|
+
* Filters out system messages (handled via convertSystemToConverse).
|
|
181
|
+
* Merges consecutive messages with the same role as required by the API.
|
|
182
|
+
*/
|
|
183
|
+
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
|
+
/**
|
|
191
|
+
* Convert @aeye/core tool definitions to AWS Bedrock Converse API tool format.
|
|
170
192
|
*/
|
|
171
|
-
private
|
|
193
|
+
private convertToolsToConverse;
|
|
172
194
|
/**
|
|
173
|
-
*
|
|
195
|
+
* Map a Bedrock Converse API stop reason to the @aeye/core FinishReason type.
|
|
174
196
|
*/
|
|
175
|
-
private
|
|
176
|
-
private convertRequestToAnthropic;
|
|
177
|
-
private executeAnthropicModel;
|
|
178
|
-
private streamAnthropicModel;
|
|
179
|
-
private convertMessagesToAnthropic;
|
|
180
|
-
private mapAnthropicStopReason;
|
|
181
|
-
private executeLlamaStyleModel;
|
|
182
|
-
private streamLlamaStyleModel;
|
|
183
|
-
private convertMessagesToLlamaPrompt;
|
|
184
|
-
private executeCohereModel;
|
|
185
|
-
private streamCohereModel;
|
|
186
|
-
private convertMessagesToCoherePrompt;
|
|
197
|
+
private mapStopReason;
|
|
187
198
|
generateImage: Provider['generateImage'];
|
|
188
199
|
embed: Provider['embed'];
|
|
189
200
|
private handleAWSError;
|
|
190
201
|
}
|
|
191
|
-
export {};
|
|
192
202
|
//# sourceMappingURL=aws.d.ts.map
|
package/dist/aws.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../src/aws.ts"],"names":[],"mappings":"AAAA
|
|
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,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACT,MAAM,UAAU,CAAC;AAClB,OAAO,EAEL,QAAQ,EAGR,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EAGT,MAAM,YAAY,CAAC;AAMpB,OAAO,EAGL,eAAe,EAEf,qBAAqB,EAGrB,kBAAkB,EAKnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAmF,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAMlI;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CAAC,QAAQ,GAAG,GAAG,EAAE,QAAQ,GAAG,GAAG,IAAI,CAC3D,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,QAAQ,EACjB,GAAG,EAAE,YAAY,KACd,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,CAAC,QAAQ,GAAG,GAAG,EAAE,QAAQ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