@effect/ai-openai 4.0.0-beta.66 → 4.0.0-beta.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Generated.d.ts +1 -1
- package/dist/Generated.js +1 -1
- package/dist/OpenAiClient.d.ts +19 -12
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +11 -9
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiClientGenerated.d.ts +5 -5
- package/dist/OpenAiClientGenerated.js +5 -5
- package/dist/OpenAiConfig.d.ts +43 -8
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiConfig.js +28 -4
- package/dist/OpenAiConfig.js.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +13 -9
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +8 -6
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiError.d.ts +124 -3
- package/dist/OpenAiError.d.ts.map +1 -1
- package/dist/OpenAiError.js +1 -1
- package/dist/OpenAiLanguageModel.d.ts +208 -9
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +9 -7
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +143 -35
- package/dist/OpenAiSchema.d.ts.map +1 -1
- package/dist/OpenAiSchema.js +72 -18
- package/dist/OpenAiSchema.js.map +1 -1
- package/dist/OpenAiTelemetry.d.ts +17 -14
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +3 -3
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/OpenAiTool.d.ts +11 -11
- package/dist/OpenAiTool.js +10 -10
- package/dist/index.d.ts +27 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Generated.ts +1 -1
- package/src/OpenAiClient.ts +20 -13
- package/src/OpenAiClientGenerated.ts +6 -6
- package/src/OpenAiConfig.ts +43 -8
- package/src/OpenAiEmbeddingModel.ts +15 -11
- package/src/OpenAiError.ts +124 -3
- package/src/OpenAiLanguageModel.ts +211 -12
- package/src/OpenAiSchema.ts +144 -36
- package/src/OpenAiTelemetry.ts +18 -15
- package/src/OpenAiTool.ts +11 -11
- package/src/index.ts +27 -11
package/src/OpenAiSchema.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Minimal local OpenAI schemas used by the handwritten Responses client path.
|
|
3
3
|
*
|
|
4
|
-
* @since
|
|
4
|
+
* @since 4.0.0
|
|
5
5
|
*/
|
|
6
6
|
import * as Predicate from "effect/Predicate"
|
|
7
7
|
import * as Schema from "effect/Schema"
|
|
@@ -15,7 +15,13 @@ const MessageRole = Schema.Literals(["system", "developer", "user", "assistant"]
|
|
|
15
15
|
const ImageDetail = Schema.Literals(["low", "high", "auto"])
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Schema for optional `include` values on OpenAI Responses requests.
|
|
19
|
+
*
|
|
20
|
+
* **Details**
|
|
21
|
+
* These values request additional response fields such as image URLs, encrypted reasoning content, output logprobs, code interpreter outputs, or web search sources.
|
|
22
|
+
*
|
|
23
|
+
* @category schemas
|
|
24
|
+
* @since 4.0.0
|
|
19
25
|
*/
|
|
20
26
|
export const IncludeEnum = Schema.Literals([
|
|
21
27
|
"message.input_image.image_url",
|
|
@@ -26,17 +32,26 @@ export const IncludeEnum = Schema.Literals([
|
|
|
26
32
|
])
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
|
-
*
|
|
35
|
+
* Type of optional `include` values accepted by OpenAI Responses requests.
|
|
36
|
+
*
|
|
37
|
+
* @category models
|
|
38
|
+
* @since 4.0.0
|
|
30
39
|
*/
|
|
31
40
|
export type IncludeEnum = typeof IncludeEnum.Type
|
|
32
41
|
|
|
33
42
|
/**
|
|
34
|
-
*
|
|
43
|
+
* Schema for lifecycle statuses shared by messages, reasoning items, and tool calls.
|
|
44
|
+
*
|
|
45
|
+
* @category schemas
|
|
46
|
+
* @since 4.0.0
|
|
35
47
|
*/
|
|
36
48
|
export const MessageStatus = Schema.Literals(["in_progress", "completed", "incomplete"])
|
|
37
49
|
|
|
38
50
|
/**
|
|
39
|
-
*
|
|
51
|
+
* Lifecycle status shared by messages, reasoning items, and tool calls.
|
|
52
|
+
*
|
|
53
|
+
* @category models
|
|
54
|
+
* @since 4.0.0
|
|
40
55
|
*/
|
|
41
56
|
export type MessageStatus = typeof MessageStatus.Type
|
|
42
57
|
|
|
@@ -61,7 +76,10 @@ const InputFileContent = Schema.Struct({
|
|
|
61
76
|
})
|
|
62
77
|
|
|
63
78
|
/**
|
|
64
|
-
*
|
|
79
|
+
* Schema for content blocks accepted in OpenAI Responses input messages.
|
|
80
|
+
*
|
|
81
|
+
* @category schemas
|
|
82
|
+
* @since 4.0.0
|
|
65
83
|
*/
|
|
66
84
|
export const InputContent = Schema.Union([
|
|
67
85
|
InputTextContent,
|
|
@@ -70,12 +88,18 @@ export const InputContent = Schema.Union([
|
|
|
70
88
|
])
|
|
71
89
|
|
|
72
90
|
/**
|
|
73
|
-
*
|
|
91
|
+
* Content block accepted in OpenAI Responses input messages.
|
|
92
|
+
*
|
|
93
|
+
* @category models
|
|
94
|
+
* @since 4.0.0
|
|
74
95
|
*/
|
|
75
96
|
export type InputContent = typeof InputContent.Type
|
|
76
97
|
|
|
77
98
|
/**
|
|
78
|
-
*
|
|
99
|
+
* Schema for a text block containing a model-provided reasoning summary.
|
|
100
|
+
*
|
|
101
|
+
* @category schemas
|
|
102
|
+
* @since 4.0.0
|
|
79
103
|
*/
|
|
80
104
|
export const SummaryTextContent = Schema.Struct({
|
|
81
105
|
type: Schema.Literal("summary_text"),
|
|
@@ -83,7 +107,10 @@ export const SummaryTextContent = Schema.Struct({
|
|
|
83
107
|
})
|
|
84
108
|
|
|
85
109
|
/**
|
|
86
|
-
*
|
|
110
|
+
* Text content block used for model-provided reasoning summaries.
|
|
111
|
+
*
|
|
112
|
+
* @category models
|
|
113
|
+
* @since 4.0.0
|
|
87
114
|
*/
|
|
88
115
|
export type SummaryTextContent = typeof SummaryTextContent.Type
|
|
89
116
|
|
|
@@ -139,7 +166,10 @@ const FilePathAnnotation = Schema.Struct({
|
|
|
139
166
|
})
|
|
140
167
|
|
|
141
168
|
/**
|
|
142
|
-
*
|
|
169
|
+
* Schema for citation and file-path annotations attached to output text content.
|
|
170
|
+
*
|
|
171
|
+
* @category schemas
|
|
172
|
+
* @since 4.0.0
|
|
143
173
|
*/
|
|
144
174
|
export const Annotation = Schema.Union([
|
|
145
175
|
FileCitationAnnotation,
|
|
@@ -149,7 +179,10 @@ export const Annotation = Schema.Union([
|
|
|
149
179
|
])
|
|
150
180
|
|
|
151
181
|
/**
|
|
152
|
-
*
|
|
182
|
+
* Citation or file-path annotation attached to output text content.
|
|
183
|
+
*
|
|
184
|
+
* @category models
|
|
185
|
+
* @since 4.0.0
|
|
153
186
|
*/
|
|
154
187
|
export type Annotation = typeof Annotation.Type
|
|
155
188
|
|
|
@@ -181,7 +214,10 @@ const OutputMessage = Schema.Struct({
|
|
|
181
214
|
})
|
|
182
215
|
|
|
183
216
|
/**
|
|
184
|
-
*
|
|
217
|
+
* Schema for a reasoning output item containing encrypted content, summaries, and optional reasoning text.
|
|
218
|
+
*
|
|
219
|
+
* @category schemas
|
|
220
|
+
* @since 4.0.0
|
|
185
221
|
*/
|
|
186
222
|
export const ReasoningItem = Schema.Struct({
|
|
187
223
|
type: Schema.Literal("reasoning"),
|
|
@@ -193,7 +229,10 @@ export const ReasoningItem = Schema.Struct({
|
|
|
193
229
|
})
|
|
194
230
|
|
|
195
231
|
/**
|
|
196
|
-
*
|
|
232
|
+
* Reasoning output item containing encrypted content, summaries, and optional reasoning text.
|
|
233
|
+
*
|
|
234
|
+
* @category models
|
|
235
|
+
* @since 4.0.0
|
|
197
236
|
*/
|
|
198
237
|
export type ReasoningItem = typeof ReasoningItem.Type
|
|
199
238
|
|
|
@@ -279,7 +318,10 @@ const RequestMessageItem = Schema.Struct({
|
|
|
279
318
|
})
|
|
280
319
|
|
|
281
320
|
/**
|
|
282
|
-
*
|
|
321
|
+
* Schema for item shapes accepted by an OpenAI Responses request `input` field.
|
|
322
|
+
*
|
|
323
|
+
* @category schemas
|
|
324
|
+
* @since 4.0.0
|
|
283
325
|
*/
|
|
284
326
|
export const InputItem = Schema.Union([
|
|
285
327
|
RequestMessageItem,
|
|
@@ -297,7 +339,10 @@ export const InputItem = Schema.Union([
|
|
|
297
339
|
])
|
|
298
340
|
|
|
299
341
|
/**
|
|
300
|
-
*
|
|
342
|
+
* Item shape accepted by an OpenAI Responses request `input` field.
|
|
343
|
+
*
|
|
344
|
+
* @category models
|
|
345
|
+
* @since 4.0.0
|
|
301
346
|
*/
|
|
302
347
|
export type InputItem = typeof InputItem.Type
|
|
303
348
|
|
|
@@ -334,7 +379,10 @@ const ProviderDefinedTool = Schema.StructWithRest(
|
|
|
334
379
|
)
|
|
335
380
|
|
|
336
381
|
/**
|
|
337
|
-
*
|
|
382
|
+
* Schema for tool definitions that can be supplied to an OpenAI Responses request.
|
|
383
|
+
*
|
|
384
|
+
* @category schemas
|
|
385
|
+
* @since 4.0.0
|
|
338
386
|
*/
|
|
339
387
|
export const Tool = Schema.Union([
|
|
340
388
|
FunctionTool,
|
|
@@ -343,12 +391,18 @@ export const Tool = Schema.Union([
|
|
|
343
391
|
])
|
|
344
392
|
|
|
345
393
|
/**
|
|
346
|
-
*
|
|
394
|
+
* Tool definition that can be supplied to an OpenAI Responses request.
|
|
395
|
+
*
|
|
396
|
+
* @category models
|
|
397
|
+
* @since 4.0.0
|
|
347
398
|
*/
|
|
348
399
|
export type Tool = typeof Tool.Type
|
|
349
400
|
|
|
350
401
|
/**
|
|
351
|
-
*
|
|
402
|
+
* Schema for selecting whether and which tools the model may call in a Responses request.
|
|
403
|
+
*
|
|
404
|
+
* @category schemas
|
|
405
|
+
* @since 4.0.0
|
|
352
406
|
*/
|
|
353
407
|
export const ToolChoice = Schema.Union([
|
|
354
408
|
Schema.Literals(["none", "auto", "required"]),
|
|
@@ -384,12 +438,18 @@ export const ToolChoice = Schema.Union([
|
|
|
384
438
|
])
|
|
385
439
|
|
|
386
440
|
/**
|
|
387
|
-
*
|
|
441
|
+
* Tool selection mode or named tool choice for a Responses request.
|
|
442
|
+
*
|
|
443
|
+
* @category models
|
|
444
|
+
* @since 4.0.0
|
|
388
445
|
*/
|
|
389
446
|
export type ToolChoice = typeof ToolChoice.Type
|
|
390
447
|
|
|
391
448
|
/**
|
|
392
|
-
*
|
|
449
|
+
* Schema for text output format configuration, including plain text, JSON object, and JSON Schema responses.
|
|
450
|
+
*
|
|
451
|
+
* @category schemas
|
|
452
|
+
* @since 4.0.0
|
|
393
453
|
*/
|
|
394
454
|
export const TextResponseFormatConfiguration = Schema.Union([
|
|
395
455
|
Schema.Struct({ type: Schema.Literal("text") }),
|
|
@@ -404,12 +464,18 @@ export const TextResponseFormatConfiguration = Schema.Union([
|
|
|
404
464
|
])
|
|
405
465
|
|
|
406
466
|
/**
|
|
407
|
-
*
|
|
467
|
+
* Text output format configuration for plain text, JSON object, or JSON Schema responses.
|
|
468
|
+
*
|
|
469
|
+
* @category models
|
|
470
|
+
* @since 4.0.0
|
|
408
471
|
*/
|
|
409
472
|
export type TextResponseFormatConfiguration = typeof TextResponseFormatConfiguration.Type
|
|
410
473
|
|
|
411
474
|
/**
|
|
412
|
-
*
|
|
475
|
+
* Schema for request options used to create an OpenAI Responses API response.
|
|
476
|
+
*
|
|
477
|
+
* @category schemas
|
|
478
|
+
* @since 4.0.0
|
|
413
479
|
*/
|
|
414
480
|
export const CreateResponse = Schema.Struct({
|
|
415
481
|
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
@@ -454,12 +520,18 @@ export const CreateResponse = Schema.Struct({
|
|
|
454
520
|
})
|
|
455
521
|
|
|
456
522
|
/**
|
|
457
|
-
*
|
|
523
|
+
* Request options used to create an OpenAI Responses API response.
|
|
524
|
+
*
|
|
525
|
+
* @category models
|
|
526
|
+
* @since 4.0.0
|
|
458
527
|
*/
|
|
459
528
|
export type CreateResponse = typeof CreateResponse.Type
|
|
460
529
|
|
|
461
530
|
/**
|
|
462
|
-
*
|
|
531
|
+
* Schema for token accounting reported on OpenAI Responses API response objects.
|
|
532
|
+
*
|
|
533
|
+
* @category schemas
|
|
534
|
+
* @since 4.0.0
|
|
463
535
|
*/
|
|
464
536
|
export const ResponseUsage = Schema.StructWithRest(
|
|
465
537
|
Schema.Struct({
|
|
@@ -473,7 +545,10 @@ export const ResponseUsage = Schema.StructWithRest(
|
|
|
473
545
|
)
|
|
474
546
|
|
|
475
547
|
/**
|
|
476
|
-
*
|
|
548
|
+
* Token accounting reported on OpenAI Responses API response objects.
|
|
549
|
+
*
|
|
550
|
+
* @category models
|
|
551
|
+
* @since 4.0.0
|
|
477
552
|
*/
|
|
478
553
|
export type ResponseUsage = typeof ResponseUsage.Type
|
|
479
554
|
|
|
@@ -570,7 +645,10 @@ const OutputItem = Schema.Union([
|
|
|
570
645
|
])
|
|
571
646
|
|
|
572
647
|
/**
|
|
573
|
-
*
|
|
648
|
+
* Schema for an OpenAI Responses API response object.
|
|
649
|
+
*
|
|
650
|
+
* @category schemas
|
|
651
|
+
* @since 4.0.0
|
|
574
652
|
*/
|
|
575
653
|
export const Response = Schema.Struct({
|
|
576
654
|
id: Schema.String,
|
|
@@ -590,7 +668,10 @@ export const Response = Schema.Struct({
|
|
|
590
668
|
})
|
|
591
669
|
|
|
592
670
|
/**
|
|
593
|
-
*
|
|
671
|
+
* OpenAI Responses API response object.
|
|
672
|
+
*
|
|
673
|
+
* @category models
|
|
674
|
+
* @since 4.0.0
|
|
594
675
|
*/
|
|
595
676
|
export type Response = typeof Response.Type
|
|
596
677
|
|
|
@@ -767,7 +848,10 @@ const knownResponseStreamEventTypes = new Set([
|
|
|
767
848
|
])
|
|
768
849
|
|
|
769
850
|
/**
|
|
770
|
-
*
|
|
851
|
+
* Fallback event shape for future or provider-specific response stream events.
|
|
852
|
+
*
|
|
853
|
+
* @category models
|
|
854
|
+
* @since 4.0.0
|
|
771
855
|
*/
|
|
772
856
|
export type UnknownResponseStreamEvent = {
|
|
773
857
|
readonly type: string
|
|
@@ -786,7 +870,10 @@ const UnknownResponseStreamEvent = Schema.declare<UnknownResponseStreamEvent>(
|
|
|
786
870
|
)
|
|
787
871
|
|
|
788
872
|
/**
|
|
789
|
-
*
|
|
873
|
+
* Schema for server-sent event shapes emitted by OpenAI Responses API streams.
|
|
874
|
+
*
|
|
875
|
+
* @category schemas
|
|
876
|
+
* @since 4.0.0
|
|
790
877
|
*/
|
|
791
878
|
export const ResponseStreamEvent = Schema.Union([
|
|
792
879
|
ResponseCreatedEvent,
|
|
@@ -812,12 +899,18 @@ export const ResponseStreamEvent = Schema.Union([
|
|
|
812
899
|
])
|
|
813
900
|
|
|
814
901
|
/**
|
|
815
|
-
*
|
|
902
|
+
* Server-sent event shape emitted by OpenAI Responses API streams.
|
|
903
|
+
*
|
|
904
|
+
* @category models
|
|
905
|
+
* @since 4.0.0
|
|
816
906
|
*/
|
|
817
907
|
export type ResponseStreamEvent = typeof ResponseStreamEvent.Type
|
|
818
908
|
|
|
819
909
|
/**
|
|
820
|
-
*
|
|
910
|
+
* Schema for one embedding item returned by the OpenAI embeddings API.
|
|
911
|
+
*
|
|
912
|
+
* @category schemas
|
|
913
|
+
* @since 4.0.0
|
|
821
914
|
*/
|
|
822
915
|
export const Embedding = Schema.Struct({
|
|
823
916
|
embedding: Schema.Union([
|
|
@@ -829,12 +922,18 @@ export const Embedding = Schema.Struct({
|
|
|
829
922
|
})
|
|
830
923
|
|
|
831
924
|
/**
|
|
832
|
-
*
|
|
925
|
+
* One embedding item returned by the OpenAI embeddings API.
|
|
926
|
+
*
|
|
927
|
+
* @category models
|
|
928
|
+
* @since 4.0.0
|
|
833
929
|
*/
|
|
834
930
|
export type Embedding = typeof Embedding.Type
|
|
835
931
|
|
|
836
932
|
/**
|
|
837
|
-
*
|
|
933
|
+
* Schema for the request payload sent to the OpenAI embeddings endpoint.
|
|
934
|
+
*
|
|
935
|
+
* @category schemas
|
|
936
|
+
* @since 4.0.0
|
|
838
937
|
*/
|
|
839
938
|
export const CreateEmbeddingRequest = Schema.Struct({
|
|
840
939
|
input: Schema.Union([
|
|
@@ -850,12 +949,18 @@ export const CreateEmbeddingRequest = Schema.Struct({
|
|
|
850
949
|
})
|
|
851
950
|
|
|
852
951
|
/**
|
|
853
|
-
*
|
|
952
|
+
* Request payload sent to the OpenAI embeddings endpoint.
|
|
953
|
+
*
|
|
954
|
+
* @category models
|
|
955
|
+
* @since 4.0.0
|
|
854
956
|
*/
|
|
855
957
|
export type CreateEmbeddingRequest = typeof CreateEmbeddingRequest.Type
|
|
856
958
|
|
|
857
959
|
/**
|
|
858
|
-
*
|
|
960
|
+
* Schema for a successful response payload returned by the OpenAI embeddings endpoint.
|
|
961
|
+
*
|
|
962
|
+
* @category schemas
|
|
963
|
+
* @since 4.0.0
|
|
859
964
|
*/
|
|
860
965
|
export const CreateEmbeddingResponse = Schema.Struct({
|
|
861
966
|
data: Schema.Array(Embedding),
|
|
@@ -870,6 +975,9 @@ export const CreateEmbeddingResponse = Schema.Struct({
|
|
|
870
975
|
})
|
|
871
976
|
|
|
872
977
|
/**
|
|
873
|
-
*
|
|
978
|
+
* Successful response payload returned by the OpenAI embeddings endpoint.
|
|
979
|
+
*
|
|
980
|
+
* @category models
|
|
981
|
+
* @since 4.0.0
|
|
874
982
|
*/
|
|
875
983
|
export type CreateEmbeddingResponse = typeof CreateEmbeddingResponse.Type
|
package/src/OpenAiTelemetry.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* semantic conventions, extending the base GenAI attributes with OpenAI-specific
|
|
6
6
|
* request and response metadata.
|
|
7
7
|
*
|
|
8
|
-
* @since
|
|
8
|
+
* @since 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { dual } from "effect/Function"
|
|
11
11
|
import * as String from "effect/String"
|
|
@@ -19,8 +19,8 @@ import * as Telemetry from "effect/unstable/ai/Telemetry"
|
|
|
19
19
|
*
|
|
20
20
|
* {@see https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/}
|
|
21
21
|
*
|
|
22
|
-
* @since 1.0.0
|
|
23
22
|
* @category models
|
|
23
|
+
* @since 4.0.0
|
|
24
24
|
*/
|
|
25
25
|
export type OpenAiTelemetryAttributes = Simplify<
|
|
26
26
|
& Telemetry.GenAITelemetryAttributes
|
|
@@ -32,8 +32,8 @@ export type OpenAiTelemetryAttributes = Simplify<
|
|
|
32
32
|
* All telemetry attributes which are part of the GenAI specification,
|
|
33
33
|
* including the OpenAi-specific attributes.
|
|
34
34
|
*
|
|
35
|
-
* @since 1.0.0
|
|
36
35
|
* @category models
|
|
36
|
+
* @since 4.0.0
|
|
37
37
|
*/
|
|
38
38
|
export type AllAttributes = Telemetry.AllAttributes & RequestAttributes & ResponseAttributes
|
|
39
39
|
|
|
@@ -41,8 +41,8 @@ export type AllAttributes = Telemetry.AllAttributes & RequestAttributes & Respon
|
|
|
41
41
|
* Telemetry attributes which are part of the GenAI specification and are
|
|
42
42
|
* namespaced by `gen_ai.openai.request`.
|
|
43
43
|
*
|
|
44
|
-
* @since 1.0.0
|
|
45
44
|
* @category models
|
|
45
|
+
* @since 4.0.0
|
|
46
46
|
*/
|
|
47
47
|
export interface RequestAttributes {
|
|
48
48
|
/**
|
|
@@ -59,8 +59,8 @@ export interface RequestAttributes {
|
|
|
59
59
|
* Telemetry attributes which are part of the GenAI specification and are
|
|
60
60
|
* namespaced by `gen_ai.openai.response`.
|
|
61
61
|
*
|
|
62
|
-
* @since 1.0.0
|
|
63
62
|
* @category models
|
|
63
|
+
* @since 4.0.0
|
|
64
64
|
*/
|
|
65
65
|
export interface ResponseAttributes {
|
|
66
66
|
/**
|
|
@@ -81,8 +81,8 @@ export interface ResponseAttributes {
|
|
|
81
81
|
* If one of them applies, then the respective value **MUST** be used;
|
|
82
82
|
* otherwise, a custom value **MAY** be used.
|
|
83
83
|
*
|
|
84
|
-
* @since 1.0.0
|
|
85
84
|
* @category models
|
|
85
|
+
* @since 4.0.0
|
|
86
86
|
*/
|
|
87
87
|
export type WellKnownResponseFormat = "json_object" | "json_schema" | "text"
|
|
88
88
|
|
|
@@ -93,14 +93,17 @@ export type WellKnownResponseFormat = "json_object" | "json_schema" | "text"
|
|
|
93
93
|
* If one of them applies, then the respective value **MUST** be used;
|
|
94
94
|
* otherwise, a custom value **MAY** be used.
|
|
95
95
|
*
|
|
96
|
-
* @since 1.0.0
|
|
97
96
|
* @category models
|
|
97
|
+
* @since 4.0.0
|
|
98
98
|
*/
|
|
99
99
|
export type WellKnownServiceTier = "auto" | "default"
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
102
|
+
* Options accepted by `addGenAIAnnotations`, combining standard GenAI
|
|
103
|
+
* telemetry attributes with optional OpenAI request and response attributes.
|
|
104
|
+
*
|
|
105
|
+
* @category models
|
|
106
|
+
* @since 4.0.0
|
|
104
107
|
*/
|
|
105
108
|
export type OpenAiTelemetryAttributeOptions = Telemetry.GenAITelemetryAttributeOptions & {
|
|
106
109
|
openai?: {
|
|
@@ -122,8 +125,8 @@ const addOpenAiResponseAttributes = Telemetry.addSpanAttributes("gen_ai.openai.r
|
|
|
122
125
|
*
|
|
123
126
|
* **NOTE**: This method will mutate the `Span` **in-place**.
|
|
124
127
|
*
|
|
125
|
-
* @
|
|
126
|
-
* @since
|
|
128
|
+
* @category tracing
|
|
129
|
+
* @since 4.0.0
|
|
127
130
|
*/
|
|
128
131
|
export const addGenAIAnnotations: {
|
|
129
132
|
/**
|
|
@@ -132,8 +135,8 @@ export const addGenAIAnnotations: {
|
|
|
132
135
|
*
|
|
133
136
|
* **NOTE**: This method will mutate the `Span` **in-place**.
|
|
134
137
|
*
|
|
135
|
-
* @
|
|
136
|
-
* @since
|
|
138
|
+
* @category tracing
|
|
139
|
+
* @since 4.0.0
|
|
137
140
|
*/
|
|
138
141
|
(options: OpenAiTelemetryAttributeOptions): (span: Span) => void
|
|
139
142
|
/**
|
|
@@ -142,8 +145,8 @@ export const addGenAIAnnotations: {
|
|
|
142
145
|
*
|
|
143
146
|
* **NOTE**: This method will mutate the `Span` **in-place**.
|
|
144
147
|
*
|
|
145
|
-
* @
|
|
146
|
-
* @since
|
|
148
|
+
* @category tracing
|
|
149
|
+
* @since 4.0.0
|
|
147
150
|
*/
|
|
148
151
|
(span: Span, options: OpenAiTelemetryAttributeOptions): void
|
|
149
152
|
} = dual(2, (span: Span, options: OpenAiTelemetryAttributeOptions) => {
|
package/src/OpenAiTool.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides tools that are natively supported by OpenAI's API, including
|
|
5
5
|
* code interpreter, file search, and web search functionality.
|
|
6
6
|
*
|
|
7
|
-
* @since
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
import * as Schema from "effect/Schema"
|
|
10
10
|
import * as Tool from "effect/unstable/ai/Tool"
|
|
@@ -13,8 +13,8 @@ import * as Generated from "./Generated.ts"
|
|
|
13
13
|
/**
|
|
14
14
|
* Union of all OpenAI provider-defined tools.
|
|
15
15
|
*
|
|
16
|
-
* @since 1.0.0
|
|
17
16
|
* @category models
|
|
17
|
+
* @since 4.0.0
|
|
18
18
|
*/
|
|
19
19
|
export type OpenAiTool =
|
|
20
20
|
| ReturnType<typeof ApplyPatch>
|
|
@@ -34,8 +34,8 @@ export type OpenAiTool =
|
|
|
34
34
|
* This is a local tool that runs in your environment and requires a handler
|
|
35
35
|
* to execute file operations.
|
|
36
36
|
*
|
|
37
|
-
* @since 1.0.0
|
|
38
37
|
* @category tools
|
|
38
|
+
* @since 4.0.0
|
|
39
39
|
*/
|
|
40
40
|
export const ApplyPatch = Tool.providerDefined({
|
|
41
41
|
id: "openai.apply_patch",
|
|
@@ -57,8 +57,8 @@ export const ApplyPatch = Tool.providerDefined({
|
|
|
57
57
|
*
|
|
58
58
|
* Allows the model to execute Python code in a sandboxed environment.
|
|
59
59
|
*
|
|
60
|
-
* @since 1.0.0
|
|
61
60
|
* @category tools
|
|
61
|
+
* @since 4.0.0
|
|
62
62
|
*/
|
|
63
63
|
export const CodeInterpreter = Tool.providerDefined({
|
|
64
64
|
id: "openai.code_interpreter",
|
|
@@ -81,8 +81,8 @@ export const CodeInterpreter = Tool.providerDefined({
|
|
|
81
81
|
*
|
|
82
82
|
* Enables the model to search through uploaded files and vector stores.
|
|
83
83
|
*
|
|
84
|
-
* @since 1.0.0
|
|
85
84
|
* @category tools
|
|
85
|
+
* @since 4.0.0
|
|
86
86
|
*/
|
|
87
87
|
export const FileSearch = Tool.providerDefined({
|
|
88
88
|
id: "openai.file_search",
|
|
@@ -106,8 +106,8 @@ export const FileSearch = Tool.providerDefined({
|
|
|
106
106
|
*
|
|
107
107
|
* Enables the model to generate images using the GPT image models.
|
|
108
108
|
*
|
|
109
|
-
* @since 1.0.0
|
|
110
109
|
* @category tools
|
|
110
|
+
* @since 4.0.0
|
|
111
111
|
*/
|
|
112
112
|
export const ImageGeneration = Tool.providerDefined({
|
|
113
113
|
id: "openai.image_generation",
|
|
@@ -136,8 +136,8 @@ export const ImageGeneration = Tool.providerDefined({
|
|
|
136
136
|
* Enables the model to run a command with a local shell. This is a local tool
|
|
137
137
|
* that runs in your environment and requires a handler to execute commands.
|
|
138
138
|
*
|
|
139
|
-
* @since 1.0.0
|
|
140
139
|
* @category tools
|
|
140
|
+
* @since 4.0.0
|
|
141
141
|
*/
|
|
142
142
|
export const LocalShell = Tool.providerDefined({
|
|
143
143
|
id: "openai.local_shell",
|
|
@@ -158,8 +158,8 @@ export const LocalShell = Tool.providerDefined({
|
|
|
158
158
|
* Gives the model access to additional tools via remote Model Context Protocol
|
|
159
159
|
* (MCP) servers
|
|
160
160
|
*
|
|
161
|
-
* @since 1.0.0
|
|
162
161
|
* @category tools
|
|
162
|
+
* @since 4.0.0
|
|
163
163
|
*/
|
|
164
164
|
export const Mcp = Tool.providerDefined({
|
|
165
165
|
id: "openai.mcp",
|
|
@@ -192,8 +192,8 @@ export const Mcp = Tool.providerDefined({
|
|
|
192
192
|
* environment. This is a local tool that runs in your environment and requires
|
|
193
193
|
* a handler to execute commands.
|
|
194
194
|
*
|
|
195
|
-
* @since 1.0.0
|
|
196
195
|
* @category tools
|
|
196
|
+
* @since 4.0.0
|
|
197
197
|
*/
|
|
198
198
|
export const Shell = Tool.providerDefined({
|
|
199
199
|
id: "openai.shell",
|
|
@@ -213,8 +213,8 @@ export const Shell = Tool.providerDefined({
|
|
|
213
213
|
*
|
|
214
214
|
* Enables the model to search the web for information.
|
|
215
215
|
*
|
|
216
|
-
* @since 1.0.0
|
|
217
216
|
* @category tools
|
|
217
|
+
* @since 4.0.0
|
|
218
218
|
*/
|
|
219
219
|
export const WebSearch = Tool.providerDefined({
|
|
220
220
|
id: "openai.web_search",
|
|
@@ -239,8 +239,8 @@ export const WebSearch = Tool.providerDefined({
|
|
|
239
239
|
*
|
|
240
240
|
* Preview version of the web search tool with additional features.
|
|
241
241
|
*
|
|
242
|
-
* @since 1.0.0
|
|
243
242
|
* @category tools
|
|
243
|
+
* @since 4.0.0
|
|
244
244
|
*/
|
|
245
245
|
export const WebSearchPreview = Tool.providerDefined({
|
|
246
246
|
id: "openai.web_search_preview",
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @since
|
|
8
|
+
* @since 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
export * as Generated from "./Generated.ts"
|
|
11
11
|
|
|
@@ -15,17 +15,33 @@ export * as Generated from "./Generated.ts"
|
|
|
15
15
|
* Provides a type-safe, Effect-based client for OpenAI operations including
|
|
16
16
|
* completions, embeddings, and streaming responses.
|
|
17
17
|
*
|
|
18
|
-
* @since
|
|
18
|
+
* @since 4.0.0
|
|
19
19
|
*/
|
|
20
20
|
export * as OpenAiClient from "./OpenAiClient.ts"
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @since
|
|
23
|
+
* @since 4.0.0
|
|
24
24
|
*/
|
|
25
25
|
export * as OpenAiClientGenerated from "./OpenAiClientGenerated.ts"
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
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
|
+
* @since 4.0.0
|
|
29
45
|
*/
|
|
30
46
|
export * as OpenAiConfig from "./OpenAiConfig.ts"
|
|
31
47
|
|
|
@@ -34,7 +50,7 @@ export * as OpenAiConfig from "./OpenAiConfig.ts"
|
|
|
34
50
|
*
|
|
35
51
|
* Provides an EmbeddingModel implementation for OpenAI's embeddings API.
|
|
36
52
|
*
|
|
37
|
-
* @since
|
|
53
|
+
* @since 4.0.0
|
|
38
54
|
*/
|
|
39
55
|
export * as OpenAiEmbeddingModel from "./OpenAiEmbeddingModel.ts"
|
|
40
56
|
|
|
@@ -44,7 +60,7 @@ export * as OpenAiEmbeddingModel from "./OpenAiEmbeddingModel.ts"
|
|
|
44
60
|
* Provides OpenAI-specific metadata fields for AI error types through module
|
|
45
61
|
* augmentation, enabling typed access to OpenAI error details.
|
|
46
62
|
*
|
|
47
|
-
* @since
|
|
63
|
+
* @since 4.0.0
|
|
48
64
|
*/
|
|
49
65
|
export * as OpenAiError from "./OpenAiError.ts"
|
|
50
66
|
|
|
@@ -54,14 +70,14 @@ export * as OpenAiError from "./OpenAiError.ts"
|
|
|
54
70
|
* Provides a LanguageModel implementation for OpenAI's responses API,
|
|
55
71
|
* supporting text generation, structured output, tool calling, and streaming.
|
|
56
72
|
*
|
|
57
|
-
* @since
|
|
73
|
+
* @since 4.0.0
|
|
58
74
|
*/
|
|
59
75
|
export * as OpenAiLanguageModel from "./OpenAiLanguageModel.ts"
|
|
60
76
|
|
|
61
77
|
/**
|
|
62
78
|
* Minimal local OpenAI schemas used by the handwritten Responses client path.
|
|
63
79
|
*
|
|
64
|
-
* @since
|
|
80
|
+
* @since 4.0.0
|
|
65
81
|
*/
|
|
66
82
|
export * as OpenAiSchema from "./OpenAiSchema.ts"
|
|
67
83
|
|
|
@@ -72,7 +88,7 @@ export * as OpenAiSchema from "./OpenAiSchema.ts"
|
|
|
72
88
|
* semantic conventions, extending the base GenAI attributes with OpenAI-specific
|
|
73
89
|
* request and response metadata.
|
|
74
90
|
*
|
|
75
|
-
* @since
|
|
91
|
+
* @since 4.0.0
|
|
76
92
|
*/
|
|
77
93
|
export * as OpenAiTelemetry from "./OpenAiTelemetry.ts"
|
|
78
94
|
|
|
@@ -82,6 +98,6 @@ export * as OpenAiTelemetry from "./OpenAiTelemetry.ts"
|
|
|
82
98
|
* Provides tools that are natively supported by OpenAI's API, including
|
|
83
99
|
* code interpreter, file search, and web search functionality.
|
|
84
100
|
*
|
|
85
|
-
* @since
|
|
101
|
+
* @since 4.0.0
|
|
86
102
|
*/
|
|
87
103
|
export * as OpenAiTool from "./OpenAiTool.ts"
|