@effect/ai-openai 4.0.0-beta.1 → 4.0.0-beta.100
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 +68897 -39886
- package/dist/Generated.d.ts.map +1 -1
- package/dist/Generated.js +1 -1
- package/dist/Generated.js.map +1 -1
- package/dist/OpenAiClient.d.ts +170 -29
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +321 -46
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiClientGenerated.d.ts +91 -0
- package/dist/OpenAiClientGenerated.d.ts.map +1 -0
- package/dist/OpenAiClientGenerated.js +84 -0
- package/dist/OpenAiClientGenerated.js.map +1 -0
- package/dist/OpenAiConfig.d.ts +88 -10
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +42 -7
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +188 -0
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -0
- package/dist/OpenAiEmbeddingModel.js +194 -0
- package/dist/OpenAiEmbeddingModel.js.map +1 -0
- package/dist/OpenAiError.d.ts +168 -35
- package/dist/OpenAiError.d.ts.map +1 -1
- package/dist/OpenAiError.js +1 -1
- package/dist/OpenAiLanguageModel.d.ts +360 -72
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +393 -171
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +2325 -0
- package/dist/OpenAiSchema.d.ts.map +1 -0
- package/dist/OpenAiSchema.js +811 -0
- package/dist/OpenAiSchema.js.map +1 -0
- package/dist/OpenAiTelemetry.d.ts +63 -22
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +20 -10
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/OpenAiTool.d.ts +199 -109
- package/dist/OpenAiTool.d.ts.map +1 -1
- package/dist/OpenAiTool.js +125 -39
- package/dist/OpenAiTool.js.map +1 -1
- package/dist/index.d.ts +19 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -33
- 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 -4
- package/dist/internal/utilities.js.map +1 -1
- package/package.json +5 -6
- package/src/Generated.ts +9897 -5083
- package/src/OpenAiClient.ts +499 -98
- package/src/OpenAiClientGenerated.ts +202 -0
- package/src/OpenAiConfig.ts +89 -11
- package/src/OpenAiEmbeddingModel.ts +332 -0
- package/src/OpenAiError.ts +170 -35
- package/src/OpenAiLanguageModel.ts +779 -172
- package/src/OpenAiSchema.ts +1286 -0
- package/src/OpenAiTelemetry.ts +69 -28
- package/src/OpenAiTool.ts +126 -40
- package/src/index.ts +22 -33
- package/src/internal/errors.ts +6 -4
- package/src/internal/utilities.ts +0 -6
|
@@ -1,63 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `OpenAiLanguageModel` module provides the OpenAI Responses API
|
|
3
|
+
* implementation of Effect AI's `LanguageModel` service. It translates Effect
|
|
4
|
+
* AI prompts, files, tools, structured output requests, reasoning metadata, and
|
|
5
|
+
* provider options into OpenAI response requests, then converts OpenAI
|
|
6
|
+
* non-streaming or streaming response results back into Effect AI response
|
|
7
|
+
* content and 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
14
|
import * as Schema from "effect/Schema";
|
|
4
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
5
15
|
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
6
16
|
import * as AiModel from "effect/unstable/ai/Model";
|
|
7
|
-
import * as Generated from "./Generated.ts";
|
|
8
17
|
import { OpenAiClient } from "./OpenAiClient.ts";
|
|
18
|
+
import type * as OpenAiSchema from "./OpenAiSchema.ts";
|
|
9
19
|
declare const ResponseModelIds: Schema.Literals<readonly ["o1-pro", "o1-pro-2025-03-19", "o3-pro", "o3-pro-2025-06-10", "o3-deep-research", "o3-deep-research-2025-06-26", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26", "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-5-codex", "gpt-5-pro", "gpt-5-pro-2025-10-06", "gpt-5.1-codex-max"]>;
|
|
10
|
-
declare const SharedModelIds: Schema.Literals<readonly ["gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11", "gpt-5.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613"]>;
|
|
20
|
+
declare const SharedModelIds: Schema.Literals<readonly ["gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.4-mini-2026-03-17", "gpt-5.4-nano-2026-03-17", "gpt-5.3-chat-latest", "gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11", "gpt-5.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613"]>;
|
|
11
21
|
/**
|
|
12
|
-
*
|
|
22
|
+
* OpenAI model identifiers supported by the Responses API language model.
|
|
23
|
+
*
|
|
13
24
|
* @category models
|
|
25
|
+
* @since 4.0.0
|
|
14
26
|
*/
|
|
15
27
|
export type Model = typeof ResponseModelIds.Encoded | typeof SharedModelIds.Encoded;
|
|
16
28
|
/**
|
|
17
29
|
* Image detail level for vision requests.
|
|
18
30
|
*/
|
|
19
31
|
type ImageDetail = "auto" | "low" | "high";
|
|
20
|
-
declare const Config_base:
|
|
21
|
-
readonly metadata?: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
readonly temperature?: number | null;
|
|
32
|
-
readonly top_p?: number | null;
|
|
33
|
-
readonly background?: boolean | null;
|
|
34
|
-
readonly conversation?: string | {
|
|
35
|
-
readonly id: string;
|
|
36
|
-
} | null;
|
|
37
|
-
readonly service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
38
|
-
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null;
|
|
39
|
-
readonly stream_options?: {
|
|
40
|
-
readonly include_obfuscation?: boolean;
|
|
41
|
-
} | null;
|
|
42
|
-
readonly max_output_tokens?: number | null;
|
|
32
|
+
declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai/OpenAiLanguageModel/Config", {
|
|
33
|
+
readonly metadata?: {
|
|
34
|
+
readonly [x: string]: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
readonly top_logprobs?: number | undefined;
|
|
37
|
+
readonly temperature?: number | undefined;
|
|
38
|
+
readonly top_p?: number | undefined;
|
|
39
|
+
readonly user?: string | undefined;
|
|
40
|
+
readonly service_tier?: string | undefined;
|
|
41
|
+
readonly previous_response_id?: string | undefined;
|
|
42
|
+
readonly model?: string | undefined;
|
|
43
43
|
readonly reasoning?: {
|
|
44
|
-
readonly
|
|
45
|
-
readonly
|
|
46
|
-
readonly generate_summary?: "auto" | "concise" | "detailed" |
|
|
47
|
-
} |
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
53
|
-
readonly store?: boolean |
|
|
54
|
-
readonly
|
|
55
|
-
readonly
|
|
56
|
-
readonly
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}[] | null;
|
|
60
|
-
readonly fileIdPrefixes?: readonly string[] | undefined;
|
|
44
|
+
readonly effort?: "high" | "low" | "medium" | "minimal" | "none" | "xhigh" | undefined;
|
|
45
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
46
|
+
readonly generate_summary?: "auto" | "concise" | "detailed" | undefined;
|
|
47
|
+
} | undefined;
|
|
48
|
+
readonly background?: boolean | undefined;
|
|
49
|
+
readonly max_output_tokens?: number | undefined;
|
|
50
|
+
readonly max_tool_calls?: number | undefined;
|
|
51
|
+
readonly truncation?: "auto" | "disabled" | undefined;
|
|
52
|
+
readonly include?: readonly ("code_interpreter_call.outputs" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources")[] | undefined;
|
|
53
|
+
readonly store?: boolean | undefined;
|
|
54
|
+
readonly instructions?: string | undefined;
|
|
55
|
+
readonly conversation?: string | undefined;
|
|
56
|
+
readonly modalities?: readonly ("audio" | "text")[] | undefined;
|
|
57
|
+
readonly seed?: number | undefined;
|
|
58
|
+
readonly fileIdPrefixes?: ReadonlyArray<string> | undefined;
|
|
61
59
|
readonly text?: {
|
|
62
60
|
/**
|
|
63
61
|
* Constrains the verbosity of the model's response. Lower values will
|
|
@@ -67,25 +65,40 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openai/Op
|
|
|
67
65
|
* Defaults to `"medium"`.
|
|
68
66
|
*/
|
|
69
67
|
readonly verbosity?: "low" | "medium" | "high" | undefined;
|
|
70
|
-
} | undefined
|
|
71
|
-
|
|
72
|
-
* Whether to use strict JSON schema validation.
|
|
73
|
-
*
|
|
74
|
-
* Defaults to `true`.
|
|
75
|
-
*/
|
|
76
|
-
| undefined;
|
|
77
|
-
readonly strictJsonSchema?: boolean | undefined | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
readonly strictJsonSchema?: boolean | undefined;
|
|
78
70
|
}>;
|
|
79
71
|
/**
|
|
80
|
-
*
|
|
72
|
+
* Context service for OpenAI language model configuration.
|
|
73
|
+
*
|
|
74
|
+
* **When to use**
|
|
75
|
+
*
|
|
76
|
+
* Use when you need to provide OpenAI Responses API request defaults through
|
|
77
|
+
* Effect context for language model operations.
|
|
78
|
+
*
|
|
79
|
+
* **Details**
|
|
80
|
+
*
|
|
81
|
+
* Config values are merged with the config object passed to `model`, `make`, or
|
|
82
|
+
* `layer`, with scoped context values taking precedence.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link withConfigOverride} for scoping language model request overrides
|
|
81
85
|
*
|
|
82
|
-
* @since 1.0.0
|
|
83
86
|
* @category services
|
|
87
|
+
* @since 4.0.0
|
|
84
88
|
*/
|
|
85
89
|
export declare class Config extends Config_base {
|
|
86
90
|
}
|
|
87
91
|
declare module "effect/unstable/ai/Prompt" {
|
|
92
|
+
/**
|
|
93
|
+
* OpenAI-specific options for file prompt parts.
|
|
94
|
+
*
|
|
95
|
+
* @category request
|
|
96
|
+
* @since 4.0.0
|
|
97
|
+
*/
|
|
88
98
|
interface FilePartOptions extends ProviderOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Provider-specific file options for the OpenAI Responses API.
|
|
101
|
+
*/
|
|
89
102
|
readonly openai?: {
|
|
90
103
|
/**
|
|
91
104
|
* The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
|
|
@@ -93,7 +106,16 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
93
106
|
readonly imageDetail?: ImageDetail | null;
|
|
94
107
|
} | null;
|
|
95
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* OpenAI-specific options for reasoning prompt parts.
|
|
111
|
+
*
|
|
112
|
+
* @category request
|
|
113
|
+
* @since 4.0.0
|
|
114
|
+
*/
|
|
96
115
|
interface ReasoningPartOptions extends ProviderOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Provider-specific reasoning options for the OpenAI Responses API.
|
|
118
|
+
*/
|
|
97
119
|
readonly openai?: {
|
|
98
120
|
/**
|
|
99
121
|
* The ID of the item to reference.
|
|
@@ -107,7 +129,16 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
107
129
|
readonly encryptedContent?: string | null;
|
|
108
130
|
} | null;
|
|
109
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* OpenAI-specific options for assistant tool-call prompt parts.
|
|
134
|
+
*
|
|
135
|
+
* @category request
|
|
136
|
+
* @since 4.0.0
|
|
137
|
+
*/
|
|
110
138
|
interface ToolCallPartOptions extends ProviderOptions {
|
|
139
|
+
/**
|
|
140
|
+
* Provider-specific tool-call options for the OpenAI Responses API.
|
|
141
|
+
*/
|
|
111
142
|
readonly openai?: {
|
|
112
143
|
/**
|
|
113
144
|
* The ID of the item to reference.
|
|
@@ -116,14 +147,23 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
116
147
|
/**
|
|
117
148
|
* The status of item.
|
|
118
149
|
*/
|
|
119
|
-
readonly status?: typeof
|
|
150
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
120
151
|
/**
|
|
121
152
|
* The ID of the approval request.
|
|
122
153
|
*/
|
|
123
154
|
readonly approvalRequestId?: string | null;
|
|
124
155
|
} | null;
|
|
125
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* OpenAI-specific options for tool-result prompt parts.
|
|
159
|
+
*
|
|
160
|
+
* @category request
|
|
161
|
+
* @since 4.0.0
|
|
162
|
+
*/
|
|
126
163
|
interface ToolResultPartOptions extends ProviderOptions {
|
|
164
|
+
/**
|
|
165
|
+
* Provider-specific tool-result options for the OpenAI Responses API.
|
|
166
|
+
*/
|
|
127
167
|
readonly openai?: {
|
|
128
168
|
/**
|
|
129
169
|
* The ID of the item to reference.
|
|
@@ -132,14 +172,23 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
132
172
|
/**
|
|
133
173
|
* The status of item.
|
|
134
174
|
*/
|
|
135
|
-
readonly status?: typeof
|
|
175
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
136
176
|
/**
|
|
137
177
|
* The ID of the approval request.
|
|
138
178
|
*/
|
|
139
179
|
readonly approvalId?: string | null;
|
|
140
180
|
} | null;
|
|
141
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* OpenAI-specific options for text prompt parts.
|
|
184
|
+
*
|
|
185
|
+
* @category request
|
|
186
|
+
* @since 4.0.0
|
|
187
|
+
*/
|
|
142
188
|
interface TextPartOptions extends ProviderOptions {
|
|
189
|
+
/**
|
|
190
|
+
* Provider-specific text options for the OpenAI Responses API.
|
|
191
|
+
*/
|
|
143
192
|
readonly openai?: {
|
|
144
193
|
/**
|
|
145
194
|
* The ID of the item to reference.
|
|
@@ -148,17 +197,29 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
148
197
|
/**
|
|
149
198
|
* The status of item.
|
|
150
199
|
*/
|
|
151
|
-
readonly status?: typeof
|
|
200
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
152
201
|
/**
|
|
153
202
|
* A list of annotations that apply to the output text.
|
|
154
203
|
*/
|
|
155
|
-
readonly annotations?: ReadonlyArray<typeof
|
|
204
|
+
readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
|
|
156
205
|
} | null;
|
|
157
206
|
}
|
|
158
207
|
}
|
|
159
208
|
declare module "effect/unstable/ai/Response" {
|
|
209
|
+
/**
|
|
210
|
+
* OpenAI metadata attached to a complete text response part.
|
|
211
|
+
*
|
|
212
|
+
* @category response
|
|
213
|
+
* @since 4.0.0
|
|
214
|
+
*/
|
|
160
215
|
interface TextPartMetadata extends ProviderMetadata {
|
|
216
|
+
/**
|
|
217
|
+
* Provider-specific metadata returned for the text part.
|
|
218
|
+
*/
|
|
161
219
|
readonly openai?: {
|
|
220
|
+
/**
|
|
221
|
+
* The OpenAI item ID associated with the text part.
|
|
222
|
+
*/
|
|
162
223
|
readonly itemId?: string | null;
|
|
163
224
|
/**
|
|
164
225
|
* If the model emits a refusal content part, the refusal explanation
|
|
@@ -169,54 +230,162 @@ declare module "effect/unstable/ai/Response" {
|
|
|
169
230
|
/**
|
|
170
231
|
* The status of item.
|
|
171
232
|
*/
|
|
172
|
-
readonly status?: typeof
|
|
233
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
173
234
|
/**
|
|
174
235
|
* The text content part annotations.
|
|
175
236
|
*/
|
|
176
|
-
readonly annotations?: ReadonlyArray<typeof
|
|
237
|
+
readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
|
|
177
238
|
};
|
|
178
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* OpenAI metadata emitted when a streamed text part starts.
|
|
242
|
+
*
|
|
243
|
+
* @category response
|
|
244
|
+
* @since 4.0.0
|
|
245
|
+
*/
|
|
179
246
|
interface TextStartPartMetadata extends ProviderMetadata {
|
|
247
|
+
/**
|
|
248
|
+
* Provider-specific metadata returned for the streamed text start.
|
|
249
|
+
*/
|
|
180
250
|
readonly openai?: {
|
|
251
|
+
/**
|
|
252
|
+
* The OpenAI item ID associated with the streamed text part.
|
|
253
|
+
*/
|
|
181
254
|
readonly itemId?: string | null;
|
|
182
255
|
} | null;
|
|
183
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* OpenAI metadata emitted when a streamed text part ends.
|
|
259
|
+
*
|
|
260
|
+
* @category response
|
|
261
|
+
* @since 4.0.0
|
|
262
|
+
*/
|
|
184
263
|
interface TextEndPartMetadata extends ProviderMetadata {
|
|
264
|
+
/**
|
|
265
|
+
* Provider-specific metadata returned for the streamed text end.
|
|
266
|
+
*/
|
|
185
267
|
readonly openai?: {
|
|
268
|
+
/**
|
|
269
|
+
* The OpenAI item ID associated with the streamed text part.
|
|
270
|
+
*/
|
|
186
271
|
readonly itemId?: string | null;
|
|
187
|
-
|
|
272
|
+
/**
|
|
273
|
+
* The annotations collected for the completed streamed text part.
|
|
274
|
+
*/
|
|
275
|
+
readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
|
|
188
276
|
} | null;
|
|
189
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* OpenAI metadata attached to a complete reasoning response part.
|
|
280
|
+
*
|
|
281
|
+
* @category response
|
|
282
|
+
* @since 4.0.0
|
|
283
|
+
*/
|
|
190
284
|
interface ReasoningPartMetadata extends ProviderMetadata {
|
|
285
|
+
/**
|
|
286
|
+
* Provider-specific metadata returned for the reasoning part.
|
|
287
|
+
*/
|
|
191
288
|
readonly openai?: {
|
|
289
|
+
/**
|
|
290
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
291
|
+
*/
|
|
192
292
|
readonly itemId?: string | null;
|
|
293
|
+
/**
|
|
294
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
295
|
+
*/
|
|
193
296
|
readonly encryptedContent?: string | null;
|
|
194
297
|
} | null;
|
|
195
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* OpenAI metadata emitted when a streamed reasoning part starts.
|
|
301
|
+
*
|
|
302
|
+
* @category response
|
|
303
|
+
* @since 4.0.0
|
|
304
|
+
*/
|
|
196
305
|
interface ReasoningStartPartMetadata extends ProviderMetadata {
|
|
306
|
+
/**
|
|
307
|
+
* Provider-specific metadata returned for the streamed reasoning start.
|
|
308
|
+
*/
|
|
197
309
|
readonly openai?: {
|
|
310
|
+
/**
|
|
311
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
312
|
+
*/
|
|
198
313
|
readonly itemId?: string | null;
|
|
314
|
+
/**
|
|
315
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
316
|
+
*/
|
|
199
317
|
readonly encryptedContent?: string | null;
|
|
200
318
|
} | null;
|
|
201
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* OpenAI metadata emitted for a streamed reasoning delta.
|
|
322
|
+
*
|
|
323
|
+
* @category response
|
|
324
|
+
* @since 4.0.0
|
|
325
|
+
*/
|
|
202
326
|
interface ReasoningDeltaPartMetadata extends ProviderMetadata {
|
|
327
|
+
/**
|
|
328
|
+
* Provider-specific metadata returned for the streamed reasoning delta.
|
|
329
|
+
*/
|
|
203
330
|
readonly openai?: {
|
|
331
|
+
/**
|
|
332
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
333
|
+
*/
|
|
204
334
|
readonly itemId?: string | null;
|
|
205
335
|
} | null;
|
|
206
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* OpenAI metadata emitted when a streamed reasoning part ends.
|
|
339
|
+
*
|
|
340
|
+
* @category response
|
|
341
|
+
* @since 4.0.0
|
|
342
|
+
*/
|
|
207
343
|
interface ReasoningEndPartMetadata extends ProviderMetadata {
|
|
344
|
+
/**
|
|
345
|
+
* Provider-specific metadata returned for the streamed reasoning end.
|
|
346
|
+
*/
|
|
208
347
|
readonly openai?: {
|
|
348
|
+
/**
|
|
349
|
+
* The OpenAI item ID associated with the reasoning part.
|
|
350
|
+
*/
|
|
209
351
|
readonly itemId?: string | null;
|
|
352
|
+
/**
|
|
353
|
+
* Encrypted reasoning content that can be sent back in later requests.
|
|
354
|
+
*/
|
|
210
355
|
readonly encryptedContent?: string;
|
|
211
356
|
} | null;
|
|
212
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* OpenAI metadata attached to tool-call response parts.
|
|
360
|
+
*
|
|
361
|
+
* @category response
|
|
362
|
+
* @since 4.0.0
|
|
363
|
+
*/
|
|
213
364
|
interface ToolCallPartMetadata extends ProviderMetadata {
|
|
365
|
+
/**
|
|
366
|
+
* Provider-specific metadata returned for the tool call.
|
|
367
|
+
*/
|
|
214
368
|
readonly openai?: {
|
|
369
|
+
/**
|
|
370
|
+
* The OpenAI item ID associated with the tool call.
|
|
371
|
+
*/
|
|
215
372
|
readonly itemId?: string | null;
|
|
216
373
|
} | null;
|
|
217
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* OpenAI metadata attached to document source citations.
|
|
377
|
+
*
|
|
378
|
+
* @category response
|
|
379
|
+
* @since 4.0.0
|
|
380
|
+
*/
|
|
218
381
|
interface DocumentSourcePartMetadata extends ProviderMetadata {
|
|
382
|
+
/**
|
|
383
|
+
* Provider-specific citation metadata for the OpenAI Responses API.
|
|
384
|
+
*/
|
|
219
385
|
readonly openai?: {
|
|
386
|
+
/**
|
|
387
|
+
* Identifies a citation to an uploaded file.
|
|
388
|
+
*/
|
|
220
389
|
readonly type: "file_citation";
|
|
221
390
|
/**
|
|
222
391
|
* The index of the file in the list of files.
|
|
@@ -227,6 +396,9 @@ declare module "effect/unstable/ai/Response" {
|
|
|
227
396
|
*/
|
|
228
397
|
readonly fileId: string;
|
|
229
398
|
} | {
|
|
399
|
+
/**
|
|
400
|
+
* Identifies a citation to a generated file path.
|
|
401
|
+
*/
|
|
230
402
|
readonly type: "file_path";
|
|
231
403
|
/**
|
|
232
404
|
* The index of the file in the list of files.
|
|
@@ -237,6 +409,9 @@ declare module "effect/unstable/ai/Response" {
|
|
|
237
409
|
*/
|
|
238
410
|
readonly fileId: string;
|
|
239
411
|
} | {
|
|
412
|
+
/**
|
|
413
|
+
* Identifies a citation to a file inside a container.
|
|
414
|
+
*/
|
|
240
415
|
readonly type: "container_file_citation";
|
|
241
416
|
/**
|
|
242
417
|
* The ID of the file.
|
|
@@ -248,8 +423,20 @@ declare module "effect/unstable/ai/Response" {
|
|
|
248
423
|
readonly containerId: string;
|
|
249
424
|
} | null;
|
|
250
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* OpenAI metadata attached to URL source citations.
|
|
428
|
+
*
|
|
429
|
+
* @category response
|
|
430
|
+
* @since 4.0.0
|
|
431
|
+
*/
|
|
251
432
|
interface UrlSourcePartMetadata extends ProviderMetadata {
|
|
433
|
+
/**
|
|
434
|
+
* Provider-specific URL citation metadata for the OpenAI Responses API.
|
|
435
|
+
*/
|
|
252
436
|
readonly openai?: {
|
|
437
|
+
/**
|
|
438
|
+
* Identifies a citation to a URL.
|
|
439
|
+
*/
|
|
253
440
|
readonly type: "url_citation";
|
|
254
441
|
/**
|
|
255
442
|
* The index of the first character of the URL citation in the message.
|
|
@@ -261,56 +448,157 @@ declare module "effect/unstable/ai/Response" {
|
|
|
261
448
|
readonly endIndex: number;
|
|
262
449
|
} | null;
|
|
263
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* OpenAI metadata attached to finish response parts.
|
|
453
|
+
*
|
|
454
|
+
* @category response
|
|
455
|
+
* @since 4.0.0
|
|
456
|
+
*/
|
|
264
457
|
interface FinishPartMetadata extends ProviderMetadata {
|
|
458
|
+
/**
|
|
459
|
+
* Provider-specific metadata returned when generation finishes.
|
|
460
|
+
*/
|
|
265
461
|
readonly openai?: {
|
|
462
|
+
/**
|
|
463
|
+
* The service tier reported by OpenAI for the response.
|
|
464
|
+
*/
|
|
266
465
|
readonly serviceTier?: "default" | "auto" | "flex" | "scale" | "priority" | null;
|
|
267
466
|
} | null;
|
|
268
467
|
}
|
|
269
468
|
}
|
|
270
469
|
/**
|
|
271
|
-
*
|
|
470
|
+
* Creates an OpenAI model descriptor that can be provided with
|
|
471
|
+
* `Effect.provide`.
|
|
472
|
+
*
|
|
473
|
+
* **When to use**
|
|
474
|
+
*
|
|
475
|
+
* Use when you want an OpenAI language model value that carries provider and
|
|
476
|
+
* model metadata and can be supplied directly to an Effect program.
|
|
477
|
+
*
|
|
478
|
+
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
479
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
480
|
+
*
|
|
272
481
|
* @category constructors
|
|
482
|
+
* @since 4.0.0
|
|
273
483
|
*/
|
|
274
484
|
export declare const model: (model: (string & {}) | Model, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenAiClient>;
|
|
275
485
|
/**
|
|
276
|
-
* Creates an OpenAI
|
|
486
|
+
* Creates an OpenAI `LanguageModel` service from a model identifier and
|
|
487
|
+
* optional request defaults.
|
|
488
|
+
*
|
|
489
|
+
* **When to use**
|
|
490
|
+
*
|
|
491
|
+
* Use to construct an OpenAI Responses API language model service backed by
|
|
492
|
+
* `OpenAiClient`.
|
|
493
|
+
*
|
|
494
|
+
* **Details**
|
|
495
|
+
*
|
|
496
|
+
* The returned effect requires `OpenAiClient`. Request defaults from the
|
|
497
|
+
* `config` option are merged with any `Config` service in the context, with
|
|
498
|
+
* context values taking precedence. The service supports both `generateText`
|
|
499
|
+
* and `streamText`.
|
|
500
|
+
*
|
|
501
|
+
* @see {@link layer} for providing the service as a `Layer`
|
|
502
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
277
503
|
*
|
|
278
|
-
* @since 1.0.0
|
|
279
504
|
* @category constructors
|
|
505
|
+
* @since 4.0.0
|
|
280
506
|
*/
|
|
281
507
|
export declare const make: (args_0: {
|
|
282
508
|
readonly model: (string & {}) | Model;
|
|
283
509
|
readonly config?: Omit<typeof Config.Service, "model"> | undefined;
|
|
284
510
|
}) => Effect.Effect<LanguageModel.Service, never, OpenAiClient>;
|
|
285
511
|
/**
|
|
286
|
-
* Creates a layer
|
|
512
|
+
* Creates a layer that provides the OpenAI `LanguageModel.LanguageModel`
|
|
513
|
+
* service.
|
|
514
|
+
*
|
|
515
|
+
* **When to use**
|
|
516
|
+
*
|
|
517
|
+
* Use when composing application layers and you want OpenAI to satisfy
|
|
518
|
+
* `LanguageModel.LanguageModel` while supplying `OpenAiClient` from another
|
|
519
|
+
* layer.
|
|
520
|
+
*
|
|
521
|
+
* **Details**
|
|
522
|
+
*
|
|
523
|
+
* The `config` option supplies request defaults for the selected model. Scoped
|
|
524
|
+
* values from `withConfigOverride` are merged when each request is built and
|
|
525
|
+
* take precedence over these defaults.
|
|
526
|
+
*
|
|
527
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
528
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
529
|
+
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
287
530
|
*
|
|
288
|
-
* @since 1.0.0
|
|
289
531
|
* @category layers
|
|
532
|
+
* @since 4.0.0
|
|
290
533
|
*/
|
|
291
534
|
export declare const layer: (options: {
|
|
292
535
|
readonly model: (string & {}) | Model;
|
|
293
536
|
readonly config?: Omit<typeof Config.Service, "model"> | undefined;
|
|
294
537
|
}) => Layer.Layer<LanguageModel.LanguageModel, never, OpenAiClient>;
|
|
295
538
|
/**
|
|
296
|
-
* Provides config overrides for OpenAI language model operations.
|
|
539
|
+
* Provides scoped config overrides for OpenAI language model operations.
|
|
540
|
+
*
|
|
541
|
+
* **When to use**
|
|
542
|
+
*
|
|
543
|
+
* Use to apply OpenAI Responses API config overrides around one or more
|
|
544
|
+
* language model operations without changing the defaults passed to `model`,
|
|
545
|
+
* `make`, or `layer`.
|
|
546
|
+
*
|
|
547
|
+
* **Details**
|
|
548
|
+
*
|
|
549
|
+
* The override is dual, so it can be used in pipe form or as
|
|
550
|
+
* `withConfigOverride(effect, overrides)`. Overrides are merged with any
|
|
551
|
+
* existing `Config` service in the current context, and the override values take
|
|
552
|
+
* precedence.
|
|
553
|
+
*
|
|
554
|
+
* @see {@link Config} for the scoped configuration service consumed by this function
|
|
297
555
|
*
|
|
298
|
-
* @since 1.0.0
|
|
299
556
|
* @category configuration
|
|
557
|
+
* @since 4.0.0
|
|
300
558
|
*/
|
|
301
559
|
export declare const withConfigOverride: {
|
|
302
560
|
/**
|
|
303
|
-
* Provides config overrides for OpenAI language model operations.
|
|
561
|
+
* Provides scoped config overrides for OpenAI language model operations.
|
|
562
|
+
*
|
|
563
|
+
* **When to use**
|
|
564
|
+
*
|
|
565
|
+
* Use to apply OpenAI Responses API config overrides around one or more
|
|
566
|
+
* language model operations without changing the defaults passed to `model`,
|
|
567
|
+
* `make`, or `layer`.
|
|
568
|
+
*
|
|
569
|
+
* **Details**
|
|
570
|
+
*
|
|
571
|
+
* The override is dual, so it can be used in pipe form or as
|
|
572
|
+
* `withConfigOverride(effect, overrides)`. Overrides are merged with any
|
|
573
|
+
* existing `Config` service in the current context, and the override values take
|
|
574
|
+
* precedence.
|
|
575
|
+
*
|
|
576
|
+
* @see {@link Config} for the scoped configuration service consumed by this function
|
|
304
577
|
*
|
|
305
|
-
* @since 1.0.0
|
|
306
578
|
* @category configuration
|
|
579
|
+
* @since 4.0.0
|
|
307
580
|
*/
|
|
308
581
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
309
582
|
/**
|
|
310
|
-
* Provides config overrides for OpenAI language model operations.
|
|
583
|
+
* Provides scoped config overrides for OpenAI language model operations.
|
|
584
|
+
*
|
|
585
|
+
* **When to use**
|
|
586
|
+
*
|
|
587
|
+
* Use to apply OpenAI Responses API config overrides around one or more
|
|
588
|
+
* language model operations without changing the defaults passed to `model`,
|
|
589
|
+
* `make`, or `layer`.
|
|
590
|
+
*
|
|
591
|
+
* **Details**
|
|
592
|
+
*
|
|
593
|
+
* The override is dual, so it can be used in pipe form or as
|
|
594
|
+
* `withConfigOverride(effect, overrides)`. Overrides are merged with any
|
|
595
|
+
* existing `Config` service in the current context, and the override values take
|
|
596
|
+
* precedence.
|
|
597
|
+
*
|
|
598
|
+
* @see {@link Config} for the scoped configuration service consumed by this function
|
|
311
599
|
*
|
|
312
|
-
* @since 1.0.0
|
|
313
600
|
* @category configuration
|
|
601
|
+
* @since 4.0.0
|
|
314
602
|
*/
|
|
315
603
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>;
|
|
316
604
|
};
|