@aeye/aws 0.1.0 → 0.2.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 CHANGED
@@ -400,7 +400,7 @@ AWS_REGION=us-east-1
400
400
 
401
401
  ## License
402
402
 
403
- MIT - See [LICENSE](../../LICENSE) file for details.
403
+ GPL-3.0 - See [LICENSE](../../LICENSE) file for details.
404
404
 
405
405
  ## Contributing
406
406
 
package/dist/aws.d.ts CHANGED
@@ -4,8 +4,10 @@
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
6
  */
7
- import type { AIContextAny, AIMetadataAny, ModelInfo, Provider } from '@aeye/ai';
8
- import type { Executor, Streamer, ModelInput } from '@aeye/core';
7
+ import type { AIContextAny, AIMetadataAny, EmbeddingRequest, EmbeddingResponse, ImageGenerationRequest, ImageGenerationResponse, ModelInfo, Provider } from '@aeye/ai';
8
+ import { Executor, ModelInput, Request, Response, Streamer } from '@aeye/core';
9
+ import type { Anthropic } from '@anthropic-ai/sdk';
10
+ import { InvokeModelCommand, InvokeModelWithResponseStreamCommand } from '@aws-sdk/client-bedrock-runtime';
9
11
  import { type ModelFamilyConfig } from './types';
10
12
  /**
11
13
  * Configuration options for the AWS Bedrock provider.
@@ -34,20 +36,67 @@ import { type ModelFamilyConfig } from './types';
34
36
  * };
35
37
  * ```
36
38
  */
39
+ /**
40
+ * Hook called before a request is made to the provider.
41
+ *
42
+ * @template TRequest - The request type
43
+ * @template TCommand - The AWS command type
44
+ * @param request - The request object
45
+ * @param command - The AWS SDK command being sent
46
+ * @param ctx - The context object
47
+ */
48
+ export type PreRequestHook<TRequest = any, TCommand = any> = (request: TRequest, command: TCommand, ctx: AIContextAny) => void | Promise<void>;
49
+ /**
50
+ * Hook called after a response is received from the provider.
51
+ *
52
+ * @template TRequest - The request type
53
+ * @template TCommand - The AWS command type
54
+ * @template TResponse - The response type
55
+ * @param request - The request object
56
+ * @param command - The AWS SDK command that was sent
57
+ * @param response - The response object
58
+ * @param ctx - The context object
59
+ */
60
+ export type PostRequestHook<TRequest = any, TCommand = any, TResponse = any> = (request: TRequest, command: TCommand, response: TResponse, ctx: AIContextAny) => void | Promise<void>;
61
+ /**
62
+ * Hooks for different operation types.
63
+ */
64
+ export interface AWSBedrockHooks {
65
+ chat?: {
66
+ beforeRequest?: PreRequestHook<Request, InvokeModelCommand | InvokeModelWithResponseStreamCommand>;
67
+ afterRequest?: PostRequestHook<Request, InvokeModelCommand | InvokeModelWithResponseStreamCommand, Response>;
68
+ };
69
+ imageGenerate?: {
70
+ beforeRequest?: PreRequestHook<ImageGenerationRequest, InvokeModelCommand>;
71
+ afterRequest?: PostRequestHook<ImageGenerationRequest, InvokeModelCommand, ImageGenerationResponse>;
72
+ };
73
+ embed?: {
74
+ beforeRequest?: PreRequestHook<EmbeddingRequest, InvokeModelCommand>;
75
+ afterRequest?: PostRequestHook<EmbeddingRequest, InvokeModelCommand, EmbeddingResponse>;
76
+ };
77
+ }
37
78
  export interface AWSBedrockConfig {
38
79
  region?: string;
39
80
  credentials?: {
40
- accessKeyId: string;
41
- secretAccessKey: string;
81
+ accessKeyId?: string;
82
+ secretAccessKey?: string;
42
83
  sessionToken?: string;
43
84
  };
85
+ modelPrefix?: string;
44
86
  modelFamilies?: Record<string, ModelFamilyConfig>;
45
87
  defaultModels?: {
46
88
  chat?: ModelInput;
47
89
  imageGenerate?: ModelInput;
48
90
  embedding?: ModelInput;
49
91
  };
92
+ anthropic?: {
93
+ version?: string;
94
+ beta?: AnthropicBeta[];
95
+ emptyMessage?: Anthropic.MessageParam;
96
+ };
97
+ hooks?: AWSBedrockHooks;
50
98
  }
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';
51
100
  /**
52
101
  * AWS Bedrock provider implementation for the @aeye framework.
53
102
  *
@@ -87,13 +136,19 @@ export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
87
136
  private bedrockRuntimeClient;
88
137
  constructor(config: AWSBedrockConfig);
89
138
  /**
90
- * Detect model family from model ID
139
+ * Convert AWSBedrockConfig to BedrockClientConfig
140
+ *
141
+ * @param config
142
+ * @returns
91
143
  */
92
- private detectModelFamily;
144
+ private static convertConfig;
93
145
  /**
94
- * Convert AWS Bedrock model to @aeye ModelInfo format
146
+ * Prepend model prefix if configured
147
+ *
148
+ * @param modelId - The base model ID
149
+ * @returns Model ID with prefix prepended if configured
95
150
  */
96
- private convertModel;
151
+ private applyModelPrefix;
97
152
  /**
98
153
  * List available models from AWS Bedrock
99
154
  */
@@ -118,6 +173,7 @@ export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
118
173
  * Convert tool choice to Anthropic format
119
174
  */
120
175
  private convertToolChoiceToAnthropic;
176
+ private convertRequestToAnthropic;
121
177
  private executeAnthropicModel;
122
178
  private streamAnthropicModel;
123
179
  private convertMessagesToAnthropic;
@@ -132,4 +188,5 @@ export declare class AWSBedrockProvider implements Provider<AWSBedrockConfig> {
132
188
  embed: Provider['embed'];
133
189
  private handleAWSError;
134
190
  }
191
+ export {};
135
192
  //# 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;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAMb,SAAS,EACT,QAAQ,EACT,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAEV,QAAQ,EAIR,QAAQ,EAER,UAAU,EACX,MAAM,YAAY,CAAC;AAcpB,OAAO,EAAmF,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAMlI;;;;;;;;;;;;;;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