@effect/ai-openai 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/Generated.d.ts +1 -1
- package/dist/Generated.js +1 -1
- package/dist/OpenAiClient.d.ts +18 -11
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +11 -9
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiClientGenerated.d.ts +5 -5
- package/dist/OpenAiClientGenerated.js +5 -5
- package/dist/OpenAiConfig.d.ts +43 -8
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +28 -4
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +13 -9
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +8 -6
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiError.d.ts +124 -3
- package/dist/OpenAiError.d.ts.map +1 -1
- package/dist/OpenAiError.js +1 -1
- package/dist/OpenAiLanguageModel.d.ts +161 -10
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +9 -7
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +108 -35
- package/dist/OpenAiSchema.d.ts.map +1 -1
- package/dist/OpenAiSchema.js +55 -18
- package/dist/OpenAiSchema.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/OpenAiTool.d.ts +26 -26
- package/dist/OpenAiTool.js +10 -10
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -11
- package/package.json +3 -3
- package/src/Generated.ts +1 -1
- package/src/OpenAiClient.ts +20 -13
- package/src/OpenAiClientGenerated.ts +6 -6
- package/src/OpenAiConfig.ts +43 -8
- package/src/OpenAiEmbeddingModel.ts +15 -11
- package/src/OpenAiError.ts +124 -3
- package/src/OpenAiLanguageModel.ts +163 -12
- package/src/OpenAiSchema.ts +109 -36
- package/src/OpenAiTelemetry.ts +14 -11
- package/src/OpenAiTool.ts +11 -11
- package/src/index.ts +11 -11
package/src/OpenAiClient.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides a type-safe, Effect-based client for OpenAI operations including
|
|
5
5
|
* completions, embeddings, and streaming responses.
|
|
6
6
|
*
|
|
7
|
-
* @since
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
import * as Array from "effect/Array"
|
|
10
10
|
import type * as Config from "effect/Config"
|
|
@@ -39,10 +39,13 @@ import * as OpenAiSchema from "./OpenAiSchema.ts"
|
|
|
39
39
|
// =============================================================================
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Effect service interface for the handwritten OpenAI client.
|
|
43
|
+
*
|
|
44
|
+
* **Details**
|
|
45
|
+
* Provides the configured HTTP client plus helpers for Responses API calls, streaming Responses events, and embeddings. Transport and schema decoding failures are mapped to `AiError`.
|
|
43
46
|
*
|
|
44
|
-
* @since 1.0.0
|
|
45
47
|
* @category models
|
|
48
|
+
* @since 4.0.0
|
|
46
49
|
*/
|
|
47
50
|
export interface Service {
|
|
48
51
|
/**
|
|
@@ -88,8 +91,8 @@ export interface Service {
|
|
|
88
91
|
/**
|
|
89
92
|
* Service identifier for the OpenAI client.
|
|
90
93
|
*
|
|
91
|
-
* @since 1.0.0
|
|
92
94
|
* @category service
|
|
95
|
+
* @since 4.0.0
|
|
93
96
|
*/
|
|
94
97
|
export class OpenAiClient extends Context.Service<OpenAiClient, Service>()(
|
|
95
98
|
"@effect/ai-openai/OpenAiClient"
|
|
@@ -102,8 +105,8 @@ export class OpenAiClient extends Context.Service<OpenAiClient, Service>()(
|
|
|
102
105
|
/**
|
|
103
106
|
* Options for configuring the OpenAI client.
|
|
104
107
|
*
|
|
105
|
-
* @since 1.0.0
|
|
106
108
|
* @category models
|
|
109
|
+
* @since 4.0.0
|
|
107
110
|
*/
|
|
108
111
|
export type Options = {
|
|
109
112
|
/**
|
|
@@ -146,8 +149,8 @@ const RedactedOpenAiHeaders = {
|
|
|
146
149
|
/**
|
|
147
150
|
* Creates an OpenAI client service with the given options.
|
|
148
151
|
*
|
|
149
|
-
* @since 1.0.0
|
|
150
152
|
* @category constructors
|
|
153
|
+
* @since 4.0.0
|
|
151
154
|
*/
|
|
152
155
|
export const make = Effect.fnUntraced(
|
|
153
156
|
function*(
|
|
@@ -298,8 +301,8 @@ export const make = Effect.fnUntraced(
|
|
|
298
301
|
/**
|
|
299
302
|
* Creates a layer for the OpenAI client with the given options.
|
|
300
303
|
*
|
|
301
|
-
* @since 1.0.0
|
|
302
304
|
* @category layers
|
|
305
|
+
* @since 4.0.0
|
|
303
306
|
*/
|
|
304
307
|
export const layer = (options: Options): Layer.Layer<OpenAiClient, never, HttpClient.HttpClient> =>
|
|
305
308
|
Layer.effect(OpenAiClient, make(options))
|
|
@@ -308,8 +311,8 @@ export const layer = (options: Options): Layer.Layer<OpenAiClient, never, HttpCl
|
|
|
308
311
|
* Creates a layer for the OpenAI client, loading the requisite configuration
|
|
309
312
|
* via Effect's `Config` module.
|
|
310
313
|
*
|
|
311
|
-
* @since 1.0.0
|
|
312
314
|
* @category layers
|
|
315
|
+
* @since 4.0.0
|
|
313
316
|
*/
|
|
314
317
|
export const layerConfig = (options?: {
|
|
315
318
|
/**
|
|
@@ -367,14 +370,18 @@ export const layerConfig = (options?: {
|
|
|
367
370
|
// =============================================================================
|
|
368
371
|
|
|
369
372
|
/**
|
|
370
|
-
*
|
|
373
|
+
* Response stream event emitted by the OpenAI Responses API.
|
|
374
|
+
*
|
|
371
375
|
* @category Events
|
|
376
|
+
* @since 4.0.0
|
|
372
377
|
*/
|
|
373
378
|
export type ResponseStreamEvent = typeof OpenAiSchema.ResponseStreamEvent.Type
|
|
374
379
|
|
|
375
380
|
/**
|
|
376
|
-
*
|
|
381
|
+
* Service for creating OpenAI response streams over a WebSocket connection.
|
|
382
|
+
*
|
|
377
383
|
* @category Websocket mode
|
|
384
|
+
* @since 4.0.0
|
|
378
385
|
*/
|
|
379
386
|
export class OpenAiSocket extends Context.Service<OpenAiSocket, {
|
|
380
387
|
/**
|
|
@@ -504,7 +511,7 @@ const makeSocket = Effect.gen(function*() {
|
|
|
504
511
|
},
|
|
505
512
|
description: error.message
|
|
506
513
|
})
|
|
507
|
-
})
|
|
514
|
+
})),
|
|
508
515
|
Effect.catchCause((cause) => Queue.failCause(incoming, cause)),
|
|
509
516
|
Effect.ensuring(Effect.forkIn(RcRef.invalidate(queueRef), socketScope, {
|
|
510
517
|
startImmediately: true
|
|
@@ -587,8 +594,8 @@ const decodeEvent = Schema.decodeUnknownSync(Schema.fromJsonString(AllEvents))
|
|
|
587
594
|
* This is because it needs to use non-standard options for setting the
|
|
588
595
|
* Authorization header.
|
|
589
596
|
*
|
|
590
|
-
* @since 1.0.0
|
|
591
597
|
* @category Websocket mode
|
|
598
|
+
* @since 4.0.0
|
|
592
599
|
*/
|
|
593
600
|
export const withWebSocketMode = <A, E, R>(
|
|
594
601
|
effect: Effect.Effect<A, E, R>
|
|
@@ -615,8 +622,8 @@ export const withWebSocketMode = <A, E, R>(
|
|
|
615
622
|
* This is because it needs to use non-standard options for setting the
|
|
616
623
|
* Authorization header.
|
|
617
624
|
*
|
|
618
|
-
* @since 1.0.0
|
|
619
625
|
* @category Websocket mode
|
|
626
|
+
* @since 4.0.0
|
|
620
627
|
*/
|
|
621
628
|
export const layerWebSocketMode: Layer.Layer<
|
|
622
629
|
OpenAiSocket | ResponseIdTracker.ResponseIdTracker,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
import * as Array from "effect/Array"
|
|
5
5
|
import type * as Config from "effect/Config"
|
|
@@ -23,7 +23,7 @@ import { OpenAiConfig } from "./OpenAiConfig.ts"
|
|
|
23
23
|
/**
|
|
24
24
|
* Service identifier for the generated OpenAI client.
|
|
25
25
|
*
|
|
26
|
-
* @since
|
|
26
|
+
* @since 4.0.0
|
|
27
27
|
* @category service
|
|
28
28
|
*/
|
|
29
29
|
export class OpenAiClientGenerated extends Context.Service<OpenAiClientGenerated, Generated.OpenAiClient>()(
|
|
@@ -37,7 +37,7 @@ export class OpenAiClientGenerated extends Context.Service<OpenAiClientGenerated
|
|
|
37
37
|
/**
|
|
38
38
|
* Options for configuring the generated OpenAI client.
|
|
39
39
|
*
|
|
40
|
-
* @since
|
|
40
|
+
* @since 4.0.0
|
|
41
41
|
* @category models
|
|
42
42
|
*/
|
|
43
43
|
export type Options = {
|
|
@@ -81,7 +81,7 @@ const RedactedOpenAiHeaders = {
|
|
|
81
81
|
/**
|
|
82
82
|
* Creates a generated OpenAI client service with the given options.
|
|
83
83
|
*
|
|
84
|
-
* @since
|
|
84
|
+
* @since 4.0.0
|
|
85
85
|
* @category constructors
|
|
86
86
|
*/
|
|
87
87
|
export const make = Effect.fnUntraced(
|
|
@@ -137,7 +137,7 @@ export const make = Effect.fnUntraced(
|
|
|
137
137
|
/**
|
|
138
138
|
* Creates a layer for the generated OpenAI client with the given options.
|
|
139
139
|
*
|
|
140
|
-
* @since
|
|
140
|
+
* @since 4.0.0
|
|
141
141
|
* @category layers
|
|
142
142
|
*/
|
|
143
143
|
export const layer = (options: Options): Layer.Layer<OpenAiClientGenerated, never, HttpClient.HttpClient> =>
|
|
@@ -147,7 +147,7 @@ export const layer = (options: Options): Layer.Layer<OpenAiClientGenerated, neve
|
|
|
147
147
|
* Creates a layer for the generated OpenAI client, loading the requisite
|
|
148
148
|
* configuration via Effect's `Config` module.
|
|
149
149
|
*
|
|
150
|
-
* @since
|
|
150
|
+
* @since 4.0.0
|
|
151
151
|
* @category layers
|
|
152
152
|
*/
|
|
153
153
|
export const layerConfig = (options?: {
|
package/src/OpenAiConfig.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The `OpenAiConfig` module provides contextual configuration for the
|
|
3
|
+
* `@effect/ai-openai` integration. It is used to customize how OpenAI clients
|
|
4
|
+
* are built and interpreted without threading configuration through every API
|
|
5
|
+
* call manually.
|
|
6
|
+
*
|
|
7
|
+
* The primary use case is installing an HTTP client transform with
|
|
8
|
+
* {@link withClientTransform}. This lets applications adapt the underlying
|
|
9
|
+
* OpenAI HTTP client for cross-cutting concerns such as custom middleware,
|
|
10
|
+
* instrumentation, proxying, or request policy changes while keeping the
|
|
11
|
+
* OpenAI service APIs unchanged.
|
|
12
|
+
*
|
|
13
|
+
* Configuration is scoped through Effect's context, so transforms only apply to
|
|
14
|
+
* the effect they are provided to and anything evaluated inside that scope.
|
|
15
|
+
* When multiple transforms are needed, compose them into a single
|
|
16
|
+
* `HttpClient => HttpClient` function before providing the configuration.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
3
19
|
*/
|
|
4
20
|
import * as Context from "effect/Context"
|
|
5
21
|
import * as Effect from "effect/Effect"
|
|
@@ -7,15 +23,20 @@ import { dual } from "effect/Function"
|
|
|
7
23
|
import type { HttpClient } from "effect/unstable/http/HttpClient"
|
|
8
24
|
|
|
9
25
|
/**
|
|
10
|
-
*
|
|
26
|
+
* Context service carrying scoped OpenAI configuration for provider
|
|
27
|
+
* operations.
|
|
28
|
+
*
|
|
11
29
|
* @category services
|
|
30
|
+
* @since 4.0.0
|
|
12
31
|
*/
|
|
13
32
|
export class OpenAiConfig extends Context.Service<
|
|
14
33
|
OpenAiConfig,
|
|
15
34
|
OpenAiConfig.Service
|
|
16
35
|
>()("@effect/ai-openai/OpenAiConfig") {
|
|
17
36
|
/**
|
|
18
|
-
*
|
|
37
|
+
* Gets the configured OpenAI service from the current context when present.
|
|
38
|
+
*
|
|
39
|
+
* @since 4.0.0
|
|
19
40
|
*/
|
|
20
41
|
static readonly getOrUndefined: Effect.Effect<typeof OpenAiConfig.Service | undefined> = Effect.map(
|
|
21
42
|
Effect.context<never>(),
|
|
@@ -24,12 +45,17 @@ export class OpenAiConfig extends Context.Service<
|
|
|
24
45
|
}
|
|
25
46
|
|
|
26
47
|
/**
|
|
27
|
-
*
|
|
48
|
+
* Types used by the `OpenAiConfig` context service.
|
|
49
|
+
*
|
|
50
|
+
* @since 4.0.0
|
|
28
51
|
*/
|
|
29
52
|
export declare namespace OpenAiConfig {
|
|
30
53
|
/**
|
|
31
|
-
*
|
|
54
|
+
* Configuration values read by OpenAI provider operations when executing
|
|
55
|
+
* requests.
|
|
56
|
+
*
|
|
32
57
|
* @category models
|
|
58
|
+
* @since 1.0.
|
|
33
59
|
*/
|
|
34
60
|
export interface Service {
|
|
35
61
|
readonly transformClient?: ((client: HttpClient) => HttpClient) | undefined
|
|
@@ -37,18 +63,27 @@ export declare namespace OpenAiConfig {
|
|
|
37
63
|
}
|
|
38
64
|
|
|
39
65
|
/**
|
|
40
|
-
*
|
|
66
|
+
* Provides a scoped transform for the OpenAI HTTP client used by provider
|
|
67
|
+
* operations.
|
|
68
|
+
*
|
|
41
69
|
* @category configuration
|
|
70
|
+
* @since 4.0.0
|
|
42
71
|
*/
|
|
43
72
|
export const withClientTransform: {
|
|
44
73
|
/**
|
|
45
|
-
*
|
|
74
|
+
* Provides a scoped transform for the OpenAI HTTP client used by provider
|
|
75
|
+
* operations.
|
|
76
|
+
*
|
|
46
77
|
* @category configuration
|
|
78
|
+
* @since 4.0.0
|
|
47
79
|
*/
|
|
48
80
|
(transform: (client: HttpClient) => HttpClient): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
49
81
|
/**
|
|
50
|
-
*
|
|
82
|
+
* Provides a scoped transform for the OpenAI HTTP client used by provider
|
|
83
|
+
* operations.
|
|
84
|
+
*
|
|
51
85
|
* @category configuration
|
|
86
|
+
* @since 4.0.0
|
|
52
87
|
*/
|
|
53
88
|
<A, E, R>(
|
|
54
89
|
self: Effect.Effect<A, E, R>,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides an EmbeddingModel implementation for OpenAI's embeddings API.
|
|
5
5
|
*
|
|
6
|
-
* @since
|
|
6
|
+
* @since 4.0.0
|
|
7
7
|
*/
|
|
8
8
|
import * as Context from "effect/Context"
|
|
9
9
|
import * as Effect from "effect/Effect"
|
|
@@ -17,16 +17,18 @@ import { OpenAiClient } from "./OpenAiClient.ts"
|
|
|
17
17
|
import type * as OpenAiSchema from "./OpenAiSchema.ts"
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Model identifiers supported by OpenAI's embeddings API.
|
|
21
|
+
*
|
|
21
22
|
* @category models
|
|
23
|
+
* @since 4.0.0
|
|
22
24
|
*/
|
|
23
25
|
export type Model = "text-embedding-ada-002" | "text-embedding-3-small" | "text-embedding-3-large"
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* Service definition for OpenAI embedding model configuration.
|
|
27
29
|
*
|
|
28
|
-
* @since 1.0.0
|
|
29
30
|
* @category services
|
|
31
|
+
* @since 4.0.0
|
|
30
32
|
*/
|
|
31
33
|
export class Config extends Context.Service<
|
|
32
34
|
Config,
|
|
@@ -44,8 +46,10 @@ export class Config extends Context.Service<
|
|
|
44
46
|
>()("@effect/ai-openai/OpenAiEmbeddingModel/Config") {}
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
|
-
*
|
|
49
|
+
* Creates an `AiModel` for an OpenAI embedding model with its configured vector dimensions.
|
|
50
|
+
*
|
|
48
51
|
* @category constructors
|
|
52
|
+
* @since 4.0.0
|
|
49
53
|
*/
|
|
50
54
|
export const model = (
|
|
51
55
|
model: (string & {}) | Model,
|
|
@@ -72,8 +76,8 @@ export const model = (
|
|
|
72
76
|
/**
|
|
73
77
|
* Creates an OpenAI embedding model service.
|
|
74
78
|
*
|
|
75
|
-
* @since 1.0.0
|
|
76
79
|
* @category constructors
|
|
80
|
+
* @since 4.0.0
|
|
77
81
|
*/
|
|
78
82
|
export const make = Effect.fnUntraced(function*({ model, config: providerConfig }: {
|
|
79
83
|
readonly model: (string & {}) | Model
|
|
@@ -98,8 +102,8 @@ export const make = Effect.fnUntraced(function*({ model, config: providerConfig
|
|
|
98
102
|
/**
|
|
99
103
|
* Creates a layer for the OpenAI embedding model.
|
|
100
104
|
*
|
|
101
|
-
* @since 1.0.0
|
|
102
105
|
* @category layers
|
|
106
|
+
* @since 4.0.0
|
|
103
107
|
*/
|
|
104
108
|
export const layer = (options: {
|
|
105
109
|
readonly model: (string & {}) | Model
|
|
@@ -110,37 +114,37 @@ export const layer = (options: {
|
|
|
110
114
|
/**
|
|
111
115
|
* Provides config overrides for OpenAI embedding model operations.
|
|
112
116
|
*
|
|
113
|
-
* @since 1.0.0
|
|
114
117
|
* @category configuration
|
|
118
|
+
* @since 4.0.0
|
|
115
119
|
*/
|
|
116
120
|
export const withConfigOverride: {
|
|
117
121
|
/**
|
|
118
122
|
* Provides config overrides for OpenAI embedding model operations.
|
|
119
123
|
*
|
|
120
|
-
* @since 1.0.0
|
|
121
124
|
* @category configuration
|
|
125
|
+
* @since 4.0.0
|
|
122
126
|
*/
|
|
123
127
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>
|
|
124
128
|
/**
|
|
125
129
|
* Provides config overrides for OpenAI embedding model operations.
|
|
126
130
|
*
|
|
127
|
-
* @since 1.0.0
|
|
128
131
|
* @category configuration
|
|
132
|
+
* @since 4.0.0
|
|
129
133
|
*/
|
|
130
134
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>
|
|
131
135
|
} = dual<
|
|
132
136
|
/**
|
|
133
137
|
* Provides config overrides for OpenAI embedding model operations.
|
|
134
138
|
*
|
|
135
|
-
* @since 1.0.0
|
|
136
139
|
* @category configuration
|
|
140
|
+
* @since 4.0.0
|
|
137
141
|
*/
|
|
138
142
|
(overrides: typeof Config.Service) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>,
|
|
139
143
|
/**
|
|
140
144
|
* Provides config overrides for OpenAI embedding model operations.
|
|
141
145
|
*
|
|
142
|
-
* @since 1.0.0
|
|
143
146
|
* @category configuration
|
|
147
|
+
* @since 4.0.0
|
|
144
148
|
*/
|
|
145
149
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service) => Effect.Effect<A, E, Exclude<R, Config>>
|
|
146
150
|
>(2, (self, overrides) =>
|
package/src/OpenAiError.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Provides OpenAI-specific metadata fields for AI error types through module
|
|
5
5
|
* augmentation, enabling typed access to OpenAI error details.
|
|
6
6
|
*
|
|
7
|
-
* @since
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* OpenAI-specific error metadata fields.
|
|
12
12
|
*
|
|
13
|
-
* @since 1.0.0
|
|
14
13
|
* @category models
|
|
14
|
+
* @since 4.0.0
|
|
15
15
|
*/
|
|
16
16
|
export type OpenAiErrorMetadata = {
|
|
17
17
|
/**
|
|
@@ -34,8 +34,8 @@ export type OpenAiErrorMetadata = {
|
|
|
34
34
|
* Extends base error metadata with rate limit specific information from
|
|
35
35
|
* OpenAI's rate limit headers.
|
|
36
36
|
*
|
|
37
|
-
* @since 1.0.0
|
|
38
37
|
* @category models
|
|
38
|
+
* @since 4.0.0
|
|
39
39
|
*/
|
|
40
40
|
export type OpenAiRateLimitMetadata = OpenAiErrorMetadata & {
|
|
41
41
|
/**
|
|
@@ -57,43 +57,164 @@ export type OpenAiRateLimitMetadata = OpenAiErrorMetadata & {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
declare module "effect/unstable/ai/AiError" {
|
|
60
|
+
/**
|
|
61
|
+
* OpenAI metadata attached to `RateLimitError` values.
|
|
62
|
+
*
|
|
63
|
+
* Captures OpenAI error details together with rate limit header information
|
|
64
|
+
* from responses where the provider rejected the request because a limit was
|
|
65
|
+
* reached.
|
|
66
|
+
*
|
|
67
|
+
* @category provider options
|
|
68
|
+
* @since 4.0.0
|
|
69
|
+
*/
|
|
60
70
|
export interface RateLimitErrorMetadata {
|
|
71
|
+
/**
|
|
72
|
+
* OpenAI-specific details for the rate limit response.
|
|
73
|
+
*/
|
|
61
74
|
readonly openai?: OpenAiRateLimitMetadata | null
|
|
62
75
|
}
|
|
63
76
|
|
|
77
|
+
/**
|
|
78
|
+
* OpenAI metadata attached to `QuotaExhaustedError` values.
|
|
79
|
+
*
|
|
80
|
+
* Preserves provider error details for failures caused by exhausted account,
|
|
81
|
+
* billing, or usage quota.
|
|
82
|
+
*
|
|
83
|
+
* @category provider options
|
|
84
|
+
* @since 4.0.0
|
|
85
|
+
*/
|
|
64
86
|
export interface QuotaExhaustedErrorMetadata {
|
|
87
|
+
/**
|
|
88
|
+
* OpenAI-specific details for the quota exhaustion response.
|
|
89
|
+
*/
|
|
65
90
|
readonly openai?: OpenAiErrorMetadata | null
|
|
66
91
|
}
|
|
67
92
|
|
|
93
|
+
/**
|
|
94
|
+
* OpenAI metadata attached to `AuthenticationError` values.
|
|
95
|
+
*
|
|
96
|
+
* Preserves provider error details for failed API key, authorization, or
|
|
97
|
+
* permission checks.
|
|
98
|
+
*
|
|
99
|
+
* @category provider options
|
|
100
|
+
* @since 4.0.0
|
|
101
|
+
*/
|
|
68
102
|
export interface AuthenticationErrorMetadata {
|
|
103
|
+
/**
|
|
104
|
+
* OpenAI-specific details for the authentication failure.
|
|
105
|
+
*/
|
|
69
106
|
readonly openai?: OpenAiErrorMetadata | null
|
|
70
107
|
}
|
|
71
108
|
|
|
109
|
+
/**
|
|
110
|
+
* OpenAI metadata attached to `ContentPolicyError` values.
|
|
111
|
+
*
|
|
112
|
+
* Preserves provider error details when OpenAI rejects input or output because
|
|
113
|
+
* it violates a content policy.
|
|
114
|
+
*
|
|
115
|
+
* @category provider options
|
|
116
|
+
* @since 4.0.0
|
|
117
|
+
*/
|
|
72
118
|
export interface ContentPolicyErrorMetadata {
|
|
119
|
+
/**
|
|
120
|
+
* OpenAI-specific details for the content policy response.
|
|
121
|
+
*/
|
|
73
122
|
readonly openai?: OpenAiErrorMetadata | null
|
|
74
123
|
}
|
|
75
124
|
|
|
125
|
+
/**
|
|
126
|
+
* OpenAI metadata attached to `InvalidRequestError` values.
|
|
127
|
+
*
|
|
128
|
+
* Preserves provider error details for malformed requests, unsupported
|
|
129
|
+
* parameters, or other request validation failures reported by OpenAI.
|
|
130
|
+
*
|
|
131
|
+
* @category provider options
|
|
132
|
+
* @since 4.0.0
|
|
133
|
+
*/
|
|
76
134
|
export interface InvalidRequestErrorMetadata {
|
|
135
|
+
/**
|
|
136
|
+
* OpenAI-specific details for the invalid request response.
|
|
137
|
+
*/
|
|
77
138
|
readonly openai?: OpenAiErrorMetadata | null
|
|
78
139
|
}
|
|
79
140
|
|
|
141
|
+
/**
|
|
142
|
+
* OpenAI metadata attached to `InternalProviderError` values.
|
|
143
|
+
*
|
|
144
|
+
* Preserves provider error details for OpenAI-side failures such as transient
|
|
145
|
+
* server errors.
|
|
146
|
+
*
|
|
147
|
+
* @category provider options
|
|
148
|
+
* @since 4.0.0
|
|
149
|
+
*/
|
|
80
150
|
export interface InternalProviderErrorMetadata {
|
|
151
|
+
/**
|
|
152
|
+
* OpenAI-specific details for the internal provider response.
|
|
153
|
+
*/
|
|
81
154
|
readonly openai?: OpenAiErrorMetadata | null
|
|
82
155
|
}
|
|
83
156
|
|
|
157
|
+
/**
|
|
158
|
+
* OpenAI metadata attached to `InvalidOutputError` values.
|
|
159
|
+
*
|
|
160
|
+
* Preserves provider error details when an OpenAI response cannot be parsed or
|
|
161
|
+
* validated as the expected output.
|
|
162
|
+
*
|
|
163
|
+
* @category provider options
|
|
164
|
+
* @since 4.0.0
|
|
165
|
+
*/
|
|
84
166
|
export interface InvalidOutputErrorMetadata {
|
|
167
|
+
/**
|
|
168
|
+
* OpenAI-specific details for the invalid output response.
|
|
169
|
+
*/
|
|
85
170
|
readonly openai?: OpenAiErrorMetadata | null
|
|
86
171
|
}
|
|
87
172
|
|
|
173
|
+
/**
|
|
174
|
+
* OpenAI metadata attached to `StructuredOutputError` values.
|
|
175
|
+
*
|
|
176
|
+
* Preserves provider error details when OpenAI returns content that does not
|
|
177
|
+
* satisfy the requested structured output schema.
|
|
178
|
+
*
|
|
179
|
+
* @category provider options
|
|
180
|
+
* @since 4.0.0
|
|
181
|
+
*/
|
|
88
182
|
export interface StructuredOutputErrorMetadata {
|
|
183
|
+
/**
|
|
184
|
+
* OpenAI-specific details for the structured output failure.
|
|
185
|
+
*/
|
|
89
186
|
readonly openai?: OpenAiErrorMetadata | null
|
|
90
187
|
}
|
|
91
188
|
|
|
189
|
+
/**
|
|
190
|
+
* OpenAI metadata attached to `UnsupportedSchemaError` values.
|
|
191
|
+
*
|
|
192
|
+
* Preserves provider error details when an unsupported schema failure is
|
|
193
|
+
* associated with an OpenAI response.
|
|
194
|
+
*
|
|
195
|
+
* @category provider options
|
|
196
|
+
* @since 4.0.0
|
|
197
|
+
*/
|
|
92
198
|
export interface UnsupportedSchemaErrorMetadata {
|
|
199
|
+
/**
|
|
200
|
+
* OpenAI-specific details for the unsupported schema failure.
|
|
201
|
+
*/
|
|
93
202
|
readonly openai?: OpenAiErrorMetadata | null
|
|
94
203
|
}
|
|
95
204
|
|
|
205
|
+
/**
|
|
206
|
+
* OpenAI metadata attached to `UnknownError` values.
|
|
207
|
+
*
|
|
208
|
+
* Preserves provider error details for OpenAI failures that do not map cleanly
|
|
209
|
+
* to a more specific AI error category.
|
|
210
|
+
*
|
|
211
|
+
* @category provider options
|
|
212
|
+
* @since 4.0.0
|
|
213
|
+
*/
|
|
96
214
|
export interface UnknownErrorMetadata {
|
|
215
|
+
/**
|
|
216
|
+
* OpenAI-specific details for the unclassified provider failure.
|
|
217
|
+
*/
|
|
97
218
|
readonly openai?: OpenAiErrorMetadata | null
|
|
98
219
|
}
|
|
99
220
|
}
|