@effect/ai-openai 4.0.0-beta.70 → 4.0.0-beta.72

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.
Files changed (41) hide show
  1. package/dist/OpenAiClient.d.ts +88 -4
  2. package/dist/OpenAiClient.d.ts.map +1 -1
  3. package/dist/OpenAiClient.js +127 -8
  4. package/dist/OpenAiClient.js.map +1 -1
  5. package/dist/OpenAiConfig.d.ts +85 -17
  6. package/dist/OpenAiConfig.d.ts.map +1 -1
  7. package/dist/OpenAiConfig.js +53 -17
  8. package/dist/OpenAiConfig.js.map +1 -1
  9. package/dist/OpenAiEmbeddingModel.d.ts +127 -3
  10. package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
  11. package/dist/OpenAiEmbeddingModel.js +101 -3
  12. package/dist/OpenAiEmbeddingModel.js.map +1 -1
  13. package/dist/OpenAiLanguageModel.d.ts +139 -10
  14. package/dist/OpenAiLanguageModel.d.ts.map +1 -1
  15. package/dist/OpenAiLanguageModel.js +107 -8
  16. package/dist/OpenAiLanguageModel.js.map +1 -1
  17. package/dist/OpenAiSchema.d.ts +281 -12
  18. package/dist/OpenAiSchema.d.ts.map +1 -1
  19. package/dist/OpenAiSchema.js +227 -4
  20. package/dist/OpenAiSchema.js.map +1 -1
  21. package/dist/OpenAiTelemetry.d.ts +29 -1
  22. package/dist/OpenAiTelemetry.d.ts.map +1 -1
  23. package/dist/OpenAiTelemetry.js +29 -4
  24. package/dist/OpenAiTelemetry.js.map +1 -1
  25. package/dist/OpenAiTool.d.ts +130 -15
  26. package/dist/OpenAiTool.d.ts.map +1 -1
  27. package/dist/OpenAiTool.js +130 -15
  28. package/dist/OpenAiTool.js.map +1 -1
  29. package/dist/index.d.ts +1 -49
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -49
  32. package/dist/index.js.map +1 -1
  33. package/package.json +3 -3
  34. package/src/OpenAiClient.ts +129 -9
  35. package/src/OpenAiConfig.ts +85 -17
  36. package/src/OpenAiEmbeddingModel.ts +153 -3
  37. package/src/OpenAiLanguageModel.ts +171 -12
  38. package/src/OpenAiSchema.ts +309 -4
  39. package/src/OpenAiTelemetry.ts +50 -5
  40. package/src/OpenAiTool.ts +130 -15
  41. package/src/index.ts +1 -49
package/src/OpenAiTool.ts CHANGED
@@ -1,8 +1,27 @@
1
1
  /**
2
- * OpenAI provider-defined tools for use with the LanguageModel.
2
+ * OpenAI provider-defined tools for Effect AI language model requests.
3
3
  *
4
- * Provides tools that are natively supported by OpenAI's API, including
5
- * code interpreter, file search, and web search functionality.
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
  */
@@ -28,10 +47,16 @@ export type OpenAiTool =
28
47
  | ReturnType<typeof WebSearchPreview>
29
48
 
30
49
  /**
31
- * OpenAI Apply Patch tool that allows the model to apply diffs by creating,
50
+ * Defines the OpenAI Apply Patch tool that allows the model to apply diffs by creating,
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
  */
@@ -51,9 +76,19 @@ export const ApplyPatch = Tool.providerDefined({
51
76
  })
52
77
 
53
78
  /**
54
- * OpenAI Code Interpreter tool that allows the model to execute Python code in
79
+ * Defines the 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
  */
@@ -74,9 +109,20 @@ export const CodeInterpreter = Tool.providerDefined({
74
109
  })
75
110
 
76
111
  /**
77
- * OpenAI File Search tool that enables the model to search through uploaded
112
+ * Defines the 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
  */
@@ -98,9 +144,21 @@ export const FileSearch = Tool.providerDefined({
98
144
  })
99
145
 
100
146
  /**
101
- * OpenAI Image Generation tool that enables the model to generate images using
147
+ * Defines the 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
  */
@@ -126,10 +184,21 @@ export const ImageGeneration = Tool.providerDefined({
126
184
  })
127
185
 
128
186
  /**
129
- * OpenAI Local Shell tool that enables the model to run a command with a local
187
+ * Defines the OpenAI Local Shell tool that enables the model to run a command with a local
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
  */
@@ -147,9 +216,25 @@ export const LocalShell = Tool.providerDefined({
147
216
  })
148
217
 
149
218
  /**
150
- * OpenAI MCP tool that gives the model access to additional tools via remote
219
+ * Defines the 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
  */
@@ -178,9 +263,18 @@ export const Mcp = Tool.providerDefined({
178
263
  })
179
264
 
180
265
  /**
181
- * OpenAI Function Shell tool that enables the model to execute one or more shell
182
- * commands in a managed environment. This local tool runs in your environment
183
- * and requires a handler to execute commands.
266
+ * Defines the OpenAI shell tool for model-requested command execution.
267
+ *
268
+ * **When to use**
269
+ *
270
+ * Use to let an OpenAI model request shell commands that your application
271
+ * executes through a handler.
272
+ *
273
+ * **Details**
274
+ *
275
+ * The tool exposes a provider-defined `shell` call. It is marked as
276
+ * handler-required, so applications must provide the command execution policy
277
+ * and implementation.
184
278
  *
185
279
  * @category tools
186
280
  * @since 4.0.0
@@ -199,9 +293,20 @@ export const Shell = Tool.providerDefined({
199
293
  })
200
294
 
201
295
  /**
202
- * OpenAI Web Search tool that enables the model to search the web for
296
+ * Defines the OpenAI Web Search tool that enables the model to search the web for
203
297
  * information.
204
298
  *
299
+ * **When to use**
300
+ *
301
+ * Use to enable OpenAI provider-defined web search for a model response.
302
+ *
303
+ * **Details**
304
+ *
305
+ * The tool accepts optional filters, user location, and search context size.
306
+ * Successful calls expose the performed search action and status.
307
+ *
308
+ * @see {@link WebSearchPreview} for the preview web search provider tool
309
+ *
205
310
  * @category tools
206
311
  * @since 4.0.0
207
312
  */
@@ -224,8 +329,18 @@ export const WebSearch = Tool.providerDefined({
224
329
  })
225
330
 
226
331
  /**
227
- * OpenAI Web Search Preview tool, a preview version of the web search tool with
228
- * additional features.
332
+ * Defines the OpenAI preview Web Search tool for model responses.
333
+ *
334
+ * **When to use**
335
+ *
336
+ * Use to enable the preview OpenAI web search provider tool.
337
+ *
338
+ * **Details**
339
+ *
340
+ * The preview tool accepts optional user location and search context size, then
341
+ * exposes the performed search action and status in successful calls.
342
+ *
343
+ * @see {@link WebSearch} for the stable web search provider tool
229
344
  *
230
345
  * @category tools
231
346
  * @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 4.0.0
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"