@effect/ai-openai-compat 4.0.0-beta.7 → 4.0.0-beta.71
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 +250 -51
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +108 -9
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiConfig.d.ts +83 -10
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +51 -7
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +214 -0
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -0
- package/dist/OpenAiEmbeddingModel.js +218 -0
- package/dist/OpenAiEmbeddingModel.js.map +1 -0
- package/dist/OpenAiError.d.ts +109 -35
- package/dist/OpenAiError.d.ts.map +1 -1
- package/dist/OpenAiError.js +14 -1
- package/dist/OpenAiLanguageModel.d.ts +326 -18
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +126 -25
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiTelemetry.d.ts +72 -22
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +47 -8
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/index.d.ts +10 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -17
- package/dist/index.js.map +1 -1
- package/dist/internal/errors.js +4 -4
- package/dist/internal/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/OpenAiClient.ts +283 -49
- package/src/OpenAiConfig.ts +84 -11
- package/src/OpenAiEmbeddingModel.ts +360 -0
- package/src/OpenAiError.ts +111 -35
- package/src/OpenAiLanguageModel.ts +409 -40
- package/src/OpenAiTelemetry.ts +103 -27
- package/src/index.ts +11 -17
- package/src/internal/errors.ts +4 -4
|
@@ -1,6 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `OpenAiLanguageModel` module adapts OpenAI-compatible chat-completions
|
|
3
|
+
* providers to the shared Effect AI `LanguageModel` interface. It translates
|
|
4
|
+
* provider-neutral prompts, tools, structured output schemas, and streaming
|
|
5
|
+
* responses into the request and response shapes used by `OpenAiClient`.
|
|
6
|
+
*
|
|
7
|
+
* Use this module when an application wants to talk to OpenAI-compatible
|
|
8
|
+
* endpoints through Effect AI abstractions rather than constructing provider
|
|
9
|
+
* payloads directly. The exported constructors build a language model service
|
|
10
|
+
* from a model id, while `Config` and {@link withConfigOverride} provide scoped
|
|
11
|
+
* defaults for request fields such as temperature, reasoning options, text
|
|
12
|
+
* format, and provider-specific file handling.
|
|
13
|
+
*
|
|
14
|
+
* **Common tasks**
|
|
15
|
+
*
|
|
16
|
+
* - Create a model descriptor with {@link model}
|
|
17
|
+
* - Build or provide the `LanguageModel` service with {@link make} or
|
|
18
|
+
* {@link layer}
|
|
19
|
+
* - Scope request defaults with {@link Config} and {@link withConfigOverride}
|
|
20
|
+
* - Send tool calls, structured output schemas, images, files, and reasoning
|
|
21
|
+
* metadata through the provider-neutral Effect AI prompt types
|
|
22
|
+
*
|
|
23
|
+
* **Gotchas**
|
|
24
|
+
*
|
|
25
|
+
* - The module requires an `OpenAiClient` service; configure authentication,
|
|
26
|
+
* base URL, and HTTP behavior through that client layer.
|
|
27
|
+
* - Compatibility depends on the provider supporting the OpenAI request fields
|
|
28
|
+
* being used. Optional capabilities such as strict JSON schemas, reasoning
|
|
29
|
+
* metadata, and tool status fields may vary across providers.
|
|
30
|
+
* - `fileIdPrefixes` tells the prompt conversion which file references are
|
|
31
|
+
* provider file IDs instead of base64 file contents.
|
|
32
|
+
*
|
|
33
|
+
* @since 4.0.0
|
|
34
|
+
*/
|
|
35
|
+
import * as Context from "effect/Context";
|
|
1
36
|
import * as Effect from "effect/Effect";
|
|
2
37
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
4
38
|
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
5
39
|
import * as AiModel from "effect/unstable/ai/Model";
|
|
6
40
|
import { type Annotation, type IncludeEnum, type MessageStatus, OpenAiClient } from "./OpenAiClient.ts";
|
|
@@ -8,7 +42,8 @@ import { type Annotation, type IncludeEnum, type MessageStatus, OpenAiClient } f
|
|
|
8
42
|
* Image detail level for vision requests.
|
|
9
43
|
*/
|
|
10
44
|
type ImageDetail = "auto" | "low" | "high";
|
|
11
|
-
declare const Config_base:
|
|
45
|
+
declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai-compat/OpenAiLanguageModel/Config", {
|
|
46
|
+
readonly [x: string]: unknown;
|
|
12
47
|
readonly metadata?: Readonly<Record<string, string>> | null | undefined;
|
|
13
48
|
readonly service_tier?: string | undefined | undefined;
|
|
14
49
|
readonly model?: string | undefined | undefined;
|
|
@@ -54,13 +89,30 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openai-co
|
|
|
54
89
|
/**
|
|
55
90
|
* Service definition for OpenAI language model configuration.
|
|
56
91
|
*
|
|
57
|
-
*
|
|
92
|
+
* **When to use**
|
|
93
|
+
*
|
|
94
|
+
* Use as the context service for OpenAI-compatible language model request
|
|
95
|
+
* configuration, especially when a scoped operation should override the defaults
|
|
96
|
+
* supplied to `model`, `make`, or `layer`.
|
|
97
|
+
*
|
|
98
|
+
* @see {@link withConfigOverride} for scoping language model request overrides
|
|
99
|
+
*
|
|
58
100
|
* @category context
|
|
101
|
+
* @since 4.0.0
|
|
59
102
|
*/
|
|
60
103
|
export declare class Config extends Config_base {
|
|
61
104
|
}
|
|
62
105
|
declare module "effect/unstable/ai/Prompt" {
|
|
106
|
+
/**
|
|
107
|
+
* OpenAI-compatible options for file prompt parts.
|
|
108
|
+
*
|
|
109
|
+
* @category request
|
|
110
|
+
* @since 4.0.0
|
|
111
|
+
*/
|
|
63
112
|
interface FilePartOptions extends ProviderOptions {
|
|
113
|
+
/**
|
|
114
|
+
* Provider-specific file options for OpenAI-compatible APIs.
|
|
115
|
+
*/
|
|
64
116
|
readonly openai?: {
|
|
65
117
|
/**
|
|
66
118
|
* The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
|
|
@@ -68,7 +120,16 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
68
120
|
readonly imageDetail?: ImageDetail | null;
|
|
69
121
|
} | null;
|
|
70
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* OpenAI-compatible options for reasoning prompt parts.
|
|
125
|
+
*
|
|
126
|
+
* @category request
|
|
127
|
+
* @since 4.0.0
|
|
128
|
+
*/
|
|
71
129
|
interface ReasoningPartOptions extends ProviderOptions {
|
|
130
|
+
/**
|
|
131
|
+
* Provider-specific reasoning options for OpenAI-compatible APIs.
|
|
132
|
+
*/
|
|
72
133
|
readonly openai?: {
|
|
73
134
|
/**
|
|
74
135
|
* The ID of the item to reference.
|
|
@@ -82,38 +143,65 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
82
143
|
readonly encryptedContent?: string | null;
|
|
83
144
|
} | null;
|
|
84
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* OpenAI-compatible options for assistant tool-call prompt parts.
|
|
148
|
+
*
|
|
149
|
+
* @category request
|
|
150
|
+
* @since 4.0.0
|
|
151
|
+
*/
|
|
85
152
|
interface ToolCallPartOptions extends ProviderOptions {
|
|
153
|
+
/**
|
|
154
|
+
* Provider-specific tool-call options for OpenAI-compatible APIs.
|
|
155
|
+
*/
|
|
86
156
|
readonly openai?: {
|
|
87
157
|
/**
|
|
88
158
|
* The ID of the item to reference.
|
|
89
159
|
*/
|
|
90
160
|
readonly itemId?: string | null;
|
|
91
161
|
/**
|
|
92
|
-
* The status
|
|
162
|
+
* The status to send for the tool-call item.
|
|
93
163
|
*/
|
|
94
164
|
readonly status?: MessageStatus | null;
|
|
95
165
|
} | null;
|
|
96
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* OpenAI-compatible options for tool-result prompt parts.
|
|
169
|
+
*
|
|
170
|
+
* @category request
|
|
171
|
+
* @since 4.0.0
|
|
172
|
+
*/
|
|
97
173
|
interface ToolResultPartOptions extends ProviderOptions {
|
|
174
|
+
/**
|
|
175
|
+
* Provider-specific tool-result options for OpenAI-compatible APIs.
|
|
176
|
+
*/
|
|
98
177
|
readonly openai?: {
|
|
99
178
|
/**
|
|
100
179
|
* The ID of the item to reference.
|
|
101
180
|
*/
|
|
102
181
|
readonly itemId?: string | null;
|
|
103
182
|
/**
|
|
104
|
-
* The status
|
|
183
|
+
* The status to send for the tool-result item.
|
|
105
184
|
*/
|
|
106
185
|
readonly status?: MessageStatus | null;
|
|
107
186
|
} | null;
|
|
108
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* OpenAI-compatible options for text prompt parts.
|
|
190
|
+
*
|
|
191
|
+
* @category request
|
|
192
|
+
* @since 4.0.0
|
|
193
|
+
*/
|
|
109
194
|
interface TextPartOptions extends ProviderOptions {
|
|
195
|
+
/**
|
|
196
|
+
* Provider-specific text options for OpenAI-compatible APIs.
|
|
197
|
+
*/
|
|
110
198
|
readonly openai?: {
|
|
111
199
|
/**
|
|
112
200
|
* The ID of the item to reference.
|
|
113
201
|
*/
|
|
114
202
|
readonly itemId?: string | null;
|
|
115
203
|
/**
|
|
116
|
-
* The status
|
|
204
|
+
* The status to send for the text item.
|
|
117
205
|
*/
|
|
118
206
|
readonly status?: MessageStatus | null;
|
|
119
207
|
/**
|
|
@@ -124,8 +212,20 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
124
212
|
}
|
|
125
213
|
}
|
|
126
214
|
declare module "effect/unstable/ai/Response" {
|
|
215
|
+
/**
|
|
216
|
+
* OpenAI-compatible metadata attached to a complete text response part.
|
|
217
|
+
*
|
|
218
|
+
* @category response
|
|
219
|
+
* @since 4.0.0
|
|
220
|
+
*/
|
|
127
221
|
interface TextPartMetadata extends ProviderMetadata {
|
|
222
|
+
/**
|
|
223
|
+
* Provider-specific metadata returned for the text part.
|
|
224
|
+
*/
|
|
128
225
|
readonly openai?: {
|
|
226
|
+
/**
|
|
227
|
+
* The OpenAI item ID associated with the text part.
|
|
228
|
+
*/
|
|
129
229
|
readonly itemId?: string | null;
|
|
130
230
|
/**
|
|
131
231
|
* If the model emits a refusal content part, the refusal explanation
|
|
@@ -134,7 +234,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
134
234
|
*/
|
|
135
235
|
readonly refusal?: string | null;
|
|
136
236
|
/**
|
|
137
|
-
* The status
|
|
237
|
+
* The status returned for the text item.
|
|
138
238
|
*/
|
|
139
239
|
readonly status?: MessageStatus | null;
|
|
140
240
|
/**
|
|
@@ -143,47 +243,155 @@ declare module "effect/unstable/ai/Response" {
|
|
|
143
243
|
readonly annotations?: ReadonlyArray<Annotation> | null;
|
|
144
244
|
};
|
|
145
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* OpenAI-compatible metadata emitted when a streamed text part starts.
|
|
248
|
+
*
|
|
249
|
+
* @category response
|
|
250
|
+
* @since 4.0.0
|
|
251
|
+
*/
|
|
146
252
|
interface TextStartPartMetadata extends ProviderMetadata {
|
|
253
|
+
/**
|
|
254
|
+
* Provider-specific metadata returned for the streamed text start.
|
|
255
|
+
*/
|
|
147
256
|
readonly openai?: {
|
|
257
|
+
/**
|
|
258
|
+
* The OpenAI item ID associated with the streamed text part.
|
|
259
|
+
*/
|
|
148
260
|
readonly itemId?: string | null;
|
|
149
261
|
} | null;
|
|
150
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* OpenAI-compatible metadata emitted when a streamed text part ends.
|
|
265
|
+
*
|
|
266
|
+
* @category response
|
|
267
|
+
* @since 4.0.0
|
|
268
|
+
*/
|
|
151
269
|
interface TextEndPartMetadata extends ProviderMetadata {
|
|
270
|
+
/**
|
|
271
|
+
* Provider-specific metadata returned for the streamed text end.
|
|
272
|
+
*/
|
|
152
273
|
readonly openai?: {
|
|
274
|
+
/**
|
|
275
|
+
* The OpenAI item ID associated with the streamed text part.
|
|
276
|
+
*/
|
|
153
277
|
readonly itemId?: string | null;
|
|
278
|
+
/**
|
|
279
|
+
* The annotations collected for the completed streamed text part.
|
|
280
|
+
*/
|
|
154
281
|
readonly annotations?: ReadonlyArray<Annotation> | null;
|
|
155
282
|
} | null;
|
|
156
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* OpenAI-compatible metadata attached to a complete reasoning response part.
|
|
286
|
+
*
|
|
287
|
+
* @category response
|
|
288
|
+
* @since 4.0.0
|
|
289
|
+
*/
|
|
157
290
|
interface ReasoningPartMetadata extends ProviderMetadata {
|
|
291
|
+
/**
|
|
292
|
+
* Provider-specific metadata returned for the reasoning part.
|
|
293
|
+
*/
|
|
158
294
|
readonly openai?: {
|
|
295
|
+
/**
|
|
296
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
297
|
+
*/
|
|
159
298
|
readonly itemId?: string | null;
|
|
299
|
+
/**
|
|
300
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
301
|
+
*/
|
|
160
302
|
readonly encryptedContent?: string | null;
|
|
161
303
|
} | null;
|
|
162
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* OpenAI-compatible metadata emitted when a streamed reasoning part starts.
|
|
307
|
+
*
|
|
308
|
+
* @category response
|
|
309
|
+
* @since 4.0.0
|
|
310
|
+
*/
|
|
163
311
|
interface ReasoningStartPartMetadata extends ProviderMetadata {
|
|
312
|
+
/**
|
|
313
|
+
* Provider-specific metadata returned for the streamed reasoning start.
|
|
314
|
+
*/
|
|
164
315
|
readonly openai?: {
|
|
316
|
+
/**
|
|
317
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
318
|
+
*/
|
|
165
319
|
readonly itemId?: string | null;
|
|
320
|
+
/**
|
|
321
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
322
|
+
*/
|
|
166
323
|
readonly encryptedContent?: string | null;
|
|
167
324
|
} | null;
|
|
168
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* OpenAI-compatible metadata emitted for a streamed reasoning delta.
|
|
328
|
+
*
|
|
329
|
+
* @category response
|
|
330
|
+
* @since 4.0.0
|
|
331
|
+
*/
|
|
169
332
|
interface ReasoningDeltaPartMetadata extends ProviderMetadata {
|
|
333
|
+
/**
|
|
334
|
+
* Provider-specific metadata returned for the streamed reasoning delta.
|
|
335
|
+
*/
|
|
170
336
|
readonly openai?: {
|
|
337
|
+
/**
|
|
338
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
339
|
+
*/
|
|
171
340
|
readonly itemId?: string | null;
|
|
172
341
|
} | null;
|
|
173
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* OpenAI-compatible metadata emitted when a streamed reasoning part ends.
|
|
345
|
+
*
|
|
346
|
+
* @category response
|
|
347
|
+
* @since 4.0.0
|
|
348
|
+
*/
|
|
174
349
|
interface ReasoningEndPartMetadata extends ProviderMetadata {
|
|
350
|
+
/**
|
|
351
|
+
* Provider-specific metadata returned for the streamed reasoning end.
|
|
352
|
+
*/
|
|
175
353
|
readonly openai?: {
|
|
354
|
+
/**
|
|
355
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
356
|
+
*/
|
|
176
357
|
readonly itemId?: string | null;
|
|
358
|
+
/**
|
|
359
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
360
|
+
*/
|
|
177
361
|
readonly encryptedContent?: string;
|
|
178
362
|
} | null;
|
|
179
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* OpenAI-compatible metadata attached to tool-call response parts.
|
|
366
|
+
*
|
|
367
|
+
* @category response
|
|
368
|
+
* @since 4.0.0
|
|
369
|
+
*/
|
|
180
370
|
interface ToolCallPartMetadata extends ProviderMetadata {
|
|
371
|
+
/**
|
|
372
|
+
* Provider-specific metadata returned for the tool call.
|
|
373
|
+
*/
|
|
181
374
|
readonly openai?: {
|
|
375
|
+
/**
|
|
376
|
+
* The OpenAI item ID associated with the tool call.
|
|
377
|
+
*/
|
|
182
378
|
readonly itemId?: string | null;
|
|
183
379
|
} | null;
|
|
184
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* OpenAI-compatible metadata attached to document source citations.
|
|
383
|
+
*
|
|
384
|
+
* @category response
|
|
385
|
+
* @since 4.0.0
|
|
386
|
+
*/
|
|
185
387
|
interface DocumentSourcePartMetadata extends ProviderMetadata {
|
|
388
|
+
/**
|
|
389
|
+
* Provider-specific citation metadata for OpenAI-compatible APIs.
|
|
390
|
+
*/
|
|
186
391
|
readonly openai?: {
|
|
392
|
+
/**
|
|
393
|
+
* Identifies a citation to an uploaded file.
|
|
394
|
+
*/
|
|
187
395
|
readonly type: "file_citation";
|
|
188
396
|
/**
|
|
189
397
|
* The index of the file in the list of files.
|
|
@@ -194,6 +402,9 @@ declare module "effect/unstable/ai/Response" {
|
|
|
194
402
|
*/
|
|
195
403
|
readonly fileId: string;
|
|
196
404
|
} | {
|
|
405
|
+
/**
|
|
406
|
+
* Identifies a citation to a generated file path.
|
|
407
|
+
*/
|
|
197
408
|
readonly type: "file_path";
|
|
198
409
|
/**
|
|
199
410
|
* The index of the file in the list of files.
|
|
@@ -204,6 +415,9 @@ declare module "effect/unstable/ai/Response" {
|
|
|
204
415
|
*/
|
|
205
416
|
readonly fileId: string;
|
|
206
417
|
} | {
|
|
418
|
+
/**
|
|
419
|
+
* Identifies a citation to a file inside a container.
|
|
420
|
+
*/
|
|
207
421
|
readonly type: "container_file_citation";
|
|
208
422
|
/**
|
|
209
423
|
* The ID of the file.
|
|
@@ -215,8 +429,20 @@ declare module "effect/unstable/ai/Response" {
|
|
|
215
429
|
readonly containerId: string;
|
|
216
430
|
} | null;
|
|
217
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* OpenAI-compatible metadata attached to URL source citations.
|
|
434
|
+
*
|
|
435
|
+
* @category response
|
|
436
|
+
* @since 4.0.0
|
|
437
|
+
*/
|
|
218
438
|
interface UrlSourcePartMetadata extends ProviderMetadata {
|
|
439
|
+
/**
|
|
440
|
+
* Provider-specific URL citation metadata for OpenAI-compatible APIs.
|
|
441
|
+
*/
|
|
219
442
|
readonly openai?: {
|
|
443
|
+
/**
|
|
444
|
+
* Identifies a citation to a URL.
|
|
445
|
+
*/
|
|
220
446
|
readonly type: "url_citation";
|
|
221
447
|
/**
|
|
222
448
|
* The index of the first character of the URL citation in the message.
|
|
@@ -228,56 +454,138 @@ declare module "effect/unstable/ai/Response" {
|
|
|
228
454
|
readonly endIndex: number;
|
|
229
455
|
} | null;
|
|
230
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* OpenAI-compatible metadata attached to finish response parts.
|
|
459
|
+
*
|
|
460
|
+
* @category response
|
|
461
|
+
* @since 4.0.0
|
|
462
|
+
*/
|
|
231
463
|
interface FinishPartMetadata extends ProviderMetadata {
|
|
464
|
+
/**
|
|
465
|
+
* Provider-specific metadata returned when generation finishes.
|
|
466
|
+
*/
|
|
232
467
|
readonly openai?: {
|
|
468
|
+
/**
|
|
469
|
+
* The service tier reported by the OpenAI-compatible provider.
|
|
470
|
+
*/
|
|
233
471
|
readonly serviceTier?: "default" | "auto" | "flex" | "scale" | "priority" | null;
|
|
234
472
|
} | null;
|
|
235
473
|
}
|
|
236
474
|
}
|
|
237
475
|
/**
|
|
238
|
-
*
|
|
476
|
+
* Creates an OpenAI-compatible model descriptor that can be provided with `Effect.provide`.
|
|
477
|
+
*
|
|
478
|
+
* **When to use**
|
|
479
|
+
*
|
|
480
|
+
* Use when you want an OpenAI-compatible language model value that carries
|
|
481
|
+
* provider and model metadata and can be supplied directly to an Effect program.
|
|
482
|
+
*
|
|
483
|
+
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
484
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
485
|
+
*
|
|
239
486
|
* @category constructors
|
|
487
|
+
* @since 4.0.0
|
|
240
488
|
*/
|
|
241
489
|
export declare const model: (model: string, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenAiClient>;
|
|
242
490
|
/**
|
|
243
|
-
* Creates an OpenAI
|
|
491
|
+
* Creates an OpenAI-compatible `LanguageModel` service from a model identifier and optional request defaults.
|
|
492
|
+
*
|
|
493
|
+
* **When to use**
|
|
494
|
+
*
|
|
495
|
+
* Use when an Effect needs to construct a `LanguageModel.Service` value backed
|
|
496
|
+
* by `OpenAiClient`.
|
|
497
|
+
*
|
|
498
|
+
* **Details**
|
|
499
|
+
*
|
|
500
|
+
* The returned effect requires `OpenAiClient`. Request defaults from the
|
|
501
|
+
* `config` option are merged with any `Config` service in the context, with
|
|
502
|
+
* context values taking precedence. The service supports both `generateText` and
|
|
503
|
+
* `streamText`.
|
|
504
|
+
*
|
|
505
|
+
* @see {@link layer} for providing the service as a `Layer`
|
|
506
|
+
* @see {@link model} for creating a model descriptor for `AiModel.provide`
|
|
244
507
|
*
|
|
245
|
-
* @since 1.0.0
|
|
246
508
|
* @category constructors
|
|
509
|
+
* @since 4.0.0
|
|
247
510
|
*/
|
|
248
511
|
export declare const make: (args_0: {
|
|
249
512
|
readonly model: string;
|
|
250
513
|
readonly config?: Omit<typeof Config.Service, "model"> | undefined;
|
|
251
514
|
}) => Effect.Effect<LanguageModel.Service, never, OpenAiClient>;
|
|
252
515
|
/**
|
|
253
|
-
* Creates a layer for the OpenAI language model.
|
|
516
|
+
* Creates a layer for the OpenAI-compatible language model.
|
|
517
|
+
*
|
|
518
|
+
* **When to use**
|
|
519
|
+
*
|
|
520
|
+
* Use when composing application layers and you want OpenAI-compatible APIs to
|
|
521
|
+
* satisfy `LanguageModel.LanguageModel` while supplying `OpenAiClient` from
|
|
522
|
+
* another layer.
|
|
523
|
+
*
|
|
524
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
525
|
+
* @see {@link model} for creating an AI model descriptor
|
|
254
526
|
*
|
|
255
|
-
* @since 1.0.0
|
|
256
527
|
* @category layers
|
|
528
|
+
* @since 4.0.0
|
|
257
529
|
*/
|
|
258
530
|
export declare const layer: (options: {
|
|
259
531
|
readonly model: string;
|
|
260
532
|
readonly config?: Omit<typeof Config.Service, "model"> | undefined;
|
|
261
533
|
}) => Layer.Layer<LanguageModel.LanguageModel, never, OpenAiClient>;
|
|
262
534
|
/**
|
|
263
|
-
* Provides config overrides for OpenAI language model operations.
|
|
535
|
+
* Provides scoped config overrides for OpenAI-compatible language model operations.
|
|
536
|
+
*
|
|
537
|
+
* **When to use**
|
|
538
|
+
*
|
|
539
|
+
* Use to override request configuration for a single language model effect
|
|
540
|
+
* without changing the defaults supplied to `model`, `make`, or `layer`.
|
|
541
|
+
*
|
|
542
|
+
* **Details**
|
|
543
|
+
*
|
|
544
|
+
* Existing `Config` values from the Effect context are merged with `overrides`,
|
|
545
|
+
* and the override values take precedence.
|
|
546
|
+
*
|
|
547
|
+
* @see {@link Config} for the configuration shape
|
|
264
548
|
*
|
|
265
|
-
* @since 1.0.0
|
|
266
549
|
* @category configuration
|
|
550
|
+
* @since 4.0.0
|
|
267
551
|
*/
|
|
268
552
|
export declare const withConfigOverride: {
|
|
269
553
|
/**
|
|
270
|
-
* Provides config overrides for OpenAI language model operations.
|
|
554
|
+
* Provides scoped config overrides for OpenAI-compatible language model operations.
|
|
555
|
+
*
|
|
556
|
+
* **When to use**
|
|
557
|
+
*
|
|
558
|
+
* Use to override request configuration for a single language model effect
|
|
559
|
+
* without changing the defaults supplied to `model`, `make`, or `layer`.
|
|
560
|
+
*
|
|
561
|
+
* **Details**
|
|
562
|
+
*
|
|
563
|
+
* Existing `Config` values from the Effect context are merged with `overrides`,
|
|
564
|
+
* and the override values take precedence.
|
|
565
|
+
*
|
|
566
|
+
* @see {@link Config} for the configuration shape
|
|
271
567
|
*
|
|
272
|
-
* @since 1.0.0
|
|
273
568
|
* @category configuration
|
|
569
|
+
* @since 4.0.0
|
|
274
570
|
*/
|
|
275
571
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
276
572
|
/**
|
|
277
|
-
* Provides config overrides for OpenAI language model operations.
|
|
573
|
+
* Provides scoped config overrides for OpenAI-compatible language model operations.
|
|
574
|
+
*
|
|
575
|
+
* **When to use**
|
|
576
|
+
*
|
|
577
|
+
* Use to override request configuration for a single language model effect
|
|
578
|
+
* without changing the defaults supplied to `model`, `make`, or `layer`.
|
|
579
|
+
*
|
|
580
|
+
* **Details**
|
|
581
|
+
*
|
|
582
|
+
* Existing `Config` values from the Effect context are merged with `overrides`,
|
|
583
|
+
* and the override values take precedence.
|
|
584
|
+
*
|
|
585
|
+
* @see {@link Config} for the configuration shape
|
|
278
586
|
*
|
|
279
|
-
* @since 1.0.0
|
|
280
587
|
* @category configuration
|
|
588
|
+
* @since 4.0.0
|
|
281
589
|
*/
|
|
282
590
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>;
|
|
283
591
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenAiLanguageModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenAiLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenAiLanguageModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;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;;;;;;;;;;;;;;;;;;;;;;;;;;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