@ai-sdk/openai 2.0.31 → 2.0.32
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 +7 -0
- package/dist/index.d.mts +44 -12
- package/dist/index.d.ts +44 -12
- package/dist/index.js +388 -425
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +354 -391
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +420 -457
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +372 -409
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
parseProviderOptions,
|
|
18
18
|
postJsonToApi
|
|
19
19
|
} from "@ai-sdk/provider-utils";
|
|
20
|
-
import { z as
|
|
20
|
+
import { z as z3 } from "zod/v4";
|
|
21
21
|
|
|
22
22
|
// src/openai-error.ts
|
|
23
23
|
import { z } from "zod/v4";
|
|
@@ -342,98 +342,6 @@ var openaiProviderOptions = z2.object({
|
|
|
342
342
|
import {
|
|
343
343
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
344
344
|
} from "@ai-sdk/provider";
|
|
345
|
-
|
|
346
|
-
// src/tool/file-search.ts
|
|
347
|
-
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
348
|
-
import { z as z3 } from "zod/v4";
|
|
349
|
-
var comparisonFilterSchema = z3.object({
|
|
350
|
-
key: z3.string(),
|
|
351
|
-
type: z3.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
352
|
-
value: z3.union([z3.string(), z3.number(), z3.boolean()])
|
|
353
|
-
});
|
|
354
|
-
var compoundFilterSchema = z3.object({
|
|
355
|
-
type: z3.enum(["and", "or"]),
|
|
356
|
-
filters: z3.array(
|
|
357
|
-
z3.union([comparisonFilterSchema, z3.lazy(() => compoundFilterSchema)])
|
|
358
|
-
)
|
|
359
|
-
});
|
|
360
|
-
var filtersSchema = z3.union([comparisonFilterSchema, compoundFilterSchema]);
|
|
361
|
-
var fileSearchArgsSchema = z3.object({
|
|
362
|
-
vectorStoreIds: z3.array(z3.string()).optional(),
|
|
363
|
-
maxNumResults: z3.number().optional(),
|
|
364
|
-
ranking: z3.object({
|
|
365
|
-
ranker: z3.enum(["auto", "default-2024-08-21"]).optional()
|
|
366
|
-
}).optional(),
|
|
367
|
-
filters: filtersSchema.optional()
|
|
368
|
-
});
|
|
369
|
-
var fileSearch = createProviderDefinedToolFactory({
|
|
370
|
-
id: "openai.file_search",
|
|
371
|
-
name: "file_search",
|
|
372
|
-
inputSchema: z3.object({
|
|
373
|
-
query: z3.string()
|
|
374
|
-
})
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// src/tool/web-search-preview.ts
|
|
378
|
-
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
379
|
-
import { z as z4 } from "zod/v4";
|
|
380
|
-
var webSearchPreviewArgsSchema = z4.object({
|
|
381
|
-
/**
|
|
382
|
-
* Search context size to use for the web search.
|
|
383
|
-
* - high: Most comprehensive context, highest cost, slower response
|
|
384
|
-
* - medium: Balanced context, cost, and latency (default)
|
|
385
|
-
* - low: Least context, lowest cost, fastest response
|
|
386
|
-
*/
|
|
387
|
-
searchContextSize: z4.enum(["low", "medium", "high"]).optional(),
|
|
388
|
-
/**
|
|
389
|
-
* User location information to provide geographically relevant search results.
|
|
390
|
-
*/
|
|
391
|
-
userLocation: z4.object({
|
|
392
|
-
/**
|
|
393
|
-
* Type of location (always 'approximate')
|
|
394
|
-
*/
|
|
395
|
-
type: z4.literal("approximate"),
|
|
396
|
-
/**
|
|
397
|
-
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
398
|
-
*/
|
|
399
|
-
country: z4.string().optional(),
|
|
400
|
-
/**
|
|
401
|
-
* City name (free text, e.g., 'Minneapolis')
|
|
402
|
-
*/
|
|
403
|
-
city: z4.string().optional(),
|
|
404
|
-
/**
|
|
405
|
-
* Region name (free text, e.g., 'Minnesota')
|
|
406
|
-
*/
|
|
407
|
-
region: z4.string().optional(),
|
|
408
|
-
/**
|
|
409
|
-
* IANA timezone (e.g., 'America/Chicago')
|
|
410
|
-
*/
|
|
411
|
-
timezone: z4.string().optional()
|
|
412
|
-
}).optional()
|
|
413
|
-
});
|
|
414
|
-
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
415
|
-
id: "openai.web_search_preview",
|
|
416
|
-
name: "web_search_preview",
|
|
417
|
-
inputSchema: z4.object({
|
|
418
|
-
action: z4.discriminatedUnion("type", [
|
|
419
|
-
z4.object({
|
|
420
|
-
type: z4.literal("search"),
|
|
421
|
-
query: z4.string().nullish()
|
|
422
|
-
}),
|
|
423
|
-
z4.object({
|
|
424
|
-
type: z4.literal("open_page"),
|
|
425
|
-
url: z4.string()
|
|
426
|
-
}),
|
|
427
|
-
z4.object({
|
|
428
|
-
type: z4.literal("find"),
|
|
429
|
-
url: z4.string(),
|
|
430
|
-
pattern: z4.string()
|
|
431
|
-
})
|
|
432
|
-
]).nullish()
|
|
433
|
-
})
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
// src/chat/openai-chat-prepare-tools.ts
|
|
437
345
|
function prepareChatTools({
|
|
438
346
|
tools,
|
|
439
347
|
toolChoice,
|
|
@@ -459,33 +367,6 @@ function prepareChatTools({
|
|
|
459
367
|
}
|
|
460
368
|
});
|
|
461
369
|
break;
|
|
462
|
-
case "provider-defined":
|
|
463
|
-
switch (tool.id) {
|
|
464
|
-
case "openai.file_search": {
|
|
465
|
-
const args = fileSearchArgsSchema.parse(tool.args);
|
|
466
|
-
openaiTools2.push({
|
|
467
|
-
type: "file_search",
|
|
468
|
-
vector_store_ids: args.vectorStoreIds,
|
|
469
|
-
max_num_results: args.maxNumResults,
|
|
470
|
-
ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
|
|
471
|
-
filters: args.filters
|
|
472
|
-
});
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
case "openai.web_search_preview": {
|
|
476
|
-
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
477
|
-
openaiTools2.push({
|
|
478
|
-
type: "web_search_preview",
|
|
479
|
-
search_context_size: args.searchContextSize,
|
|
480
|
-
user_location: args.userLocation
|
|
481
|
-
});
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
default:
|
|
485
|
-
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
break;
|
|
489
370
|
default:
|
|
490
371
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
491
372
|
break;
|
|
@@ -1013,115 +894,115 @@ var OpenAIChatLanguageModel = class {
|
|
|
1013
894
|
};
|
|
1014
895
|
}
|
|
1015
896
|
};
|
|
1016
|
-
var openaiTokenUsageSchema =
|
|
1017
|
-
prompt_tokens:
|
|
1018
|
-
completion_tokens:
|
|
1019
|
-
total_tokens:
|
|
1020
|
-
prompt_tokens_details:
|
|
1021
|
-
cached_tokens:
|
|
897
|
+
var openaiTokenUsageSchema = z3.object({
|
|
898
|
+
prompt_tokens: z3.number().nullish(),
|
|
899
|
+
completion_tokens: z3.number().nullish(),
|
|
900
|
+
total_tokens: z3.number().nullish(),
|
|
901
|
+
prompt_tokens_details: z3.object({
|
|
902
|
+
cached_tokens: z3.number().nullish()
|
|
1022
903
|
}).nullish(),
|
|
1023
|
-
completion_tokens_details:
|
|
1024
|
-
reasoning_tokens:
|
|
1025
|
-
accepted_prediction_tokens:
|
|
1026
|
-
rejected_prediction_tokens:
|
|
904
|
+
completion_tokens_details: z3.object({
|
|
905
|
+
reasoning_tokens: z3.number().nullish(),
|
|
906
|
+
accepted_prediction_tokens: z3.number().nullish(),
|
|
907
|
+
rejected_prediction_tokens: z3.number().nullish()
|
|
1027
908
|
}).nullish()
|
|
1028
909
|
}).nullish();
|
|
1029
|
-
var openaiChatResponseSchema =
|
|
1030
|
-
id:
|
|
1031
|
-
created:
|
|
1032
|
-
model:
|
|
1033
|
-
choices:
|
|
1034
|
-
|
|
1035
|
-
message:
|
|
1036
|
-
role:
|
|
1037
|
-
content:
|
|
1038
|
-
tool_calls:
|
|
1039
|
-
|
|
1040
|
-
id:
|
|
1041
|
-
type:
|
|
1042
|
-
function:
|
|
1043
|
-
name:
|
|
1044
|
-
arguments:
|
|
910
|
+
var openaiChatResponseSchema = z3.object({
|
|
911
|
+
id: z3.string().nullish(),
|
|
912
|
+
created: z3.number().nullish(),
|
|
913
|
+
model: z3.string().nullish(),
|
|
914
|
+
choices: z3.array(
|
|
915
|
+
z3.object({
|
|
916
|
+
message: z3.object({
|
|
917
|
+
role: z3.literal("assistant").nullish(),
|
|
918
|
+
content: z3.string().nullish(),
|
|
919
|
+
tool_calls: z3.array(
|
|
920
|
+
z3.object({
|
|
921
|
+
id: z3.string().nullish(),
|
|
922
|
+
type: z3.literal("function"),
|
|
923
|
+
function: z3.object({
|
|
924
|
+
name: z3.string(),
|
|
925
|
+
arguments: z3.string()
|
|
1045
926
|
})
|
|
1046
927
|
})
|
|
1047
928
|
).nullish(),
|
|
1048
|
-
annotations:
|
|
1049
|
-
|
|
1050
|
-
type:
|
|
1051
|
-
start_index:
|
|
1052
|
-
end_index:
|
|
1053
|
-
url:
|
|
1054
|
-
title:
|
|
929
|
+
annotations: z3.array(
|
|
930
|
+
z3.object({
|
|
931
|
+
type: z3.literal("url_citation"),
|
|
932
|
+
start_index: z3.number(),
|
|
933
|
+
end_index: z3.number(),
|
|
934
|
+
url: z3.string(),
|
|
935
|
+
title: z3.string()
|
|
1055
936
|
})
|
|
1056
937
|
).nullish()
|
|
1057
938
|
}),
|
|
1058
|
-
index:
|
|
1059
|
-
logprobs:
|
|
1060
|
-
content:
|
|
1061
|
-
|
|
1062
|
-
token:
|
|
1063
|
-
logprob:
|
|
1064
|
-
top_logprobs:
|
|
1065
|
-
|
|
1066
|
-
token:
|
|
1067
|
-
logprob:
|
|
939
|
+
index: z3.number(),
|
|
940
|
+
logprobs: z3.object({
|
|
941
|
+
content: z3.array(
|
|
942
|
+
z3.object({
|
|
943
|
+
token: z3.string(),
|
|
944
|
+
logprob: z3.number(),
|
|
945
|
+
top_logprobs: z3.array(
|
|
946
|
+
z3.object({
|
|
947
|
+
token: z3.string(),
|
|
948
|
+
logprob: z3.number()
|
|
1068
949
|
})
|
|
1069
950
|
)
|
|
1070
951
|
})
|
|
1071
952
|
).nullish()
|
|
1072
953
|
}).nullish(),
|
|
1073
|
-
finish_reason:
|
|
954
|
+
finish_reason: z3.string().nullish()
|
|
1074
955
|
})
|
|
1075
956
|
),
|
|
1076
957
|
usage: openaiTokenUsageSchema
|
|
1077
958
|
});
|
|
1078
|
-
var openaiChatChunkSchema =
|
|
1079
|
-
|
|
1080
|
-
id:
|
|
1081
|
-
created:
|
|
1082
|
-
model:
|
|
1083
|
-
choices:
|
|
1084
|
-
|
|
1085
|
-
delta:
|
|
1086
|
-
role:
|
|
1087
|
-
content:
|
|
1088
|
-
tool_calls:
|
|
1089
|
-
|
|
1090
|
-
index:
|
|
1091
|
-
id:
|
|
1092
|
-
type:
|
|
1093
|
-
function:
|
|
1094
|
-
name:
|
|
1095
|
-
arguments:
|
|
959
|
+
var openaiChatChunkSchema = z3.union([
|
|
960
|
+
z3.object({
|
|
961
|
+
id: z3.string().nullish(),
|
|
962
|
+
created: z3.number().nullish(),
|
|
963
|
+
model: z3.string().nullish(),
|
|
964
|
+
choices: z3.array(
|
|
965
|
+
z3.object({
|
|
966
|
+
delta: z3.object({
|
|
967
|
+
role: z3.enum(["assistant"]).nullish(),
|
|
968
|
+
content: z3.string().nullish(),
|
|
969
|
+
tool_calls: z3.array(
|
|
970
|
+
z3.object({
|
|
971
|
+
index: z3.number(),
|
|
972
|
+
id: z3.string().nullish(),
|
|
973
|
+
type: z3.literal("function").nullish(),
|
|
974
|
+
function: z3.object({
|
|
975
|
+
name: z3.string().nullish(),
|
|
976
|
+
arguments: z3.string().nullish()
|
|
1096
977
|
})
|
|
1097
978
|
})
|
|
1098
979
|
).nullish(),
|
|
1099
|
-
annotations:
|
|
1100
|
-
|
|
1101
|
-
type:
|
|
1102
|
-
start_index:
|
|
1103
|
-
end_index:
|
|
1104
|
-
url:
|
|
1105
|
-
title:
|
|
980
|
+
annotations: z3.array(
|
|
981
|
+
z3.object({
|
|
982
|
+
type: z3.literal("url_citation"),
|
|
983
|
+
start_index: z3.number(),
|
|
984
|
+
end_index: z3.number(),
|
|
985
|
+
url: z3.string(),
|
|
986
|
+
title: z3.string()
|
|
1106
987
|
})
|
|
1107
988
|
).nullish()
|
|
1108
989
|
}).nullish(),
|
|
1109
|
-
logprobs:
|
|
1110
|
-
content:
|
|
1111
|
-
|
|
1112
|
-
token:
|
|
1113
|
-
logprob:
|
|
1114
|
-
top_logprobs:
|
|
1115
|
-
|
|
1116
|
-
token:
|
|
1117
|
-
logprob:
|
|
990
|
+
logprobs: z3.object({
|
|
991
|
+
content: z3.array(
|
|
992
|
+
z3.object({
|
|
993
|
+
token: z3.string(),
|
|
994
|
+
logprob: z3.number(),
|
|
995
|
+
top_logprobs: z3.array(
|
|
996
|
+
z3.object({
|
|
997
|
+
token: z3.string(),
|
|
998
|
+
logprob: z3.number()
|
|
1118
999
|
})
|
|
1119
1000
|
)
|
|
1120
1001
|
})
|
|
1121
1002
|
).nullish()
|
|
1122
1003
|
}).nullish(),
|
|
1123
|
-
finish_reason:
|
|
1124
|
-
index:
|
|
1004
|
+
finish_reason: z3.string().nullish(),
|
|
1005
|
+
index: z3.number()
|
|
1125
1006
|
})
|
|
1126
1007
|
),
|
|
1127
1008
|
usage: openaiTokenUsageSchema
|
|
@@ -1185,7 +1066,7 @@ import {
|
|
|
1185
1066
|
parseProviderOptions as parseProviderOptions2,
|
|
1186
1067
|
postJsonToApi as postJsonToApi2
|
|
1187
1068
|
} from "@ai-sdk/provider-utils";
|
|
1188
|
-
import { z as
|
|
1069
|
+
import { z as z5 } from "zod/v4";
|
|
1189
1070
|
|
|
1190
1071
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1191
1072
|
import {
|
|
@@ -1296,12 +1177,12 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1296
1177
|
}
|
|
1297
1178
|
|
|
1298
1179
|
// src/completion/openai-completion-options.ts
|
|
1299
|
-
import { z as
|
|
1300
|
-
var openaiCompletionProviderOptions =
|
|
1180
|
+
import { z as z4 } from "zod/v4";
|
|
1181
|
+
var openaiCompletionProviderOptions = z4.object({
|
|
1301
1182
|
/**
|
|
1302
1183
|
Echo back the prompt in addition to the completion.
|
|
1303
1184
|
*/
|
|
1304
|
-
echo:
|
|
1185
|
+
echo: z4.boolean().optional(),
|
|
1305
1186
|
/**
|
|
1306
1187
|
Modify the likelihood of specified tokens appearing in the completion.
|
|
1307
1188
|
|
|
@@ -1316,16 +1197,16 @@ var openaiCompletionProviderOptions = z6.object({
|
|
|
1316
1197
|
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1317
1198
|
token from being generated.
|
|
1318
1199
|
*/
|
|
1319
|
-
logitBias:
|
|
1200
|
+
logitBias: z4.record(z4.string(), z4.number()).optional(),
|
|
1320
1201
|
/**
|
|
1321
1202
|
The suffix that comes after a completion of inserted text.
|
|
1322
1203
|
*/
|
|
1323
|
-
suffix:
|
|
1204
|
+
suffix: z4.string().optional(),
|
|
1324
1205
|
/**
|
|
1325
1206
|
A unique identifier representing your end-user, which can help OpenAI to
|
|
1326
1207
|
monitor and detect abuse. Learn more.
|
|
1327
1208
|
*/
|
|
1328
|
-
user:
|
|
1209
|
+
user: z4.string().optional(),
|
|
1329
1210
|
/**
|
|
1330
1211
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
1331
1212
|
the response size and can slow down response times. However, it can
|
|
@@ -1335,7 +1216,7 @@ var openaiCompletionProviderOptions = z6.object({
|
|
|
1335
1216
|
Setting to a number will return the log probabilities of the top n
|
|
1336
1217
|
tokens that were generated.
|
|
1337
1218
|
*/
|
|
1338
|
-
logprobs:
|
|
1219
|
+
logprobs: z4.union([z4.boolean(), z4.number()]).optional()
|
|
1339
1220
|
});
|
|
1340
1221
|
|
|
1341
1222
|
// src/completion/openai-completion-language-model.ts
|
|
@@ -1567,42 +1448,42 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1567
1448
|
};
|
|
1568
1449
|
}
|
|
1569
1450
|
};
|
|
1570
|
-
var usageSchema =
|
|
1571
|
-
prompt_tokens:
|
|
1572
|
-
completion_tokens:
|
|
1573
|
-
total_tokens:
|
|
1451
|
+
var usageSchema = z5.object({
|
|
1452
|
+
prompt_tokens: z5.number(),
|
|
1453
|
+
completion_tokens: z5.number(),
|
|
1454
|
+
total_tokens: z5.number()
|
|
1574
1455
|
});
|
|
1575
|
-
var openaiCompletionResponseSchema =
|
|
1576
|
-
id:
|
|
1577
|
-
created:
|
|
1578
|
-
model:
|
|
1579
|
-
choices:
|
|
1580
|
-
|
|
1581
|
-
text:
|
|
1582
|
-
finish_reason:
|
|
1583
|
-
logprobs:
|
|
1584
|
-
tokens:
|
|
1585
|
-
token_logprobs:
|
|
1586
|
-
top_logprobs:
|
|
1456
|
+
var openaiCompletionResponseSchema = z5.object({
|
|
1457
|
+
id: z5.string().nullish(),
|
|
1458
|
+
created: z5.number().nullish(),
|
|
1459
|
+
model: z5.string().nullish(),
|
|
1460
|
+
choices: z5.array(
|
|
1461
|
+
z5.object({
|
|
1462
|
+
text: z5.string(),
|
|
1463
|
+
finish_reason: z5.string(),
|
|
1464
|
+
logprobs: z5.object({
|
|
1465
|
+
tokens: z5.array(z5.string()),
|
|
1466
|
+
token_logprobs: z5.array(z5.number()),
|
|
1467
|
+
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1587
1468
|
}).nullish()
|
|
1588
1469
|
})
|
|
1589
1470
|
),
|
|
1590
1471
|
usage: usageSchema.nullish()
|
|
1591
1472
|
});
|
|
1592
|
-
var openaiCompletionChunkSchema =
|
|
1593
|
-
|
|
1594
|
-
id:
|
|
1595
|
-
created:
|
|
1596
|
-
model:
|
|
1597
|
-
choices:
|
|
1598
|
-
|
|
1599
|
-
text:
|
|
1600
|
-
finish_reason:
|
|
1601
|
-
index:
|
|
1602
|
-
logprobs:
|
|
1603
|
-
tokens:
|
|
1604
|
-
token_logprobs:
|
|
1605
|
-
top_logprobs:
|
|
1473
|
+
var openaiCompletionChunkSchema = z5.union([
|
|
1474
|
+
z5.object({
|
|
1475
|
+
id: z5.string().nullish(),
|
|
1476
|
+
created: z5.number().nullish(),
|
|
1477
|
+
model: z5.string().nullish(),
|
|
1478
|
+
choices: z5.array(
|
|
1479
|
+
z5.object({
|
|
1480
|
+
text: z5.string(),
|
|
1481
|
+
finish_reason: z5.string().nullish(),
|
|
1482
|
+
index: z5.number(),
|
|
1483
|
+
logprobs: z5.object({
|
|
1484
|
+
tokens: z5.array(z5.string()),
|
|
1485
|
+
token_logprobs: z5.array(z5.number()),
|
|
1486
|
+
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1606
1487
|
}).nullish()
|
|
1607
1488
|
})
|
|
1608
1489
|
),
|
|
@@ -1621,21 +1502,21 @@ import {
|
|
|
1621
1502
|
parseProviderOptions as parseProviderOptions3,
|
|
1622
1503
|
postJsonToApi as postJsonToApi3
|
|
1623
1504
|
} from "@ai-sdk/provider-utils";
|
|
1624
|
-
import { z as
|
|
1505
|
+
import { z as z7 } from "zod/v4";
|
|
1625
1506
|
|
|
1626
1507
|
// src/embedding/openai-embedding-options.ts
|
|
1627
|
-
import { z as
|
|
1628
|
-
var openaiEmbeddingProviderOptions =
|
|
1508
|
+
import { z as z6 } from "zod/v4";
|
|
1509
|
+
var openaiEmbeddingProviderOptions = z6.object({
|
|
1629
1510
|
/**
|
|
1630
1511
|
The number of dimensions the resulting output embeddings should have.
|
|
1631
1512
|
Only supported in text-embedding-3 and later models.
|
|
1632
1513
|
*/
|
|
1633
|
-
dimensions:
|
|
1514
|
+
dimensions: z6.number().optional(),
|
|
1634
1515
|
/**
|
|
1635
1516
|
A unique identifier representing your end-user, which can help OpenAI to
|
|
1636
1517
|
monitor and detect abuse. Learn more.
|
|
1637
1518
|
*/
|
|
1638
|
-
user:
|
|
1519
|
+
user: z6.string().optional()
|
|
1639
1520
|
});
|
|
1640
1521
|
|
|
1641
1522
|
// src/embedding/openai-embedding-model.ts
|
|
@@ -1701,9 +1582,9 @@ var OpenAIEmbeddingModel = class {
|
|
|
1701
1582
|
};
|
|
1702
1583
|
}
|
|
1703
1584
|
};
|
|
1704
|
-
var openaiTextEmbeddingResponseSchema =
|
|
1705
|
-
data:
|
|
1706
|
-
usage:
|
|
1585
|
+
var openaiTextEmbeddingResponseSchema = z7.object({
|
|
1586
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1587
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1707
1588
|
});
|
|
1708
1589
|
|
|
1709
1590
|
// src/image/openai-image-model.ts
|
|
@@ -1712,7 +1593,7 @@ import {
|
|
|
1712
1593
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1713
1594
|
postJsonToApi as postJsonToApi4
|
|
1714
1595
|
} from "@ai-sdk/provider-utils";
|
|
1715
|
-
import { z as
|
|
1596
|
+
import { z as z8 } from "zod/v4";
|
|
1716
1597
|
|
|
1717
1598
|
// src/image/openai-image-options.ts
|
|
1718
1599
|
var modelMaxImagesPerCall = {
|
|
@@ -1800,32 +1681,32 @@ var OpenAIImageModel = class {
|
|
|
1800
1681
|
};
|
|
1801
1682
|
}
|
|
1802
1683
|
};
|
|
1803
|
-
var openaiImageResponseSchema =
|
|
1804
|
-
data:
|
|
1805
|
-
|
|
1684
|
+
var openaiImageResponseSchema = z8.object({
|
|
1685
|
+
data: z8.array(
|
|
1686
|
+
z8.object({ b64_json: z8.string(), revised_prompt: z8.string().optional() })
|
|
1806
1687
|
)
|
|
1807
1688
|
});
|
|
1808
1689
|
|
|
1809
1690
|
// src/tool/code-interpreter.ts
|
|
1810
1691
|
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
1811
|
-
import { z as
|
|
1812
|
-
var codeInterpreterInputSchema =
|
|
1813
|
-
code:
|
|
1814
|
-
containerId:
|
|
1692
|
+
import { z as z9 } from "zod/v4";
|
|
1693
|
+
var codeInterpreterInputSchema = z9.object({
|
|
1694
|
+
code: z9.string().nullish(),
|
|
1695
|
+
containerId: z9.string()
|
|
1815
1696
|
});
|
|
1816
|
-
var codeInterpreterOutputSchema =
|
|
1817
|
-
outputs:
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1697
|
+
var codeInterpreterOutputSchema = z9.object({
|
|
1698
|
+
outputs: z9.array(
|
|
1699
|
+
z9.discriminatedUnion("type", [
|
|
1700
|
+
z9.object({ type: z9.literal("logs"), logs: z9.string() }),
|
|
1701
|
+
z9.object({ type: z9.literal("image"), url: z9.string() })
|
|
1821
1702
|
])
|
|
1822
1703
|
).nullish()
|
|
1823
1704
|
});
|
|
1824
|
-
var codeInterpreterArgsSchema =
|
|
1825
|
-
container:
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
fileIds:
|
|
1705
|
+
var codeInterpreterArgsSchema = z9.object({
|
|
1706
|
+
container: z9.union([
|
|
1707
|
+
z9.string(),
|
|
1708
|
+
z9.object({
|
|
1709
|
+
fileIds: z9.array(z9.string()).optional()
|
|
1829
1710
|
})
|
|
1830
1711
|
]).optional()
|
|
1831
1712
|
});
|
|
@@ -1839,30 +1720,72 @@ var codeInterpreter = (args = {}) => {
|
|
|
1839
1720
|
return codeInterpreterToolFactory(args);
|
|
1840
1721
|
};
|
|
1841
1722
|
|
|
1842
|
-
// src/tool/
|
|
1723
|
+
// src/tool/file-search.ts
|
|
1843
1724
|
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
|
|
1844
|
-
import { z as
|
|
1845
|
-
var
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1725
|
+
import { z as z10 } from "zod/v4";
|
|
1726
|
+
var comparisonFilterSchema = z10.object({
|
|
1727
|
+
key: z10.string(),
|
|
1728
|
+
type: z10.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
1729
|
+
value: z10.union([z10.string(), z10.number(), z10.boolean()])
|
|
1730
|
+
});
|
|
1731
|
+
var compoundFilterSchema = z10.object({
|
|
1732
|
+
type: z10.enum(["and", "or"]),
|
|
1733
|
+
filters: z10.array(
|
|
1734
|
+
z10.union([comparisonFilterSchema, z10.lazy(() => compoundFilterSchema)])
|
|
1735
|
+
)
|
|
1736
|
+
});
|
|
1737
|
+
var fileSearchArgsSchema = z10.object({
|
|
1738
|
+
vectorStoreIds: z10.array(z10.string()),
|
|
1739
|
+
maxNumResults: z10.number().optional(),
|
|
1740
|
+
ranking: z10.object({
|
|
1741
|
+
ranker: z10.string().optional(),
|
|
1742
|
+
scoreThreshold: z10.number().optional()
|
|
1743
|
+
}).optional(),
|
|
1744
|
+
filters: z10.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
1745
|
+
});
|
|
1746
|
+
var fileSearchOutputSchema = z10.object({
|
|
1747
|
+
queries: z10.array(z10.string()),
|
|
1748
|
+
results: z10.array(
|
|
1749
|
+
z10.object({
|
|
1750
|
+
attributes: z10.record(z10.string(), z10.unknown()),
|
|
1751
|
+
fileId: z10.string(),
|
|
1752
|
+
filename: z10.string(),
|
|
1753
|
+
score: z10.number(),
|
|
1754
|
+
text: z10.string()
|
|
1755
|
+
})
|
|
1756
|
+
).nullable()
|
|
1757
|
+
});
|
|
1758
|
+
var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
1759
|
+
id: "openai.file_search",
|
|
1760
|
+
name: "file_search",
|
|
1761
|
+
inputSchema: z10.object({}),
|
|
1762
|
+
outputSchema: fileSearchOutputSchema
|
|
1763
|
+
});
|
|
1764
|
+
|
|
1765
|
+
// src/tool/image-generation.ts
|
|
1766
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/provider-utils";
|
|
1767
|
+
import { z as z11 } from "zod/v4";
|
|
1768
|
+
var imageGenerationArgsSchema = z11.object({
|
|
1769
|
+
background: z11.enum(["auto", "opaque", "transparent"]).optional(),
|
|
1770
|
+
inputFidelity: z11.enum(["low", "high"]).optional(),
|
|
1771
|
+
inputImageMask: z11.object({
|
|
1772
|
+
fileId: z11.string().optional(),
|
|
1773
|
+
imageUrl: z11.string().optional()
|
|
1851
1774
|
}).optional(),
|
|
1852
|
-
model:
|
|
1853
|
-
moderation:
|
|
1854
|
-
outputCompression:
|
|
1855
|
-
outputFormat:
|
|
1856
|
-
quality:
|
|
1857
|
-
size:
|
|
1775
|
+
model: z11.string().optional(),
|
|
1776
|
+
moderation: z11.enum(["auto"]).optional(),
|
|
1777
|
+
outputCompression: z11.number().int().min(0).max(100).optional(),
|
|
1778
|
+
outputFormat: z11.enum(["png", "jpeg", "webp"]).optional(),
|
|
1779
|
+
quality: z11.enum(["auto", "low", "medium", "high"]).optional(),
|
|
1780
|
+
size: z11.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
1858
1781
|
}).strict();
|
|
1859
|
-
var imageGenerationOutputSchema =
|
|
1860
|
-
result:
|
|
1782
|
+
var imageGenerationOutputSchema = z11.object({
|
|
1783
|
+
result: z11.string()
|
|
1861
1784
|
});
|
|
1862
|
-
var imageGenerationToolFactory =
|
|
1785
|
+
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
1863
1786
|
id: "openai.image_generation",
|
|
1864
1787
|
name: "image_generation",
|
|
1865
|
-
inputSchema:
|
|
1788
|
+
inputSchema: z11.object({}),
|
|
1866
1789
|
outputSchema: imageGenerationOutputSchema
|
|
1867
1790
|
});
|
|
1868
1791
|
var imageGeneration = (args = {}) => {
|
|
@@ -1870,24 +1793,86 @@ var imageGeneration = (args = {}) => {
|
|
|
1870
1793
|
};
|
|
1871
1794
|
|
|
1872
1795
|
// src/tool/web-search.ts
|
|
1873
|
-
import { createProviderDefinedToolFactory
|
|
1874
|
-
import { z as
|
|
1875
|
-
var webSearchArgsSchema =
|
|
1876
|
-
filters:
|
|
1877
|
-
allowedDomains:
|
|
1796
|
+
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
1797
|
+
import { z as z12 } from "zod/v4";
|
|
1798
|
+
var webSearchArgsSchema = z12.object({
|
|
1799
|
+
filters: z12.object({
|
|
1800
|
+
allowedDomains: z12.array(z12.string()).optional()
|
|
1878
1801
|
}).optional(),
|
|
1802
|
+
searchContextSize: z12.enum(["low", "medium", "high"]).optional(),
|
|
1803
|
+
userLocation: z12.object({
|
|
1804
|
+
type: z12.literal("approximate"),
|
|
1805
|
+
country: z12.string().optional(),
|
|
1806
|
+
city: z12.string().optional(),
|
|
1807
|
+
region: z12.string().optional(),
|
|
1808
|
+
timezone: z12.string().optional()
|
|
1809
|
+
}).optional()
|
|
1810
|
+
});
|
|
1811
|
+
var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
1812
|
+
id: "openai.web_search",
|
|
1813
|
+
name: "web_search",
|
|
1814
|
+
inputSchema: z12.object({
|
|
1815
|
+
action: z12.discriminatedUnion("type", [
|
|
1816
|
+
z12.object({
|
|
1817
|
+
type: z12.literal("search"),
|
|
1818
|
+
query: z12.string().nullish()
|
|
1819
|
+
}),
|
|
1820
|
+
z12.object({
|
|
1821
|
+
type: z12.literal("open_page"),
|
|
1822
|
+
url: z12.string()
|
|
1823
|
+
}),
|
|
1824
|
+
z12.object({
|
|
1825
|
+
type: z12.literal("find"),
|
|
1826
|
+
url: z12.string(),
|
|
1827
|
+
pattern: z12.string()
|
|
1828
|
+
})
|
|
1829
|
+
]).nullish()
|
|
1830
|
+
})
|
|
1831
|
+
});
|
|
1832
|
+
var webSearch = (args = {}) => {
|
|
1833
|
+
return webSearchToolFactory(args);
|
|
1834
|
+
};
|
|
1835
|
+
|
|
1836
|
+
// src/tool/web-search-preview.ts
|
|
1837
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
1838
|
+
import { z as z13 } from "zod/v4";
|
|
1839
|
+
var webSearchPreviewArgsSchema = z13.object({
|
|
1840
|
+
/**
|
|
1841
|
+
* Search context size to use for the web search.
|
|
1842
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
1843
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
1844
|
+
* - low: Least context, lowest cost, fastest response
|
|
1845
|
+
*/
|
|
1879
1846
|
searchContextSize: z13.enum(["low", "medium", "high"]).optional(),
|
|
1847
|
+
/**
|
|
1848
|
+
* User location information to provide geographically relevant search results.
|
|
1849
|
+
*/
|
|
1880
1850
|
userLocation: z13.object({
|
|
1851
|
+
/**
|
|
1852
|
+
* Type of location (always 'approximate')
|
|
1853
|
+
*/
|
|
1881
1854
|
type: z13.literal("approximate"),
|
|
1855
|
+
/**
|
|
1856
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
1857
|
+
*/
|
|
1882
1858
|
country: z13.string().optional(),
|
|
1859
|
+
/**
|
|
1860
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
1861
|
+
*/
|
|
1883
1862
|
city: z13.string().optional(),
|
|
1863
|
+
/**
|
|
1864
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
1865
|
+
*/
|
|
1884
1866
|
region: z13.string().optional(),
|
|
1867
|
+
/**
|
|
1868
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
1869
|
+
*/
|
|
1885
1870
|
timezone: z13.string().optional()
|
|
1886
1871
|
}).optional()
|
|
1887
1872
|
});
|
|
1888
|
-
var
|
|
1889
|
-
id: "openai.
|
|
1890
|
-
name: "
|
|
1873
|
+
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
1874
|
+
id: "openai.web_search_preview",
|
|
1875
|
+
name: "web_search_preview",
|
|
1891
1876
|
inputSchema: z13.object({
|
|
1892
1877
|
action: z13.discriminatedUnion("type", [
|
|
1893
1878
|
z13.object({
|
|
@@ -1906,9 +1891,6 @@ var webSearchToolFactory = createProviderDefinedToolFactory3({
|
|
|
1906
1891
|
]).nullish()
|
|
1907
1892
|
})
|
|
1908
1893
|
});
|
|
1909
|
-
var webSearch = (args = {}) => {
|
|
1910
|
-
return webSearchToolFactory(args);
|
|
1911
|
-
};
|
|
1912
1894
|
|
|
1913
1895
|
// src/openai-tools.ts
|
|
1914
1896
|
var openaiTools = {
|
|
@@ -2246,7 +2228,10 @@ function prepareResponsesTools({
|
|
|
2246
2228
|
type: "file_search",
|
|
2247
2229
|
vector_store_ids: args.vectorStoreIds,
|
|
2248
2230
|
max_num_results: args.maxNumResults,
|
|
2249
|
-
ranking_options: args.ranking ? {
|
|
2231
|
+
ranking_options: args.ranking ? {
|
|
2232
|
+
ranker: args.ranking.ranker,
|
|
2233
|
+
score_threshold: args.ranking.scoreThreshold
|
|
2234
|
+
} : void 0,
|
|
2250
2235
|
filters: args.filters
|
|
2251
2236
|
});
|
|
2252
2237
|
break;
|
|
@@ -2350,6 +2335,20 @@ var webSearchCallItem = z15.object({
|
|
|
2350
2335
|
})
|
|
2351
2336
|
]).nullish()
|
|
2352
2337
|
});
|
|
2338
|
+
var fileSearchCallItem = z15.object({
|
|
2339
|
+
type: z15.literal("file_search_call"),
|
|
2340
|
+
id: z15.string(),
|
|
2341
|
+
queries: z15.array(z15.string()),
|
|
2342
|
+
results: z15.array(
|
|
2343
|
+
z15.object({
|
|
2344
|
+
attributes: z15.record(z15.string(), z15.unknown()),
|
|
2345
|
+
file_id: z15.string(),
|
|
2346
|
+
filename: z15.string(),
|
|
2347
|
+
score: z15.number(),
|
|
2348
|
+
text: z15.string()
|
|
2349
|
+
})
|
|
2350
|
+
).nullish()
|
|
2351
|
+
});
|
|
2353
2352
|
var codeInterpreterCallItem = z15.object({
|
|
2354
2353
|
type: z15.literal("code_interpreter_call"),
|
|
2355
2354
|
id: z15.string(),
|
|
@@ -2408,7 +2407,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2408
2407
|
toolChoice,
|
|
2409
2408
|
responseFormat
|
|
2410
2409
|
}) {
|
|
2411
|
-
var _a, _b, _c, _d
|
|
2410
|
+
var _a, _b, _c, _d;
|
|
2412
2411
|
const warnings = [];
|
|
2413
2412
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
2414
2413
|
if (topK != null) {
|
|
@@ -2446,16 +2445,27 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2446
2445
|
warnings.push(...inputWarnings);
|
|
2447
2446
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
2448
2447
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
2448
|
+
function addInclude(key) {
|
|
2449
|
+
include = include != null ? [...include, key] : [key];
|
|
2450
|
+
}
|
|
2451
|
+
function hasOpenAITool(id) {
|
|
2452
|
+
return (tools == null ? void 0 : tools.find(
|
|
2453
|
+
(tool) => tool.type === "provider-defined" && tool.id === id
|
|
2454
|
+
)) != null;
|
|
2455
|
+
}
|
|
2449
2456
|
const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
|
|
2450
|
-
|
|
2457
|
+
if (topLogprobs) {
|
|
2458
|
+
addInclude("message.output_text.logprobs");
|
|
2459
|
+
}
|
|
2451
2460
|
const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
|
|
2452
2461
|
(tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
2453
2462
|
)) == null ? void 0 : _c.name;
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
))
|
|
2458
|
-
|
|
2463
|
+
if (webSearchToolName) {
|
|
2464
|
+
addInclude("web_search_call.action.sources");
|
|
2465
|
+
}
|
|
2466
|
+
if (hasOpenAITool("openai.code_interpreter")) {
|
|
2467
|
+
addInclude("code_interpreter_call.outputs");
|
|
2468
|
+
}
|
|
2459
2469
|
const baseArgs = {
|
|
2460
2470
|
model: this.modelId,
|
|
2461
2471
|
input,
|
|
@@ -2468,7 +2478,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2468
2478
|
format: responseFormat.schema != null ? {
|
|
2469
2479
|
type: "json_schema",
|
|
2470
2480
|
strict: strictJsonSchema,
|
|
2471
|
-
name: (
|
|
2481
|
+
name: (_d = responseFormat.name) != null ? _d : "response",
|
|
2472
2482
|
description: responseFormat.description,
|
|
2473
2483
|
schema: responseFormat.schema
|
|
2474
2484
|
} : { type: "json_object" }
|
|
@@ -2575,7 +2585,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2575
2585
|
};
|
|
2576
2586
|
}
|
|
2577
2587
|
async doGenerate(options) {
|
|
2578
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2588
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2579
2589
|
const {
|
|
2580
2590
|
args: body,
|
|
2581
2591
|
warnings,
|
|
@@ -2640,6 +2650,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2640
2650
|
})
|
|
2641
2651
|
)
|
|
2642
2652
|
}),
|
|
2653
|
+
webSearchCallItem,
|
|
2654
|
+
fileSearchCallItem,
|
|
2643
2655
|
codeInterpreterCallItem,
|
|
2644
2656
|
imageGenerationCallItem,
|
|
2645
2657
|
z15.object({
|
|
@@ -2649,28 +2661,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2649
2661
|
arguments: z15.string(),
|
|
2650
2662
|
id: z15.string()
|
|
2651
2663
|
}),
|
|
2652
|
-
webSearchCallItem,
|
|
2653
2664
|
z15.object({
|
|
2654
2665
|
type: z15.literal("computer_call"),
|
|
2655
2666
|
id: z15.string(),
|
|
2656
2667
|
status: z15.string().optional()
|
|
2657
2668
|
}),
|
|
2658
|
-
z15.object({
|
|
2659
|
-
type: z15.literal("file_search_call"),
|
|
2660
|
-
id: z15.string(),
|
|
2661
|
-
status: z15.string().optional(),
|
|
2662
|
-
queries: z15.array(z15.string()).nullish(),
|
|
2663
|
-
results: z15.array(
|
|
2664
|
-
z15.object({
|
|
2665
|
-
attributes: z15.object({
|
|
2666
|
-
file_id: z15.string(),
|
|
2667
|
-
filename: z15.string(),
|
|
2668
|
-
score: z15.number(),
|
|
2669
|
-
text: z15.string()
|
|
2670
|
-
})
|
|
2671
|
-
})
|
|
2672
|
-
).nullish()
|
|
2673
|
-
}),
|
|
2674
2669
|
z15.object({
|
|
2675
2670
|
type: z15.literal("reasoning"),
|
|
2676
2671
|
id: z15.string(),
|
|
@@ -2839,7 +2834,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2839
2834
|
type: "tool-call",
|
|
2840
2835
|
toolCallId: part.id,
|
|
2841
2836
|
toolName: "file_search",
|
|
2842
|
-
input: "",
|
|
2837
|
+
input: "{}",
|
|
2843
2838
|
providerExecuted: true
|
|
2844
2839
|
});
|
|
2845
2840
|
content.push({
|
|
@@ -2847,10 +2842,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2847
2842
|
toolCallId: part.id,
|
|
2848
2843
|
toolName: "file_search",
|
|
2849
2844
|
result: {
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2845
|
+
queries: part.queries,
|
|
2846
|
+
results: (_n = (_m = part.results) == null ? void 0 : _m.map((result) => ({
|
|
2847
|
+
attributes: result.attributes,
|
|
2848
|
+
fileId: result.file_id,
|
|
2849
|
+
filename: result.filename,
|
|
2850
|
+
score: result.score,
|
|
2851
|
+
text: result.text
|
|
2852
|
+
}))) != null ? _n : null
|
|
2854
2853
|
},
|
|
2855
2854
|
providerExecuted: true
|
|
2856
2855
|
});
|
|
@@ -2892,15 +2891,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2892
2891
|
return {
|
|
2893
2892
|
content,
|
|
2894
2893
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2895
|
-
finishReason: (
|
|
2894
|
+
finishReason: (_o = response.incomplete_details) == null ? void 0 : _o.reason,
|
|
2896
2895
|
hasFunctionCall
|
|
2897
2896
|
}),
|
|
2898
2897
|
usage: {
|
|
2899
2898
|
inputTokens: response.usage.input_tokens,
|
|
2900
2899
|
outputTokens: response.usage.output_tokens,
|
|
2901
2900
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2902
|
-
reasoningTokens: (
|
|
2903
|
-
cachedInputTokens: (
|
|
2901
|
+
reasoningTokens: (_q = (_p = response.usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
|
|
2902
|
+
cachedInputTokens: (_s = (_r = response.usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
|
|
2904
2903
|
},
|
|
2905
2904
|
request: { body },
|
|
2906
2905
|
response: {
|
|
@@ -2957,7 +2956,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2957
2956
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2958
2957
|
},
|
|
2959
2958
|
transform(chunk, controller) {
|
|
2960
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2959
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
2961
2960
|
if (options.includeRawChunks) {
|
|
2962
2961
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2963
2962
|
}
|
|
@@ -2999,14 +2998,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2999
2998
|
toolName: "computer_use"
|
|
3000
2999
|
});
|
|
3001
3000
|
} else if (value.item.type === "file_search_call") {
|
|
3002
|
-
ongoingToolCalls[value.output_index] = {
|
|
3003
|
-
toolName: "file_search",
|
|
3004
|
-
toolCallId: value.item.id
|
|
3005
|
-
};
|
|
3006
3001
|
controller.enqueue({
|
|
3007
|
-
type: "tool-
|
|
3008
|
-
|
|
3009
|
-
toolName: "file_search"
|
|
3002
|
+
type: "tool-call",
|
|
3003
|
+
toolCallId: value.item.id,
|
|
3004
|
+
toolName: "file_search",
|
|
3005
|
+
input: "{}",
|
|
3006
|
+
providerExecuted: true
|
|
3010
3007
|
});
|
|
3011
3008
|
} else if (value.item.type === "image_generation_call") {
|
|
3012
3009
|
controller.enqueue({
|
|
@@ -3106,26 +3103,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3106
3103
|
});
|
|
3107
3104
|
} else if (value.item.type === "file_search_call") {
|
|
3108
3105
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3109
|
-
controller.enqueue({
|
|
3110
|
-
type: "tool-input-end",
|
|
3111
|
-
id: value.item.id
|
|
3112
|
-
});
|
|
3113
|
-
controller.enqueue({
|
|
3114
|
-
type: "tool-call",
|
|
3115
|
-
toolCallId: value.item.id,
|
|
3116
|
-
toolName: "file_search",
|
|
3117
|
-
input: "",
|
|
3118
|
-
providerExecuted: true
|
|
3119
|
-
});
|
|
3120
3106
|
controller.enqueue({
|
|
3121
3107
|
type: "tool-result",
|
|
3122
3108
|
toolCallId: value.item.id,
|
|
3123
3109
|
toolName: "file_search",
|
|
3124
3110
|
result: {
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3111
|
+
queries: value.item.queries,
|
|
3112
|
+
results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
|
|
3113
|
+
attributes: result.attributes,
|
|
3114
|
+
fileId: result.file_id,
|
|
3115
|
+
filename: result.filename,
|
|
3116
|
+
score: result.score,
|
|
3117
|
+
text: result.text
|
|
3118
|
+
}))) != null ? _c : null
|
|
3129
3119
|
},
|
|
3130
3120
|
providerExecuted: true
|
|
3131
3121
|
});
|
|
@@ -3173,7 +3163,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3173
3163
|
providerMetadata: {
|
|
3174
3164
|
openai: {
|
|
3175
3165
|
itemId: value.item.id,
|
|
3176
|
-
reasoningEncryptedContent: (
|
|
3166
|
+
reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
|
|
3177
3167
|
}
|
|
3178
3168
|
}
|
|
3179
3169
|
});
|
|
@@ -3203,12 +3193,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3203
3193
|
id: value.item_id,
|
|
3204
3194
|
delta: value.delta
|
|
3205
3195
|
});
|
|
3206
|
-
if (((
|
|
3196
|
+
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
3207
3197
|
logprobs.push(value.logprobs);
|
|
3208
3198
|
}
|
|
3209
3199
|
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
3210
3200
|
if (value.summary_index > 0) {
|
|
3211
|
-
(
|
|
3201
|
+
(_g = activeReasoning[value.item_id]) == null ? void 0 : _g.summaryParts.push(
|
|
3212
3202
|
value.summary_index
|
|
3213
3203
|
);
|
|
3214
3204
|
controller.enqueue({
|
|
@@ -3217,7 +3207,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3217
3207
|
providerMetadata: {
|
|
3218
3208
|
openai: {
|
|
3219
3209
|
itemId: value.item_id,
|
|
3220
|
-
reasoningEncryptedContent: (
|
|
3210
|
+
reasoningEncryptedContent: (_i = (_h = activeReasoning[value.item_id]) == null ? void 0 : _h.encryptedContent) != null ? _i : null
|
|
3221
3211
|
}
|
|
3222
3212
|
}
|
|
3223
3213
|
});
|
|
@@ -3235,14 +3225,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3235
3225
|
});
|
|
3236
3226
|
} else if (isResponseFinishedChunk(value)) {
|
|
3237
3227
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3238
|
-
finishReason: (
|
|
3228
|
+
finishReason: (_j = value.response.incomplete_details) == null ? void 0 : _j.reason,
|
|
3239
3229
|
hasFunctionCall
|
|
3240
3230
|
});
|
|
3241
3231
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3242
3232
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3243
3233
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3244
|
-
usage.reasoningTokens = (
|
|
3245
|
-
usage.cachedInputTokens = (
|
|
3234
|
+
usage.reasoningTokens = (_l = (_k = value.response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0;
|
|
3235
|
+
usage.cachedInputTokens = (_n = (_m = value.response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0;
|
|
3246
3236
|
if (typeof value.response.service_tier === "string") {
|
|
3247
3237
|
serviceTier = value.response.service_tier;
|
|
3248
3238
|
}
|
|
@@ -3251,7 +3241,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3251
3241
|
controller.enqueue({
|
|
3252
3242
|
type: "source",
|
|
3253
3243
|
sourceType: "url",
|
|
3254
|
-
id: (
|
|
3244
|
+
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : generateId2(),
|
|
3255
3245
|
url: value.annotation.url,
|
|
3256
3246
|
title: value.annotation.title
|
|
3257
3247
|
});
|
|
@@ -3259,10 +3249,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3259
3249
|
controller.enqueue({
|
|
3260
3250
|
type: "source",
|
|
3261
3251
|
sourceType: "document",
|
|
3262
|
-
id: (
|
|
3252
|
+
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : generateId2(),
|
|
3263
3253
|
mediaType: "text/plain",
|
|
3264
|
-
title: (
|
|
3265
|
-
filename: (
|
|
3254
|
+
title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
|
|
3255
|
+
filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id
|
|
3266
3256
|
});
|
|
3267
3257
|
}
|
|
3268
3258
|
} else if (isErrorChunk(value)) {
|
|
@@ -3367,19 +3357,7 @@ var responseOutputItemAddedSchema = z15.object({
|
|
|
3367
3357
|
}),
|
|
3368
3358
|
z15.object({
|
|
3369
3359
|
type: z15.literal("file_search_call"),
|
|
3370
|
-
id: z15.string()
|
|
3371
|
-
status: z15.string(),
|
|
3372
|
-
queries: z15.array(z15.string()).nullish(),
|
|
3373
|
-
results: z15.array(
|
|
3374
|
-
z15.object({
|
|
3375
|
-
attributes: z15.object({
|
|
3376
|
-
file_id: z15.string(),
|
|
3377
|
-
filename: z15.string(),
|
|
3378
|
-
score: z15.number(),
|
|
3379
|
-
text: z15.string()
|
|
3380
|
-
})
|
|
3381
|
-
})
|
|
3382
|
-
).optional()
|
|
3360
|
+
id: z15.string()
|
|
3383
3361
|
}),
|
|
3384
3362
|
z15.object({
|
|
3385
3363
|
type: z15.literal("image_generation_call"),
|
|
@@ -3411,26 +3389,11 @@ var responseOutputItemDoneSchema = z15.object({
|
|
|
3411
3389
|
codeInterpreterCallItem,
|
|
3412
3390
|
imageGenerationCallItem,
|
|
3413
3391
|
webSearchCallItem,
|
|
3392
|
+
fileSearchCallItem,
|
|
3414
3393
|
z15.object({
|
|
3415
3394
|
type: z15.literal("computer_call"),
|
|
3416
3395
|
id: z15.string(),
|
|
3417
3396
|
status: z15.literal("completed")
|
|
3418
|
-
}),
|
|
3419
|
-
z15.object({
|
|
3420
|
-
type: z15.literal("file_search_call"),
|
|
3421
|
-
id: z15.string(),
|
|
3422
|
-
status: z15.literal("completed"),
|
|
3423
|
-
queries: z15.array(z15.string()).nullish(),
|
|
3424
|
-
results: z15.array(
|
|
3425
|
-
z15.object({
|
|
3426
|
-
attributes: z15.object({
|
|
3427
|
-
file_id: z15.string(),
|
|
3428
|
-
filename: z15.string(),
|
|
3429
|
-
score: z15.number(),
|
|
3430
|
-
text: z15.string()
|
|
3431
|
-
})
|
|
3432
|
-
})
|
|
3433
|
-
).nullish()
|
|
3434
3397
|
})
|
|
3435
3398
|
])
|
|
3436
3399
|
});
|