@effect/ai-openai-compat 4.0.0-beta.65 → 4.0.0-beta.67
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 +145 -41
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +41 -5
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiConfig.d.ts +56 -8
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +35 -4
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +14 -9
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +9 -6
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiError.d.ts +85 -3
- package/dist/OpenAiError.d.ts.map +1 -1
- package/dist/OpenAiError.js +14 -1
- package/dist/OpenAiLanguageModel.d.ts +161 -12
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +9 -7
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiTelemetry.d.ts +13 -10
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +2 -2
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/package.json +3 -3
- package/src/OpenAiClient.ts +169 -42
- package/src/OpenAiConfig.ts +56 -8
- package/src/OpenAiEmbeddingModel.ts +16 -11
- package/src/OpenAiError.ts +85 -3
- package/src/OpenAiLanguageModel.ts +164 -15
- package/src/OpenAiTelemetry.ts +14 -11
- package/src/index.ts +7 -7
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides a LanguageModel implementation for OpenAI's chat completions API,
|
|
5
5
|
* supporting text generation, structured output, tool calling, and streaming.
|
|
6
6
|
*
|
|
7
|
-
* @since
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
@@ -63,13 +63,19 @@ declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai-compa
|
|
|
63
63
|
/**
|
|
64
64
|
* Service definition for OpenAI language model configuration.
|
|
65
65
|
*
|
|
66
|
-
* @since 1.0.0
|
|
67
66
|
* @category context
|
|
67
|
+
* @since 4.0.0
|
|
68
68
|
*/
|
|
69
69
|
export declare class Config extends Config_base {
|
|
70
70
|
}
|
|
71
71
|
declare module "effect/unstable/ai/Prompt" {
|
|
72
|
+
/**
|
|
73
|
+
* OpenAI-compatible options for file prompt parts.
|
|
74
|
+
*/
|
|
72
75
|
interface FilePartOptions extends ProviderOptions {
|
|
76
|
+
/**
|
|
77
|
+
* Provider-specific file options for OpenAI-compatible APIs.
|
|
78
|
+
*/
|
|
73
79
|
readonly openai?: {
|
|
74
80
|
/**
|
|
75
81
|
* The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
|
|
@@ -77,7 +83,13 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
77
83
|
readonly imageDetail?: ImageDetail | null;
|
|
78
84
|
} | null;
|
|
79
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* OpenAI-compatible options for reasoning prompt parts.
|
|
88
|
+
*/
|
|
80
89
|
interface ReasoningPartOptions extends ProviderOptions {
|
|
90
|
+
/**
|
|
91
|
+
* Provider-specific reasoning options for OpenAI-compatible APIs.
|
|
92
|
+
*/
|
|
81
93
|
readonly openai?: {
|
|
82
94
|
/**
|
|
83
95
|
* The ID of the item to reference.
|
|
@@ -91,38 +103,56 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
91
103
|
readonly encryptedContent?: string | null;
|
|
92
104
|
} | null;
|
|
93
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* OpenAI-compatible options for assistant tool-call prompt parts.
|
|
108
|
+
*/
|
|
94
109
|
interface ToolCallPartOptions extends ProviderOptions {
|
|
110
|
+
/**
|
|
111
|
+
* Provider-specific tool-call options for OpenAI-compatible APIs.
|
|
112
|
+
*/
|
|
95
113
|
readonly openai?: {
|
|
96
114
|
/**
|
|
97
115
|
* The ID of the item to reference.
|
|
98
116
|
*/
|
|
99
117
|
readonly itemId?: string | null;
|
|
100
118
|
/**
|
|
101
|
-
* The status
|
|
119
|
+
* The status to send for the tool-call item.
|
|
102
120
|
*/
|
|
103
121
|
readonly status?: MessageStatus | null;
|
|
104
122
|
} | null;
|
|
105
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* OpenAI-compatible options for tool-result prompt parts.
|
|
126
|
+
*/
|
|
106
127
|
interface ToolResultPartOptions extends ProviderOptions {
|
|
128
|
+
/**
|
|
129
|
+
* Provider-specific tool-result options for OpenAI-compatible APIs.
|
|
130
|
+
*/
|
|
107
131
|
readonly openai?: {
|
|
108
132
|
/**
|
|
109
133
|
* The ID of the item to reference.
|
|
110
134
|
*/
|
|
111
135
|
readonly itemId?: string | null;
|
|
112
136
|
/**
|
|
113
|
-
* The status
|
|
137
|
+
* The status to send for the tool-result item.
|
|
114
138
|
*/
|
|
115
139
|
readonly status?: MessageStatus | null;
|
|
116
140
|
} | null;
|
|
117
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* OpenAI-compatible options for text prompt parts.
|
|
144
|
+
*/
|
|
118
145
|
interface TextPartOptions extends ProviderOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Provider-specific text options for OpenAI-compatible APIs.
|
|
148
|
+
*/
|
|
119
149
|
readonly openai?: {
|
|
120
150
|
/**
|
|
121
151
|
* The ID of the item to reference.
|
|
122
152
|
*/
|
|
123
153
|
readonly itemId?: string | null;
|
|
124
154
|
/**
|
|
125
|
-
* The status
|
|
155
|
+
* The status to send for the text item.
|
|
126
156
|
*/
|
|
127
157
|
readonly status?: MessageStatus | null;
|
|
128
158
|
/**
|
|
@@ -133,8 +163,17 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
133
163
|
}
|
|
134
164
|
}
|
|
135
165
|
declare module "effect/unstable/ai/Response" {
|
|
166
|
+
/**
|
|
167
|
+
* OpenAI-compatible metadata attached to a complete text response part.
|
|
168
|
+
*/
|
|
136
169
|
interface TextPartMetadata extends ProviderMetadata {
|
|
170
|
+
/**
|
|
171
|
+
* Provider-specific metadata returned for the text part.
|
|
172
|
+
*/
|
|
137
173
|
readonly openai?: {
|
|
174
|
+
/**
|
|
175
|
+
* The OpenAI item ID associated with the text part.
|
|
176
|
+
*/
|
|
138
177
|
readonly itemId?: string | null;
|
|
139
178
|
/**
|
|
140
179
|
* If the model emits a refusal content part, the refusal explanation
|
|
@@ -143,7 +182,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
143
182
|
*/
|
|
144
183
|
readonly refusal?: string | null;
|
|
145
184
|
/**
|
|
146
|
-
* The status
|
|
185
|
+
* The status returned for the text item.
|
|
147
186
|
*/
|
|
148
187
|
readonly status?: MessageStatus | null;
|
|
149
188
|
/**
|
|
@@ -152,47 +191,131 @@ declare module "effect/unstable/ai/Response" {
|
|
|
152
191
|
readonly annotations?: ReadonlyArray<Annotation> | null;
|
|
153
192
|
};
|
|
154
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* OpenAI-compatible metadata emitted when a streamed text part starts.
|
|
196
|
+
*/
|
|
155
197
|
interface TextStartPartMetadata extends ProviderMetadata {
|
|
198
|
+
/**
|
|
199
|
+
* Provider-specific metadata returned for the streamed text start.
|
|
200
|
+
*/
|
|
156
201
|
readonly openai?: {
|
|
202
|
+
/**
|
|
203
|
+
* The OpenAI item ID associated with the streamed text part.
|
|
204
|
+
*/
|
|
157
205
|
readonly itemId?: string | null;
|
|
158
206
|
} | null;
|
|
159
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* OpenAI-compatible metadata emitted when a streamed text part ends.
|
|
210
|
+
*/
|
|
160
211
|
interface TextEndPartMetadata extends ProviderMetadata {
|
|
212
|
+
/**
|
|
213
|
+
* Provider-specific metadata returned for the streamed text end.
|
|
214
|
+
*/
|
|
161
215
|
readonly openai?: {
|
|
216
|
+
/**
|
|
217
|
+
* The OpenAI item ID associated with the streamed text part.
|
|
218
|
+
*/
|
|
162
219
|
readonly itemId?: string | null;
|
|
220
|
+
/**
|
|
221
|
+
* The annotations collected for the completed streamed text part.
|
|
222
|
+
*/
|
|
163
223
|
readonly annotations?: ReadonlyArray<Annotation> | null;
|
|
164
224
|
} | null;
|
|
165
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* OpenAI-compatible metadata attached to a complete reasoning response part.
|
|
228
|
+
*/
|
|
166
229
|
interface ReasoningPartMetadata extends ProviderMetadata {
|
|
230
|
+
/**
|
|
231
|
+
* Provider-specific metadata returned for the reasoning part.
|
|
232
|
+
*/
|
|
167
233
|
readonly openai?: {
|
|
234
|
+
/**
|
|
235
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
236
|
+
*/
|
|
168
237
|
readonly itemId?: string | null;
|
|
238
|
+
/**
|
|
239
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
240
|
+
*/
|
|
169
241
|
readonly encryptedContent?: string | null;
|
|
170
242
|
} | null;
|
|
171
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* OpenAI-compatible metadata emitted when a streamed reasoning part starts.
|
|
246
|
+
*/
|
|
172
247
|
interface ReasoningStartPartMetadata extends ProviderMetadata {
|
|
248
|
+
/**
|
|
249
|
+
* Provider-specific metadata returned for the streamed reasoning start.
|
|
250
|
+
*/
|
|
173
251
|
readonly openai?: {
|
|
252
|
+
/**
|
|
253
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
254
|
+
*/
|
|
174
255
|
readonly itemId?: string | null;
|
|
256
|
+
/**
|
|
257
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
258
|
+
*/
|
|
175
259
|
readonly encryptedContent?: string | null;
|
|
176
260
|
} | null;
|
|
177
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* OpenAI-compatible metadata emitted for a streamed reasoning delta.
|
|
264
|
+
*/
|
|
178
265
|
interface ReasoningDeltaPartMetadata extends ProviderMetadata {
|
|
266
|
+
/**
|
|
267
|
+
* Provider-specific metadata returned for the streamed reasoning delta.
|
|
268
|
+
*/
|
|
179
269
|
readonly openai?: {
|
|
270
|
+
/**
|
|
271
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
272
|
+
*/
|
|
180
273
|
readonly itemId?: string | null;
|
|
181
274
|
} | null;
|
|
182
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* OpenAI-compatible metadata emitted when a streamed reasoning part ends.
|
|
278
|
+
*/
|
|
183
279
|
interface ReasoningEndPartMetadata extends ProviderMetadata {
|
|
280
|
+
/**
|
|
281
|
+
* Provider-specific metadata returned for the streamed reasoning end.
|
|
282
|
+
*/
|
|
184
283
|
readonly openai?: {
|
|
284
|
+
/**
|
|
285
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
286
|
+
*/
|
|
185
287
|
readonly itemId?: string | null;
|
|
288
|
+
/**
|
|
289
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
290
|
+
*/
|
|
186
291
|
readonly encryptedContent?: string;
|
|
187
292
|
} | null;
|
|
188
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* OpenAI-compatible metadata attached to tool-call response parts.
|
|
296
|
+
*/
|
|
189
297
|
interface ToolCallPartMetadata extends ProviderMetadata {
|
|
298
|
+
/**
|
|
299
|
+
* Provider-specific metadata returned for the tool call.
|
|
300
|
+
*/
|
|
190
301
|
readonly openai?: {
|
|
302
|
+
/**
|
|
303
|
+
* The OpenAI item ID associated with the tool call.
|
|
304
|
+
*/
|
|
191
305
|
readonly itemId?: string | null;
|
|
192
306
|
} | null;
|
|
193
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* OpenAI-compatible metadata attached to document source citations.
|
|
310
|
+
*/
|
|
194
311
|
interface DocumentSourcePartMetadata extends ProviderMetadata {
|
|
312
|
+
/**
|
|
313
|
+
* Provider-specific citation metadata for OpenAI-compatible APIs.
|
|
314
|
+
*/
|
|
195
315
|
readonly openai?: {
|
|
316
|
+
/**
|
|
317
|
+
* Identifies a citation to an uploaded file.
|
|
318
|
+
*/
|
|
196
319
|
readonly type: "file_citation";
|
|
197
320
|
/**
|
|
198
321
|
* The index of the file in the list of files.
|
|
@@ -203,6 +326,9 @@ declare module "effect/unstable/ai/Response" {
|
|
|
203
326
|
*/
|
|
204
327
|
readonly fileId: string;
|
|
205
328
|
} | {
|
|
329
|
+
/**
|
|
330
|
+
* Identifies a citation to a generated file path.
|
|
331
|
+
*/
|
|
206
332
|
readonly type: "file_path";
|
|
207
333
|
/**
|
|
208
334
|
* The index of the file in the list of files.
|
|
@@ -213,6 +339,9 @@ declare module "effect/unstable/ai/Response" {
|
|
|
213
339
|
*/
|
|
214
340
|
readonly fileId: string;
|
|
215
341
|
} | {
|
|
342
|
+
/**
|
|
343
|
+
* Identifies a citation to a file inside a container.
|
|
344
|
+
*/
|
|
216
345
|
readonly type: "container_file_citation";
|
|
217
346
|
/**
|
|
218
347
|
* The ID of the file.
|
|
@@ -224,8 +353,17 @@ declare module "effect/unstable/ai/Response" {
|
|
|
224
353
|
readonly containerId: string;
|
|
225
354
|
} | null;
|
|
226
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* OpenAI-compatible metadata attached to URL source citations.
|
|
358
|
+
*/
|
|
227
359
|
interface UrlSourcePartMetadata extends ProviderMetadata {
|
|
360
|
+
/**
|
|
361
|
+
* Provider-specific URL citation metadata for OpenAI-compatible APIs.
|
|
362
|
+
*/
|
|
228
363
|
readonly openai?: {
|
|
364
|
+
/**
|
|
365
|
+
* Identifies a citation to a URL.
|
|
366
|
+
*/
|
|
229
367
|
readonly type: "url_citation";
|
|
230
368
|
/**
|
|
231
369
|
* The index of the first character of the URL citation in the message.
|
|
@@ -237,22 +375,33 @@ declare module "effect/unstable/ai/Response" {
|
|
|
237
375
|
readonly endIndex: number;
|
|
238
376
|
} | null;
|
|
239
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* OpenAI-compatible metadata attached to finish response parts.
|
|
380
|
+
*/
|
|
240
381
|
interface FinishPartMetadata extends ProviderMetadata {
|
|
382
|
+
/**
|
|
383
|
+
* Provider-specific metadata returned when generation finishes.
|
|
384
|
+
*/
|
|
241
385
|
readonly openai?: {
|
|
386
|
+
/**
|
|
387
|
+
* The service tier reported by the OpenAI-compatible provider.
|
|
388
|
+
*/
|
|
242
389
|
readonly serviceTier?: "default" | "auto" | "flex" | "scale" | "priority" | null;
|
|
243
390
|
} | null;
|
|
244
391
|
}
|
|
245
392
|
}
|
|
246
393
|
/**
|
|
247
|
-
*
|
|
394
|
+
* Creates an AI model descriptor for an OpenAI-compatible language model.
|
|
395
|
+
*
|
|
248
396
|
* @category constructors
|
|
397
|
+
* @since 4.0.0
|
|
249
398
|
*/
|
|
250
399
|
export declare const model: (model: string, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenAiClient>;
|
|
251
400
|
/**
|
|
252
401
|
* Creates an OpenAI language model service.
|
|
253
402
|
*
|
|
254
|
-
* @since 1.0.0
|
|
255
403
|
* @category constructors
|
|
404
|
+
* @since 4.0.0
|
|
256
405
|
*/
|
|
257
406
|
export declare const make: (args_0: {
|
|
258
407
|
readonly model: string;
|
|
@@ -261,8 +410,8 @@ export declare const make: (args_0: {
|
|
|
261
410
|
/**
|
|
262
411
|
* Creates a layer for the OpenAI language model.
|
|
263
412
|
*
|
|
264
|
-
* @since 1.0.0
|
|
265
413
|
* @category layers
|
|
414
|
+
* @since 4.0.0
|
|
266
415
|
*/
|
|
267
416
|
export declare const layer: (options: {
|
|
268
417
|
readonly model: string;
|
|
@@ -271,22 +420,22 @@ export declare const layer: (options: {
|
|
|
271
420
|
/**
|
|
272
421
|
* Provides config overrides for OpenAI language model operations.
|
|
273
422
|
*
|
|
274
|
-
* @since 1.0.0
|
|
275
423
|
* @category configuration
|
|
424
|
+
* @since 4.0.0
|
|
276
425
|
*/
|
|
277
426
|
export declare const withConfigOverride: {
|
|
278
427
|
/**
|
|
279
428
|
* Provides config overrides for OpenAI language model operations.
|
|
280
429
|
*
|
|
281
|
-
* @since 1.0.0
|
|
282
430
|
* @category configuration
|
|
431
|
+
* @since 4.0.0
|
|
283
432
|
*/
|
|
284
433
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
285
434
|
/**
|
|
286
435
|
* Provides config overrides for OpenAI language model operations.
|
|
287
436
|
*
|
|
288
|
-
* @since 1.0.0
|
|
289
437
|
* @category configuration
|
|
438
|
+
* @since 4.0.0
|
|
290
439
|
*/
|
|
291
440
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>;
|
|
292
441
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenAiLanguageModel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAUrC,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AAQnD,OAAO,EACL,KAAK,UAAU,EAMf,KAAK,WAAW,EAGhB,KAAK,aAAa,EAClB,YAAY,EAKb,MAAM,mBAAmB,CAAA;AAG1B;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAkCpB;QACd;;;;;;WAMG;QACH,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAA;KAC3D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AAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;CAwBhH,CAAA"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides a LanguageModel implementation for OpenAI's chat completions API,
|
|
5
5
|
* supporting text generation, structured output, tool calling, and streaming.
|
|
6
6
|
*
|
|
7
|
-
* @since
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
import * as DateTime from "effect/DateTime";
|
|
@@ -31,16 +31,18 @@ import { addGenAIAnnotations } from "./OpenAiTelemetry.js";
|
|
|
31
31
|
/**
|
|
32
32
|
* Service definition for OpenAI language model configuration.
|
|
33
33
|
*
|
|
34
|
-
* @since 1.0.0
|
|
35
34
|
* @category context
|
|
35
|
+
* @since 4.0.0
|
|
36
36
|
*/
|
|
37
37
|
export class Config extends /*#__PURE__*/Context.Service()("@effect/ai-openai-compat/OpenAiLanguageModel/Config") {}
|
|
38
38
|
// =============================================================================
|
|
39
39
|
// Language Model
|
|
40
40
|
// =============================================================================
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Creates an AI model descriptor for an OpenAI-compatible language model.
|
|
43
|
+
*
|
|
43
44
|
* @category constructors
|
|
45
|
+
* @since 4.0.0
|
|
44
46
|
*/
|
|
45
47
|
export const model = (model, config) => AiModel.make("openai", model, layer({
|
|
46
48
|
model,
|
|
@@ -48,7 +50,7 @@ export const model = (model, config) => AiModel.make("openai", model, layer({
|
|
|
48
50
|
}));
|
|
49
51
|
// TODO
|
|
50
52
|
// /**
|
|
51
|
-
// * @since
|
|
53
|
+
// * @since 4.0.0
|
|
52
54
|
// * @category constructors
|
|
53
55
|
// */
|
|
54
56
|
// export const modelWithTokenizer = (
|
|
@@ -59,8 +61,8 @@ export const model = (model, config) => AiModel.make("openai", model, layer({
|
|
|
59
61
|
/**
|
|
60
62
|
* Creates an OpenAI language model service.
|
|
61
63
|
*
|
|
62
|
-
* @since 1.0.0
|
|
63
64
|
* @category constructors
|
|
65
|
+
* @since 4.0.0
|
|
64
66
|
*/
|
|
65
67
|
export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
66
68
|
model,
|
|
@@ -166,15 +168,15 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
166
168
|
/**
|
|
167
169
|
* Creates a layer for the OpenAI language model.
|
|
168
170
|
*
|
|
169
|
-
* @since 1.0.0
|
|
170
171
|
* @category layers
|
|
172
|
+
* @since 4.0.0
|
|
171
173
|
*/
|
|
172
174
|
export const layer = options => Layer.effect(LanguageModel.LanguageModel, make(options));
|
|
173
175
|
/**
|
|
174
176
|
* Provides config overrides for OpenAI language model operations.
|
|
175
177
|
*
|
|
176
|
-
* @since 1.0.0
|
|
177
178
|
* @category configuration
|
|
179
|
+
* @since 4.0.0
|
|
178
180
|
*/
|
|
179
181
|
export const withConfigOverride = /*#__PURE__*/dual(2, (self, overrides) => Effect.flatMap(Effect.serviceOption(Config), config => Effect.provideService(self, Config, {
|
|
180
182
|
...(config._tag === "Some" ? config.value : {}),
|