@effect/ai-openai 4.0.0-beta.70 → 4.0.0-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OpenAiClient.d.ts +87 -3
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +118 -6
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiConfig.d.ts +84 -15
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +52 -15
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +126 -2
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +100 -2
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiLanguageModel.d.ts +138 -9
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +106 -7
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +281 -12
- package/dist/OpenAiSchema.d.ts.map +1 -1
- package/dist/OpenAiSchema.js +227 -4
- package/dist/OpenAiSchema.js.map +1 -1
- package/dist/OpenAiTelemetry.d.ts +29 -1
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +29 -4
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/OpenAiTool.d.ts +111 -5
- package/dist/OpenAiTool.d.ts.map +1 -1
- package/dist/OpenAiTool.js +111 -5
- package/dist/OpenAiTool.js.map +1 -1
- package/dist/index.d.ts +1 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -49
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/OpenAiClient.ts +118 -6
- package/src/OpenAiConfig.ts +84 -15
- package/src/OpenAiEmbeddingModel.ts +152 -2
- package/src/OpenAiLanguageModel.ts +170 -11
- package/src/OpenAiSchema.ts +309 -4
- package/src/OpenAiTelemetry.ts +50 -5
- package/src/OpenAiTool.ts +111 -5
- package/src/index.ts +1 -49
package/src/OpenAiTool.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenAI provider-defined tools for
|
|
2
|
+
* OpenAI provider-defined tools for Effect AI language model requests.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This module exposes typed descriptors for OpenAI tools such as code
|
|
5
|
+
* interpreter, file search, image generation, MCP, web search, and shell-like
|
|
6
|
+
* local tools. Each descriptor captures the OpenAI provider name, user-facing
|
|
7
|
+
* configuration arguments, provider call parameters, success output schema, and
|
|
8
|
+
* whether the tool call needs an application-provided handler.
|
|
9
|
+
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* Provider-defined tools are not implementations of the capability themselves.
|
|
13
|
+
* They are schemas and metadata that tell the language model provider which
|
|
14
|
+
* tool to make available and tell Effect AI how to decode any tool calls or
|
|
15
|
+
* tool results that come back.
|
|
16
|
+
*
|
|
17
|
+
* **Common tasks**
|
|
18
|
+
*
|
|
19
|
+
* Use hosted or provider-routed tools such as {@link CodeInterpreter},
|
|
20
|
+
* {@link FileSearch}, {@link ImageGeneration}, {@link Mcp}, {@link WebSearch},
|
|
21
|
+
* and {@link WebSearchPreview} to opt into OpenAI-managed capabilities. Use
|
|
22
|
+
* handler-required tools such as {@link ApplyPatch}, {@link Shell}, and
|
|
23
|
+
* {@link LocalShell} only when your application is prepared to execute the
|
|
24
|
+
* requested local operation and enforce its own safety policy.
|
|
6
25
|
*
|
|
7
26
|
* @since 4.0.0
|
|
8
27
|
*/
|
|
@@ -32,6 +51,12 @@ export type OpenAiTool =
|
|
|
32
51
|
* deleting, or updating files. This local tool runs in your environment and
|
|
33
52
|
* requires a handler to execute file operations.
|
|
34
53
|
*
|
|
54
|
+
* **When to use**
|
|
55
|
+
*
|
|
56
|
+
* Use when you want an OpenAI model to request structured file edits as create,
|
|
57
|
+
* delete, or update operations that your application executes through a local
|
|
58
|
+
* handler.
|
|
59
|
+
*
|
|
35
60
|
* @category tools
|
|
36
61
|
* @since 4.0.0
|
|
37
62
|
*/
|
|
@@ -54,6 +79,16 @@ export const ApplyPatch = Tool.providerDefined({
|
|
|
54
79
|
* OpenAI Code Interpreter tool that allows the model to execute Python code in
|
|
55
80
|
* a sandboxed environment.
|
|
56
81
|
*
|
|
82
|
+
* **When to use**
|
|
83
|
+
*
|
|
84
|
+
* Use to enable OpenAI-hosted Python execution for a model response.
|
|
85
|
+
*
|
|
86
|
+
* **Details**
|
|
87
|
+
*
|
|
88
|
+
* The tool is configured with a `container` argument. Successful tool calls
|
|
89
|
+
* expose `outputs`, which may contain logs or generated images, or `null` when
|
|
90
|
+
* no outputs are available.
|
|
91
|
+
*
|
|
57
92
|
* @category tools
|
|
58
93
|
* @since 4.0.0
|
|
59
94
|
*/
|
|
@@ -77,6 +112,17 @@ export const CodeInterpreter = Tool.providerDefined({
|
|
|
77
112
|
* OpenAI File Search tool that enables the model to search through uploaded
|
|
78
113
|
* files and vector stores.
|
|
79
114
|
*
|
|
115
|
+
* **When to use**
|
|
116
|
+
*
|
|
117
|
+
* Use to let an OpenAI model search uploaded files through one or more vector
|
|
118
|
+
* stores.
|
|
119
|
+
*
|
|
120
|
+
* **Details**
|
|
121
|
+
*
|
|
122
|
+
* The tool requires `vector_store_ids` and accepts optional `filters`,
|
|
123
|
+
* `max_num_results`, and `ranking_options`. Successful tool calls expose the
|
|
124
|
+
* search `status`, generated `queries`, and optional `results`.
|
|
125
|
+
*
|
|
80
126
|
* @category tools
|
|
81
127
|
* @since 4.0.0
|
|
82
128
|
*/
|
|
@@ -101,6 +147,18 @@ export const FileSearch = Tool.providerDefined({
|
|
|
101
147
|
* OpenAI Image Generation tool that enables the model to generate images using
|
|
102
148
|
* the GPT image models.
|
|
103
149
|
*
|
|
150
|
+
* **When to use**
|
|
151
|
+
*
|
|
152
|
+
* Use to enable OpenAI provider-defined image generation through a language
|
|
153
|
+
* model response.
|
|
154
|
+
*
|
|
155
|
+
* **Details**
|
|
156
|
+
*
|
|
157
|
+
* The tool configures the `image_generation` provider tool, including model,
|
|
158
|
+
* size, quality, output format, moderation, background, input-image options,
|
|
159
|
+
* and partial image settings. Successful tool calls expose `result` as base64
|
|
160
|
+
* image data or `null`.
|
|
161
|
+
*
|
|
104
162
|
* @category tools
|
|
105
163
|
* @since 4.0.0
|
|
106
164
|
*/
|
|
@@ -130,6 +188,17 @@ export const ImageGeneration = Tool.providerDefined({
|
|
|
130
188
|
* shell. This local tool runs in your environment and requires a handler to
|
|
131
189
|
* execute commands.
|
|
132
190
|
*
|
|
191
|
+
* **When to use**
|
|
192
|
+
*
|
|
193
|
+
* Use to let an OpenAI model request local shell commands that your application
|
|
194
|
+
* executes through a handler.
|
|
195
|
+
*
|
|
196
|
+
* **Details**
|
|
197
|
+
*
|
|
198
|
+
* The tool exposes a provider-defined `local_shell` call. It is marked as
|
|
199
|
+
* handler-required, so applications must provide the command execution policy
|
|
200
|
+
* and implementation.
|
|
201
|
+
*
|
|
133
202
|
* @category tools
|
|
134
203
|
* @since 4.0.0
|
|
135
204
|
*/
|
|
@@ -150,6 +219,22 @@ export const LocalShell = Tool.providerDefined({
|
|
|
150
219
|
* OpenAI MCP tool that gives the model access to additional tools via remote
|
|
151
220
|
* Model Context Protocol (MCP) servers.
|
|
152
221
|
*
|
|
222
|
+
* **When to use**
|
|
223
|
+
*
|
|
224
|
+
* Use to let an OpenAI model call tools exposed by a remote MCP server.
|
|
225
|
+
*
|
|
226
|
+
* **Details**
|
|
227
|
+
*
|
|
228
|
+
* The tool accepts MCP server configuration such as allowed tools,
|
|
229
|
+
* authorization, connector id, approval requirements, server metadata, and
|
|
230
|
+
* server URL. Tool call results include the called tool name, arguments, output,
|
|
231
|
+
* error, and server label.
|
|
232
|
+
*
|
|
233
|
+
* **Gotchas**
|
|
234
|
+
*
|
|
235
|
+
* This schema leaves both `server_url` and `connector_id` optional, but OpenAI
|
|
236
|
+
* may require a server URL or connector id for a usable MCP tool configuration.
|
|
237
|
+
*
|
|
153
238
|
* @category tools
|
|
154
239
|
* @since 4.0.0
|
|
155
240
|
*/
|
|
@@ -202,6 +287,17 @@ export const Shell = Tool.providerDefined({
|
|
|
202
287
|
* OpenAI Web Search tool that enables the model to search the web for
|
|
203
288
|
* information.
|
|
204
289
|
*
|
|
290
|
+
* **When to use**
|
|
291
|
+
*
|
|
292
|
+
* Use to enable OpenAI provider-defined web search for a model response.
|
|
293
|
+
*
|
|
294
|
+
* **Details**
|
|
295
|
+
*
|
|
296
|
+
* The tool accepts optional filters, user location, and search context size.
|
|
297
|
+
* Successful calls expose the performed search action and status.
|
|
298
|
+
*
|
|
299
|
+
* @see {@link WebSearchPreview} for the preview web search provider tool
|
|
300
|
+
*
|
|
205
301
|
* @category tools
|
|
206
302
|
* @since 4.0.0
|
|
207
303
|
*/
|
|
@@ -224,8 +320,18 @@ export const WebSearch = Tool.providerDefined({
|
|
|
224
320
|
})
|
|
225
321
|
|
|
226
322
|
/**
|
|
227
|
-
* OpenAI Web Search
|
|
228
|
-
*
|
|
323
|
+
* OpenAI preview Web Search tool for model responses.
|
|
324
|
+
*
|
|
325
|
+
* **When to use**
|
|
326
|
+
*
|
|
327
|
+
* Use to enable the preview OpenAI web search provider tool.
|
|
328
|
+
*
|
|
329
|
+
* **Details**
|
|
330
|
+
*
|
|
331
|
+
* The preview tool accepts optional user location and search context size, then
|
|
332
|
+
* exposes the performed search action and status in successful calls.
|
|
333
|
+
*
|
|
334
|
+
* @see {@link WebSearch} for the stable web search provider tool
|
|
229
335
|
*
|
|
230
336
|
* @category tools
|
|
231
337
|
* @since 4.0.0
|
package/src/index.ts
CHANGED
|
@@ -5,16 +5,11 @@
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @since
|
|
8
|
+
* @since 1.0.0
|
|
9
9
|
*/
|
|
10
10
|
export * as Generated from "./Generated.ts"
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* OpenAI Client module for interacting with OpenAI's API.
|
|
14
|
-
*
|
|
15
|
-
* Provides a type-safe, Effect-based client for OpenAI operations including
|
|
16
|
-
* completions, embeddings, and streaming responses.
|
|
17
|
-
*
|
|
18
13
|
* @since 4.0.0
|
|
19
14
|
*/
|
|
20
15
|
export * as OpenAiClient from "./OpenAiClient.ts"
|
|
@@ -25,79 +20,36 @@ export * as OpenAiClient from "./OpenAiClient.ts"
|
|
|
25
20
|
export * as OpenAiClientGenerated from "./OpenAiClientGenerated.ts"
|
|
26
21
|
|
|
27
22
|
/**
|
|
28
|
-
* The `OpenAiConfig` module provides contextual configuration for the
|
|
29
|
-
* `@effect/ai-openai` integration. It is used to customize how OpenAI clients
|
|
30
|
-
* are built and interpreted without threading configuration through every API
|
|
31
|
-
* call manually.
|
|
32
|
-
*
|
|
33
|
-
* The primary use case is installing an HTTP client transform with
|
|
34
|
-
* {@link withClientTransform}. This lets applications adapt the underlying
|
|
35
|
-
* OpenAI HTTP client for cross-cutting concerns such as custom middleware,
|
|
36
|
-
* instrumentation, proxying, or request policy changes while keeping the
|
|
37
|
-
* OpenAI service APIs unchanged.
|
|
38
|
-
*
|
|
39
|
-
* Configuration is scoped through Effect's context, so transforms only apply to
|
|
40
|
-
* the effect they are provided to and anything evaluated inside that scope.
|
|
41
|
-
* When multiple transforms are needed, compose them into a single
|
|
42
|
-
* `HttpClient => HttpClient` function before providing the configuration.
|
|
43
|
-
*
|
|
44
23
|
* @since 4.0.0
|
|
45
24
|
*/
|
|
46
25
|
export * as OpenAiConfig from "./OpenAiConfig.ts"
|
|
47
26
|
|
|
48
27
|
/**
|
|
49
|
-
* OpenAI Embedding Model implementation.
|
|
50
|
-
*
|
|
51
|
-
* Provides an EmbeddingModel implementation for OpenAI's embeddings API.
|
|
52
|
-
*
|
|
53
28
|
* @since 4.0.0
|
|
54
29
|
*/
|
|
55
30
|
export * as OpenAiEmbeddingModel from "./OpenAiEmbeddingModel.ts"
|
|
56
31
|
|
|
57
32
|
/**
|
|
58
|
-
* OpenAI error metadata augmentation.
|
|
59
|
-
*
|
|
60
|
-
* Provides OpenAI-specific metadata fields for AI error types through module
|
|
61
|
-
* augmentation, enabling typed access to OpenAI error details.
|
|
62
|
-
*
|
|
63
33
|
* @since 4.0.0
|
|
64
34
|
*/
|
|
65
35
|
export * as OpenAiError from "./OpenAiError.ts"
|
|
66
36
|
|
|
67
37
|
/**
|
|
68
|
-
* OpenAI Language Model implementation.
|
|
69
|
-
*
|
|
70
|
-
* Provides a LanguageModel implementation for OpenAI's responses API,
|
|
71
|
-
* supporting text generation, structured output, tool calling, and streaming.
|
|
72
|
-
*
|
|
73
38
|
* @since 4.0.0
|
|
74
39
|
*/
|
|
75
40
|
export * as OpenAiLanguageModel from "./OpenAiLanguageModel.ts"
|
|
76
41
|
|
|
77
42
|
/**
|
|
78
|
-
* Minimal local OpenAI schemas used by the handwritten Responses client path.
|
|
79
|
-
*
|
|
80
43
|
* @since 4.0.0
|
|
81
44
|
*/
|
|
82
45
|
export * as OpenAiSchema from "./OpenAiSchema.ts"
|
|
83
46
|
|
|
84
47
|
/**
|
|
85
|
-
* OpenAI telemetry attributes for OpenTelemetry integration.
|
|
86
|
-
*
|
|
87
|
-
* Provides OpenAI-specific GenAI telemetry attributes following OpenTelemetry
|
|
88
|
-
* semantic conventions, extending the base GenAI attributes with OpenAI-specific
|
|
89
|
-
* request and response metadata.
|
|
90
|
-
*
|
|
91
48
|
* @since 4.0.0
|
|
92
49
|
*/
|
|
93
50
|
export * as OpenAiTelemetry from "./OpenAiTelemetry.ts"
|
|
94
51
|
|
|
95
52
|
/**
|
|
96
|
-
* OpenAI provider-defined tools for use with the LanguageModel.
|
|
97
|
-
*
|
|
98
|
-
* Provides tools that are natively supported by OpenAI's API, including
|
|
99
|
-
* code interpreter, file search, and web search functionality.
|
|
100
|
-
*
|
|
101
53
|
* @since 4.0.0
|
|
102
54
|
*/
|
|
103
55
|
export * as OpenAiTool from "./OpenAiTool.ts"
|