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