@ai-sdk/openai 4.0.0-beta.4 → 4.0.0-beta.41
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/CHANGELOG.md +399 -22
- package/README.md +2 -0
- package/dist/index.d.ts +166 -49
- package/dist/index.js +2454 -1627
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +176 -53
- package/dist/internal/index.js +2220 -1648
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +292 -22
- package/package.json +13 -14
- package/src/chat/convert-openai-chat-usage.ts +2 -2
- package/src/chat/convert-to-openai-chat-messages.ts +99 -71
- package/src/chat/map-openai-finish-reason.ts +2 -2
- package/src/chat/openai-chat-api.ts +6 -2
- package/src/chat/openai-chat-language-model.ts +68 -164
- package/src/chat/openai-chat-options.ts +10 -1
- package/src/chat/openai-chat-prepare-tools.ts +7 -7
- package/src/completion/convert-openai-completion-usage.ts +2 -2
- package/src/completion/convert-to-openai-completion-prompt.ts +2 -3
- package/src/completion/map-openai-finish-reason.ts +2 -2
- package/src/completion/openai-completion-api.ts +5 -2
- package/src/completion/openai-completion-language-model.ts +46 -30
- package/src/completion/openai-completion-options.ts +5 -1
- package/src/embedding/openai-embedding-model.ts +25 -8
- package/src/embedding/openai-embedding-options.ts +5 -1
- package/src/files/openai-files-api.ts +17 -0
- package/src/files/openai-files-options.ts +22 -0
- package/src/files/openai-files.ts +100 -0
- package/src/image/openai-image-model.ts +31 -15
- package/src/image/openai-image-options.ts +3 -0
- package/src/index.ts +2 -0
- package/src/openai-config.ts +7 -7
- package/src/openai-language-model-capabilities.ts +3 -2
- package/src/openai-provider.ts +63 -30
- package/src/openai-tools.ts +12 -1
- package/src/responses/convert-openai-responses-usage.ts +2 -2
- package/src/responses/convert-to-openai-responses-input.ts +244 -77
- package/src/responses/map-openai-responses-finish-reason.ts +2 -2
- package/src/responses/openai-responses-api.ts +141 -3
- package/src/responses/openai-responses-language-model.ts +274 -61
- package/src/responses/openai-responses-options.ts +29 -3
- package/src/responses/openai-responses-prepare-tools.ts +48 -15
- package/src/responses/openai-responses-provider-metadata.ts +12 -2
- package/src/skills/openai-skills-api.ts +31 -0
- package/src/skills/openai-skills.ts +83 -0
- package/src/speech/openai-speech-model.ts +28 -12
- package/src/speech/openai-speech-options.ts +5 -1
- package/src/tool/apply-patch.ts +33 -32
- package/src/tool/code-interpreter.ts +40 -41
- package/src/tool/custom.ts +2 -8
- package/src/tool/file-search.ts +3 -3
- package/src/tool/image-generation.ts +2 -2
- package/src/tool/local-shell.ts +2 -2
- package/src/tool/mcp.ts +3 -3
- package/src/tool/shell.ts +9 -4
- package/src/tool/tool-search.ts +98 -0
- package/src/tool/web-search-preview.ts +2 -2
- package/src/tool/web-search.ts +2 -2
- package/src/transcription/openai-transcription-model.ts +30 -14
- package/src/transcription/openai-transcription-options.ts +5 -1
- package/dist/index.d.mts +0 -1107
- package/dist/index.mjs +0 -6508
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -1137
- package/dist/internal/index.mjs +0 -6321
- package/dist/internal/index.mjs.map +0 -1
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import { JSONSchema7 } from '@ai-sdk/provider';
|
|
2
|
-
import {
|
|
1
|
+
import type { JSONObject, JSONSchema7, JSONValue } from '@ai-sdk/provider';
|
|
2
|
+
import {
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
type InferSchema,
|
|
6
|
+
} from '@ai-sdk/provider-utils';
|
|
3
7
|
import { z } from 'zod/v4';
|
|
4
8
|
|
|
9
|
+
const jsonValueSchema: z.ZodType<JSONValue> = z.lazy(() =>
|
|
10
|
+
z.union([
|
|
11
|
+
z.string(),
|
|
12
|
+
z.number(),
|
|
13
|
+
z.boolean(),
|
|
14
|
+
z.null(),
|
|
15
|
+
z.array(jsonValueSchema),
|
|
16
|
+
z.record(z.string(), jsonValueSchema.optional()),
|
|
17
|
+
]),
|
|
18
|
+
);
|
|
19
|
+
|
|
5
20
|
export type OpenAIResponsesInput = Array<OpenAIResponsesInputItem>;
|
|
6
21
|
|
|
7
22
|
export type OpenAIResponsesInputItem =
|
|
@@ -20,8 +35,11 @@ export type OpenAIResponsesInputItem =
|
|
|
20
35
|
| OpenAIResponsesShellCallOutput
|
|
21
36
|
| OpenAIResponsesApplyPatchCall
|
|
22
37
|
| OpenAIResponsesApplyPatchCallOutput
|
|
38
|
+
| OpenAIResponsesToolSearchCall
|
|
39
|
+
| OpenAIResponsesToolSearchOutput
|
|
23
40
|
| OpenAIResponsesReasoning
|
|
24
|
-
| OpenAIResponsesItemReference
|
|
41
|
+
| OpenAIResponsesItemReference
|
|
42
|
+
| OpenAIResponsesCompactionItem;
|
|
25
43
|
|
|
26
44
|
export type OpenAIResponsesIncludeValue =
|
|
27
45
|
| 'web_search_call.action.sources'
|
|
@@ -93,6 +111,7 @@ export type OpenAIResponsesFunctionCallOutput = {
|
|
|
93
111
|
| { type: 'input_text'; text: string }
|
|
94
112
|
| { type: 'input_image'; image_url: string }
|
|
95
113
|
| { type: 'input_file'; filename: string; file_data: string }
|
|
114
|
+
| { type: 'input_file'; file_url: string }
|
|
96
115
|
>;
|
|
97
116
|
};
|
|
98
117
|
|
|
@@ -199,11 +218,35 @@ export type OpenAIResponsesApplyPatchCallOutput = {
|
|
|
199
218
|
output?: string;
|
|
200
219
|
};
|
|
201
220
|
|
|
221
|
+
export type OpenAIResponsesToolSearchCall = {
|
|
222
|
+
type: 'tool_search_call';
|
|
223
|
+
id: string;
|
|
224
|
+
execution: 'server' | 'client';
|
|
225
|
+
call_id: string | null;
|
|
226
|
+
status: 'in_progress' | 'completed' | 'incomplete';
|
|
227
|
+
arguments: unknown;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export type OpenAIResponsesToolSearchOutput = {
|
|
231
|
+
type: 'tool_search_output';
|
|
232
|
+
id?: string;
|
|
233
|
+
execution: 'server' | 'client';
|
|
234
|
+
call_id: string | null;
|
|
235
|
+
status: 'in_progress' | 'completed' | 'incomplete';
|
|
236
|
+
tools: Array<JSONObject>;
|
|
237
|
+
};
|
|
238
|
+
|
|
202
239
|
export type OpenAIResponsesItemReference = {
|
|
203
240
|
type: 'item_reference';
|
|
204
241
|
id: string;
|
|
205
242
|
};
|
|
206
243
|
|
|
244
|
+
export type OpenAIResponsesCompactionItem = {
|
|
245
|
+
type: 'compaction';
|
|
246
|
+
id: string;
|
|
247
|
+
encrypted_content: string;
|
|
248
|
+
};
|
|
249
|
+
|
|
207
250
|
/**
|
|
208
251
|
* A filter used to compare a specified attribute key to a given value using a defined comparison operation.
|
|
209
252
|
*/
|
|
@@ -249,6 +292,7 @@ export type OpenAIResponsesTool =
|
|
|
249
292
|
description: string | undefined;
|
|
250
293
|
parameters: JSONSchema7;
|
|
251
294
|
strict?: boolean;
|
|
295
|
+
defer_loading?: boolean;
|
|
252
296
|
}
|
|
253
297
|
| {
|
|
254
298
|
type: 'apply_patch';
|
|
@@ -407,6 +451,12 @@ export type OpenAIResponsesTool =
|
|
|
407
451
|
path: string;
|
|
408
452
|
}>;
|
|
409
453
|
};
|
|
454
|
+
}
|
|
455
|
+
| {
|
|
456
|
+
type: 'tool_search';
|
|
457
|
+
execution?: 'server' | 'client';
|
|
458
|
+
description?: string;
|
|
459
|
+
parameters?: Record<string, unknown>;
|
|
410
460
|
};
|
|
411
461
|
|
|
412
462
|
export type OpenAIResponsesReasoning = {
|
|
@@ -458,6 +508,31 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
458
508
|
service_tier: z.string().nullish(),
|
|
459
509
|
}),
|
|
460
510
|
}),
|
|
511
|
+
z.object({
|
|
512
|
+
type: z.literal('response.failed'),
|
|
513
|
+
response: z.object({
|
|
514
|
+
error: z
|
|
515
|
+
.object({
|
|
516
|
+
code: z.string().nullish(),
|
|
517
|
+
message: z.string(),
|
|
518
|
+
})
|
|
519
|
+
.nullish(),
|
|
520
|
+
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
521
|
+
usage: z
|
|
522
|
+
.object({
|
|
523
|
+
input_tokens: z.number(),
|
|
524
|
+
input_tokens_details: z
|
|
525
|
+
.object({ cached_tokens: z.number().nullish() })
|
|
526
|
+
.nullish(),
|
|
527
|
+
output_tokens: z.number(),
|
|
528
|
+
output_tokens_details: z
|
|
529
|
+
.object({ reasoning_tokens: z.number().nullish() })
|
|
530
|
+
.nullish(),
|
|
531
|
+
})
|
|
532
|
+
.nullish(),
|
|
533
|
+
service_tier: z.string().nullish(),
|
|
534
|
+
}),
|
|
535
|
+
}),
|
|
461
536
|
z.object({
|
|
462
537
|
type: z.literal('response.created'),
|
|
463
538
|
response: z.object({
|
|
@@ -573,6 +648,11 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
573
648
|
commands: z.array(z.string()),
|
|
574
649
|
}),
|
|
575
650
|
}),
|
|
651
|
+
z.object({
|
|
652
|
+
type: z.literal('compaction'),
|
|
653
|
+
id: z.string(),
|
|
654
|
+
encrypted_content: z.string().nullish(),
|
|
655
|
+
}),
|
|
576
656
|
z.object({
|
|
577
657
|
type: z.literal('shell_call_output'),
|
|
578
658
|
id: z.string(),
|
|
@@ -592,6 +672,22 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
592
672
|
}),
|
|
593
673
|
),
|
|
594
674
|
}),
|
|
675
|
+
z.object({
|
|
676
|
+
type: z.literal('tool_search_call'),
|
|
677
|
+
id: z.string(),
|
|
678
|
+
execution: z.enum(['server', 'client']),
|
|
679
|
+
call_id: z.string().nullable(),
|
|
680
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
681
|
+
arguments: z.unknown(),
|
|
682
|
+
}),
|
|
683
|
+
z.object({
|
|
684
|
+
type: z.literal('tool_search_output'),
|
|
685
|
+
id: z.string(),
|
|
686
|
+
execution: z.enum(['server', 'client']),
|
|
687
|
+
call_id: z.string().nullable(),
|
|
688
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
689
|
+
tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
|
|
690
|
+
}),
|
|
595
691
|
]),
|
|
596
692
|
}),
|
|
597
693
|
z.object({
|
|
@@ -796,6 +892,11 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
796
892
|
commands: z.array(z.string()),
|
|
797
893
|
}),
|
|
798
894
|
}),
|
|
895
|
+
z.object({
|
|
896
|
+
type: z.literal('compaction'),
|
|
897
|
+
id: z.string(),
|
|
898
|
+
encrypted_content: z.string(),
|
|
899
|
+
}),
|
|
799
900
|
z.object({
|
|
800
901
|
type: z.literal('shell_call_output'),
|
|
801
902
|
id: z.string(),
|
|
@@ -815,6 +916,22 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
815
916
|
}),
|
|
816
917
|
),
|
|
817
918
|
}),
|
|
919
|
+
z.object({
|
|
920
|
+
type: z.literal('tool_search_call'),
|
|
921
|
+
id: z.string(),
|
|
922
|
+
execution: z.enum(['server', 'client']),
|
|
923
|
+
call_id: z.string().nullable(),
|
|
924
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
925
|
+
arguments: z.unknown(),
|
|
926
|
+
}),
|
|
927
|
+
z.object({
|
|
928
|
+
type: z.literal('tool_search_output'),
|
|
929
|
+
id: z.string(),
|
|
930
|
+
execution: z.enum(['server', 'client']),
|
|
931
|
+
call_id: z.string().nullable(),
|
|
932
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
933
|
+
tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
|
|
934
|
+
}),
|
|
818
935
|
]),
|
|
819
936
|
}),
|
|
820
937
|
z.object({
|
|
@@ -1219,6 +1336,11 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1219
1336
|
commands: z.array(z.string()),
|
|
1220
1337
|
}),
|
|
1221
1338
|
}),
|
|
1339
|
+
z.object({
|
|
1340
|
+
type: z.literal('compaction'),
|
|
1341
|
+
id: z.string(),
|
|
1342
|
+
encrypted_content: z.string(),
|
|
1343
|
+
}),
|
|
1222
1344
|
z.object({
|
|
1223
1345
|
type: z.literal('shell_call_output'),
|
|
1224
1346
|
id: z.string(),
|
|
@@ -1238,6 +1360,22 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1238
1360
|
}),
|
|
1239
1361
|
),
|
|
1240
1362
|
}),
|
|
1363
|
+
z.object({
|
|
1364
|
+
type: z.literal('tool_search_call'),
|
|
1365
|
+
id: z.string(),
|
|
1366
|
+
execution: z.enum(['server', 'client']),
|
|
1367
|
+
call_id: z.string().nullable(),
|
|
1368
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
1369
|
+
arguments: z.unknown(),
|
|
1370
|
+
}),
|
|
1371
|
+
z.object({
|
|
1372
|
+
type: z.literal('tool_search_output'),
|
|
1373
|
+
id: z.string(),
|
|
1374
|
+
execution: z.enum(['server', 'client']),
|
|
1375
|
+
call_id: z.string().nullable(),
|
|
1376
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
1377
|
+
tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
|
|
1378
|
+
}),
|
|
1241
1379
|
]),
|
|
1242
1380
|
)
|
|
1243
1381
|
.optional(),
|