@effect/ai-openai 4.0.0-beta.51 → 4.0.0-beta.53
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 +9 -9
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +27 -32
- 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/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +3 -0
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiLanguageModel.d.ts +28 -47
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +56 -76
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +1925 -0
- package/dist/OpenAiSchema.d.ts.map +1 -0
- package/dist/OpenAiSchema.js +537 -0
- package/dist/OpenAiSchema.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/OpenAiClient.ts +90 -59
- package/src/OpenAiClientGenerated.ts +202 -0
- package/src/OpenAiEmbeddingModel.ts +6 -3
- package/src/OpenAiLanguageModel.ts +148 -63
- package/src/OpenAiSchema.ts +878 -0
- package/src/index.ts +12 -0
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal local OpenAI schemas used by the handwritten Responses client path.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Predicate from "effect/Predicate"
|
|
7
|
+
import * as Schema from "effect/Schema"
|
|
8
|
+
|
|
9
|
+
const UnknownRecord = Schema.Record(Schema.String, Schema.Unknown)
|
|
10
|
+
|
|
11
|
+
const JsonObject = Schema.Record(Schema.String, Schema.Unknown)
|
|
12
|
+
|
|
13
|
+
const MessageRole = Schema.Literals(["system", "developer", "user", "assistant"])
|
|
14
|
+
|
|
15
|
+
const ImageDetail = Schema.Literals(["low", "high", "auto"])
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
export const IncludeEnum = Schema.Literals([
|
|
21
|
+
"message.input_image.image_url",
|
|
22
|
+
"reasoning.encrypted_content",
|
|
23
|
+
"message.output_text.logprobs",
|
|
24
|
+
"code_interpreter_call.outputs",
|
|
25
|
+
"web_search_call.action.sources"
|
|
26
|
+
])
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
*/
|
|
31
|
+
export type IncludeEnum = typeof IncludeEnum.Type
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
export const MessageStatus = Schema.Literals(["in_progress", "completed", "incomplete"])
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @since 1.0.0
|
|
40
|
+
*/
|
|
41
|
+
export type MessageStatus = typeof MessageStatus.Type
|
|
42
|
+
|
|
43
|
+
const InputTextContent = Schema.Struct({
|
|
44
|
+
type: Schema.Literal("input_text"),
|
|
45
|
+
text: Schema.String
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const InputImageContent = Schema.Struct({
|
|
49
|
+
type: Schema.Literal("input_image"),
|
|
50
|
+
image_url: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
51
|
+
file_id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
52
|
+
detail: Schema.optionalKey(Schema.NullOr(ImageDetail))
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const InputFileContent = Schema.Struct({
|
|
56
|
+
type: Schema.Literal("input_file"),
|
|
57
|
+
file_id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
58
|
+
filename: Schema.optionalKey(Schema.String),
|
|
59
|
+
file_url: Schema.optionalKey(Schema.String),
|
|
60
|
+
file_data: Schema.optionalKey(Schema.String)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @since 1.0.0
|
|
65
|
+
*/
|
|
66
|
+
export const InputContent = Schema.Union([
|
|
67
|
+
InputTextContent,
|
|
68
|
+
InputImageContent,
|
|
69
|
+
InputFileContent
|
|
70
|
+
])
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @since 1.0.0
|
|
74
|
+
*/
|
|
75
|
+
export type InputContent = typeof InputContent.Type
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @since 1.0.0
|
|
79
|
+
*/
|
|
80
|
+
export const SummaryTextContent = Schema.Struct({
|
|
81
|
+
type: Schema.Literal("summary_text"),
|
|
82
|
+
text: Schema.String
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @since 1.0.0
|
|
87
|
+
*/
|
|
88
|
+
export type SummaryTextContent = typeof SummaryTextContent.Type
|
|
89
|
+
|
|
90
|
+
const ReasoningTextContent = Schema.Struct({
|
|
91
|
+
type: Schema.Literal("reasoning_text"),
|
|
92
|
+
text: Schema.String
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const RefusalContent = Schema.Struct({
|
|
96
|
+
type: Schema.Literal("refusal"),
|
|
97
|
+
refusal: Schema.String
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const TextContent = Schema.Struct({
|
|
101
|
+
type: Schema.Literal("text"),
|
|
102
|
+
text: Schema.String
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const ComputerScreenshotContent = Schema.Struct({
|
|
106
|
+
type: Schema.Literal("computer_screenshot"),
|
|
107
|
+
image_url: Schema.NullOr(Schema.String),
|
|
108
|
+
file_id: Schema.NullOr(Schema.String)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const FileCitationAnnotation = Schema.Struct({
|
|
112
|
+
type: Schema.Literal("file_citation"),
|
|
113
|
+
file_id: Schema.String,
|
|
114
|
+
index: Schema.Number,
|
|
115
|
+
filename: Schema.String
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const UrlCitationAnnotation = Schema.Struct({
|
|
119
|
+
type: Schema.Literal("url_citation"),
|
|
120
|
+
url: Schema.String,
|
|
121
|
+
start_index: Schema.Number,
|
|
122
|
+
end_index: Schema.Number,
|
|
123
|
+
title: Schema.String
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const ContainerFileCitationAnnotation = Schema.Struct({
|
|
127
|
+
type: Schema.Literal("container_file_citation"),
|
|
128
|
+
container_id: Schema.String,
|
|
129
|
+
file_id: Schema.String,
|
|
130
|
+
start_index: Schema.Number,
|
|
131
|
+
end_index: Schema.Number,
|
|
132
|
+
filename: Schema.String
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const FilePathAnnotation = Schema.Struct({
|
|
136
|
+
type: Schema.Literal("file_path"),
|
|
137
|
+
file_id: Schema.String,
|
|
138
|
+
index: Schema.Number
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @since 1.0.0
|
|
143
|
+
*/
|
|
144
|
+
export const Annotation = Schema.Union([
|
|
145
|
+
FileCitationAnnotation,
|
|
146
|
+
UrlCitationAnnotation,
|
|
147
|
+
ContainerFileCitationAnnotation,
|
|
148
|
+
FilePathAnnotation
|
|
149
|
+
])
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @since 1.0.0
|
|
153
|
+
*/
|
|
154
|
+
export type Annotation = typeof Annotation.Type
|
|
155
|
+
|
|
156
|
+
const OutputTextContent = Schema.Struct({
|
|
157
|
+
type: Schema.Literal("output_text"),
|
|
158
|
+
text: Schema.String,
|
|
159
|
+
annotations: Schema.Array(Annotation),
|
|
160
|
+
logprobs: Schema.optionalKey(Schema.Array(Schema.Unknown))
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
const OutputMessageContent = Schema.Union([
|
|
164
|
+
InputTextContent,
|
|
165
|
+
OutputTextContent,
|
|
166
|
+
TextContent,
|
|
167
|
+
SummaryTextContent,
|
|
168
|
+
ReasoningTextContent,
|
|
169
|
+
RefusalContent,
|
|
170
|
+
InputImageContent,
|
|
171
|
+
ComputerScreenshotContent,
|
|
172
|
+
InputFileContent
|
|
173
|
+
])
|
|
174
|
+
|
|
175
|
+
const OutputMessage = Schema.Struct({
|
|
176
|
+
id: Schema.String,
|
|
177
|
+
type: Schema.Literal("message"),
|
|
178
|
+
role: Schema.Literal("assistant"),
|
|
179
|
+
content: Schema.Array(OutputMessageContent),
|
|
180
|
+
status: MessageStatus
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @since 1.0.0
|
|
185
|
+
*/
|
|
186
|
+
export const ReasoningItem = Schema.Struct({
|
|
187
|
+
type: Schema.Literal("reasoning"),
|
|
188
|
+
id: Schema.String,
|
|
189
|
+
encrypted_content: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
190
|
+
summary: Schema.Array(SummaryTextContent),
|
|
191
|
+
content: Schema.optionalKey(Schema.Array(ReasoningTextContent)),
|
|
192
|
+
status: Schema.optionalKey(MessageStatus)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @since 1.0.0
|
|
197
|
+
*/
|
|
198
|
+
export type ReasoningItem = typeof ReasoningItem.Type
|
|
199
|
+
|
|
200
|
+
const FunctionCall = Schema.Struct({
|
|
201
|
+
id: Schema.optionalKey(Schema.String),
|
|
202
|
+
type: Schema.Literal("function_call"),
|
|
203
|
+
call_id: Schema.String,
|
|
204
|
+
name: Schema.String,
|
|
205
|
+
arguments: Schema.String,
|
|
206
|
+
status: Schema.optionalKey(MessageStatus)
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
const FunctionCallOutput = Schema.Struct({
|
|
210
|
+
id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
211
|
+
type: Schema.Literal("function_call_output"),
|
|
212
|
+
call_id: Schema.String,
|
|
213
|
+
output: Schema.Union([
|
|
214
|
+
Schema.String,
|
|
215
|
+
Schema.Array(InputContent)
|
|
216
|
+
]),
|
|
217
|
+
status: Schema.optionalKey(Schema.NullOr(MessageStatus))
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
const ItemReference = Schema.Struct({
|
|
221
|
+
type: Schema.Literal("item_reference"),
|
|
222
|
+
id: Schema.String
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
const LocalShellCall = Schema.Struct({
|
|
226
|
+
id: Schema.optionalKey(Schema.String),
|
|
227
|
+
type: Schema.Literal("local_shell_call"),
|
|
228
|
+
call_id: Schema.String,
|
|
229
|
+
action: Schema.Unknown,
|
|
230
|
+
status: Schema.optionalKey(MessageStatus)
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
const LocalShellCallOutput = Schema.Struct({
|
|
234
|
+
id: Schema.optionalKey(Schema.String),
|
|
235
|
+
type: Schema.Literal("local_shell_call_output"),
|
|
236
|
+
call_id: Schema.String,
|
|
237
|
+
output: Schema.Unknown,
|
|
238
|
+
status: Schema.optionalKey(MessageStatus)
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
const ShellCall = Schema.Struct({
|
|
242
|
+
id: Schema.optionalKey(Schema.String),
|
|
243
|
+
type: Schema.Literal("shell_call"),
|
|
244
|
+
call_id: Schema.String,
|
|
245
|
+
action: Schema.Unknown,
|
|
246
|
+
status: Schema.optionalKey(MessageStatus)
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
const ShellCallOutput = Schema.Struct({
|
|
250
|
+
id: Schema.optionalKey(Schema.String),
|
|
251
|
+
type: Schema.Literal("shell_call_output"),
|
|
252
|
+
call_id: Schema.String,
|
|
253
|
+
output: Schema.Unknown,
|
|
254
|
+
status: Schema.optionalKey(MessageStatus)
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
const ApplyPatchCallOutput = Schema.Struct({
|
|
258
|
+
id: Schema.optionalKey(Schema.String),
|
|
259
|
+
type: Schema.Literal("apply_patch_call_output"),
|
|
260
|
+
call_id: Schema.String,
|
|
261
|
+
status: Schema.optionalKey(MessageStatus),
|
|
262
|
+
output: Schema.optionalKey(Schema.Unknown)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
const McpApprovalResponse = Schema.Struct({
|
|
266
|
+
type: Schema.Literal("mcp_approval_response"),
|
|
267
|
+
approval_request_id: Schema.String,
|
|
268
|
+
approve: Schema.Boolean
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
const RequestMessageItem = Schema.Struct({
|
|
272
|
+
type: Schema.optionalKey(Schema.Literal("message")),
|
|
273
|
+
role: MessageRole,
|
|
274
|
+
status: Schema.optionalKey(MessageStatus),
|
|
275
|
+
content: Schema.Union([
|
|
276
|
+
Schema.String,
|
|
277
|
+
Schema.Array(InputContent)
|
|
278
|
+
])
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @since 1.0.0
|
|
283
|
+
*/
|
|
284
|
+
export const InputItem = Schema.Union([
|
|
285
|
+
RequestMessageItem,
|
|
286
|
+
OutputMessage,
|
|
287
|
+
FunctionCall,
|
|
288
|
+
FunctionCallOutput,
|
|
289
|
+
ReasoningItem,
|
|
290
|
+
ItemReference,
|
|
291
|
+
LocalShellCall,
|
|
292
|
+
LocalShellCallOutput,
|
|
293
|
+
ShellCall,
|
|
294
|
+
ShellCallOutput,
|
|
295
|
+
ApplyPatchCallOutput,
|
|
296
|
+
McpApprovalResponse
|
|
297
|
+
])
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @since 1.0.0
|
|
301
|
+
*/
|
|
302
|
+
export type InputItem = typeof InputItem.Type
|
|
303
|
+
|
|
304
|
+
const FunctionTool = Schema.Struct({
|
|
305
|
+
type: Schema.Literal("function"),
|
|
306
|
+
name: Schema.String,
|
|
307
|
+
description: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
308
|
+
parameters: Schema.optionalKey(Schema.NullOr(JsonObject)),
|
|
309
|
+
strict: Schema.optionalKey(Schema.NullOr(Schema.Boolean))
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
const CustomTool = Schema.Struct({
|
|
313
|
+
type: Schema.Literal("custom"),
|
|
314
|
+
name: Schema.String,
|
|
315
|
+
description: Schema.optionalKey(Schema.String),
|
|
316
|
+
format: Schema.optionalKey(Schema.Unknown)
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
const ProviderDefinedTool = Schema.StructWithRest(
|
|
320
|
+
Schema.Struct({
|
|
321
|
+
type: Schema.Literals([
|
|
322
|
+
"apply_patch",
|
|
323
|
+
"code_interpreter",
|
|
324
|
+
"file_search",
|
|
325
|
+
"image_generation",
|
|
326
|
+
"local_shell",
|
|
327
|
+
"mcp",
|
|
328
|
+
"shell",
|
|
329
|
+
"web_search",
|
|
330
|
+
"web_search_preview"
|
|
331
|
+
])
|
|
332
|
+
}),
|
|
333
|
+
[UnknownRecord]
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @since 1.0.0
|
|
338
|
+
*/
|
|
339
|
+
export const Tool = Schema.Union([
|
|
340
|
+
FunctionTool,
|
|
341
|
+
CustomTool,
|
|
342
|
+
ProviderDefinedTool
|
|
343
|
+
])
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* @since 1.0.0
|
|
347
|
+
*/
|
|
348
|
+
export type Tool = typeof Tool.Type
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* @since 1.0.0
|
|
352
|
+
*/
|
|
353
|
+
export const ToolChoice = Schema.Union([
|
|
354
|
+
Schema.Literals(["none", "auto", "required"]),
|
|
355
|
+
Schema.Struct({
|
|
356
|
+
type: Schema.Literal("allowed_tools"),
|
|
357
|
+
mode: Schema.Literals(["auto", "required"]),
|
|
358
|
+
tools: Schema.Array(JsonObject)
|
|
359
|
+
}),
|
|
360
|
+
Schema.Struct({
|
|
361
|
+
type: Schema.Literal("function"),
|
|
362
|
+
name: Schema.String
|
|
363
|
+
}),
|
|
364
|
+
Schema.Struct({
|
|
365
|
+
type: Schema.Literal("custom"),
|
|
366
|
+
name: Schema.String
|
|
367
|
+
}),
|
|
368
|
+
Schema.StructWithRest(
|
|
369
|
+
Schema.Struct({
|
|
370
|
+
type: Schema.Literals([
|
|
371
|
+
"apply_patch",
|
|
372
|
+
"code_interpreter",
|
|
373
|
+
"file_search",
|
|
374
|
+
"image_generation",
|
|
375
|
+
"local_shell",
|
|
376
|
+
"mcp",
|
|
377
|
+
"shell",
|
|
378
|
+
"web_search",
|
|
379
|
+
"web_search_preview"
|
|
380
|
+
])
|
|
381
|
+
}),
|
|
382
|
+
[UnknownRecord]
|
|
383
|
+
)
|
|
384
|
+
])
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @since 1.0.0
|
|
388
|
+
*/
|
|
389
|
+
export type ToolChoice = typeof ToolChoice.Type
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* @since 1.0.0
|
|
393
|
+
*/
|
|
394
|
+
export const TextResponseFormatConfiguration = Schema.Union([
|
|
395
|
+
Schema.Struct({ type: Schema.Literal("text") }),
|
|
396
|
+
Schema.Struct({
|
|
397
|
+
type: Schema.Literal("json_schema"),
|
|
398
|
+
description: Schema.optionalKey(Schema.String),
|
|
399
|
+
name: Schema.String,
|
|
400
|
+
schema: JsonObject,
|
|
401
|
+
strict: Schema.optionalKey(Schema.NullOr(Schema.Boolean))
|
|
402
|
+
}),
|
|
403
|
+
Schema.Struct({ type: Schema.Literal("json_object") })
|
|
404
|
+
])
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @since 1.0.0
|
|
408
|
+
*/
|
|
409
|
+
export type TextResponseFormatConfiguration = typeof TextResponseFormatConfiguration.Type
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @since 1.0.0
|
|
413
|
+
*/
|
|
414
|
+
export const CreateResponse = Schema.Struct({
|
|
415
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
416
|
+
top_logprobs: Schema.optional(Schema.Number),
|
|
417
|
+
temperature: Schema.optional(Schema.Number),
|
|
418
|
+
top_p: Schema.optional(Schema.Number),
|
|
419
|
+
user: Schema.optional(Schema.String),
|
|
420
|
+
service_tier: Schema.optional(Schema.String),
|
|
421
|
+
previous_response_id: Schema.optional(Schema.String),
|
|
422
|
+
model: Schema.optional(Schema.String),
|
|
423
|
+
reasoning: Schema.optional(Schema.Struct({
|
|
424
|
+
effort: Schema.optional(Schema.Literals(["none", "minimal", "low", "medium", "high", "xhigh"])),
|
|
425
|
+
|
|
426
|
+
summary: Schema.optional(Schema.Literals(["auto", "concise", "detailed"])),
|
|
427
|
+
generate_summary: Schema.optional(Schema.Literals(["auto", "concise", "detailed"]))
|
|
428
|
+
})),
|
|
429
|
+
background: Schema.optional(Schema.Boolean),
|
|
430
|
+
max_output_tokens: Schema.optional(Schema.Number),
|
|
431
|
+
max_tool_calls: Schema.optional(Schema.Number),
|
|
432
|
+
text: Schema.optional(
|
|
433
|
+
Schema.Struct({
|
|
434
|
+
format: Schema.optional(TextResponseFormatConfiguration),
|
|
435
|
+
verbosity: Schema.optional(Schema.Literals(["low", "medium", "high"]))
|
|
436
|
+
})
|
|
437
|
+
),
|
|
438
|
+
tools: Schema.optional(Schema.Array(Tool)),
|
|
439
|
+
tool_choice: Schema.optional(ToolChoice),
|
|
440
|
+
truncation: Schema.optional(Schema.Literals(["auto", "disabled"])),
|
|
441
|
+
input: Schema.optional(
|
|
442
|
+
Schema.Union([
|
|
443
|
+
Schema.String,
|
|
444
|
+
Schema.Array(InputItem)
|
|
445
|
+
])
|
|
446
|
+
),
|
|
447
|
+
include: Schema.optional(Schema.Array(IncludeEnum)),
|
|
448
|
+
store: Schema.optional(Schema.Boolean),
|
|
449
|
+
instructions: Schema.optional(Schema.String),
|
|
450
|
+
stream: Schema.optional(Schema.Boolean),
|
|
451
|
+
conversation: Schema.optional(Schema.String),
|
|
452
|
+
modalities: Schema.optional(Schema.Array(Schema.Literals(["text", "audio"]))),
|
|
453
|
+
seed: Schema.optional(Schema.Number)
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @since 1.0.0
|
|
458
|
+
*/
|
|
459
|
+
export type CreateResponse = typeof CreateResponse.Type
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @since 1.0.0
|
|
463
|
+
*/
|
|
464
|
+
export const ResponseUsage = Schema.StructWithRest(
|
|
465
|
+
Schema.Struct({
|
|
466
|
+
input_tokens: Schema.Number,
|
|
467
|
+
output_tokens: Schema.Number,
|
|
468
|
+
total_tokens: Schema.Number,
|
|
469
|
+
input_tokens_details: Schema.optionalKey(Schema.Unknown),
|
|
470
|
+
output_tokens_details: Schema.optionalKey(Schema.Unknown)
|
|
471
|
+
}),
|
|
472
|
+
[UnknownRecord]
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* @since 1.0.0
|
|
477
|
+
*/
|
|
478
|
+
export type ResponseUsage = typeof ResponseUsage.Type
|
|
479
|
+
|
|
480
|
+
const ApplyPatchOperation = Schema.Struct({
|
|
481
|
+
type: Schema.String,
|
|
482
|
+
path: Schema.String,
|
|
483
|
+
diff: Schema.optionalKey(Schema.String)
|
|
484
|
+
})
|
|
485
|
+
|
|
486
|
+
const ApplyPatchCall = Schema.Struct({
|
|
487
|
+
id: Schema.String,
|
|
488
|
+
type: Schema.Literal("apply_patch_call"),
|
|
489
|
+
call_id: Schema.String,
|
|
490
|
+
operation: ApplyPatchOperation,
|
|
491
|
+
status: Schema.optionalKey(MessageStatus)
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
const CodeInterpreterCall = Schema.Struct({
|
|
495
|
+
id: Schema.String,
|
|
496
|
+
type: Schema.Literal("code_interpreter_call"),
|
|
497
|
+
code: Schema.optionalKey(Schema.String),
|
|
498
|
+
container_id: Schema.String,
|
|
499
|
+
outputs: Schema.optionalKey(Schema.Array(Schema.Unknown)),
|
|
500
|
+
status: Schema.optionalKey(MessageStatus)
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
const ComputerCall = Schema.Struct({
|
|
504
|
+
id: Schema.String,
|
|
505
|
+
type: Schema.Literal("computer_call"),
|
|
506
|
+
status: Schema.optionalKey(MessageStatus)
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
const FileSearchCall = Schema.Struct({
|
|
510
|
+
id: Schema.String,
|
|
511
|
+
type: Schema.Literal("file_search_call"),
|
|
512
|
+
status: Schema.optionalKey(Schema.String),
|
|
513
|
+
queries: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
514
|
+
results: Schema.optionalKey(Schema.NullOr(Schema.Unknown))
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
const ImageGenerationCall = Schema.Struct({
|
|
518
|
+
id: Schema.String,
|
|
519
|
+
type: Schema.Literal("image_generation_call"),
|
|
520
|
+
result: Schema.optionalKey(Schema.String),
|
|
521
|
+
status: Schema.optionalKey(MessageStatus)
|
|
522
|
+
})
|
|
523
|
+
|
|
524
|
+
const McpCall = Schema.Struct({
|
|
525
|
+
id: Schema.String,
|
|
526
|
+
type: Schema.Literal("mcp_call"),
|
|
527
|
+
approval_request_id: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
528
|
+
name: Schema.String,
|
|
529
|
+
arguments: Schema.Unknown,
|
|
530
|
+
output: Schema.optionalKey(Schema.Unknown),
|
|
531
|
+
error: Schema.optionalKey(Schema.Unknown),
|
|
532
|
+
server_label: Schema.optionalKey(Schema.NullOr(Schema.String))
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
const McpListTools = Schema.Struct({
|
|
536
|
+
id: Schema.String,
|
|
537
|
+
type: Schema.Literal("mcp_list_tools")
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
const McpApprovalRequest = Schema.Struct({
|
|
541
|
+
id: Schema.String,
|
|
542
|
+
type: Schema.Literal("mcp_approval_request"),
|
|
543
|
+
approval_request_id: Schema.optionalKey(Schema.String),
|
|
544
|
+
name: Schema.String,
|
|
545
|
+
arguments: Schema.Unknown
|
|
546
|
+
})
|
|
547
|
+
|
|
548
|
+
const WebSearchCall = Schema.Struct({
|
|
549
|
+
id: Schema.String,
|
|
550
|
+
type: Schema.Literal("web_search_call"),
|
|
551
|
+
action: Schema.optionalKey(Schema.Unknown),
|
|
552
|
+
status: Schema.optionalKey(Schema.String)
|
|
553
|
+
})
|
|
554
|
+
|
|
555
|
+
const OutputItem = Schema.Union([
|
|
556
|
+
ApplyPatchCall,
|
|
557
|
+
CodeInterpreterCall,
|
|
558
|
+
ComputerCall,
|
|
559
|
+
FileSearchCall,
|
|
560
|
+
FunctionCall,
|
|
561
|
+
ImageGenerationCall,
|
|
562
|
+
LocalShellCall,
|
|
563
|
+
McpCall,
|
|
564
|
+
McpListTools,
|
|
565
|
+
McpApprovalRequest,
|
|
566
|
+
OutputMessage,
|
|
567
|
+
ReasoningItem,
|
|
568
|
+
ShellCall,
|
|
569
|
+
WebSearchCall
|
|
570
|
+
])
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* @since 1.0.0
|
|
574
|
+
*/
|
|
575
|
+
export const Response = Schema.Struct({
|
|
576
|
+
id: Schema.String,
|
|
577
|
+
object: Schema.optionalKey(Schema.Literal("response")),
|
|
578
|
+
model: Schema.String,
|
|
579
|
+
status: Schema.optionalKey(
|
|
580
|
+
Schema.Literals(["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"])
|
|
581
|
+
),
|
|
582
|
+
created_at: Schema.Number,
|
|
583
|
+
output: Schema.Array(OutputItem),
|
|
584
|
+
usage: Schema.optionalKey(Schema.NullOr(ResponseUsage)),
|
|
585
|
+
incomplete_details: Schema.optionalKey(
|
|
586
|
+
Schema.NullOr(
|
|
587
|
+
Schema.Struct({
|
|
588
|
+
reason: Schema.optionalKey(Schema.Literals(["max_output_tokens", "content_filter"]))
|
|
589
|
+
})
|
|
590
|
+
)
|
|
591
|
+
),
|
|
592
|
+
service_tier: Schema.optionalKey(Schema.String)
|
|
593
|
+
})
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* @since 1.0.0
|
|
597
|
+
*/
|
|
598
|
+
export type Response = typeof Response.Type
|
|
599
|
+
|
|
600
|
+
const ResponseCreatedEvent = Schema.Struct({
|
|
601
|
+
type: Schema.Literal("response.created"),
|
|
602
|
+
response: Response,
|
|
603
|
+
sequence_number: Schema.Number
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
const ResponseCompletedEvent = Schema.Struct({
|
|
607
|
+
type: Schema.Literal("response.completed"),
|
|
608
|
+
response: Response,
|
|
609
|
+
sequence_number: Schema.Number
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
const ResponseIncompleteEvent = Schema.Struct({
|
|
613
|
+
type: Schema.Literal("response.incomplete"),
|
|
614
|
+
response: Response,
|
|
615
|
+
sequence_number: Schema.Number
|
|
616
|
+
})
|
|
617
|
+
|
|
618
|
+
const ResponseFailedEvent = Schema.Struct({
|
|
619
|
+
type: Schema.Literal("response.failed"),
|
|
620
|
+
response: Response,
|
|
621
|
+
sequence_number: Schema.Number
|
|
622
|
+
})
|
|
623
|
+
|
|
624
|
+
const ResponseOutputItemAddedEvent = Schema.Struct({
|
|
625
|
+
type: Schema.Literal("response.output_item.added"),
|
|
626
|
+
output_index: Schema.Number,
|
|
627
|
+
sequence_number: Schema.Number,
|
|
628
|
+
item: OutputItem
|
|
629
|
+
})
|
|
630
|
+
|
|
631
|
+
const ResponseOutputItemDoneEvent = Schema.Struct({
|
|
632
|
+
type: Schema.Literal("response.output_item.done"),
|
|
633
|
+
output_index: Schema.Number,
|
|
634
|
+
sequence_number: Schema.Number,
|
|
635
|
+
item: OutputItem
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
const ResponseOutputTextDeltaEvent = Schema.Struct({
|
|
639
|
+
type: Schema.Literal("response.output_text.delta"),
|
|
640
|
+
item_id: Schema.String,
|
|
641
|
+
output_index: Schema.Number,
|
|
642
|
+
content_index: Schema.Number,
|
|
643
|
+
delta: Schema.String,
|
|
644
|
+
sequence_number: Schema.Number,
|
|
645
|
+
logprobs: Schema.optionalKey(Schema.Array(Schema.Unknown))
|
|
646
|
+
})
|
|
647
|
+
|
|
648
|
+
const ResponseOutputTextAnnotationAddedEvent = Schema.Struct({
|
|
649
|
+
type: Schema.Literal("response.output_text.annotation.added"),
|
|
650
|
+
item_id: Schema.String,
|
|
651
|
+
output_index: Schema.Number,
|
|
652
|
+
content_index: Schema.Number,
|
|
653
|
+
annotation_index: Schema.Number,
|
|
654
|
+
sequence_number: Schema.Number,
|
|
655
|
+
annotation: Annotation
|
|
656
|
+
})
|
|
657
|
+
|
|
658
|
+
const ResponseReasoningSummaryPartAddedEvent = Schema.Struct({
|
|
659
|
+
type: Schema.Literal("response.reasoning_summary_part.added"),
|
|
660
|
+
item_id: Schema.String,
|
|
661
|
+
output_index: Schema.Number,
|
|
662
|
+
summary_index: Schema.Number,
|
|
663
|
+
sequence_number: Schema.Number,
|
|
664
|
+
part: SummaryTextContent
|
|
665
|
+
})
|
|
666
|
+
|
|
667
|
+
const ResponseReasoningSummaryPartDoneEvent = Schema.Struct({
|
|
668
|
+
type: Schema.Literal("response.reasoning_summary_part.done"),
|
|
669
|
+
item_id: Schema.String,
|
|
670
|
+
output_index: Schema.Number,
|
|
671
|
+
summary_index: Schema.Number,
|
|
672
|
+
sequence_number: Schema.Number,
|
|
673
|
+
part: SummaryTextContent
|
|
674
|
+
})
|
|
675
|
+
|
|
676
|
+
const ResponseReasoningSummaryTextDeltaEvent = Schema.Struct({
|
|
677
|
+
type: Schema.Literal("response.reasoning_summary_text.delta"),
|
|
678
|
+
item_id: Schema.String,
|
|
679
|
+
output_index: Schema.Number,
|
|
680
|
+
summary_index: Schema.Number,
|
|
681
|
+
delta: Schema.String,
|
|
682
|
+
sequence_number: Schema.Number
|
|
683
|
+
})
|
|
684
|
+
|
|
685
|
+
const ResponseFunctionCallArgumentsDeltaEvent = Schema.Struct({
|
|
686
|
+
type: Schema.Literal("response.function_call_arguments.delta"),
|
|
687
|
+
item_id: Schema.String,
|
|
688
|
+
output_index: Schema.Number,
|
|
689
|
+
sequence_number: Schema.Number,
|
|
690
|
+
delta: Schema.String
|
|
691
|
+
})
|
|
692
|
+
|
|
693
|
+
const ResponseFunctionCallArgumentsDoneEvent = Schema.Struct({
|
|
694
|
+
type: Schema.Literal("response.function_call_arguments.done"),
|
|
695
|
+
item_id: Schema.String,
|
|
696
|
+
output_index: Schema.Number,
|
|
697
|
+
sequence_number: Schema.Number,
|
|
698
|
+
arguments: Schema.String
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
const ResponseCodeInterpreterCallCodeDeltaEvent = Schema.Struct({
|
|
702
|
+
type: Schema.Literal("response.code_interpreter_call_code.delta"),
|
|
703
|
+
item_id: Schema.String,
|
|
704
|
+
output_index: Schema.Number,
|
|
705
|
+
sequence_number: Schema.Number,
|
|
706
|
+
delta: Schema.String
|
|
707
|
+
})
|
|
708
|
+
|
|
709
|
+
const ResponseCodeInterpreterCallCodeDoneEvent = Schema.Struct({
|
|
710
|
+
type: Schema.Literal("response.code_interpreter_call_code.done"),
|
|
711
|
+
item_id: Schema.String,
|
|
712
|
+
output_index: Schema.Number,
|
|
713
|
+
sequence_number: Schema.Number,
|
|
714
|
+
code: Schema.String
|
|
715
|
+
})
|
|
716
|
+
|
|
717
|
+
const ResponseApplyPatchCallOperationDiffDeltaEvent = Schema.Struct({
|
|
718
|
+
type: Schema.Literal("response.apply_patch_call_operation_diff.delta"),
|
|
719
|
+
item_id: Schema.String,
|
|
720
|
+
output_index: Schema.Number,
|
|
721
|
+
sequence_number: Schema.Number,
|
|
722
|
+
delta: Schema.String
|
|
723
|
+
})
|
|
724
|
+
|
|
725
|
+
const ResponseApplyPatchCallOperationDiffDoneEvent = Schema.Struct({
|
|
726
|
+
type: Schema.Literal("response.apply_patch_call_operation_diff.done"),
|
|
727
|
+
item_id: Schema.String,
|
|
728
|
+
output_index: Schema.Number,
|
|
729
|
+
sequence_number: Schema.Number,
|
|
730
|
+
delta: Schema.optionalKey(Schema.String)
|
|
731
|
+
})
|
|
732
|
+
|
|
733
|
+
const ResponseImageGenerationCallPartialImageEvent = Schema.Struct({
|
|
734
|
+
type: Schema.Literal("response.image_generation_call.partial_image"),
|
|
735
|
+
item_id: Schema.String,
|
|
736
|
+
output_index: Schema.Number,
|
|
737
|
+
sequence_number: Schema.Number,
|
|
738
|
+
partial_image_b64: Schema.String
|
|
739
|
+
})
|
|
740
|
+
|
|
741
|
+
const ResponseErrorEvent = Schema.Struct({
|
|
742
|
+
type: Schema.Literal("error"),
|
|
743
|
+
code: Schema.NullOr(Schema.String),
|
|
744
|
+
message: Schema.String,
|
|
745
|
+
param: Schema.NullOr(Schema.String),
|
|
746
|
+
sequence_number: Schema.Number,
|
|
747
|
+
status: Schema.optionalKey(Schema.Number)
|
|
748
|
+
})
|
|
749
|
+
|
|
750
|
+
const knownResponseStreamEventTypes = new Set([
|
|
751
|
+
"response.created",
|
|
752
|
+
"response.completed",
|
|
753
|
+
"response.incomplete",
|
|
754
|
+
"response.failed",
|
|
755
|
+
"response.output_item.added",
|
|
756
|
+
"response.output_item.done",
|
|
757
|
+
"response.output_text.delta",
|
|
758
|
+
"response.output_text.annotation.added",
|
|
759
|
+
"response.reasoning_summary_part.added",
|
|
760
|
+
"response.reasoning_summary_part.done",
|
|
761
|
+
"response.reasoning_summary_text.delta",
|
|
762
|
+
"response.function_call_arguments.delta",
|
|
763
|
+
"response.function_call_arguments.done",
|
|
764
|
+
"response.code_interpreter_call_code.delta",
|
|
765
|
+
"response.code_interpreter_call_code.done",
|
|
766
|
+
"response.apply_patch_call_operation_diff.delta",
|
|
767
|
+
"response.apply_patch_call_operation_diff.done",
|
|
768
|
+
"response.image_generation_call.partial_image",
|
|
769
|
+
"error"
|
|
770
|
+
])
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* @since 1.0.0
|
|
774
|
+
*/
|
|
775
|
+
export type UnknownResponseStreamEvent = {
|
|
776
|
+
readonly type: string
|
|
777
|
+
readonly [key: string]: unknown
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const UnknownResponseStreamEvent = Schema.declare<UnknownResponseStreamEvent>(
|
|
781
|
+
(value): value is UnknownResponseStreamEvent =>
|
|
782
|
+
Predicate.hasProperty(value, "type") &&
|
|
783
|
+
typeof value.type === "string" &&
|
|
784
|
+
!knownResponseStreamEventTypes.has(value.type),
|
|
785
|
+
{
|
|
786
|
+
identifier: "UnknownResponseStreamEvent",
|
|
787
|
+
description: "Fallback for unknown future stream events"
|
|
788
|
+
}
|
|
789
|
+
)
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* @since 1.0.0
|
|
793
|
+
*/
|
|
794
|
+
export const ResponseStreamEvent = Schema.Union([
|
|
795
|
+
ResponseCreatedEvent,
|
|
796
|
+
ResponseCompletedEvent,
|
|
797
|
+
ResponseIncompleteEvent,
|
|
798
|
+
ResponseFailedEvent,
|
|
799
|
+
ResponseOutputItemAddedEvent,
|
|
800
|
+
ResponseOutputItemDoneEvent,
|
|
801
|
+
ResponseOutputTextDeltaEvent,
|
|
802
|
+
ResponseOutputTextAnnotationAddedEvent,
|
|
803
|
+
ResponseReasoningSummaryPartAddedEvent,
|
|
804
|
+
ResponseReasoningSummaryPartDoneEvent,
|
|
805
|
+
ResponseReasoningSummaryTextDeltaEvent,
|
|
806
|
+
ResponseFunctionCallArgumentsDeltaEvent,
|
|
807
|
+
ResponseFunctionCallArgumentsDoneEvent,
|
|
808
|
+
ResponseCodeInterpreterCallCodeDeltaEvent,
|
|
809
|
+
ResponseCodeInterpreterCallCodeDoneEvent,
|
|
810
|
+
ResponseApplyPatchCallOperationDiffDeltaEvent,
|
|
811
|
+
ResponseApplyPatchCallOperationDiffDoneEvent,
|
|
812
|
+
ResponseImageGenerationCallPartialImageEvent,
|
|
813
|
+
ResponseErrorEvent,
|
|
814
|
+
UnknownResponseStreamEvent
|
|
815
|
+
])
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* @since 1.0.0
|
|
819
|
+
*/
|
|
820
|
+
export type ResponseStreamEvent = typeof ResponseStreamEvent.Type
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* @since 1.0.0
|
|
824
|
+
*/
|
|
825
|
+
export const Embedding = Schema.Struct({
|
|
826
|
+
embedding: Schema.Union([
|
|
827
|
+
Schema.Array(Schema.Number),
|
|
828
|
+
Schema.String
|
|
829
|
+
]),
|
|
830
|
+
index: Schema.Number,
|
|
831
|
+
object: Schema.optionalKey(Schema.String)
|
|
832
|
+
})
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* @since 1.0.0
|
|
836
|
+
*/
|
|
837
|
+
export type Embedding = typeof Embedding.Type
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* @since 1.0.0
|
|
841
|
+
*/
|
|
842
|
+
export const CreateEmbeddingRequest = Schema.Struct({
|
|
843
|
+
input: Schema.Union([
|
|
844
|
+
Schema.String,
|
|
845
|
+
Schema.Array(Schema.String),
|
|
846
|
+
Schema.Array(Schema.Number),
|
|
847
|
+
Schema.Array(Schema.Array(Schema.Number))
|
|
848
|
+
]),
|
|
849
|
+
model: Schema.String,
|
|
850
|
+
encoding_format: Schema.optionalKey(Schema.Literals(["float", "base64"])),
|
|
851
|
+
dimensions: Schema.optionalKey(Schema.Number),
|
|
852
|
+
user: Schema.optionalKey(Schema.String)
|
|
853
|
+
})
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* @since 1.0.0
|
|
857
|
+
*/
|
|
858
|
+
export type CreateEmbeddingRequest = typeof CreateEmbeddingRequest.Type
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* @since 1.0.0
|
|
862
|
+
*/
|
|
863
|
+
export const CreateEmbeddingResponse = Schema.Struct({
|
|
864
|
+
data: Schema.Array(Embedding),
|
|
865
|
+
model: Schema.String,
|
|
866
|
+
object: Schema.optionalKey(Schema.Literal("list")),
|
|
867
|
+
usage: Schema.optionalKey(
|
|
868
|
+
Schema.Struct({
|
|
869
|
+
prompt_tokens: Schema.Number,
|
|
870
|
+
total_tokens: Schema.Number
|
|
871
|
+
})
|
|
872
|
+
)
|
|
873
|
+
})
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* @since 1.0.0
|
|
877
|
+
*/
|
|
878
|
+
export type CreateEmbeddingResponse = typeof CreateEmbeddingResponse.Type
|