@effect/ai-openai 4.0.0-beta.70 → 4.0.0-beta.72
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/OpenAiClient.d.ts +88 -4
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +127 -8
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiConfig.d.ts +85 -17
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +53 -17
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +127 -3
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +101 -3
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiLanguageModel.d.ts +139 -10
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +107 -8
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +281 -12
- package/dist/OpenAiSchema.d.ts.map +1 -1
- package/dist/OpenAiSchema.js +227 -4
- package/dist/OpenAiSchema.js.map +1 -1
- package/dist/OpenAiTelemetry.d.ts +29 -1
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +29 -4
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/OpenAiTool.d.ts +130 -15
- package/dist/OpenAiTool.d.ts.map +1 -1
- package/dist/OpenAiTool.js +130 -15
- package/dist/OpenAiTool.js.map +1 -1
- package/dist/index.d.ts +1 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -49
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/OpenAiClient.ts +129 -9
- package/src/OpenAiConfig.ts +85 -17
- package/src/OpenAiEmbeddingModel.ts +153 -3
- package/src/OpenAiLanguageModel.ts +171 -12
- package/src/OpenAiSchema.ts +309 -4
- package/src/OpenAiTelemetry.ts +50 -5
- package/src/OpenAiTool.ts +130 -15
- package/src/index.ts +1 -49
package/dist/OpenAiConfig.js
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `OpenAiConfig` module
|
|
3
|
-
* `@effect/ai-openai`
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* OpenAI
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
2
|
+
* The `OpenAiConfig` module carries request-time configuration for the
|
|
3
|
+
* `@effect/ai-openai` package through Effect's context. It currently exposes a
|
|
4
|
+
* scoped HTTP client transform used by OpenAI request helpers when they execute
|
|
5
|
+
* provider calls.
|
|
6
|
+
*
|
|
7
|
+
* **Mental model**
|
|
8
|
+
*
|
|
9
|
+
* Client constructors set the baseline HTTP client for an OpenAI service.
|
|
10
|
+
* `OpenAiConfig` is for narrower dynamic scopes: wrap an effect with
|
|
11
|
+
* {@link withClientTransform} and OpenAI requests evaluated inside that effect
|
|
12
|
+
* see the transformed `HttpClient`. Leaving the scope restores the previous
|
|
13
|
+
* configuration.
|
|
14
|
+
*
|
|
15
|
+
* **Common tasks**
|
|
16
|
+
*
|
|
17
|
+
* - Add request middleware, tracing, retry policy, proxy routing, or test
|
|
18
|
+
* interception around a group of OpenAI calls.
|
|
19
|
+
* - Apply a temporary HTTP client transform without rebuilding the OpenAI
|
|
20
|
+
* service layer.
|
|
21
|
+
* - Share one transform across all OpenAI helpers executed inside the same
|
|
22
|
+
* Effect scope.
|
|
23
|
+
*
|
|
24
|
+
* **Gotchas**
|
|
25
|
+
*
|
|
26
|
+
* - Only one `transformClient` value is stored in the scoped config. Compose
|
|
27
|
+
* transforms into a single `HttpClient => HttpClient` function when multiple
|
|
28
|
+
* behaviors should apply.
|
|
29
|
+
* - The transform affects OpenAI requests that read this contextual config; it
|
|
30
|
+
* does not mutate an already constructed HTTP client globally.
|
|
17
31
|
*
|
|
18
32
|
* @since 4.0.0
|
|
19
33
|
*/
|
|
@@ -21,8 +35,14 @@ import * as Context from "effect/Context";
|
|
|
21
35
|
import * as Effect from "effect/Effect";
|
|
22
36
|
import { dual } from "effect/Function";
|
|
23
37
|
/**
|
|
24
|
-
* Context service
|
|
25
|
-
*
|
|
38
|
+
* Context service for scoped OpenAI configuration used by provider operations.
|
|
39
|
+
*
|
|
40
|
+
* **When to use**
|
|
41
|
+
*
|
|
42
|
+
* Use to provide scoped OpenAI client configuration, such as an HTTP client
|
|
43
|
+
* transform, to OpenAI provider operations without passing it through each call.
|
|
44
|
+
*
|
|
45
|
+
* @see {@link withClientTransform} for scoping an HTTP client transformation
|
|
26
46
|
*
|
|
27
47
|
* @category services
|
|
28
48
|
* @since 4.0.0
|
|
@@ -39,6 +59,22 @@ export class OpenAiConfig extends /*#__PURE__*/Context.Service()("@effect/ai-ope
|
|
|
39
59
|
* Provides a scoped transform for the OpenAI HTTP client used by provider
|
|
40
60
|
* operations.
|
|
41
61
|
*
|
|
62
|
+
* **When to use**
|
|
63
|
+
*
|
|
64
|
+
* Use when a single effect or workflow needs temporary OpenAI HTTP client
|
|
65
|
+
* customization without rebuilding the client layer.
|
|
66
|
+
*
|
|
67
|
+
* **Details**
|
|
68
|
+
*
|
|
69
|
+
* Supports both data-first and data-last forms. The transform is stored in the
|
|
70
|
+
* scoped `OpenAiConfig` service and read by OpenAI provider operations while
|
|
71
|
+
* running the supplied effect.
|
|
72
|
+
*
|
|
73
|
+
* **Gotchas**
|
|
74
|
+
*
|
|
75
|
+
* If a transform is already present in the scoped config, this helper replaces
|
|
76
|
+
* it. Compose transforms manually when both should apply.
|
|
77
|
+
*
|
|
42
78
|
* @category configuration
|
|
43
79
|
* @since 4.0.0
|
|
44
80
|
*/
|
package/dist/OpenAiConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiConfig.js","names":["Context","Effect","dual","OpenAiConfig","Service","getOrUndefined","map","context","mapUnsafe","get","key","withClientTransform","self","transformClient","flatMap","config","provideService"],"sources":["../src/OpenAiConfig.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenAiConfig.js","names":["Context","Effect","dual","OpenAiConfig","Service","getOrUndefined","map","context","mapUnsafe","get","key","withClientTransform","self","transformClient","flatMap","config","provideService"],"sources":["../src/OpenAiConfig.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,IAAI,QAAQ,iBAAiB;AAGtC;;;;;;;;;;;;;AAaA,OAAM,MAAOC,YAAa,sBAAQH,OAAO,CAACI,OAAO,EAG9C,CAAC,gCAAgC,CAAC;EACnC;;;;;EAKA,OAAgBC,cAAc,gBAA2DJ,MAAM,CAACK,GAAG,cACjGL,MAAM,CAACM,OAAO,EAAS,EACtBA,OAAO,IAAKA,OAAO,CAACC,SAAS,CAACC,GAAG,CAACN,YAAY,CAACO,GAAG,CAAC,CACrD;;AAqBH;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,MAAMC,mBAAmB,gBAoD5BT,IAAI,CAAC,CAAC,EAAE,CACVU,IAA4B,EAC5BC,eAAmD,KAEnDZ,MAAM,CAACa,OAAO,CACZX,YAAY,CAACE,cAAc,EAC1BU,MAAM,IAAKd,MAAM,CAACe,cAAc,CAACJ,IAAI,EAAET,YAAY,EAAE;EAAE,GAAGY,MAAM;EAAEF;AAAe,CAAE,CAAC,CACtF,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The `OpenAiEmbeddingModel` module provides the OpenAI implementation of
|
|
3
|
+
* Effect AI's `EmbeddingModel` service. It adapts the OpenAI embeddings
|
|
4
|
+
* endpoint into Effect AI's batch embedding interface, preserving input order
|
|
5
|
+
* and returning numeric vectors for each requested input.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
7
|
+
* **Mental model**
|
|
8
|
+
*
|
|
9
|
+
* `OpenAiClient` owns transport, authentication, and provider request
|
|
10
|
+
* execution. This module owns embedding-specific configuration, response
|
|
11
|
+
* validation, and the `EmbeddingModel.EmbeddingModel` layer. Use {@link model}
|
|
12
|
+
* when you want an `AiModel` descriptor that also provides the configured
|
|
13
|
+
* embedding dimensions, or {@link layer} / {@link make} when the dimensions are
|
|
14
|
+
* managed separately.
|
|
15
|
+
*
|
|
16
|
+
* **Common tasks**
|
|
17
|
+
*
|
|
18
|
+
* - Provide an OpenAI-backed `EmbeddingModel.EmbeddingModel` from an existing
|
|
19
|
+
* `OpenAiClient`
|
|
20
|
+
* - Configure the OpenAI embedding model id, dimensions, encoding format, and
|
|
21
|
+
* other create-embedding request fields
|
|
22
|
+
* - Scope per-request defaults with {@link Config} and
|
|
23
|
+
* {@link withConfigOverride}
|
|
24
|
+
*
|
|
25
|
+
* **Gotchas**
|
|
26
|
+
*
|
|
27
|
+
* - The service expects OpenAI to return floating-point embedding arrays.
|
|
28
|
+
* Requesting base64 embeddings causes an `InvalidOutputError`.
|
|
29
|
+
* - Provider results are checked for missing, duplicate, or out-of-range
|
|
30
|
+
* indexes before they are exposed as Effect AI embedding results.
|
|
5
31
|
*
|
|
6
32
|
* @since 4.0.0
|
|
7
33
|
*/
|
|
@@ -26,7 +52,20 @@ declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai/OpenA
|
|
|
26
52
|
readonly model?: string;
|
|
27
53
|
}>;
|
|
28
54
|
/**
|
|
29
|
-
*
|
|
55
|
+
* Context service for OpenAI embedding model configuration.
|
|
56
|
+
*
|
|
57
|
+
* **When to use**
|
|
58
|
+
*
|
|
59
|
+
* Use when embedding requests need scoped OpenAI request defaults or overrides
|
|
60
|
+
* from Effect context.
|
|
61
|
+
*
|
|
62
|
+
* **Details**
|
|
63
|
+
*
|
|
64
|
+
* The service stores the OpenAI create-embedding request payload without
|
|
65
|
+
* `input`, carrying options such as `model`, `dimensions`, `encoding_format`,
|
|
66
|
+
* and `user`.
|
|
67
|
+
*
|
|
68
|
+
* @see {@link withConfigOverride} for scoping embedding request overrides
|
|
30
69
|
*
|
|
31
70
|
* @category services
|
|
32
71
|
* @since 4.0.0
|
|
@@ -36,6 +75,14 @@ export declare class Config extends Config_base {
|
|
|
36
75
|
/**
|
|
37
76
|
* Creates an `AiModel` for an OpenAI embedding model with its configured vector dimensions.
|
|
38
77
|
*
|
|
78
|
+
* **When to use**
|
|
79
|
+
*
|
|
80
|
+
* Use to provide an OpenAI `EmbeddingModel` and its `Dimensions` service to an
|
|
81
|
+
* Effect program.
|
|
82
|
+
*
|
|
83
|
+
* @see {@link layer} for providing only the embedding model service
|
|
84
|
+
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
85
|
+
*
|
|
39
86
|
* @category constructors
|
|
40
87
|
* @since 4.0.0
|
|
41
88
|
*/
|
|
@@ -46,6 +93,29 @@ export declare const model: (model: (string & {}) | Model, options: {
|
|
|
46
93
|
/**
|
|
47
94
|
* Creates an OpenAI embedding model service.
|
|
48
95
|
*
|
|
96
|
+
* **When to use**
|
|
97
|
+
*
|
|
98
|
+
* Use to construct the `EmbeddingModel.Service` effectfully when
|
|
99
|
+
* `OpenAiClient` is already available in the environment or when the service
|
|
100
|
+
* value is needed directly.
|
|
101
|
+
*
|
|
102
|
+
* **Details**
|
|
103
|
+
*
|
|
104
|
+
* The `model` option is sent with each embedding request. Constructor `config`
|
|
105
|
+
* supplies create-embedding request fields other than `model` and `input`, and
|
|
106
|
+
* scoped overrides from `withConfigOverride` are merged last for each request.
|
|
107
|
+
*
|
|
108
|
+
* **Gotchas**
|
|
109
|
+
*
|
|
110
|
+
* The service expects numeric embedding vectors. It fails with
|
|
111
|
+
* `InvalidOutputError` when the provider returns base64 embeddings,
|
|
112
|
+
* out-of-range indexes, duplicate indexes, or an unexpected number of
|
|
113
|
+
* embeddings.
|
|
114
|
+
*
|
|
115
|
+
* @see {@link layer} for providing the embedding model service as a layer
|
|
116
|
+
* @see {@link model} for creating an `AiModel` that also provides dimensions
|
|
117
|
+
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
118
|
+
*
|
|
49
119
|
* @category constructors
|
|
50
120
|
* @since 4.0.0
|
|
51
121
|
*/
|
|
@@ -56,6 +126,21 @@ export declare const make: (args_0: {
|
|
|
56
126
|
/**
|
|
57
127
|
* Creates a layer for the OpenAI embedding model.
|
|
58
128
|
*
|
|
129
|
+
* **When to use**
|
|
130
|
+
*
|
|
131
|
+
* Use when composing application layers and you want OpenAI to satisfy
|
|
132
|
+
* `EmbeddingModel.EmbeddingModel` while supplying `OpenAiClient` from another
|
|
133
|
+
* layer.
|
|
134
|
+
*
|
|
135
|
+
* **Gotchas**
|
|
136
|
+
*
|
|
137
|
+
* Use the default floating-point embedding format. The service expects numeric
|
|
138
|
+
* vectors and fails with `InvalidOutputError` if OpenAI returns base64
|
|
139
|
+
* embeddings.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link make} for constructing the embedding model service effectfully
|
|
142
|
+
* @see {@link model} for creating an `AiModel` that also provides embedding dimensions
|
|
143
|
+
*
|
|
59
144
|
* @category layers
|
|
60
145
|
* @since 4.0.0
|
|
61
146
|
*/
|
|
@@ -66,6 +151,19 @@ export declare const layer: (options: {
|
|
|
66
151
|
/**
|
|
67
152
|
* Provides config overrides for OpenAI embedding model operations.
|
|
68
153
|
*
|
|
154
|
+
* **When to use**
|
|
155
|
+
*
|
|
156
|
+
* Use when a single effect or workflow needs scoped OpenAI embedding request
|
|
157
|
+
* defaults without rebuilding the embedding model service.
|
|
158
|
+
*
|
|
159
|
+
* **Details**
|
|
160
|
+
*
|
|
161
|
+
* Supports both data-first and data-last forms. Existing scoped config is read
|
|
162
|
+
* first, then the provided overrides are applied so override fields take
|
|
163
|
+
* precedence.
|
|
164
|
+
*
|
|
165
|
+
* @see {@link Config} for the scoped embedding request configuration service
|
|
166
|
+
*
|
|
69
167
|
* @category configuration
|
|
70
168
|
* @since 4.0.0
|
|
71
169
|
*/
|
|
@@ -73,6 +171,19 @@ export declare const withConfigOverride: {
|
|
|
73
171
|
/**
|
|
74
172
|
* Provides config overrides for OpenAI embedding model operations.
|
|
75
173
|
*
|
|
174
|
+
* **When to use**
|
|
175
|
+
*
|
|
176
|
+
* Use when a single effect or workflow needs scoped OpenAI embedding request
|
|
177
|
+
* defaults without rebuilding the embedding model service.
|
|
178
|
+
*
|
|
179
|
+
* **Details**
|
|
180
|
+
*
|
|
181
|
+
* Supports both data-first and data-last forms. Existing scoped config is read
|
|
182
|
+
* first, then the provided overrides are applied so override fields take
|
|
183
|
+
* precedence.
|
|
184
|
+
*
|
|
185
|
+
* @see {@link Config} for the scoped embedding request configuration service
|
|
186
|
+
*
|
|
76
187
|
* @category configuration
|
|
77
188
|
* @since 4.0.0
|
|
78
189
|
*/
|
|
@@ -80,6 +191,19 @@ export declare const withConfigOverride: {
|
|
|
80
191
|
/**
|
|
81
192
|
* Provides config overrides for OpenAI embedding model operations.
|
|
82
193
|
*
|
|
194
|
+
* **When to use**
|
|
195
|
+
*
|
|
196
|
+
* Use when a single effect or workflow needs scoped OpenAI embedding request
|
|
197
|
+
* defaults without rebuilding the embedding model service.
|
|
198
|
+
*
|
|
199
|
+
* **Details**
|
|
200
|
+
*
|
|
201
|
+
* Supports both data-first and data-last forms. Existing scoped config is read
|
|
202
|
+
* first, then the provided overrides are applied so override fields take
|
|
203
|
+
* precedence.
|
|
204
|
+
*
|
|
205
|
+
* @see {@link Config} for the scoped embedding request configuration service
|
|
206
|
+
*
|
|
83
207
|
* @category configuration
|
|
84
208
|
* @since 4.0.0
|
|
85
209
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiEmbeddingModel.d.ts","sourceRoot":"","sources":["../src/Open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;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS;IAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,KAAK,CAAA;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CACnE,KAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,KAAK,EAAE,YAAY,CACN,CAAA;AAE5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,EAAE;IAC/B;;;;;;;;;;;;;;;;;;OAkBG;IACH,CAAC,SAAS,EAAE,OAAO,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;IACtH;;;;;;;;;;;;;;;;;;OAkBG;IACH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;CAkDhH,CAAA"}
|
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The `OpenAiEmbeddingModel` module provides the OpenAI implementation of
|
|
3
|
+
* Effect AI's `EmbeddingModel` service. It adapts the OpenAI embeddings
|
|
4
|
+
* endpoint into Effect AI's batch embedding interface, preserving input order
|
|
5
|
+
* and returning numeric vectors for each requested input.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
7
|
+
* **Mental model**
|
|
8
|
+
*
|
|
9
|
+
* `OpenAiClient` owns transport, authentication, and provider request
|
|
10
|
+
* execution. This module owns embedding-specific configuration, response
|
|
11
|
+
* validation, and the `EmbeddingModel.EmbeddingModel` layer. Use {@link model}
|
|
12
|
+
* when you want an `AiModel` descriptor that also provides the configured
|
|
13
|
+
* embedding dimensions, or {@link layer} / {@link make} when the dimensions are
|
|
14
|
+
* managed separately.
|
|
15
|
+
*
|
|
16
|
+
* **Common tasks**
|
|
17
|
+
*
|
|
18
|
+
* - Provide an OpenAI-backed `EmbeddingModel.EmbeddingModel` from an existing
|
|
19
|
+
* `OpenAiClient`
|
|
20
|
+
* - Configure the OpenAI embedding model id, dimensions, encoding format, and
|
|
21
|
+
* other create-embedding request fields
|
|
22
|
+
* - Scope per-request defaults with {@link Config} and
|
|
23
|
+
* {@link withConfigOverride}
|
|
24
|
+
*
|
|
25
|
+
* **Gotchas**
|
|
26
|
+
*
|
|
27
|
+
* - The service expects OpenAI to return floating-point embedding arrays.
|
|
28
|
+
* Requesting base64 embeddings causes an `InvalidOutputError`.
|
|
29
|
+
* - Provider results are checked for missing, duplicate, or out-of-range
|
|
30
|
+
* indexes before they are exposed as Effect AI embedding results.
|
|
5
31
|
*
|
|
6
32
|
* @since 4.0.0
|
|
7
33
|
*/
|
|
@@ -14,7 +40,20 @@ import * as EmbeddingModel from "effect/unstable/ai/EmbeddingModel";
|
|
|
14
40
|
import * as AiModel from "effect/unstable/ai/Model";
|
|
15
41
|
import { OpenAiClient } from "./OpenAiClient.js";
|
|
16
42
|
/**
|
|
17
|
-
*
|
|
43
|
+
* Context service for OpenAI embedding model configuration.
|
|
44
|
+
*
|
|
45
|
+
* **When to use**
|
|
46
|
+
*
|
|
47
|
+
* Use when embedding requests need scoped OpenAI request defaults or overrides
|
|
48
|
+
* from Effect context.
|
|
49
|
+
*
|
|
50
|
+
* **Details**
|
|
51
|
+
*
|
|
52
|
+
* The service stores the OpenAI create-embedding request payload without
|
|
53
|
+
* `input`, carrying options such as `model`, `dimensions`, `encoding_format`,
|
|
54
|
+
* and `user`.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link withConfigOverride} for scoping embedding request overrides
|
|
18
57
|
*
|
|
19
58
|
* @category services
|
|
20
59
|
* @since 4.0.0
|
|
@@ -23,6 +62,14 @@ export class Config extends /*#__PURE__*/Context.Service()("@effect/ai-openai/Op
|
|
|
23
62
|
/**
|
|
24
63
|
* Creates an `AiModel` for an OpenAI embedding model with its configured vector dimensions.
|
|
25
64
|
*
|
|
65
|
+
* **When to use**
|
|
66
|
+
*
|
|
67
|
+
* Use to provide an OpenAI `EmbeddingModel` and its `Dimensions` service to an
|
|
68
|
+
* Effect program.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link layer} for providing only the embedding model service
|
|
71
|
+
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
72
|
+
*
|
|
26
73
|
* @category constructors
|
|
27
74
|
* @since 4.0.0
|
|
28
75
|
*/
|
|
@@ -36,6 +83,29 @@ export const model = (model, options) => AiModel.make("openai", model, Layer.mer
|
|
|
36
83
|
/**
|
|
37
84
|
* Creates an OpenAI embedding model service.
|
|
38
85
|
*
|
|
86
|
+
* **When to use**
|
|
87
|
+
*
|
|
88
|
+
* Use to construct the `EmbeddingModel.Service` effectfully when
|
|
89
|
+
* `OpenAiClient` is already available in the environment or when the service
|
|
90
|
+
* value is needed directly.
|
|
91
|
+
*
|
|
92
|
+
* **Details**
|
|
93
|
+
*
|
|
94
|
+
* The `model` option is sent with each embedding request. Constructor `config`
|
|
95
|
+
* supplies create-embedding request fields other than `model` and `input`, and
|
|
96
|
+
* scoped overrides from `withConfigOverride` are merged last for each request.
|
|
97
|
+
*
|
|
98
|
+
* **Gotchas**
|
|
99
|
+
*
|
|
100
|
+
* The service expects numeric embedding vectors. It fails with
|
|
101
|
+
* `InvalidOutputError` when the provider returns base64 embeddings,
|
|
102
|
+
* out-of-range indexes, duplicate indexes, or an unexpected number of
|
|
103
|
+
* embeddings.
|
|
104
|
+
*
|
|
105
|
+
* @see {@link layer} for providing the embedding model service as a layer
|
|
106
|
+
* @see {@link model} for creating an `AiModel` that also provides dimensions
|
|
107
|
+
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
108
|
+
*
|
|
39
109
|
* @category constructors
|
|
40
110
|
* @since 4.0.0
|
|
41
111
|
*/
|
|
@@ -68,6 +138,21 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
68
138
|
/**
|
|
69
139
|
* Creates a layer for the OpenAI embedding model.
|
|
70
140
|
*
|
|
141
|
+
* **When to use**
|
|
142
|
+
*
|
|
143
|
+
* Use when composing application layers and you want OpenAI to satisfy
|
|
144
|
+
* `EmbeddingModel.EmbeddingModel` while supplying `OpenAiClient` from another
|
|
145
|
+
* layer.
|
|
146
|
+
*
|
|
147
|
+
* **Gotchas**
|
|
148
|
+
*
|
|
149
|
+
* Use the default floating-point embedding format. The service expects numeric
|
|
150
|
+
* vectors and fails with `InvalidOutputError` if OpenAI returns base64
|
|
151
|
+
* embeddings.
|
|
152
|
+
*
|
|
153
|
+
* @see {@link make} for constructing the embedding model service effectfully
|
|
154
|
+
* @see {@link model} for creating an `AiModel` that also provides embedding dimensions
|
|
155
|
+
*
|
|
71
156
|
* @category layers
|
|
72
157
|
* @since 4.0.0
|
|
73
158
|
*/
|
|
@@ -75,6 +160,19 @@ export const layer = options => Layer.effect(EmbeddingModel.EmbeddingModel, make
|
|
|
75
160
|
/**
|
|
76
161
|
* Provides config overrides for OpenAI embedding model operations.
|
|
77
162
|
*
|
|
163
|
+
* **When to use**
|
|
164
|
+
*
|
|
165
|
+
* Use when a single effect or workflow needs scoped OpenAI embedding request
|
|
166
|
+
* defaults without rebuilding the embedding model service.
|
|
167
|
+
*
|
|
168
|
+
* **Details**
|
|
169
|
+
*
|
|
170
|
+
* Supports both data-first and data-last forms. Existing scoped config is read
|
|
171
|
+
* first, then the provided overrides are applied so override fields take
|
|
172
|
+
* precedence.
|
|
173
|
+
*
|
|
174
|
+
* @see {@link Config} for the scoped embedding request configuration service
|
|
175
|
+
*
|
|
78
176
|
* @category configuration
|
|
79
177
|
* @since 4.0.0
|
|
80
178
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiEmbeddingModel.js","names":["Context","Effect","dual","Layer","AiError","EmbeddingModel","AiModel","OpenAiClient","Config","Service","model","options","make","merge","layer","config","dimensions","succeed","Dimensions","fnUntraced","providerConfig","client","makeConfig","gen","services","context","mapUnsafe","get","key","embedMany","inputs","response","createEmbedding","input","mapProviderResponse","length","effect","withConfigOverride","self","overrides","flatMap","serviceOption","provideService","_tag","value","inputLength","data","fail","invalidOutput","results","Array","seen","Set","entry","Number","isInteger","index","has","isArray","embedding","add","size","usage","inputTokens","prompt_tokens","description","module","method","reason","InvalidOutputError"],"sources":["../src/OpenAiEmbeddingModel.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenAiEmbeddingModel.js","names":["Context","Effect","dual","Layer","AiError","EmbeddingModel","AiModel","OpenAiClient","Config","Service","model","options","make","merge","layer","config","dimensions","succeed","Dimensions","fnUntraced","providerConfig","client","makeConfig","gen","services","context","mapUnsafe","get","key","embedMany","inputs","response","createEmbedding","input","mapProviderResponse","length","effect","withConfigOverride","self","overrides","flatMap","serviceOption","provideService","_tag","value","inputLength","data","fail","invalidOutput","results","Array","seen","Set","entry","Number","isInteger","index","has","isArray","embedding","add","size","usage","inputTokens","prompt_tokens","description","module","method","reason","InvalidOutputError"],"sources":["../src/OpenAiEmbeddingModel.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,IAAI,QAAQ,iBAAiB;A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E,sBAAsB;EAC9BC,MAAM,EAAE,WAAW;EACnBC,MAAM,EAAE,IAAIhE,OAAO,CAACiE,kBAAkB,CAAC;IAAEJ;EAAW,CAAE;CACvD,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenAI
|
|
2
|
+
* The `OpenAiLanguageModel` module provides the OpenAI Responses API
|
|
3
|
+
* implementation of Effect AI's `LanguageModel` service. It translates Effect
|
|
4
|
+
* AI prompts, files, tools, structured output requests, reasoning metadata, and
|
|
5
|
+
* provider options into OpenAI response requests, then converts OpenAI
|
|
6
|
+
* responses and streams back into Effect AI response parts.
|
|
3
7
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
8
|
+
* **Mental model**
|
|
9
|
+
*
|
|
10
|
+
* `OpenAiClient` owns HTTP transport and provider calls. This module owns
|
|
11
|
+
* protocol translation: request assembly, tool choice conversion, structured
|
|
12
|
+
* output codecs, streaming event handling, response metadata, and GenAI
|
|
13
|
+
* telemetry annotations. {@link model}, {@link layer}, and {@link make} all
|
|
14
|
+
* build the same OpenAI-backed `LanguageModel.LanguageModel` service from a
|
|
15
|
+
* model id and optional request defaults.
|
|
16
|
+
*
|
|
17
|
+
* **Common tasks**
|
|
18
|
+
*
|
|
19
|
+
* - Provide an OpenAI-backed `LanguageModel.LanguageModel` from an existing
|
|
20
|
+
* `OpenAiClient`
|
|
21
|
+
* - Generate text or stream text through Effect AI's provider-neutral language
|
|
22
|
+
* model API
|
|
23
|
+
* - Use OpenAI provider metadata for files, reasoning items, tool calls, and
|
|
24
|
+
* response parts
|
|
25
|
+
* - Scope Responses API defaults with {@link Config} and
|
|
26
|
+
* {@link withConfigOverride}
|
|
27
|
+
*
|
|
28
|
+
* **Gotchas**
|
|
29
|
+
*
|
|
30
|
+
* - Some OpenAI model families receive system instructions as developer
|
|
31
|
+
* messages because the Responses API treats them differently.
|
|
32
|
+
* - File prompt parts are sent either as provider file ids or as base64
|
|
33
|
+
* content, depending on `fileIdPrefixes`.
|
|
34
|
+
* - Structured output and tool-call behavior depends on both Effect AI tool
|
|
35
|
+
* definitions and OpenAI model capabilities.
|
|
6
36
|
*
|
|
7
37
|
* @since 4.0.0
|
|
8
38
|
*/
|
|
@@ -73,7 +103,19 @@ declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai/OpenA
|
|
|
73
103
|
readonly strictJsonSchema?: boolean | undefined | undefined;
|
|
74
104
|
}>;
|
|
75
105
|
/**
|
|
76
|
-
*
|
|
106
|
+
* Context service for OpenAI language model configuration.
|
|
107
|
+
*
|
|
108
|
+
* **When to use**
|
|
109
|
+
*
|
|
110
|
+
* Use when you need to provide OpenAI Responses API request defaults through
|
|
111
|
+
* Effect context for language model operations.
|
|
112
|
+
*
|
|
113
|
+
* **Details**
|
|
114
|
+
*
|
|
115
|
+
* Config values are merged with the config object passed to `model`, `make`, or
|
|
116
|
+
* `layer`, with scoped context values taking precedence.
|
|
117
|
+
*
|
|
118
|
+
* @see {@link withConfigOverride} for scoping language model request overrides
|
|
77
119
|
*
|
|
78
120
|
* @category services
|
|
79
121
|
* @since 4.0.0
|
|
@@ -459,14 +501,39 @@ declare module "effect/unstable/ai/Response" {
|
|
|
459
501
|
}
|
|
460
502
|
}
|
|
461
503
|
/**
|
|
462
|
-
* Creates an OpenAI
|
|
504
|
+
* Creates an OpenAI model descriptor that can be provided with
|
|
505
|
+
* `Effect.provide`.
|
|
506
|
+
*
|
|
507
|
+
* **When to use**
|
|
508
|
+
*
|
|
509
|
+
* Use when you want an OpenAI language model value that carries provider and
|
|
510
|
+
* model metadata and can be supplied directly to an Effect program.
|
|
511
|
+
*
|
|
512
|
+
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
513
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
463
514
|
*
|
|
464
515
|
* @category constructors
|
|
465
516
|
* @since 4.0.0
|
|
466
517
|
*/
|
|
467
518
|
export declare const model: (model: (string & {}) | Model, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenAiClient>;
|
|
468
519
|
/**
|
|
469
|
-
* Creates an OpenAI
|
|
520
|
+
* Creates an OpenAI `LanguageModel` service from a model identifier and
|
|
521
|
+
* optional request defaults.
|
|
522
|
+
*
|
|
523
|
+
* **When to use**
|
|
524
|
+
*
|
|
525
|
+
* Use when an Effect needs to construct a `LanguageModel.Service` value backed
|
|
526
|
+
* by `OpenAiClient`.
|
|
527
|
+
*
|
|
528
|
+
* **Details**
|
|
529
|
+
*
|
|
530
|
+
* The returned effect requires `OpenAiClient`. Request defaults from the
|
|
531
|
+
* `config` option are merged with any `Config` service in the context, with
|
|
532
|
+
* context values taking precedence. The service supports both `generateText`
|
|
533
|
+
* and `streamText`.
|
|
534
|
+
*
|
|
535
|
+
* @see {@link layer} for providing the service as a `Layer`
|
|
536
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
470
537
|
*
|
|
471
538
|
* @category constructors
|
|
472
539
|
* @since 4.0.0
|
|
@@ -476,7 +543,24 @@ export declare const make: (args_0: {
|
|
|
476
543
|
readonly config?: Omit<typeof Config.Service, "model"> | undefined;
|
|
477
544
|
}) => Effect.Effect<LanguageModel.Service, never, OpenAiClient>;
|
|
478
545
|
/**
|
|
479
|
-
* Creates a layer
|
|
546
|
+
* Creates a layer that provides the OpenAI `LanguageModel.LanguageModel`
|
|
547
|
+
* service.
|
|
548
|
+
*
|
|
549
|
+
* **When to use**
|
|
550
|
+
*
|
|
551
|
+
* Use when composing application layers and you want OpenAI to satisfy
|
|
552
|
+
* `LanguageModel.LanguageModel` while supplying `OpenAiClient` from another
|
|
553
|
+
* layer.
|
|
554
|
+
*
|
|
555
|
+
* **Details**
|
|
556
|
+
*
|
|
557
|
+
* The `config` option supplies request defaults for the selected model. Scoped
|
|
558
|
+
* values from `withConfigOverride` are merged when each request is built and
|
|
559
|
+
* take precedence over these defaults.
|
|
560
|
+
*
|
|
561
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
562
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
563
|
+
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
480
564
|
*
|
|
481
565
|
* @category layers
|
|
482
566
|
* @since 4.0.0
|
|
@@ -486,21 +570,66 @@ export declare const layer: (options: {
|
|
|
486
570
|
readonly config?: Omit<typeof Config.Service, "model"> | undefined;
|
|
487
571
|
}) => Layer.Layer<LanguageModel.LanguageModel, never, OpenAiClient>;
|
|
488
572
|
/**
|
|
489
|
-
* Provides config overrides for OpenAI language model operations.
|
|
573
|
+
* Provides scoped config overrides for OpenAI language model operations.
|
|
574
|
+
*
|
|
575
|
+
* **When to use**
|
|
576
|
+
*
|
|
577
|
+
* Use to apply OpenAI Responses API config overrides around one or more
|
|
578
|
+
* language model operations without changing the defaults passed to `model`,
|
|
579
|
+
* `make`, or `layer`.
|
|
580
|
+
*
|
|
581
|
+
* **Details**
|
|
582
|
+
*
|
|
583
|
+
* The override is dual, so it can be used in pipe form or as
|
|
584
|
+
* `withConfigOverride(effect, overrides)`. Overrides are merged with any
|
|
585
|
+
* existing `Config` service in the current context, and the override values take
|
|
586
|
+
* precedence.
|
|
587
|
+
*
|
|
588
|
+
* @see {@link Config} for the scoped configuration service consumed by this function
|
|
490
589
|
*
|
|
491
590
|
* @category configuration
|
|
492
591
|
* @since 4.0.0
|
|
493
592
|
*/
|
|
494
593
|
export declare const withConfigOverride: {
|
|
495
594
|
/**
|
|
496
|
-
* Provides config overrides for OpenAI language model operations.
|
|
595
|
+
* Provides scoped config overrides for OpenAI language model operations.
|
|
596
|
+
*
|
|
597
|
+
* **When to use**
|
|
598
|
+
*
|
|
599
|
+
* Use to apply OpenAI Responses API config overrides around one or more
|
|
600
|
+
* language model operations without changing the defaults passed to `model`,
|
|
601
|
+
* `make`, or `layer`.
|
|
602
|
+
*
|
|
603
|
+
* **Details**
|
|
604
|
+
*
|
|
605
|
+
* The override is dual, so it can be used in pipe form or as
|
|
606
|
+
* `withConfigOverride(effect, overrides)`. Overrides are merged with any
|
|
607
|
+
* existing `Config` service in the current context, and the override values take
|
|
608
|
+
* precedence.
|
|
609
|
+
*
|
|
610
|
+
* @see {@link Config} for the scoped configuration service consumed by this function
|
|
497
611
|
*
|
|
498
612
|
* @category configuration
|
|
499
613
|
* @since 4.0.0
|
|
500
614
|
*/
|
|
501
615
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
502
616
|
/**
|
|
503
|
-
* Provides config overrides for OpenAI language model operations.
|
|
617
|
+
* Provides scoped config overrides for OpenAI language model operations.
|
|
618
|
+
*
|
|
619
|
+
* **When to use**
|
|
620
|
+
*
|
|
621
|
+
* Use to apply OpenAI Responses API config overrides around one or more
|
|
622
|
+
* language model operations without changing the defaults passed to `model`,
|
|
623
|
+
* `make`, or `layer`.
|
|
624
|
+
*
|
|
625
|
+
* **Details**
|
|
626
|
+
*
|
|
627
|
+
* The override is dual, so it can be used in pipe form or as
|
|
628
|
+
* `withConfigOverride(effect, overrides)`. Overrides are merged with any
|
|
629
|
+
* existing `Config` service in the current context, and the override values take
|
|
630
|
+
* precedence.
|
|
631
|
+
*
|
|
632
|
+
* @see {@link Config} for the scoped configuration service consumed by this function
|
|
504
633
|
*
|
|
505
634
|
* @category configuration
|
|
506
635
|
* @since 4.0.0
|