@effect/ai-openai 4.0.0-beta.9 → 4.0.0-beta.90
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 +66675 -37672
- 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 +357 -63
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +390 -168
- 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 +157 -67
- 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 +3 -3
- package/src/Generated.ts +9720 -4890
- 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 +776 -169
- 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
package/dist/OpenAiTool.d.ts
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenAI provider
|
|
2
|
+
* The `OpenAiTool` module defines OpenAI provider tools for Effect AI language
|
|
3
|
+
* model requests. It exposes typed descriptors for tools such as Apply Patch,
|
|
4
|
+
* Code Interpreter, File Search, Image Generation, MCP, Web Search, and
|
|
5
|
+
* shell-like local tools, including their provider names, configuration
|
|
6
|
+
* arguments, call parameters, success schemas, and handler requirements.
|
|
3
7
|
*
|
|
4
|
-
*
|
|
5
|
-
* code interpreter, file search, and web search functionality.
|
|
6
|
-
*
|
|
7
|
-
* @since 1.0.0
|
|
8
|
+
* @since 4.0.0
|
|
8
9
|
*/
|
|
9
10
|
import * as Schema from "effect/Schema";
|
|
10
11
|
import * as Tool from "effect/unstable/ai/Tool";
|
|
11
12
|
/**
|
|
12
13
|
* Union of all OpenAI provider-defined tools.
|
|
13
14
|
*
|
|
14
|
-
* @since 1.0.0
|
|
15
15
|
* @category models
|
|
16
|
+
* @since 4.0.0
|
|
16
17
|
*/
|
|
17
18
|
export type OpenAiTool = ReturnType<typeof ApplyPatch> | ReturnType<typeof CodeInterpreter> | ReturnType<typeof FileSearch> | ReturnType<typeof Shell> | ReturnType<typeof ImageGeneration> | ReturnType<typeof LocalShell> | ReturnType<typeof Mcp> | ReturnType<typeof WebSearch> | ReturnType<typeof WebSearchPreview>;
|
|
18
19
|
/**
|
|
19
|
-
* OpenAI Apply Patch tool
|
|
20
|
+
* Defines the OpenAI Apply Patch tool that allows the model to apply diffs by creating,
|
|
21
|
+
* deleting, or updating files. This local tool runs in your environment and
|
|
22
|
+
* requires a handler to execute file operations.
|
|
23
|
+
*
|
|
24
|
+
* **When to use**
|
|
20
25
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
26
|
+
* Use when you want an OpenAI model to request structured file edits as create,
|
|
27
|
+
* delete, or update operations that your application executes through a local
|
|
28
|
+
* handler.
|
|
24
29
|
*
|
|
25
|
-
* @since 1.0.0
|
|
26
30
|
* @category tools
|
|
31
|
+
* @since 4.0.0
|
|
27
32
|
*/
|
|
28
33
|
export declare const ApplyPatch: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
29
34
|
readonly failureMode?: Mode | undefined;
|
|
@@ -52,27 +57,36 @@ export declare const ApplyPatch: <Mode extends Tool.FailureMode | undefined = un
|
|
|
52
57
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
53
58
|
}, true>;
|
|
54
59
|
/**
|
|
55
|
-
* OpenAI Code Interpreter tool
|
|
60
|
+
* Defines the OpenAI Code Interpreter tool that allows the model to execute Python code in
|
|
61
|
+
* a sandboxed environment.
|
|
62
|
+
*
|
|
63
|
+
* **When to use**
|
|
56
64
|
*
|
|
57
|
-
*
|
|
65
|
+
* Use to enable OpenAI-hosted Python execution for a model response.
|
|
66
|
+
*
|
|
67
|
+
* **Details**
|
|
68
|
+
*
|
|
69
|
+
* The tool is configured with a `container` argument. Successful tool calls
|
|
70
|
+
* expose `outputs`, which may contain logs or generated images, or `null` when
|
|
71
|
+
* no outputs are available.
|
|
58
72
|
*
|
|
59
|
-
* @since 1.0.0
|
|
60
73
|
* @category tools
|
|
74
|
+
* @since 4.0.0
|
|
61
75
|
*/
|
|
62
76
|
export declare const CodeInterpreter: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
63
77
|
readonly container: string | {
|
|
64
78
|
readonly type: "auto";
|
|
65
79
|
readonly memory_limit?: "1g" | "4g" | "16g" | "64g" | null;
|
|
66
|
-
readonly network_policy?: {
|
|
67
|
-
readonly type: "disabled"
|
|
68
|
-
} | {
|
|
80
|
+
readonly network_policy?: Schema.Struct.ReadonlySide<{
|
|
81
|
+
readonly type: Schema.Literal<"disabled">;
|
|
82
|
+
}, "Encoded"> | {
|
|
69
83
|
readonly type: "allowlist";
|
|
70
84
|
readonly allowed_domains: readonly string[];
|
|
71
|
-
readonly domain_secrets?: readonly {
|
|
72
|
-
readonly
|
|
73
|
-
readonly name:
|
|
74
|
-
readonly
|
|
75
|
-
}[];
|
|
85
|
+
readonly domain_secrets?: readonly Schema.Struct.ReadonlySide<{
|
|
86
|
+
readonly domain: Schema.String;
|
|
87
|
+
readonly name: Schema.String;
|
|
88
|
+
readonly value: Schema.String;
|
|
89
|
+
}, "Encoded">[];
|
|
76
90
|
};
|
|
77
91
|
readonly file_ids?: readonly string[];
|
|
78
92
|
};
|
|
@@ -112,42 +126,56 @@ export declare const CodeInterpreter: <Mode extends Tool.FailureMode | undefined
|
|
|
112
126
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
113
127
|
}, false>;
|
|
114
128
|
/**
|
|
115
|
-
* OpenAI File Search tool
|
|
129
|
+
* Defines the OpenAI File Search tool that enables the model to search through uploaded
|
|
130
|
+
* files and vector stores.
|
|
131
|
+
*
|
|
132
|
+
* **When to use**
|
|
116
133
|
*
|
|
117
|
-
*
|
|
134
|
+
* Use to let an OpenAI model search uploaded files through one or more vector
|
|
135
|
+
* stores.
|
|
136
|
+
*
|
|
137
|
+
* **Details**
|
|
138
|
+
*
|
|
139
|
+
* The tool requires `vector_store_ids` and accepts optional `filters`,
|
|
140
|
+
* `max_num_results`, and `ranking_options`. Successful tool calls expose the
|
|
141
|
+
* search `status`, generated `queries`, and optional `results`.
|
|
118
142
|
*
|
|
119
|
-
* @since 1.0.0
|
|
120
143
|
* @category tools
|
|
144
|
+
* @since 4.0.0
|
|
121
145
|
*/
|
|
122
146
|
export declare const FileSearch: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
123
147
|
readonly vector_store_ids: readonly string[];
|
|
124
|
-
readonly filters?: {
|
|
125
|
-
readonly
|
|
126
|
-
readonly
|
|
127
|
-
readonly
|
|
128
|
-
} | {
|
|
129
|
-
readonly type: "and"
|
|
130
|
-
readonly filters: readonly
|
|
131
|
-
|
|
148
|
+
readonly filters?: Schema.Struct.ReadonlySide<{
|
|
149
|
+
readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]>;
|
|
150
|
+
readonly key: Schema.String;
|
|
151
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>]>;
|
|
152
|
+
}, "Encoded"> | Schema.Struct.ReadonlySide<{
|
|
153
|
+
readonly type: Schema.Literals<readonly ["and", "or"]>;
|
|
154
|
+
readonly filters: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
155
|
+
readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]>;
|
|
156
|
+
readonly key: Schema.String;
|
|
157
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>]>;
|
|
158
|
+
}>, Schema.Unknown]>>;
|
|
159
|
+
}, "Encoded"> | null;
|
|
132
160
|
readonly max_num_results?: number;
|
|
133
161
|
readonly ranking_options?: {
|
|
134
162
|
readonly ranker?: "auto" | "default-2024-11-15";
|
|
135
163
|
readonly score_threshold?: number;
|
|
136
|
-
readonly hybrid_search?: {
|
|
137
|
-
readonly embedding_weight:
|
|
138
|
-
readonly text_weight:
|
|
139
|
-
}
|
|
164
|
+
readonly hybrid_search?: Schema.Struct.ReadonlySide<{
|
|
165
|
+
readonly embedding_weight: Schema.Number;
|
|
166
|
+
readonly text_weight: Schema.Number;
|
|
167
|
+
}, "Encoded">;
|
|
140
168
|
};
|
|
141
169
|
}) => Tool.ProviderDefined<"openai.file_search", "OpenAiFileSearch", {
|
|
142
170
|
readonly args: Schema.Struct<{
|
|
143
171
|
readonly filters: Schema.optionalKey<Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
144
|
-
readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte"]>;
|
|
172
|
+
readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]>;
|
|
145
173
|
readonly key: Schema.String;
|
|
146
174
|
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>]>;
|
|
147
175
|
}>, Schema.Struct<{
|
|
148
176
|
readonly type: Schema.Literals<readonly ["and", "or"]>;
|
|
149
177
|
readonly filters: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
150
|
-
readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte"]>;
|
|
178
|
+
readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]>;
|
|
151
179
|
readonly key: Schema.String;
|
|
152
180
|
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>]>;
|
|
153
181
|
}>, Schema.Unknown]>>;
|
|
@@ -179,16 +207,27 @@ export declare const FileSearch: <Mode extends Tool.FailureMode | undefined = un
|
|
|
179
207
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
180
208
|
}, false>;
|
|
181
209
|
/**
|
|
182
|
-
* OpenAI Image Generation tool
|
|
210
|
+
* Defines the OpenAI Image Generation tool that enables the model to generate images using
|
|
211
|
+
* the GPT image models.
|
|
212
|
+
*
|
|
213
|
+
* **When to use**
|
|
214
|
+
*
|
|
215
|
+
* Use to enable OpenAI provider-defined image generation through a language
|
|
216
|
+
* model response.
|
|
217
|
+
*
|
|
218
|
+
* **Details**
|
|
183
219
|
*
|
|
184
|
-
*
|
|
220
|
+
* The tool configures the `image_generation` provider tool, including model,
|
|
221
|
+
* size, quality, output format, moderation, background, input-image options,
|
|
222
|
+
* and partial image settings. Successful tool calls expose `result` as base64
|
|
223
|
+
* image data or `null`.
|
|
185
224
|
*
|
|
186
|
-
* @since 1.0.0
|
|
187
225
|
* @category tools
|
|
226
|
+
* @since 4.0.0
|
|
188
227
|
*/
|
|
189
228
|
export declare const ImageGeneration: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
190
229
|
readonly model?: string;
|
|
191
|
-
readonly size?:
|
|
230
|
+
readonly size?: string;
|
|
192
231
|
readonly quality?: "auto" | "low" | "high" | "medium";
|
|
193
232
|
readonly background?: "auto" | "transparent" | "opaque";
|
|
194
233
|
readonly output_format?: "png" | "webp" | "jpeg";
|
|
@@ -214,7 +253,7 @@ export declare const ImageGeneration: <Mode extends Tool.FailureMode | undefined
|
|
|
214
253
|
readonly output_format: Schema.optionalKey<Schema.Literals<readonly ["png", "webp", "jpeg"]>>;
|
|
215
254
|
readonly partial_images: Schema.optionalKey<Schema.Number>;
|
|
216
255
|
readonly quality: Schema.optionalKey<Schema.Literals<readonly ["low", "medium", "high", "auto"]>>;
|
|
217
|
-
readonly size: Schema.optionalKey<Schema.Literals<readonly ["1024x1024", "1024x1536", "1536x1024", "auto"]>>;
|
|
256
|
+
readonly size: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Literals<readonly ["1024x1024", "1024x1536", "1536x1024", "auto"]>]>>;
|
|
218
257
|
}>;
|
|
219
258
|
readonly parameters: Schema.Void;
|
|
220
259
|
readonly success: Schema.Struct<{
|
|
@@ -224,13 +263,23 @@ export declare const ImageGeneration: <Mode extends Tool.FailureMode | undefined
|
|
|
224
263
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
225
264
|
}, false>;
|
|
226
265
|
/**
|
|
227
|
-
* OpenAI Local Shell tool
|
|
266
|
+
* Defines the OpenAI Local Shell tool that enables the model to run a command with a local
|
|
267
|
+
* shell. This local tool runs in your environment and requires a handler to
|
|
268
|
+
* execute commands.
|
|
228
269
|
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
270
|
+
* **When to use**
|
|
271
|
+
*
|
|
272
|
+
* Use to let an OpenAI model request local shell commands that your application
|
|
273
|
+
* executes through a handler.
|
|
274
|
+
*
|
|
275
|
+
* **Details**
|
|
276
|
+
*
|
|
277
|
+
* The tool exposes a provider-defined `local_shell` call. It is marked as
|
|
278
|
+
* handler-required, so applications must provide the command execution policy
|
|
279
|
+
* and implementation.
|
|
231
280
|
*
|
|
232
|
-
* @since 1.0.0
|
|
233
281
|
* @category tools
|
|
282
|
+
* @since 4.0.0
|
|
234
283
|
*/
|
|
235
284
|
export declare const LocalShell: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
236
285
|
readonly failureMode?: Mode | undefined;
|
|
@@ -253,13 +302,27 @@ export declare const LocalShell: <Mode extends Tool.FailureMode | undefined = un
|
|
|
253
302
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
254
303
|
}, true>;
|
|
255
304
|
/**
|
|
256
|
-
* OpenAI MCP tool
|
|
305
|
+
* Defines the OpenAI MCP tool that gives the model access to additional tools via remote
|
|
306
|
+
* Model Context Protocol (MCP) servers.
|
|
307
|
+
*
|
|
308
|
+
* **When to use**
|
|
309
|
+
*
|
|
310
|
+
* Use to let an OpenAI model call tools exposed by a remote MCP server.
|
|
257
311
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
312
|
+
* **Details**
|
|
313
|
+
*
|
|
314
|
+
* The tool accepts MCP server configuration such as allowed tools,
|
|
315
|
+
* authorization, connector id, approval requirements, server metadata, and
|
|
316
|
+
* server URL. Tool call results include the called tool name, arguments, output,
|
|
317
|
+
* error, and server label.
|
|
318
|
+
*
|
|
319
|
+
* **Gotchas**
|
|
320
|
+
*
|
|
321
|
+
* This schema leaves both `server_url` and `connector_id` optional, but OpenAI
|
|
322
|
+
* may require a server URL or connector id for a usable MCP tool configuration.
|
|
260
323
|
*
|
|
261
|
-
* @since 1.0.0
|
|
262
324
|
* @category tools
|
|
325
|
+
* @since 4.0.0
|
|
263
326
|
*/
|
|
264
327
|
export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
265
328
|
readonly server_label: string;
|
|
@@ -303,7 +366,7 @@ export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined
|
|
|
303
366
|
readonly server_label: Schema.String;
|
|
304
367
|
readonly server_url: Schema.optionalKey<Schema.String>;
|
|
305
368
|
}>;
|
|
306
|
-
readonly parameters: Schema.
|
|
369
|
+
readonly parameters: Schema.Unknown;
|
|
307
370
|
readonly success: Schema.Struct<{
|
|
308
371
|
readonly type: Schema.Literal<"mcp_call">;
|
|
309
372
|
readonly name: Schema.String;
|
|
@@ -316,14 +379,21 @@ export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined
|
|
|
316
379
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
317
380
|
}, false>;
|
|
318
381
|
/**
|
|
319
|
-
* OpenAI
|
|
382
|
+
* Defines the OpenAI shell tool for model-requested command execution.
|
|
383
|
+
*
|
|
384
|
+
* **When to use**
|
|
385
|
+
*
|
|
386
|
+
* Use to let an OpenAI model request shell commands that your application
|
|
387
|
+
* executes through a handler.
|
|
320
388
|
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* a
|
|
389
|
+
* **Details**
|
|
390
|
+
*
|
|
391
|
+
* The tool exposes a provider-defined `shell` call. It is marked as
|
|
392
|
+
* handler-required, so applications must provide the command execution policy
|
|
393
|
+
* and implementation.
|
|
324
394
|
*
|
|
325
|
-
* @since 1.0.0
|
|
326
395
|
* @category tools
|
|
396
|
+
* @since 4.0.0
|
|
327
397
|
*/
|
|
328
398
|
export declare const Shell: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
329
399
|
readonly failureMode?: Mode | undefined;
|
|
@@ -346,20 +416,34 @@ export declare const Shell: <Mode extends Tool.FailureMode | undefined = undefin
|
|
|
346
416
|
readonly type: Schema.Literal<"exit">;
|
|
347
417
|
readonly exit_code: Schema.Number;
|
|
348
418
|
}>]>;
|
|
419
|
+
readonly created_by: Schema.optionalKey<Schema.String>;
|
|
349
420
|
}>>;
|
|
350
421
|
}>;
|
|
351
422
|
readonly failure: Schema.Never;
|
|
352
423
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
353
424
|
}, true>;
|
|
354
425
|
/**
|
|
355
|
-
* OpenAI Web Search tool
|
|
426
|
+
* Defines the OpenAI Web Search tool that enables the model to search the web for
|
|
427
|
+
* information.
|
|
428
|
+
*
|
|
429
|
+
* **When to use**
|
|
430
|
+
*
|
|
431
|
+
* Use to enable OpenAI provider-defined web search for a model response.
|
|
432
|
+
*
|
|
433
|
+
* **Details**
|
|
434
|
+
*
|
|
435
|
+
* The tool accepts optional filters, user location, and search context size.
|
|
436
|
+
* Successful calls expose the performed search action and status.
|
|
356
437
|
*
|
|
357
|
-
*
|
|
438
|
+
* @see {@link WebSearchPreview} for the preview web search provider tool
|
|
358
439
|
*
|
|
359
|
-
* @since 1.0.0
|
|
360
440
|
* @category tools
|
|
441
|
+
* @since 4.0.0
|
|
361
442
|
*/
|
|
362
443
|
export declare const WebSearch: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
444
|
+
readonly filters?: {
|
|
445
|
+
readonly allowed_domains?: readonly string[] | null;
|
|
446
|
+
} | null;
|
|
363
447
|
readonly user_location?: {
|
|
364
448
|
readonly type?: "approximate";
|
|
365
449
|
readonly country?: string | null;
|
|
@@ -368,9 +452,6 @@ export declare const WebSearch: <Mode extends Tool.FailureMode | undefined = und
|
|
|
368
452
|
readonly timezone?: string | null;
|
|
369
453
|
} | null;
|
|
370
454
|
readonly search_context_size?: "low" | "high" | "medium";
|
|
371
|
-
readonly filters?: {
|
|
372
|
-
readonly allowed_domains?: readonly string[] | null;
|
|
373
|
-
} | null;
|
|
374
455
|
}) => Tool.ProviderDefined<"openai.web_search", "OpenAiWebSearch", {
|
|
375
456
|
readonly args: Schema.Struct<{
|
|
376
457
|
readonly filters: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -426,12 +507,21 @@ export declare const WebSearch: <Mode extends Tool.FailureMode | undefined = und
|
|
|
426
507
|
readonly failureMode: Mode extends undefined ? "error" : Mode;
|
|
427
508
|
}, false>;
|
|
428
509
|
/**
|
|
429
|
-
* OpenAI Web Search
|
|
510
|
+
* Defines the OpenAI preview Web Search tool for model responses.
|
|
511
|
+
*
|
|
512
|
+
* **When to use**
|
|
513
|
+
*
|
|
514
|
+
* Use to enable the preview OpenAI web search provider tool.
|
|
515
|
+
*
|
|
516
|
+
* **Details**
|
|
517
|
+
*
|
|
518
|
+
* The preview tool accepts optional user location and search context size, then
|
|
519
|
+
* exposes the performed search action and status in successful calls.
|
|
430
520
|
*
|
|
431
|
-
*
|
|
521
|
+
* @see {@link WebSearch} for the stable web search provider tool
|
|
432
522
|
*
|
|
433
|
-
* @since 1.0.0
|
|
434
523
|
* @category tools
|
|
524
|
+
* @since 4.0.0
|
|
435
525
|
*/
|
|
436
526
|
export declare const WebSearchPreview: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
|
|
437
527
|
readonly user_location?: {
|
package/dist/OpenAiTool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiTool.d.ts","sourceRoot":"","sources":["../src/OpenAiTool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenAiTool.d.ts","sourceRoot":"","sources":["../src/OpenAiTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAA;AAG/C;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,UAAU,CAAC,OAAO,UAAU,CAAC,GAC7B,UAAU,CAAC,OAAO,eAAe,CAAC,GAClC,UAAU,CAAC,OAAO,UAAU,CAAC,GAC7B,UAAU,CAAC,OAAO,KAAK,CAAC,GACxB,UAAU,CAAC,OAAO,eAAe,CAAC,GAClC,UAAU,CAAC,OAAO,UAAU,CAAC,GAC7B,UAAU,CAAC,OAAO,GAAG,CAAC,GACtB,UAAU,CAAC,OAAO,SAAS,CAAC,GAC5B,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEvC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;QAarB,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAc1B,CAAA;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAerB,CAAA;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAmB1B,CAAA;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;QAWrB,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAsBd,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;QAWhB,CAAA;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgBpB,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAY3B,CAAA"}
|
package/dist/OpenAiTool.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenAI provider
|
|
2
|
+
* The `OpenAiTool` module defines OpenAI provider tools for Effect AI language
|
|
3
|
+
* model requests. It exposes typed descriptors for tools such as Apply Patch,
|
|
4
|
+
* Code Interpreter, File Search, Image Generation, MCP, Web Search, and
|
|
5
|
+
* shell-like local tools, including their provider names, configuration
|
|
6
|
+
* arguments, call parameters, success schemas, and handler requirements.
|
|
3
7
|
*
|
|
4
|
-
*
|
|
5
|
-
* code interpreter, file search, and web search functionality.
|
|
6
|
-
*
|
|
7
|
-
* @since 1.0.0
|
|
8
|
+
* @since 4.0.0
|
|
8
9
|
*/
|
|
9
10
|
import * as Schema from "effect/Schema";
|
|
10
11
|
import * as Tool from "effect/unstable/ai/Tool";
|
|
11
12
|
import * as Generated from "./Generated.js";
|
|
12
13
|
/**
|
|
13
|
-
* OpenAI Apply Patch tool
|
|
14
|
+
* Defines the OpenAI Apply Patch tool that allows the model to apply diffs by creating,
|
|
15
|
+
* deleting, or updating files. This local tool runs in your environment and
|
|
16
|
+
* requires a handler to execute file operations.
|
|
17
|
+
*
|
|
18
|
+
* **When to use**
|
|
14
19
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* Use when you want an OpenAI model to request structured file edits as create,
|
|
21
|
+
* delete, or update operations that your application executes through a local
|
|
22
|
+
* handler.
|
|
18
23
|
*
|
|
19
|
-
* @since 1.0.0
|
|
20
24
|
* @category tools
|
|
25
|
+
* @since 4.0.0
|
|
21
26
|
*/
|
|
22
27
|
export const ApplyPatch = /*#__PURE__*/Tool.providerDefined({
|
|
23
28
|
id: "openai.apply_patch",
|
|
@@ -34,12 +39,21 @@ export const ApplyPatch = /*#__PURE__*/Tool.providerDefined({
|
|
|
34
39
|
})
|
|
35
40
|
});
|
|
36
41
|
/**
|
|
37
|
-
* OpenAI Code Interpreter tool
|
|
42
|
+
* Defines the OpenAI Code Interpreter tool that allows the model to execute Python code in
|
|
43
|
+
* a sandboxed environment.
|
|
44
|
+
*
|
|
45
|
+
* **When to use**
|
|
46
|
+
*
|
|
47
|
+
* Use to enable OpenAI-hosted Python execution for a model response.
|
|
38
48
|
*
|
|
39
|
-
*
|
|
49
|
+
* **Details**
|
|
50
|
+
*
|
|
51
|
+
* The tool is configured with a `container` argument. Successful tool calls
|
|
52
|
+
* expose `outputs`, which may contain logs or generated images, or `null` when
|
|
53
|
+
* no outputs are available.
|
|
40
54
|
*
|
|
41
|
-
* @since 1.0.0
|
|
42
55
|
* @category tools
|
|
56
|
+
* @since 4.0.0
|
|
43
57
|
*/
|
|
44
58
|
export const CodeInterpreter = /*#__PURE__*/Tool.providerDefined({
|
|
45
59
|
id: "openai.code_interpreter",
|
|
@@ -57,12 +71,22 @@ export const CodeInterpreter = /*#__PURE__*/Tool.providerDefined({
|
|
|
57
71
|
})
|
|
58
72
|
});
|
|
59
73
|
/**
|
|
60
|
-
* OpenAI File Search tool
|
|
74
|
+
* Defines the OpenAI File Search tool that enables the model to search through uploaded
|
|
75
|
+
* files and vector stores.
|
|
76
|
+
*
|
|
77
|
+
* **When to use**
|
|
78
|
+
*
|
|
79
|
+
* Use to let an OpenAI model search uploaded files through one or more vector
|
|
80
|
+
* stores.
|
|
81
|
+
*
|
|
82
|
+
* **Details**
|
|
61
83
|
*
|
|
62
|
-
*
|
|
84
|
+
* The tool requires `vector_store_ids` and accepts optional `filters`,
|
|
85
|
+
* `max_num_results`, and `ranking_options`. Successful tool calls expose the
|
|
86
|
+
* search `status`, generated `queries`, and optional `results`.
|
|
63
87
|
*
|
|
64
|
-
* @since 1.0.0
|
|
65
88
|
* @category tools
|
|
89
|
+
* @since 4.0.0
|
|
66
90
|
*/
|
|
67
91
|
export const FileSearch = /*#__PURE__*/Tool.providerDefined({
|
|
68
92
|
id: "openai.file_search",
|
|
@@ -81,12 +105,23 @@ export const FileSearch = /*#__PURE__*/Tool.providerDefined({
|
|
|
81
105
|
})
|
|
82
106
|
});
|
|
83
107
|
/**
|
|
84
|
-
* OpenAI Image Generation tool
|
|
108
|
+
* Defines the OpenAI Image Generation tool that enables the model to generate images using
|
|
109
|
+
* the GPT image models.
|
|
85
110
|
*
|
|
86
|
-
*
|
|
111
|
+
* **When to use**
|
|
112
|
+
*
|
|
113
|
+
* Use to enable OpenAI provider-defined image generation through a language
|
|
114
|
+
* model response.
|
|
115
|
+
*
|
|
116
|
+
* **Details**
|
|
117
|
+
*
|
|
118
|
+
* The tool configures the `image_generation` provider tool, including model,
|
|
119
|
+
* size, quality, output format, moderation, background, input-image options,
|
|
120
|
+
* and partial image settings. Successful tool calls expose `result` as base64
|
|
121
|
+
* image data or `null`.
|
|
87
122
|
*
|
|
88
|
-
* @since 1.0.0
|
|
89
123
|
* @category tools
|
|
124
|
+
* @since 4.0.0
|
|
90
125
|
*/
|
|
91
126
|
export const ImageGeneration = /*#__PURE__*/Tool.providerDefined({
|
|
92
127
|
id: "openai.image_generation",
|
|
@@ -109,13 +144,23 @@ export const ImageGeneration = /*#__PURE__*/Tool.providerDefined({
|
|
|
109
144
|
})
|
|
110
145
|
});
|
|
111
146
|
/**
|
|
112
|
-
* OpenAI Local Shell tool
|
|
147
|
+
* Defines the OpenAI Local Shell tool that enables the model to run a command with a local
|
|
148
|
+
* shell. This local tool runs in your environment and requires a handler to
|
|
149
|
+
* execute commands.
|
|
150
|
+
*
|
|
151
|
+
* **When to use**
|
|
113
152
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
153
|
+
* Use to let an OpenAI model request local shell commands that your application
|
|
154
|
+
* executes through a handler.
|
|
155
|
+
*
|
|
156
|
+
* **Details**
|
|
157
|
+
*
|
|
158
|
+
* The tool exposes a provider-defined `local_shell` call. It is marked as
|
|
159
|
+
* handler-required, so applications must provide the command execution policy
|
|
160
|
+
* and implementation.
|
|
116
161
|
*
|
|
117
|
-
* @since 1.0.0
|
|
118
162
|
* @category tools
|
|
163
|
+
* @since 4.0.0
|
|
119
164
|
*/
|
|
120
165
|
export const LocalShell = /*#__PURE__*/Tool.providerDefined({
|
|
121
166
|
id: "openai.local_shell",
|
|
@@ -130,13 +175,27 @@ export const LocalShell = /*#__PURE__*/Tool.providerDefined({
|
|
|
130
175
|
})
|
|
131
176
|
});
|
|
132
177
|
/**
|
|
133
|
-
* OpenAI MCP tool
|
|
178
|
+
* Defines the OpenAI MCP tool that gives the model access to additional tools via remote
|
|
179
|
+
* Model Context Protocol (MCP) servers.
|
|
180
|
+
*
|
|
181
|
+
* **When to use**
|
|
134
182
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
183
|
+
* Use to let an OpenAI model call tools exposed by a remote MCP server.
|
|
184
|
+
*
|
|
185
|
+
* **Details**
|
|
186
|
+
*
|
|
187
|
+
* The tool accepts MCP server configuration such as allowed tools,
|
|
188
|
+
* authorization, connector id, approval requirements, server metadata, and
|
|
189
|
+
* server URL. Tool call results include the called tool name, arguments, output,
|
|
190
|
+
* error, and server label.
|
|
191
|
+
*
|
|
192
|
+
* **Gotchas**
|
|
193
|
+
*
|
|
194
|
+
* This schema leaves both `server_url` and `connector_id` optional, but OpenAI
|
|
195
|
+
* may require a server URL or connector id for a usable MCP tool configuration.
|
|
137
196
|
*
|
|
138
|
-
* @since 1.0.0
|
|
139
197
|
* @category tools
|
|
198
|
+
* @since 4.0.0
|
|
140
199
|
*/
|
|
141
200
|
export const Mcp = /*#__PURE__*/Tool.providerDefined({
|
|
142
201
|
id: "openai.mcp",
|
|
@@ -151,6 +210,7 @@ export const Mcp = /*#__PURE__*/Tool.providerDefined({
|
|
|
151
210
|
server_label: Generated.MCPTool.fields.server_label,
|
|
152
211
|
server_url: Generated.MCPTool.fields.server_url
|
|
153
212
|
}),
|
|
213
|
+
parameters: Schema.Unknown,
|
|
154
214
|
success: /*#__PURE__*/Schema.Struct({
|
|
155
215
|
type: Generated.MCPToolCall.fields.type,
|
|
156
216
|
name: Generated.MCPToolCall.fields.name,
|
|
@@ -161,14 +221,21 @@ export const Mcp = /*#__PURE__*/Tool.providerDefined({
|
|
|
161
221
|
})
|
|
162
222
|
});
|
|
163
223
|
/**
|
|
164
|
-
* OpenAI
|
|
224
|
+
* Defines the OpenAI shell tool for model-requested command execution.
|
|
165
225
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
226
|
+
* **When to use**
|
|
227
|
+
*
|
|
228
|
+
* Use to let an OpenAI model request shell commands that your application
|
|
229
|
+
* executes through a handler.
|
|
230
|
+
*
|
|
231
|
+
* **Details**
|
|
232
|
+
*
|
|
233
|
+
* The tool exposes a provider-defined `shell` call. It is marked as
|
|
234
|
+
* handler-required, so applications must provide the command execution policy
|
|
235
|
+
* and implementation.
|
|
169
236
|
*
|
|
170
|
-
* @since 1.0.0
|
|
171
237
|
* @category tools
|
|
238
|
+
* @since 4.0.0
|
|
172
239
|
*/
|
|
173
240
|
export const Shell = /*#__PURE__*/Tool.providerDefined({
|
|
174
241
|
id: "openai.shell",
|
|
@@ -179,16 +246,26 @@ export const Shell = /*#__PURE__*/Tool.providerDefined({
|
|
|
179
246
|
action: Generated.FunctionShellCall.fields.action
|
|
180
247
|
}),
|
|
181
248
|
success: /*#__PURE__*/Schema.Struct({
|
|
182
|
-
output: Generated.
|
|
249
|
+
output: Generated.FunctionShellCallOutput.fields.output
|
|
183
250
|
})
|
|
184
251
|
});
|
|
185
252
|
/**
|
|
186
|
-
* OpenAI Web Search tool
|
|
253
|
+
* Defines the OpenAI Web Search tool that enables the model to search the web for
|
|
254
|
+
* information.
|
|
255
|
+
*
|
|
256
|
+
* **When to use**
|
|
187
257
|
*
|
|
188
|
-
*
|
|
258
|
+
* Use to enable OpenAI provider-defined web search for a model response.
|
|
259
|
+
*
|
|
260
|
+
* **Details**
|
|
261
|
+
*
|
|
262
|
+
* The tool accepts optional filters, user location, and search context size.
|
|
263
|
+
* Successful calls expose the performed search action and status.
|
|
264
|
+
*
|
|
265
|
+
* @see {@link WebSearchPreview} for the preview web search provider tool
|
|
189
266
|
*
|
|
190
|
-
* @since 1.0.0
|
|
191
267
|
* @category tools
|
|
268
|
+
* @since 4.0.0
|
|
192
269
|
*/
|
|
193
270
|
export const WebSearch = /*#__PURE__*/Tool.providerDefined({
|
|
194
271
|
id: "openai.web_search",
|
|
@@ -208,12 +285,21 @@ export const WebSearch = /*#__PURE__*/Tool.providerDefined({
|
|
|
208
285
|
})
|
|
209
286
|
});
|
|
210
287
|
/**
|
|
211
|
-
* OpenAI Web Search
|
|
288
|
+
* Defines the OpenAI preview Web Search tool for model responses.
|
|
289
|
+
*
|
|
290
|
+
* **When to use**
|
|
291
|
+
*
|
|
292
|
+
* Use to enable the preview OpenAI web search provider tool.
|
|
293
|
+
*
|
|
294
|
+
* **Details**
|
|
295
|
+
*
|
|
296
|
+
* The preview tool accepts optional user location and search context size, then
|
|
297
|
+
* exposes the performed search action and status in successful calls.
|
|
212
298
|
*
|
|
213
|
-
*
|
|
299
|
+
* @see {@link WebSearch} for the stable web search provider tool
|
|
214
300
|
*
|
|
215
|
-
* @since 1.0.0
|
|
216
301
|
* @category tools
|
|
302
|
+
* @since 4.0.0
|
|
217
303
|
*/
|
|
218
304
|
export const WebSearchPreview = /*#__PURE__*/Tool.providerDefined({
|
|
219
305
|
id: "openai.web_search_preview",
|