@wmaurer/effect-ai-amazon-bedrock 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/CHANGELOG.md +14 -0
- package/README.md +77 -9
- package/dist/AmazonBedrockClient.d.ts +135 -23
- package/dist/AmazonBedrockClient.d.ts.map +1 -1
- package/dist/AmazonBedrockClient.js +36 -92
- package/dist/AmazonBedrockClient.js.map +1 -1
- package/dist/AmazonBedrockConfig.d.ts +6 -6
- package/dist/AmazonBedrockConfig.js +4 -4
- package/dist/AmazonBedrockEventStream.d.ts +2 -2
- package/dist/AmazonBedrockEventStream.js +3 -3
- package/dist/AmazonBedrockLanguageModel.d.ts +22 -22
- package/dist/AmazonBedrockLanguageModel.js +7 -7
- package/dist/AmazonBedrockSchema.d.ts +52 -52
- package/dist/AmazonBedrockSchema.js +49 -49
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/internal/credentials.d.ts +79 -0
- package/dist/internal/credentials.d.ts.map +1 -0
- package/dist/internal/credentials.js +241 -0
- package/dist/internal/credentials.js.map +1 -0
- package/dist/internal/errors.d.ts +2 -0
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +6 -0
- package/dist/internal/errors.js.map +1 -1
- package/package.json +1 -1
- package/src/AmazonBedrockClient.ts +184 -95
- package/src/AmazonBedrockConfig.ts +6 -6
- package/src/AmazonBedrockEventStream.ts +3 -3
- package/src/AmazonBedrockLanguageModel.ts +23 -23
- package/src/AmazonBedrockSchema.ts +52 -52
- package/src/index.ts +6 -6
- package/src/internal/credentials.ts +319 -0
- package/src/internal/errors.ts +5 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* underlying HTTP client without changing individual request code.
|
|
5
5
|
*
|
|
6
6
|
* @stability unstable
|
|
7
|
-
* @since
|
|
7
|
+
* @since 0.1.0
|
|
8
8
|
*/
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
@@ -16,13 +16,13 @@ declare const AmazonBedrockConfig_base: Context.ServiceClass<AmazonBedrockConfig
|
|
|
16
16
|
*
|
|
17
17
|
* @stability unstable
|
|
18
18
|
* @category services
|
|
19
|
-
* @since
|
|
19
|
+
* @since 0.1.0
|
|
20
20
|
*/
|
|
21
21
|
export declare class AmazonBedrockConfig extends AmazonBedrockConfig_base {
|
|
22
22
|
/**
|
|
23
23
|
* Gets the configured Amazon Bedrock service from the current context when present.
|
|
24
24
|
*
|
|
25
|
-
* @since
|
|
25
|
+
* @since 0.1.0
|
|
26
26
|
*/
|
|
27
27
|
static readonly getOrUndefined: Effect.Effect<typeof AmazonBedrockConfig.Service | undefined>;
|
|
28
28
|
}
|
|
@@ -30,14 +30,14 @@ export declare class AmazonBedrockConfig extends AmazonBedrockConfig_base {
|
|
|
30
30
|
* Namespace containing types associated with the `AmazonBedrockConfig` service.
|
|
31
31
|
*
|
|
32
32
|
* @stability unstable
|
|
33
|
-
* @since
|
|
33
|
+
* @since 0.1.0
|
|
34
34
|
*/
|
|
35
35
|
export declare namespace AmazonBedrockConfig {
|
|
36
36
|
/**
|
|
37
37
|
* Configuration provided through `AmazonBedrockConfig`.
|
|
38
38
|
*
|
|
39
39
|
* @category models
|
|
40
|
-
* @since
|
|
40
|
+
* @since 0.1.0
|
|
41
41
|
*/
|
|
42
42
|
interface Service {
|
|
43
43
|
readonly transformClient?: ((client: HttpClient) => HttpClient) | undefined;
|
|
@@ -49,7 +49,7 @@ export declare namespace AmazonBedrockConfig {
|
|
|
49
49
|
*
|
|
50
50
|
* @stability unstable
|
|
51
51
|
* @category configuration
|
|
52
|
-
* @since
|
|
52
|
+
* @since 0.1.0
|
|
53
53
|
*/
|
|
54
54
|
export declare const withClientTransform: {
|
|
55
55
|
(transform: (client: HttpClient) => HttpClient): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* underlying HTTP client without changing individual request code.
|
|
5
5
|
*
|
|
6
6
|
* @stability unstable
|
|
7
|
-
* @since
|
|
7
|
+
* @since 0.1.0
|
|
8
8
|
*/
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
@@ -15,13 +15,13 @@ import { dual } from "effect/Function";
|
|
|
15
15
|
*
|
|
16
16
|
* @stability unstable
|
|
17
17
|
* @category services
|
|
18
|
-
* @since
|
|
18
|
+
* @since 0.1.0
|
|
19
19
|
*/
|
|
20
20
|
export class AmazonBedrockConfig extends /*#__PURE__*/Context.Service()("@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockConfig") {
|
|
21
21
|
/**
|
|
22
22
|
* Gets the configured Amazon Bedrock service from the current context when present.
|
|
23
23
|
*
|
|
24
|
-
* @since
|
|
24
|
+
* @since 0.1.0
|
|
25
25
|
*/
|
|
26
26
|
static getOrUndefined = /*#__PURE__*/Effect.map(/*#__PURE__*/Effect.context(), services => services.mapUnsafe.get(AmazonBedrockConfig.key));
|
|
27
27
|
}
|
|
@@ -31,7 +31,7 @@ export class AmazonBedrockConfig extends /*#__PURE__*/Context.Service()("@wmaure
|
|
|
31
31
|
*
|
|
32
32
|
* @stability unstable
|
|
33
33
|
* @category configuration
|
|
34
|
-
* @since
|
|
34
|
+
* @since 0.1.0
|
|
35
35
|
*/
|
|
36
36
|
export const withClientTransform = /*#__PURE__*/dual(2, (self, transformClient) => Effect.flatMap(AmazonBedrockConfig.getOrUndefined, config => Effect.provideService(self, AmazonBedrockConfig, {
|
|
37
37
|
...config,
|
|
@@ -12,7 +12,7 @@ declare const EventStreamError_base: Schema.Class<EventStreamError, Schema.Tagge
|
|
|
12
12
|
*
|
|
13
13
|
* @stability unstable
|
|
14
14
|
* @category errors
|
|
15
|
-
* @since
|
|
15
|
+
* @since 0.1.0
|
|
16
16
|
*/
|
|
17
17
|
export declare class EventStreamError extends EventStreamError_base {
|
|
18
18
|
}
|
|
@@ -22,7 +22,7 @@ export declare class EventStreamError extends EventStreamError_base {
|
|
|
22
22
|
*
|
|
23
23
|
* @stability unstable
|
|
24
24
|
* @category constructors
|
|
25
|
-
* @since
|
|
25
|
+
* @since 0.1.0
|
|
26
26
|
*/
|
|
27
27
|
export declare const makeChannel: <A, I, RD, IE, Done>(schema: Schema.Codec<A, I, RD>) => Channel.Channel<NonEmptyReadonlyArray<A>, IE | Schema.SchemaError | EventStreamError, Done, NonEmptyReadonlyArray<Uint8Array>, IE, Done, RD>;
|
|
28
28
|
export {};
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* for more information.
|
|
18
18
|
*
|
|
19
19
|
* @stability unstable
|
|
20
|
-
* @since
|
|
20
|
+
* @since 0.1.0
|
|
21
21
|
*/
|
|
22
22
|
import * as Arr from "effect/Array";
|
|
23
23
|
import * as Channel from "effect/Channel";
|
|
@@ -31,7 +31,7 @@ const textDecoder = /*#__PURE__*/new TextDecoder();
|
|
|
31
31
|
*
|
|
32
32
|
* @stability unstable
|
|
33
33
|
* @category errors
|
|
34
|
-
* @since
|
|
34
|
+
* @since 0.1.0
|
|
35
35
|
*/
|
|
36
36
|
export class EventStreamError extends /*#__PURE__*/Schema.TaggedError("@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockEventStream/EventStreamError")("EventStreamError", {
|
|
37
37
|
code: /*#__PURE__*/Schema.optional(Schema.String),
|
|
@@ -134,7 +134,7 @@ const decodeFrame = frame => {
|
|
|
134
134
|
*
|
|
135
135
|
* @stability unstable
|
|
136
136
|
* @category constructors
|
|
137
|
-
* @since
|
|
137
|
+
* @since 0.1.0
|
|
138
138
|
*/
|
|
139
139
|
export const makeChannel = schema => Channel.fromTransform((upstream, _scope) => Effect.gen(function* () {
|
|
140
140
|
const context = yield* Effect.context();
|
|
@@ -11,7 +11,7 @@ import type { CachePointBlock, CitationsConfig } from "./AmazonBedrockSchema.ts"
|
|
|
11
11
|
*
|
|
12
12
|
* @stability unstable
|
|
13
13
|
* @category models
|
|
14
|
-
* @since
|
|
14
|
+
* @since 0.1.0
|
|
15
15
|
*/
|
|
16
16
|
export type Model = string & {};
|
|
17
17
|
/**
|
|
@@ -25,7 +25,7 @@ export type Model = string & {};
|
|
|
25
25
|
*
|
|
26
26
|
* @stability unstable
|
|
27
27
|
* @category models
|
|
28
|
-
* @since
|
|
28
|
+
* @since 0.1.0
|
|
29
29
|
*/
|
|
30
30
|
export type CachePoint = typeof CachePointBlock.Encoded;
|
|
31
31
|
/**
|
|
@@ -55,7 +55,7 @@ export type CachePoint = typeof CachePointBlock.Encoded;
|
|
|
55
55
|
*
|
|
56
56
|
* @stability unstable
|
|
57
57
|
* @category services
|
|
58
|
-
* @since
|
|
58
|
+
* @since 0.1.0
|
|
59
59
|
*/
|
|
60
60
|
export declare const ToolCachePoint: Context.Reference<{
|
|
61
61
|
readonly type: "default";
|
|
@@ -79,7 +79,7 @@ declare module "effect/ai/Prompt" {
|
|
|
79
79
|
*
|
|
80
80
|
* @stability unstable
|
|
81
81
|
* @category models
|
|
82
|
-
* @since
|
|
82
|
+
* @since 0.1.0
|
|
83
83
|
*/
|
|
84
84
|
interface SystemMessageOptions extends CachePointOptions {
|
|
85
85
|
}
|
|
@@ -88,7 +88,7 @@ declare module "effect/ai/Prompt" {
|
|
|
88
88
|
*
|
|
89
89
|
* @stability unstable
|
|
90
90
|
* @category models
|
|
91
|
-
* @since
|
|
91
|
+
* @since 0.1.0
|
|
92
92
|
*/
|
|
93
93
|
interface UserMessageOptions extends CachePointOptions {
|
|
94
94
|
}
|
|
@@ -97,7 +97,7 @@ declare module "effect/ai/Prompt" {
|
|
|
97
97
|
*
|
|
98
98
|
* @stability unstable
|
|
99
99
|
* @category models
|
|
100
|
-
* @since
|
|
100
|
+
* @since 0.1.0
|
|
101
101
|
*/
|
|
102
102
|
interface AssistantMessageOptions extends CachePointOptions {
|
|
103
103
|
}
|
|
@@ -106,7 +106,7 @@ declare module "effect/ai/Prompt" {
|
|
|
106
106
|
*
|
|
107
107
|
* @stability unstable
|
|
108
108
|
* @category models
|
|
109
|
-
* @since
|
|
109
|
+
* @since 0.1.0
|
|
110
110
|
*/
|
|
111
111
|
interface ToolMessageOptions extends CachePointOptions {
|
|
112
112
|
}
|
|
@@ -115,7 +115,7 @@ declare module "effect/ai/Prompt" {
|
|
|
115
115
|
*
|
|
116
116
|
* @stability unstable
|
|
117
117
|
* @category models
|
|
118
|
-
* @since
|
|
118
|
+
* @since 0.1.0
|
|
119
119
|
*/
|
|
120
120
|
interface TextPartOptions extends CachePointOptions {
|
|
121
121
|
}
|
|
@@ -124,7 +124,7 @@ declare module "effect/ai/Prompt" {
|
|
|
124
124
|
*
|
|
125
125
|
* @stability unstable
|
|
126
126
|
* @category models
|
|
127
|
-
* @since
|
|
127
|
+
* @since 0.1.0
|
|
128
128
|
*/
|
|
129
129
|
interface ToolCallPartOptions extends CachePointOptions {
|
|
130
130
|
}
|
|
@@ -133,7 +133,7 @@ declare module "effect/ai/Prompt" {
|
|
|
133
133
|
*
|
|
134
134
|
* @stability unstable
|
|
135
135
|
* @category models
|
|
136
|
-
* @since
|
|
136
|
+
* @since 0.1.0
|
|
137
137
|
*/
|
|
138
138
|
interface ToolResultPartOptions extends CachePointOptions {
|
|
139
139
|
}
|
|
@@ -143,7 +143,7 @@ declare module "effect/ai/Prompt" {
|
|
|
143
143
|
*
|
|
144
144
|
* @stability unstable
|
|
145
145
|
* @category models
|
|
146
|
-
* @since
|
|
146
|
+
* @since 0.1.0
|
|
147
147
|
*/
|
|
148
148
|
export type Citations = typeof CitationsConfig.Encoded;
|
|
149
149
|
/**
|
|
@@ -182,7 +182,7 @@ declare module "effect/ai/Prompt" {
|
|
|
182
182
|
*
|
|
183
183
|
* @stability unstable
|
|
184
184
|
* @category models
|
|
185
|
-
* @since
|
|
185
|
+
* @since 0.1.0
|
|
186
186
|
*/
|
|
187
187
|
interface FilePartOptions extends FileOptions {
|
|
188
188
|
}
|
|
@@ -198,7 +198,7 @@ declare module "effect/ai/Response" {
|
|
|
198
198
|
*
|
|
199
199
|
* @stability unstable
|
|
200
200
|
* @category models
|
|
201
|
-
* @since
|
|
201
|
+
* @since 0.1.0
|
|
202
202
|
*/
|
|
203
203
|
interface DocumentSourcePartMetadata extends ProviderMetadata {
|
|
204
204
|
readonly amazonBedrock?: {
|
|
@@ -223,7 +223,7 @@ declare module "effect/ai/Response" {
|
|
|
223
223
|
*
|
|
224
224
|
* @stability unstable
|
|
225
225
|
* @category models
|
|
226
|
-
* @since
|
|
226
|
+
* @since 0.1.0
|
|
227
227
|
*/
|
|
228
228
|
export type ReasoningInfo = {
|
|
229
229
|
readonly type: "reasoningText";
|
|
@@ -252,7 +252,7 @@ declare module "effect/ai/Prompt" {
|
|
|
252
252
|
*
|
|
253
253
|
* @stability unstable
|
|
254
254
|
* @category models
|
|
255
|
-
* @since
|
|
255
|
+
* @since 0.1.0
|
|
256
256
|
*/
|
|
257
257
|
interface ReasoningPartOptions extends ProviderOptions {
|
|
258
258
|
readonly amazonBedrock?: {
|
|
@@ -266,7 +266,7 @@ declare module "effect/ai/Response" {
|
|
|
266
266
|
*
|
|
267
267
|
* @stability unstable
|
|
268
268
|
* @category models
|
|
269
|
-
* @since
|
|
269
|
+
* @since 0.1.0
|
|
270
270
|
*/
|
|
271
271
|
interface ReasoningPartMetadata extends ProviderMetadata {
|
|
272
272
|
readonly amazonBedrock?: {
|
|
@@ -284,7 +284,7 @@ declare module "effect/ai/Response" {
|
|
|
284
284
|
*
|
|
285
285
|
* @stability unstable
|
|
286
286
|
* @category models
|
|
287
|
-
* @since
|
|
287
|
+
* @since 0.1.0
|
|
288
288
|
*/
|
|
289
289
|
interface ReasoningDeltaPartMetadata extends ProviderMetadata {
|
|
290
290
|
readonly amazonBedrock?: {
|
|
@@ -367,7 +367,7 @@ declare const Config_base: Context.ServiceClass<Config, "@wmaurer/effect-ai-amaz
|
|
|
367
367
|
*
|
|
368
368
|
* @stability unstable
|
|
369
369
|
* @category configuration
|
|
370
|
-
* @since
|
|
370
|
+
* @since 0.1.0
|
|
371
371
|
*/
|
|
372
372
|
export declare class Config extends Config_base {
|
|
373
373
|
}
|
|
@@ -377,7 +377,7 @@ export declare class Config extends Config_base {
|
|
|
377
377
|
*
|
|
378
378
|
* @stability unstable
|
|
379
379
|
* @category constructors
|
|
380
|
-
* @since
|
|
380
|
+
* @since 0.1.0
|
|
381
381
|
*/
|
|
382
382
|
export declare const model: (model: (string & {}) | Model, config?: Omit<typeof Config.Service, "modelId">) => AiModel.Model<"amazon-bedrock", LanguageModel.LanguageModel, AmazonBedrockClient>;
|
|
383
383
|
/**
|
|
@@ -386,7 +386,7 @@ export declare const model: (model: (string & {}) | Model, config?: Omit<typeof
|
|
|
386
386
|
*
|
|
387
387
|
* @stability unstable
|
|
388
388
|
* @category constructors
|
|
389
|
-
* @since
|
|
389
|
+
* @since 0.1.0
|
|
390
390
|
*/
|
|
391
391
|
export declare const make: (args_0: {
|
|
392
392
|
readonly model: (string & {}) | Model;
|
|
@@ -397,7 +397,7 @@ export declare const make: (args_0: {
|
|
|
397
397
|
*
|
|
398
398
|
* @stability unstable
|
|
399
399
|
* @category layers
|
|
400
|
-
* @since
|
|
400
|
+
* @since 0.1.0
|
|
401
401
|
*/
|
|
402
402
|
export declare const layer: (options: {
|
|
403
403
|
readonly model: (string & {}) | Model;
|
|
@@ -408,7 +408,7 @@ export declare const layer: (options: {
|
|
|
408
408
|
*
|
|
409
409
|
* @stability unstable
|
|
410
410
|
* @category configuration
|
|
411
|
-
* @since
|
|
411
|
+
* @since 0.1.0
|
|
412
412
|
*/
|
|
413
413
|
export declare const withConfigOverride: {
|
|
414
414
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* deltas Converse returns are surfaced as document source parts.
|
|
24
24
|
*
|
|
25
25
|
* @stability unstable
|
|
26
|
-
* @since
|
|
26
|
+
* @since 0.1.0
|
|
27
27
|
*/
|
|
28
28
|
import * as AiError from "effect/ai/AiError";
|
|
29
29
|
import { toCodecAnthropic } from "effect/ai/AnthropicStructuredOutput";
|
|
@@ -70,7 +70,7 @@ import * as InternalUtilities from "./internal/utilities.js";
|
|
|
70
70
|
*
|
|
71
71
|
* @stability unstable
|
|
72
72
|
* @category services
|
|
73
|
-
* @since
|
|
73
|
+
* @since 0.1.0
|
|
74
74
|
*/
|
|
75
75
|
export const ToolCachePoint = /*#__PURE__*/Context.Reference("@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockLanguageModel/ToolCachePoint", {
|
|
76
76
|
defaultValue: () => undefined
|
|
@@ -198,7 +198,7 @@ const reasoningTextInfo = signature => ({
|
|
|
198
198
|
*
|
|
199
199
|
* @stability unstable
|
|
200
200
|
* @category configuration
|
|
201
|
-
* @since
|
|
201
|
+
* @since 0.1.0
|
|
202
202
|
*/
|
|
203
203
|
export class Config extends /*#__PURE__*/Context.Service()("@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockLanguageModel/Config") {}
|
|
204
204
|
// =============================================================================
|
|
@@ -210,7 +210,7 @@ export class Config extends /*#__PURE__*/Context.Service()("@wmaurer/effect-ai-a
|
|
|
210
210
|
*
|
|
211
211
|
* @stability unstable
|
|
212
212
|
* @category constructors
|
|
213
|
-
* @since
|
|
213
|
+
* @since 0.1.0
|
|
214
214
|
*/
|
|
215
215
|
export const model = (model, config) => AiModel.make("amazon-bedrock", model, layer({
|
|
216
216
|
model,
|
|
@@ -222,7 +222,7 @@ export const model = (model, config) => AiModel.make("amazon-bedrock", model, la
|
|
|
222
222
|
*
|
|
223
223
|
* @stability unstable
|
|
224
224
|
* @category constructors
|
|
225
|
-
* @since
|
|
225
|
+
* @since 0.1.0
|
|
226
226
|
*/
|
|
227
227
|
export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
228
228
|
config: providerConfig,
|
|
@@ -371,7 +371,7 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
371
371
|
*
|
|
372
372
|
* @stability unstable
|
|
373
373
|
* @category layers
|
|
374
|
-
* @since
|
|
374
|
+
* @since 0.1.0
|
|
375
375
|
*/
|
|
376
376
|
export const layer = options => Layer.effect(LanguageModel.LanguageModel, make(options));
|
|
377
377
|
/**
|
|
@@ -379,7 +379,7 @@ export const layer = options => Layer.effect(LanguageModel.LanguageModel, make(o
|
|
|
379
379
|
*
|
|
380
380
|
* @stability unstable
|
|
381
381
|
* @category configuration
|
|
382
|
-
* @since
|
|
382
|
+
* @since 0.1.0
|
|
383
383
|
*/
|
|
384
384
|
export const withConfigOverride = /*#__PURE__*/dual(2, (self, overrides) => Effect.flatMap(Effect.serviceOption(Config), config => Effect.provideService(self, Config, {
|
|
385
385
|
...(config._tag === "Some" ? config.value : {}),
|