@ai-sdk/openai 2.0.0-canary.10 → 2.0.0-canary.12
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 +23 -0
- package/dist/index.d.mts +11 -50
- package/dist/index.d.ts +11 -50
- package/dist/index.js +273 -301
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +278 -305
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +30 -39
- package/dist/internal/index.d.ts +30 -39
- package/dist/internal/index.js +273 -294
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +276 -298
- package/dist/internal/index.mjs.map +1 -1
- package/internal.d.ts +1 -0
- package/package.json +5 -4
package/dist/internal/index.js
CHANGED
|
@@ -27,7 +27,9 @@ __export(internal_exports, {
|
|
|
27
27
|
OpenAIResponsesLanguageModel: () => OpenAIResponsesLanguageModel,
|
|
28
28
|
OpenAISpeechModel: () => OpenAISpeechModel,
|
|
29
29
|
OpenAITranscriptionModel: () => OpenAITranscriptionModel,
|
|
30
|
+
hasDefaultResponseFormat: () => hasDefaultResponseFormat,
|
|
30
31
|
modelMaxImagesPerCall: () => modelMaxImagesPerCall,
|
|
32
|
+
openaiCompletionProviderOptions: () => openaiCompletionProviderOptions,
|
|
31
33
|
openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions,
|
|
32
34
|
openaiProviderOptions: () => openaiProviderOptions
|
|
33
35
|
});
|
|
@@ -216,19 +218,6 @@ function getResponseMetadata({
|
|
|
216
218
|
};
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
// src/map-openai-chat-logprobs.ts
|
|
220
|
-
function mapOpenAIChatLogProbsOutput(logprobs) {
|
|
221
|
-
var _a, _b;
|
|
222
|
-
return (_b = (_a = logprobs == null ? void 0 : logprobs.content) == null ? void 0 : _a.map(({ token, logprob, top_logprobs }) => ({
|
|
223
|
-
token,
|
|
224
|
-
logprob,
|
|
225
|
-
topLogprobs: top_logprobs ? top_logprobs.map(({ token: token2, logprob: logprob2 }) => ({
|
|
226
|
-
token: token2,
|
|
227
|
-
logprob: logprob2
|
|
228
|
-
})) : []
|
|
229
|
-
}))) != null ? _b : void 0;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
221
|
// src/map-openai-finish-reason.ts
|
|
233
222
|
function mapOpenAIFinishReason(finishReason) {
|
|
234
223
|
switch (finishReason) {
|
|
@@ -256,16 +245,6 @@ var openaiProviderOptions = import_zod.z.object({
|
|
|
256
245
|
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
257
246
|
*/
|
|
258
247
|
logitBias: import_zod.z.record(import_zod.z.coerce.number(), import_zod.z.number()).optional(),
|
|
259
|
-
/**
|
|
260
|
-
* Return the log probabilities of the tokens.
|
|
261
|
-
*
|
|
262
|
-
* Setting to true will return the log probabilities of the tokens that
|
|
263
|
-
* were generated.
|
|
264
|
-
*
|
|
265
|
-
* Setting to a number will return the log probabilities of the top n
|
|
266
|
-
* tokens that were generated.
|
|
267
|
-
*/
|
|
268
|
-
logprobs: import_zod.z.union([import_zod.z.boolean(), import_zod.z.number()]).optional(),
|
|
269
248
|
/**
|
|
270
249
|
* Whether to enable parallel function calling during tool use. Default to true.
|
|
271
250
|
*/
|
|
@@ -389,7 +368,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
389
368
|
"image/*": [/^https?:\/\/.*$/]
|
|
390
369
|
};
|
|
391
370
|
}
|
|
392
|
-
getArgs({
|
|
371
|
+
async getArgs({
|
|
393
372
|
prompt,
|
|
394
373
|
maxOutputTokens,
|
|
395
374
|
temperature,
|
|
@@ -406,7 +385,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
406
385
|
}) {
|
|
407
386
|
var _a, _b, _c;
|
|
408
387
|
const warnings = [];
|
|
409
|
-
const openaiOptions = (_a = (0, import_provider_utils3.parseProviderOptions)({
|
|
388
|
+
const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
|
|
410
389
|
provider: "openai",
|
|
411
390
|
providerOptions,
|
|
412
391
|
schema: openaiProviderOptions
|
|
@@ -436,8 +415,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
436
415
|
model: this.modelId,
|
|
437
416
|
// model specific settings:
|
|
438
417
|
logit_bias: openaiOptions.logitBias,
|
|
439
|
-
logprobs: openaiOptions.logprobs === true || typeof openaiOptions.logprobs === "number" ? true : void 0,
|
|
440
|
-
top_logprobs: typeof openaiOptions.logprobs === "number" ? openaiOptions.logprobs : typeof openaiOptions.logprobs === "boolean" ? openaiOptions.logprobs ? 0 : void 0 : void 0,
|
|
441
418
|
user: openaiOptions.user,
|
|
442
419
|
parallel_tool_calls: openaiOptions.parallelToolCalls,
|
|
443
420
|
// standardized settings:
|
|
@@ -510,20 +487,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
510
487
|
message: "logitBias is not supported for reasoning models"
|
|
511
488
|
});
|
|
512
489
|
}
|
|
513
|
-
if (baseArgs.logprobs != null) {
|
|
514
|
-
baseArgs.logprobs = void 0;
|
|
515
|
-
warnings.push({
|
|
516
|
-
type: "other",
|
|
517
|
-
message: "logprobs is not supported for reasoning models"
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
if (baseArgs.top_logprobs != null) {
|
|
521
|
-
baseArgs.top_logprobs = void 0;
|
|
522
|
-
warnings.push({
|
|
523
|
-
type: "other",
|
|
524
|
-
message: "topLogprobs is not supported for reasoning models"
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
490
|
if (baseArgs.max_tokens != null) {
|
|
528
491
|
if (baseArgs.max_completion_tokens == null) {
|
|
529
492
|
baseArgs.max_completion_tokens = baseArgs.max_tokens;
|
|
@@ -560,7 +523,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
560
523
|
}
|
|
561
524
|
async doGenerate(options) {
|
|
562
525
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
563
|
-
const { args: body, warnings } = this.getArgs(options);
|
|
526
|
+
const { args: body, warnings } = await this.getArgs(options);
|
|
564
527
|
const {
|
|
565
528
|
responseHeaders,
|
|
566
529
|
value: response,
|
|
@@ -623,12 +586,11 @@ var OpenAIChatLanguageModel = class {
|
|
|
623
586
|
body: rawResponse
|
|
624
587
|
},
|
|
625
588
|
warnings,
|
|
626
|
-
logprobs: mapOpenAIChatLogProbsOutput(choice.logprobs),
|
|
627
589
|
providerMetadata
|
|
628
590
|
};
|
|
629
591
|
}
|
|
630
592
|
async doStream(options) {
|
|
631
|
-
const { args, warnings } = this.getArgs(options);
|
|
593
|
+
const { args, warnings } = await this.getArgs(options);
|
|
632
594
|
const body = {
|
|
633
595
|
...args,
|
|
634
596
|
stream: true,
|
|
@@ -656,7 +618,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
656
618
|
inputTokens: void 0,
|
|
657
619
|
outputTokens: void 0
|
|
658
620
|
};
|
|
659
|
-
let logprobs;
|
|
660
621
|
let isFirstChunk = true;
|
|
661
622
|
const providerMetadata = { openai: {} };
|
|
662
623
|
return {
|
|
@@ -721,13 +682,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
721
682
|
text: delta.content
|
|
722
683
|
});
|
|
723
684
|
}
|
|
724
|
-
const mappedLogprobs = mapOpenAIChatLogProbsOutput(
|
|
725
|
-
choice == null ? void 0 : choice.logprobs
|
|
726
|
-
);
|
|
727
|
-
if (mappedLogprobs == null ? void 0 : mappedLogprobs.length) {
|
|
728
|
-
if (logprobs === void 0) logprobs = [];
|
|
729
|
-
logprobs.push(...mappedLogprobs);
|
|
730
|
-
}
|
|
731
685
|
if (delta.tool_calls != null) {
|
|
732
686
|
for (const toolCallDelta of delta.tool_calls) {
|
|
733
687
|
const index = toolCallDelta.index;
|
|
@@ -814,7 +768,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
814
768
|
controller.enqueue({
|
|
815
769
|
type: "finish",
|
|
816
770
|
finishReason,
|
|
817
|
-
logprobs,
|
|
818
771
|
usage,
|
|
819
772
|
...providerMetadata != null ? { providerMetadata } : {}
|
|
820
773
|
});
|
|
@@ -859,20 +812,6 @@ var openaiChatResponseSchema = import_zod3.z.object({
|
|
|
859
812
|
).nullish()
|
|
860
813
|
}),
|
|
861
814
|
index: import_zod3.z.number(),
|
|
862
|
-
logprobs: import_zod3.z.object({
|
|
863
|
-
content: import_zod3.z.array(
|
|
864
|
-
import_zod3.z.object({
|
|
865
|
-
token: import_zod3.z.string(),
|
|
866
|
-
logprob: import_zod3.z.number(),
|
|
867
|
-
top_logprobs: import_zod3.z.array(
|
|
868
|
-
import_zod3.z.object({
|
|
869
|
-
token: import_zod3.z.string(),
|
|
870
|
-
logprob: import_zod3.z.number()
|
|
871
|
-
})
|
|
872
|
-
)
|
|
873
|
-
})
|
|
874
|
-
).nullable()
|
|
875
|
-
}).nullish(),
|
|
876
815
|
finish_reason: import_zod3.z.string().nullish()
|
|
877
816
|
})
|
|
878
817
|
),
|
|
@@ -900,20 +839,6 @@ var openaiChatChunkSchema = import_zod3.z.union([
|
|
|
900
839
|
})
|
|
901
840
|
).nullish()
|
|
902
841
|
}).nullish(),
|
|
903
|
-
logprobs: import_zod3.z.object({
|
|
904
|
-
content: import_zod3.z.array(
|
|
905
|
-
import_zod3.z.object({
|
|
906
|
-
token: import_zod3.z.string(),
|
|
907
|
-
logprob: import_zod3.z.number(),
|
|
908
|
-
top_logprobs: import_zod3.z.array(
|
|
909
|
-
import_zod3.z.object({
|
|
910
|
-
token: import_zod3.z.string(),
|
|
911
|
-
logprob: import_zod3.z.number()
|
|
912
|
-
})
|
|
913
|
-
)
|
|
914
|
-
})
|
|
915
|
-
).nullable()
|
|
916
|
-
}).nullish(),
|
|
917
842
|
finish_reason: import_zod3.z.string().nullable().optional(),
|
|
918
843
|
index: import_zod3.z.number()
|
|
919
844
|
})
|
|
@@ -955,7 +880,7 @@ var reasoningModels = {
|
|
|
955
880
|
|
|
956
881
|
// src/openai-completion-language-model.ts
|
|
957
882
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
958
|
-
var
|
|
883
|
+
var import_zod5 = require("zod");
|
|
959
884
|
|
|
960
885
|
// src/convert-to-openai-completion-prompt.ts
|
|
961
886
|
var import_provider4 = require("@ai-sdk/provider");
|
|
@@ -1036,28 +961,49 @@ ${user}:`]
|
|
|
1036
961
|
};
|
|
1037
962
|
}
|
|
1038
963
|
|
|
1039
|
-
// src/
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
964
|
+
// src/openai-completion-options.ts
|
|
965
|
+
var import_zod4 = require("zod");
|
|
966
|
+
var openaiCompletionProviderOptions = import_zod4.z.object({
|
|
967
|
+
/**
|
|
968
|
+
Echo back the prompt in addition to the completion.
|
|
969
|
+
*/
|
|
970
|
+
echo: import_zod4.z.boolean().optional(),
|
|
971
|
+
/**
|
|
972
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
973
|
+
|
|
974
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
975
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
976
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
977
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
978
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
979
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
980
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
981
|
+
|
|
982
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
983
|
+
token from being generated.
|
|
984
|
+
*/
|
|
985
|
+
logitBias: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number()).optional(),
|
|
986
|
+
/**
|
|
987
|
+
The suffix that comes after a completion of inserted text.
|
|
988
|
+
*/
|
|
989
|
+
suffix: import_zod4.z.string().optional(),
|
|
990
|
+
/**
|
|
991
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
992
|
+
monitor and detect abuse. Learn more.
|
|
993
|
+
*/
|
|
994
|
+
user: import_zod4.z.string().optional()
|
|
995
|
+
});
|
|
1052
996
|
|
|
1053
997
|
// src/openai-completion-language-model.ts
|
|
1054
998
|
var OpenAICompletionLanguageModel = class {
|
|
1055
|
-
constructor(modelId,
|
|
999
|
+
constructor(modelId, config) {
|
|
1056
1000
|
this.specificationVersion = "v2";
|
|
1057
1001
|
this.modelId = modelId;
|
|
1058
|
-
this.settings = settings;
|
|
1059
1002
|
this.config = config;
|
|
1060
1003
|
}
|
|
1004
|
+
get providerOptionsName() {
|
|
1005
|
+
return this.config.provider.split(".")[0].trim();
|
|
1006
|
+
}
|
|
1061
1007
|
get provider() {
|
|
1062
1008
|
return this.config.provider;
|
|
1063
1009
|
}
|
|
@@ -1066,7 +1012,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1066
1012
|
// no supported urls for completion models
|
|
1067
1013
|
};
|
|
1068
1014
|
}
|
|
1069
|
-
getArgs({
|
|
1015
|
+
async getArgs({
|
|
1070
1016
|
inputFormat,
|
|
1071
1017
|
prompt,
|
|
1072
1018
|
maxOutputTokens,
|
|
@@ -1079,9 +1025,22 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1079
1025
|
responseFormat,
|
|
1080
1026
|
tools,
|
|
1081
1027
|
toolChoice,
|
|
1082
|
-
seed
|
|
1028
|
+
seed,
|
|
1029
|
+
providerOptions
|
|
1083
1030
|
}) {
|
|
1084
1031
|
const warnings = [];
|
|
1032
|
+
const openaiOptions = {
|
|
1033
|
+
...await (0, import_provider_utils4.parseProviderOptions)({
|
|
1034
|
+
provider: "openai",
|
|
1035
|
+
providerOptions,
|
|
1036
|
+
schema: openaiCompletionProviderOptions
|
|
1037
|
+
}),
|
|
1038
|
+
...await (0, import_provider_utils4.parseProviderOptions)({
|
|
1039
|
+
provider: this.providerOptionsName,
|
|
1040
|
+
providerOptions,
|
|
1041
|
+
schema: openaiCompletionProviderOptions
|
|
1042
|
+
})
|
|
1043
|
+
};
|
|
1085
1044
|
if (topK != null) {
|
|
1086
1045
|
warnings.push({ type: "unsupported-setting", setting: "topK" });
|
|
1087
1046
|
}
|
|
@@ -1105,11 +1064,10 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1105
1064
|
// model id:
|
|
1106
1065
|
model: this.modelId,
|
|
1107
1066
|
// model specific settings:
|
|
1108
|
-
echo:
|
|
1109
|
-
logit_bias:
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
user: this.settings.user,
|
|
1067
|
+
echo: openaiOptions.echo,
|
|
1068
|
+
logit_bias: openaiOptions.logitBias,
|
|
1069
|
+
suffix: openaiOptions.suffix,
|
|
1070
|
+
user: openaiOptions.user,
|
|
1113
1071
|
// standardized settings:
|
|
1114
1072
|
max_tokens: maxOutputTokens,
|
|
1115
1073
|
temperature,
|
|
@@ -1126,7 +1084,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1126
1084
|
};
|
|
1127
1085
|
}
|
|
1128
1086
|
async doGenerate(options) {
|
|
1129
|
-
const { args, warnings } = this.getArgs(options);
|
|
1087
|
+
const { args, warnings } = await this.getArgs(options);
|
|
1130
1088
|
const {
|
|
1131
1089
|
responseHeaders,
|
|
1132
1090
|
value: response,
|
|
@@ -1153,7 +1111,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1153
1111
|
outputTokens: response.usage.completion_tokens
|
|
1154
1112
|
},
|
|
1155
1113
|
finishReason: mapOpenAIFinishReason(choice.finish_reason),
|
|
1156
|
-
logprobs: mapOpenAICompletionLogProbs(choice.logprobs),
|
|
1157
1114
|
request: { body: args },
|
|
1158
1115
|
response: {
|
|
1159
1116
|
...getResponseMetadata(response),
|
|
@@ -1164,7 +1121,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1164
1121
|
};
|
|
1165
1122
|
}
|
|
1166
1123
|
async doStream(options) {
|
|
1167
|
-
const { args, warnings } = this.getArgs(options);
|
|
1124
|
+
const { args, warnings } = await this.getArgs(options);
|
|
1168
1125
|
const body = {
|
|
1169
1126
|
...args,
|
|
1170
1127
|
stream: true,
|
|
@@ -1190,7 +1147,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1190
1147
|
inputTokens: void 0,
|
|
1191
1148
|
outputTokens: void 0
|
|
1192
1149
|
};
|
|
1193
|
-
let logprobs;
|
|
1194
1150
|
let isFirstChunk = true;
|
|
1195
1151
|
return {
|
|
1196
1152
|
stream: response.pipeThrough(
|
|
@@ -1231,19 +1187,11 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1231
1187
|
text: choice.text
|
|
1232
1188
|
});
|
|
1233
1189
|
}
|
|
1234
|
-
const mappedLogprobs = mapOpenAICompletionLogProbs(
|
|
1235
|
-
choice == null ? void 0 : choice.logprobs
|
|
1236
|
-
);
|
|
1237
|
-
if (mappedLogprobs == null ? void 0 : mappedLogprobs.length) {
|
|
1238
|
-
if (logprobs === void 0) logprobs = [];
|
|
1239
|
-
logprobs.push(...mappedLogprobs);
|
|
1240
|
-
}
|
|
1241
1190
|
},
|
|
1242
1191
|
flush(controller) {
|
|
1243
1192
|
controller.enqueue({
|
|
1244
1193
|
type: "finish",
|
|
1245
1194
|
finishReason,
|
|
1246
|
-
logprobs,
|
|
1247
1195
|
usage
|
|
1248
1196
|
});
|
|
1249
1197
|
}
|
|
@@ -1254,46 +1202,36 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1254
1202
|
};
|
|
1255
1203
|
}
|
|
1256
1204
|
};
|
|
1257
|
-
var openaiCompletionResponseSchema =
|
|
1258
|
-
id:
|
|
1259
|
-
created:
|
|
1260
|
-
model:
|
|
1261
|
-
choices:
|
|
1262
|
-
|
|
1263
|
-
text:
|
|
1264
|
-
finish_reason:
|
|
1265
|
-
logprobs: import_zod4.z.object({
|
|
1266
|
-
tokens: import_zod4.z.array(import_zod4.z.string()),
|
|
1267
|
-
token_logprobs: import_zod4.z.array(import_zod4.z.number()),
|
|
1268
|
-
top_logprobs: import_zod4.z.array(import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number())).nullable()
|
|
1269
|
-
}).nullish()
|
|
1205
|
+
var openaiCompletionResponseSchema = import_zod5.z.object({
|
|
1206
|
+
id: import_zod5.z.string().nullish(),
|
|
1207
|
+
created: import_zod5.z.number().nullish(),
|
|
1208
|
+
model: import_zod5.z.string().nullish(),
|
|
1209
|
+
choices: import_zod5.z.array(
|
|
1210
|
+
import_zod5.z.object({
|
|
1211
|
+
text: import_zod5.z.string(),
|
|
1212
|
+
finish_reason: import_zod5.z.string()
|
|
1270
1213
|
})
|
|
1271
1214
|
),
|
|
1272
|
-
usage:
|
|
1273
|
-
prompt_tokens:
|
|
1274
|
-
completion_tokens:
|
|
1215
|
+
usage: import_zod5.z.object({
|
|
1216
|
+
prompt_tokens: import_zod5.z.number(),
|
|
1217
|
+
completion_tokens: import_zod5.z.number()
|
|
1275
1218
|
})
|
|
1276
1219
|
});
|
|
1277
|
-
var openaiCompletionChunkSchema =
|
|
1278
|
-
|
|
1279
|
-
id:
|
|
1280
|
-
created:
|
|
1281
|
-
model:
|
|
1282
|
-
choices:
|
|
1283
|
-
|
|
1284
|
-
text:
|
|
1285
|
-
finish_reason:
|
|
1286
|
-
index:
|
|
1287
|
-
logprobs: import_zod4.z.object({
|
|
1288
|
-
tokens: import_zod4.z.array(import_zod4.z.string()),
|
|
1289
|
-
token_logprobs: import_zod4.z.array(import_zod4.z.number()),
|
|
1290
|
-
top_logprobs: import_zod4.z.array(import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number())).nullable()
|
|
1291
|
-
}).nullish()
|
|
1220
|
+
var openaiCompletionChunkSchema = import_zod5.z.union([
|
|
1221
|
+
import_zod5.z.object({
|
|
1222
|
+
id: import_zod5.z.string().nullish(),
|
|
1223
|
+
created: import_zod5.z.number().nullish(),
|
|
1224
|
+
model: import_zod5.z.string().nullish(),
|
|
1225
|
+
choices: import_zod5.z.array(
|
|
1226
|
+
import_zod5.z.object({
|
|
1227
|
+
text: import_zod5.z.string(),
|
|
1228
|
+
finish_reason: import_zod5.z.string().nullish(),
|
|
1229
|
+
index: import_zod5.z.number()
|
|
1292
1230
|
})
|
|
1293
1231
|
),
|
|
1294
|
-
usage:
|
|
1295
|
-
prompt_tokens:
|
|
1296
|
-
completion_tokens:
|
|
1232
|
+
usage: import_zod5.z.object({
|
|
1233
|
+
prompt_tokens: import_zod5.z.number(),
|
|
1234
|
+
completion_tokens: import_zod5.z.number()
|
|
1297
1235
|
}).nullish()
|
|
1298
1236
|
}),
|
|
1299
1237
|
openaiErrorDataSchema
|
|
@@ -1302,21 +1240,21 @@ var openaiCompletionChunkSchema = import_zod4.z.union([
|
|
|
1302
1240
|
// src/openai-embedding-model.ts
|
|
1303
1241
|
var import_provider5 = require("@ai-sdk/provider");
|
|
1304
1242
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1305
|
-
var
|
|
1243
|
+
var import_zod7 = require("zod");
|
|
1306
1244
|
|
|
1307
1245
|
// src/openai-embedding-options.ts
|
|
1308
|
-
var
|
|
1309
|
-
var openaiEmbeddingProviderOptions =
|
|
1246
|
+
var import_zod6 = require("zod");
|
|
1247
|
+
var openaiEmbeddingProviderOptions = import_zod6.z.object({
|
|
1310
1248
|
/**
|
|
1311
1249
|
The number of dimensions the resulting output embeddings should have.
|
|
1312
1250
|
Only supported in text-embedding-3 and later models.
|
|
1313
1251
|
*/
|
|
1314
|
-
dimensions:
|
|
1252
|
+
dimensions: import_zod6.z.number().optional(),
|
|
1315
1253
|
/**
|
|
1316
1254
|
A unique identifier representing your end-user, which can help OpenAI to
|
|
1317
1255
|
monitor and detect abuse. Learn more.
|
|
1318
1256
|
*/
|
|
1319
|
-
user:
|
|
1257
|
+
user: import_zod6.z.string().optional()
|
|
1320
1258
|
});
|
|
1321
1259
|
|
|
1322
1260
|
// src/openai-embedding-model.ts
|
|
@@ -1353,7 +1291,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1353
1291
|
values
|
|
1354
1292
|
});
|
|
1355
1293
|
}
|
|
1356
|
-
const openaiOptions = (_a = (0, import_provider_utils5.parseProviderOptions)({
|
|
1294
|
+
const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
1357
1295
|
provider: "openai",
|
|
1358
1296
|
providerOptions,
|
|
1359
1297
|
schema: openaiEmbeddingProviderOptions
|
|
@@ -1389,20 +1327,22 @@ var OpenAIEmbeddingModel = class {
|
|
|
1389
1327
|
};
|
|
1390
1328
|
}
|
|
1391
1329
|
};
|
|
1392
|
-
var openaiTextEmbeddingResponseSchema =
|
|
1393
|
-
data:
|
|
1394
|
-
usage:
|
|
1330
|
+
var openaiTextEmbeddingResponseSchema = import_zod7.z.object({
|
|
1331
|
+
data: import_zod7.z.array(import_zod7.z.object({ embedding: import_zod7.z.array(import_zod7.z.number()) })),
|
|
1332
|
+
usage: import_zod7.z.object({ prompt_tokens: import_zod7.z.number() }).nullish()
|
|
1395
1333
|
});
|
|
1396
1334
|
|
|
1397
1335
|
// src/openai-image-model.ts
|
|
1398
1336
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1399
|
-
var
|
|
1337
|
+
var import_zod8 = require("zod");
|
|
1400
1338
|
|
|
1401
1339
|
// src/openai-image-settings.ts
|
|
1402
1340
|
var modelMaxImagesPerCall = {
|
|
1403
1341
|
"dall-e-3": 1,
|
|
1404
|
-
"dall-e-2": 10
|
|
1342
|
+
"dall-e-2": 10,
|
|
1343
|
+
"gpt-image-1": 10
|
|
1405
1344
|
};
|
|
1345
|
+
var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
|
|
1406
1346
|
|
|
1407
1347
|
// src/openai-image-model.ts
|
|
1408
1348
|
var OpenAIImageModel = class {
|
|
@@ -1454,7 +1394,7 @@ var OpenAIImageModel = class {
|
|
|
1454
1394
|
n,
|
|
1455
1395
|
size,
|
|
1456
1396
|
...(_d = providerOptions.openai) != null ? _d : {},
|
|
1457
|
-
response_format: "b64_json"
|
|
1397
|
+
...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
|
|
1458
1398
|
},
|
|
1459
1399
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1460
1400
|
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
@@ -1474,19 +1414,19 @@ var OpenAIImageModel = class {
|
|
|
1474
1414
|
};
|
|
1475
1415
|
}
|
|
1476
1416
|
};
|
|
1477
|
-
var openaiImageResponseSchema =
|
|
1478
|
-
data:
|
|
1417
|
+
var openaiImageResponseSchema = import_zod8.z.object({
|
|
1418
|
+
data: import_zod8.z.array(import_zod8.z.object({ b64_json: import_zod8.z.string() }))
|
|
1479
1419
|
});
|
|
1480
1420
|
|
|
1481
1421
|
// src/openai-transcription-model.ts
|
|
1482
1422
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1483
|
-
var
|
|
1484
|
-
var openAIProviderOptionsSchema =
|
|
1485
|
-
include:
|
|
1486
|
-
language:
|
|
1487
|
-
prompt:
|
|
1488
|
-
temperature:
|
|
1489
|
-
timestampGranularities:
|
|
1423
|
+
var import_zod9 = require("zod");
|
|
1424
|
+
var openAIProviderOptionsSchema = import_zod9.z.object({
|
|
1425
|
+
include: import_zod9.z.array(import_zod9.z.string()).nullish(),
|
|
1426
|
+
language: import_zod9.z.string().nullish(),
|
|
1427
|
+
prompt: import_zod9.z.string().nullish(),
|
|
1428
|
+
temperature: import_zod9.z.number().min(0).max(1).nullish().default(0),
|
|
1429
|
+
timestampGranularities: import_zod9.z.array(import_zod9.z.enum(["word", "segment"])).nullish().default(["segment"])
|
|
1490
1430
|
});
|
|
1491
1431
|
var languageMap = {
|
|
1492
1432
|
afrikaans: "af",
|
|
@@ -1556,14 +1496,14 @@ var OpenAITranscriptionModel = class {
|
|
|
1556
1496
|
get provider() {
|
|
1557
1497
|
return this.config.provider;
|
|
1558
1498
|
}
|
|
1559
|
-
getArgs({
|
|
1499
|
+
async getArgs({
|
|
1560
1500
|
audio,
|
|
1561
1501
|
mediaType,
|
|
1562
1502
|
providerOptions
|
|
1563
1503
|
}) {
|
|
1564
1504
|
var _a, _b, _c, _d, _e;
|
|
1565
1505
|
const warnings = [];
|
|
1566
|
-
const openAIOptions = (0, import_provider_utils7.parseProviderOptions)({
|
|
1506
|
+
const openAIOptions = await (0, import_provider_utils7.parseProviderOptions)({
|
|
1567
1507
|
provider: "openai",
|
|
1568
1508
|
providerOptions,
|
|
1569
1509
|
schema: openAIProviderOptionsSchema
|
|
@@ -1595,7 +1535,7 @@ var OpenAITranscriptionModel = class {
|
|
|
1595
1535
|
async doGenerate(options) {
|
|
1596
1536
|
var _a, _b, _c, _d, _e, _f;
|
|
1597
1537
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1598
|
-
const { formData, warnings } = this.getArgs(options);
|
|
1538
|
+
const { formData, warnings } = await this.getArgs(options);
|
|
1599
1539
|
const {
|
|
1600
1540
|
value: response,
|
|
1601
1541
|
responseHeaders,
|
|
@@ -1634,25 +1574,25 @@ var OpenAITranscriptionModel = class {
|
|
|
1634
1574
|
};
|
|
1635
1575
|
}
|
|
1636
1576
|
};
|
|
1637
|
-
var openaiTranscriptionResponseSchema =
|
|
1638
|
-
text:
|
|
1639
|
-
language:
|
|
1640
|
-
duration:
|
|
1641
|
-
words:
|
|
1642
|
-
|
|
1643
|
-
word:
|
|
1644
|
-
start:
|
|
1645
|
-
end:
|
|
1577
|
+
var openaiTranscriptionResponseSchema = import_zod9.z.object({
|
|
1578
|
+
text: import_zod9.z.string(),
|
|
1579
|
+
language: import_zod9.z.string().nullish(),
|
|
1580
|
+
duration: import_zod9.z.number().nullish(),
|
|
1581
|
+
words: import_zod9.z.array(
|
|
1582
|
+
import_zod9.z.object({
|
|
1583
|
+
word: import_zod9.z.string(),
|
|
1584
|
+
start: import_zod9.z.number(),
|
|
1585
|
+
end: import_zod9.z.number()
|
|
1646
1586
|
})
|
|
1647
1587
|
).nullish()
|
|
1648
1588
|
});
|
|
1649
1589
|
|
|
1650
1590
|
// src/openai-speech-model.ts
|
|
1651
1591
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1652
|
-
var
|
|
1653
|
-
var OpenAIProviderOptionsSchema =
|
|
1654
|
-
instructions:
|
|
1655
|
-
speed:
|
|
1592
|
+
var import_zod10 = require("zod");
|
|
1593
|
+
var OpenAIProviderOptionsSchema = import_zod10.z.object({
|
|
1594
|
+
instructions: import_zod10.z.string().nullish(),
|
|
1595
|
+
speed: import_zod10.z.number().min(0.25).max(4).default(1).nullish()
|
|
1656
1596
|
});
|
|
1657
1597
|
var OpenAISpeechModel = class {
|
|
1658
1598
|
constructor(modelId, config) {
|
|
@@ -1663,7 +1603,7 @@ var OpenAISpeechModel = class {
|
|
|
1663
1603
|
get provider() {
|
|
1664
1604
|
return this.config.provider;
|
|
1665
1605
|
}
|
|
1666
|
-
getArgs({
|
|
1606
|
+
async getArgs({
|
|
1667
1607
|
text,
|
|
1668
1608
|
voice = "alloy",
|
|
1669
1609
|
outputFormat = "mp3",
|
|
@@ -1672,7 +1612,7 @@ var OpenAISpeechModel = class {
|
|
|
1672
1612
|
providerOptions
|
|
1673
1613
|
}) {
|
|
1674
1614
|
const warnings = [];
|
|
1675
|
-
const openAIOptions = (0, import_provider_utils8.parseProviderOptions)({
|
|
1615
|
+
const openAIOptions = await (0, import_provider_utils8.parseProviderOptions)({
|
|
1676
1616
|
provider: "openai",
|
|
1677
1617
|
providerOptions,
|
|
1678
1618
|
schema: OpenAIProviderOptionsSchema
|
|
@@ -1713,7 +1653,7 @@ var OpenAISpeechModel = class {
|
|
|
1713
1653
|
async doGenerate(options) {
|
|
1714
1654
|
var _a, _b, _c;
|
|
1715
1655
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1716
|
-
const { requestBody, warnings } = this.getArgs(options);
|
|
1656
|
+
const { requestBody, warnings } = await this.getArgs(options);
|
|
1717
1657
|
const {
|
|
1718
1658
|
value: audio,
|
|
1719
1659
|
responseHeaders,
|
|
@@ -1748,7 +1688,7 @@ var OpenAISpeechModel = class {
|
|
|
1748
1688
|
|
|
1749
1689
|
// src/responses/openai-responses-language-model.ts
|
|
1750
1690
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1751
|
-
var
|
|
1691
|
+
var import_zod11 = require("zod");
|
|
1752
1692
|
|
|
1753
1693
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1754
1694
|
var import_provider6 = require("@ai-sdk/provider");
|
|
@@ -1968,7 +1908,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1968
1908
|
get provider() {
|
|
1969
1909
|
return this.config.provider;
|
|
1970
1910
|
}
|
|
1971
|
-
getArgs({
|
|
1911
|
+
async getArgs({
|
|
1972
1912
|
maxOutputTokens,
|
|
1973
1913
|
temperature,
|
|
1974
1914
|
stopSequences,
|
|
@@ -2012,7 +1952,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2012
1952
|
systemMessageMode: modelConfig.systemMessageMode
|
|
2013
1953
|
});
|
|
2014
1954
|
warnings.push(...messageWarnings);
|
|
2015
|
-
const openaiOptions = (0, import_provider_utils9.parseProviderOptions)({
|
|
1955
|
+
const openaiOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
2016
1956
|
provider: "openai",
|
|
2017
1957
|
providerOptions,
|
|
2018
1958
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -2043,8 +1983,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2043
1983
|
user: openaiOptions == null ? void 0 : openaiOptions.user,
|
|
2044
1984
|
instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
|
|
2045
1985
|
// model-specific settings:
|
|
2046
|
-
...modelConfig.isReasoningModel && (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
|
|
2047
|
-
reasoning: {
|
|
1986
|
+
...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
1987
|
+
reasoning: {
|
|
1988
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
|
|
1989
|
+
effort: openaiOptions.reasoningEffort
|
|
1990
|
+
},
|
|
1991
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
1992
|
+
summary: openaiOptions.reasoningSummary
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
2048
1995
|
},
|
|
2049
1996
|
...modelConfig.requiredAutoTruncation && {
|
|
2050
1997
|
truncation: "auto"
|
|
@@ -2088,7 +2035,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2088
2035
|
}
|
|
2089
2036
|
async doGenerate(options) {
|
|
2090
2037
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2091
|
-
const { args: body, warnings } = this.getArgs(options);
|
|
2038
|
+
const { args: body, warnings } = await this.getArgs(options);
|
|
2092
2039
|
const {
|
|
2093
2040
|
responseHeaders,
|
|
2094
2041
|
value: response,
|
|
@@ -2102,49 +2049,55 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2102
2049
|
body,
|
|
2103
2050
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2104
2051
|
successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
|
|
2105
|
-
|
|
2106
|
-
id:
|
|
2107
|
-
created_at:
|
|
2108
|
-
model:
|
|
2109
|
-
output:
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
type:
|
|
2113
|
-
role:
|
|
2114
|
-
content:
|
|
2115
|
-
|
|
2116
|
-
type:
|
|
2117
|
-
text:
|
|
2118
|
-
annotations:
|
|
2119
|
-
|
|
2120
|
-
type:
|
|
2121
|
-
start_index:
|
|
2122
|
-
end_index:
|
|
2123
|
-
url:
|
|
2124
|
-
title:
|
|
2052
|
+
import_zod11.z.object({
|
|
2053
|
+
id: import_zod11.z.string(),
|
|
2054
|
+
created_at: import_zod11.z.number(),
|
|
2055
|
+
model: import_zod11.z.string(),
|
|
2056
|
+
output: import_zod11.z.array(
|
|
2057
|
+
import_zod11.z.discriminatedUnion("type", [
|
|
2058
|
+
import_zod11.z.object({
|
|
2059
|
+
type: import_zod11.z.literal("message"),
|
|
2060
|
+
role: import_zod11.z.literal("assistant"),
|
|
2061
|
+
content: import_zod11.z.array(
|
|
2062
|
+
import_zod11.z.object({
|
|
2063
|
+
type: import_zod11.z.literal("output_text"),
|
|
2064
|
+
text: import_zod11.z.string(),
|
|
2065
|
+
annotations: import_zod11.z.array(
|
|
2066
|
+
import_zod11.z.object({
|
|
2067
|
+
type: import_zod11.z.literal("url_citation"),
|
|
2068
|
+
start_index: import_zod11.z.number(),
|
|
2069
|
+
end_index: import_zod11.z.number(),
|
|
2070
|
+
url: import_zod11.z.string(),
|
|
2071
|
+
title: import_zod11.z.string()
|
|
2125
2072
|
})
|
|
2126
2073
|
)
|
|
2127
2074
|
})
|
|
2128
2075
|
)
|
|
2129
2076
|
}),
|
|
2130
|
-
|
|
2131
|
-
type:
|
|
2132
|
-
call_id:
|
|
2133
|
-
name:
|
|
2134
|
-
arguments:
|
|
2077
|
+
import_zod11.z.object({
|
|
2078
|
+
type: import_zod11.z.literal("function_call"),
|
|
2079
|
+
call_id: import_zod11.z.string(),
|
|
2080
|
+
name: import_zod11.z.string(),
|
|
2081
|
+
arguments: import_zod11.z.string()
|
|
2135
2082
|
}),
|
|
2136
|
-
|
|
2137
|
-
type:
|
|
2083
|
+
import_zod11.z.object({
|
|
2084
|
+
type: import_zod11.z.literal("web_search_call")
|
|
2138
2085
|
}),
|
|
2139
|
-
|
|
2140
|
-
type:
|
|
2086
|
+
import_zod11.z.object({
|
|
2087
|
+
type: import_zod11.z.literal("computer_call")
|
|
2141
2088
|
}),
|
|
2142
|
-
|
|
2143
|
-
type:
|
|
2089
|
+
import_zod11.z.object({
|
|
2090
|
+
type: import_zod11.z.literal("reasoning"),
|
|
2091
|
+
summary: import_zod11.z.array(
|
|
2092
|
+
import_zod11.z.object({
|
|
2093
|
+
type: import_zod11.z.literal("summary_text"),
|
|
2094
|
+
text: import_zod11.z.string()
|
|
2095
|
+
})
|
|
2096
|
+
)
|
|
2144
2097
|
})
|
|
2145
2098
|
])
|
|
2146
2099
|
),
|
|
2147
|
-
incomplete_details:
|
|
2100
|
+
incomplete_details: import_zod11.z.object({ reason: import_zod11.z.string() }).nullable(),
|
|
2148
2101
|
usage: usageSchema
|
|
2149
2102
|
})
|
|
2150
2103
|
),
|
|
@@ -2154,6 +2107,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2154
2107
|
const content = [];
|
|
2155
2108
|
for (const part of response.output) {
|
|
2156
2109
|
switch (part.type) {
|
|
2110
|
+
case "reasoning": {
|
|
2111
|
+
content.push({
|
|
2112
|
+
type: "reasoning",
|
|
2113
|
+
text: part.summary.map((summary) => summary.text).join()
|
|
2114
|
+
});
|
|
2115
|
+
break;
|
|
2116
|
+
}
|
|
2157
2117
|
case "message": {
|
|
2158
2118
|
for (const contentPart of part.content) {
|
|
2159
2119
|
content.push({
|
|
@@ -2213,7 +2173,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2213
2173
|
};
|
|
2214
2174
|
}
|
|
2215
2175
|
async doStream(options) {
|
|
2216
|
-
const { args: body, warnings } = this.getArgs(options);
|
|
2176
|
+
const { args: body, warnings } = await this.getArgs(options);
|
|
2217
2177
|
const { responseHeaders, value: response } = await (0, import_provider_utils9.postJsonToApi)({
|
|
2218
2178
|
url: this.config.url({
|
|
2219
2179
|
path: "/responses",
|
|
@@ -2294,6 +2254,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2294
2254
|
type: "text",
|
|
2295
2255
|
text: value.delta
|
|
2296
2256
|
});
|
|
2257
|
+
} else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
|
|
2258
|
+
controller.enqueue({
|
|
2259
|
+
type: "reasoning",
|
|
2260
|
+
text: value.delta
|
|
2261
|
+
});
|
|
2297
2262
|
} else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
|
|
2298
2263
|
ongoingToolCalls[value.output_index] = void 0;
|
|
2299
2264
|
hasToolCalls = true;
|
|
@@ -2346,79 +2311,86 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2346
2311
|
};
|
|
2347
2312
|
}
|
|
2348
2313
|
};
|
|
2349
|
-
var usageSchema =
|
|
2350
|
-
input_tokens:
|
|
2351
|
-
input_tokens_details:
|
|
2352
|
-
output_tokens:
|
|
2353
|
-
output_tokens_details:
|
|
2314
|
+
var usageSchema = import_zod11.z.object({
|
|
2315
|
+
input_tokens: import_zod11.z.number(),
|
|
2316
|
+
input_tokens_details: import_zod11.z.object({ cached_tokens: import_zod11.z.number().nullish() }).nullish(),
|
|
2317
|
+
output_tokens: import_zod11.z.number(),
|
|
2318
|
+
output_tokens_details: import_zod11.z.object({ reasoning_tokens: import_zod11.z.number().nullish() }).nullish()
|
|
2354
2319
|
});
|
|
2355
|
-
var textDeltaChunkSchema =
|
|
2356
|
-
type:
|
|
2357
|
-
delta:
|
|
2320
|
+
var textDeltaChunkSchema = import_zod11.z.object({
|
|
2321
|
+
type: import_zod11.z.literal("response.output_text.delta"),
|
|
2322
|
+
delta: import_zod11.z.string()
|
|
2358
2323
|
});
|
|
2359
|
-
var responseFinishedChunkSchema =
|
|
2360
|
-
type:
|
|
2361
|
-
response:
|
|
2362
|
-
incomplete_details:
|
|
2324
|
+
var responseFinishedChunkSchema = import_zod11.z.object({
|
|
2325
|
+
type: import_zod11.z.enum(["response.completed", "response.incomplete"]),
|
|
2326
|
+
response: import_zod11.z.object({
|
|
2327
|
+
incomplete_details: import_zod11.z.object({ reason: import_zod11.z.string() }).nullish(),
|
|
2363
2328
|
usage: usageSchema
|
|
2364
2329
|
})
|
|
2365
2330
|
});
|
|
2366
|
-
var responseCreatedChunkSchema =
|
|
2367
|
-
type:
|
|
2368
|
-
response:
|
|
2369
|
-
id:
|
|
2370
|
-
created_at:
|
|
2371
|
-
model:
|
|
2331
|
+
var responseCreatedChunkSchema = import_zod11.z.object({
|
|
2332
|
+
type: import_zod11.z.literal("response.created"),
|
|
2333
|
+
response: import_zod11.z.object({
|
|
2334
|
+
id: import_zod11.z.string(),
|
|
2335
|
+
created_at: import_zod11.z.number(),
|
|
2336
|
+
model: import_zod11.z.string()
|
|
2372
2337
|
})
|
|
2373
2338
|
});
|
|
2374
|
-
var responseOutputItemDoneSchema =
|
|
2375
|
-
type:
|
|
2376
|
-
output_index:
|
|
2377
|
-
item:
|
|
2378
|
-
|
|
2379
|
-
type:
|
|
2339
|
+
var responseOutputItemDoneSchema = import_zod11.z.object({
|
|
2340
|
+
type: import_zod11.z.literal("response.output_item.done"),
|
|
2341
|
+
output_index: import_zod11.z.number(),
|
|
2342
|
+
item: import_zod11.z.discriminatedUnion("type", [
|
|
2343
|
+
import_zod11.z.object({
|
|
2344
|
+
type: import_zod11.z.literal("message")
|
|
2380
2345
|
}),
|
|
2381
|
-
|
|
2382
|
-
type:
|
|
2383
|
-
id:
|
|
2384
|
-
call_id:
|
|
2385
|
-
name:
|
|
2386
|
-
arguments:
|
|
2387
|
-
status:
|
|
2346
|
+
import_zod11.z.object({
|
|
2347
|
+
type: import_zod11.z.literal("function_call"),
|
|
2348
|
+
id: import_zod11.z.string(),
|
|
2349
|
+
call_id: import_zod11.z.string(),
|
|
2350
|
+
name: import_zod11.z.string(),
|
|
2351
|
+
arguments: import_zod11.z.string(),
|
|
2352
|
+
status: import_zod11.z.literal("completed")
|
|
2388
2353
|
})
|
|
2389
2354
|
])
|
|
2390
2355
|
});
|
|
2391
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2392
|
-
type:
|
|
2393
|
-
item_id:
|
|
2394
|
-
output_index:
|
|
2395
|
-
delta:
|
|
2356
|
+
var responseFunctionCallArgumentsDeltaSchema = import_zod11.z.object({
|
|
2357
|
+
type: import_zod11.z.literal("response.function_call_arguments.delta"),
|
|
2358
|
+
item_id: import_zod11.z.string(),
|
|
2359
|
+
output_index: import_zod11.z.number(),
|
|
2360
|
+
delta: import_zod11.z.string()
|
|
2396
2361
|
});
|
|
2397
|
-
var responseOutputItemAddedSchema =
|
|
2398
|
-
type:
|
|
2399
|
-
output_index:
|
|
2400
|
-
item:
|
|
2401
|
-
|
|
2402
|
-
type:
|
|
2362
|
+
var responseOutputItemAddedSchema = import_zod11.z.object({
|
|
2363
|
+
type: import_zod11.z.literal("response.output_item.added"),
|
|
2364
|
+
output_index: import_zod11.z.number(),
|
|
2365
|
+
item: import_zod11.z.discriminatedUnion("type", [
|
|
2366
|
+
import_zod11.z.object({
|
|
2367
|
+
type: import_zod11.z.literal("message")
|
|
2403
2368
|
}),
|
|
2404
|
-
|
|
2405
|
-
type:
|
|
2406
|
-
id:
|
|
2407
|
-
call_id:
|
|
2408
|
-
name:
|
|
2409
|
-
arguments:
|
|
2369
|
+
import_zod11.z.object({
|
|
2370
|
+
type: import_zod11.z.literal("function_call"),
|
|
2371
|
+
id: import_zod11.z.string(),
|
|
2372
|
+
call_id: import_zod11.z.string(),
|
|
2373
|
+
name: import_zod11.z.string(),
|
|
2374
|
+
arguments: import_zod11.z.string()
|
|
2410
2375
|
})
|
|
2411
2376
|
])
|
|
2412
2377
|
});
|
|
2413
|
-
var responseAnnotationAddedSchema =
|
|
2414
|
-
type:
|
|
2415
|
-
annotation:
|
|
2416
|
-
type:
|
|
2417
|
-
url:
|
|
2418
|
-
title:
|
|
2378
|
+
var responseAnnotationAddedSchema = import_zod11.z.object({
|
|
2379
|
+
type: import_zod11.z.literal("response.output_text.annotation.added"),
|
|
2380
|
+
annotation: import_zod11.z.object({
|
|
2381
|
+
type: import_zod11.z.literal("url_citation"),
|
|
2382
|
+
url: import_zod11.z.string(),
|
|
2383
|
+
title: import_zod11.z.string()
|
|
2419
2384
|
})
|
|
2420
2385
|
});
|
|
2421
|
-
var
|
|
2386
|
+
var responseReasoningSummaryTextDeltaSchema = import_zod11.z.object({
|
|
2387
|
+
type: import_zod11.z.literal("response.reasoning_summary_text.delta"),
|
|
2388
|
+
item_id: import_zod11.z.string(),
|
|
2389
|
+
output_index: import_zod11.z.number(),
|
|
2390
|
+
summary_index: import_zod11.z.number(),
|
|
2391
|
+
delta: import_zod11.z.string()
|
|
2392
|
+
});
|
|
2393
|
+
var openaiResponsesChunkSchema = import_zod11.z.union([
|
|
2422
2394
|
textDeltaChunkSchema,
|
|
2423
2395
|
responseFinishedChunkSchema,
|
|
2424
2396
|
responseCreatedChunkSchema,
|
|
@@ -2426,7 +2398,8 @@ var openaiResponsesChunkSchema = import_zod10.z.union([
|
|
|
2426
2398
|
responseFunctionCallArgumentsDeltaSchema,
|
|
2427
2399
|
responseOutputItemAddedSchema,
|
|
2428
2400
|
responseAnnotationAddedSchema,
|
|
2429
|
-
|
|
2401
|
+
responseReasoningSummaryTextDeltaSchema,
|
|
2402
|
+
import_zod11.z.object({ type: import_zod11.z.string() }).passthrough()
|
|
2430
2403
|
// fallback for unknown chunks
|
|
2431
2404
|
]);
|
|
2432
2405
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2450,6 +2423,9 @@ function isResponseOutputItemAddedChunk(chunk) {
|
|
|
2450
2423
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
2451
2424
|
return chunk.type === "response.output_text.annotation.added";
|
|
2452
2425
|
}
|
|
2426
|
+
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
2427
|
+
return chunk.type === "response.reasoning_summary_text.delta";
|
|
2428
|
+
}
|
|
2453
2429
|
function getResponsesModelConfig(modelId) {
|
|
2454
2430
|
if (modelId.startsWith("o")) {
|
|
2455
2431
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
@@ -2471,15 +2447,16 @@ function getResponsesModelConfig(modelId) {
|
|
|
2471
2447
|
requiredAutoTruncation: false
|
|
2472
2448
|
};
|
|
2473
2449
|
}
|
|
2474
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2475
|
-
metadata:
|
|
2476
|
-
parallelToolCalls:
|
|
2477
|
-
previousResponseId:
|
|
2478
|
-
store:
|
|
2479
|
-
user:
|
|
2480
|
-
reasoningEffort:
|
|
2481
|
-
strictSchemas:
|
|
2482
|
-
instructions:
|
|
2450
|
+
var openaiResponsesProviderOptionsSchema = import_zod11.z.object({
|
|
2451
|
+
metadata: import_zod11.z.any().nullish(),
|
|
2452
|
+
parallelToolCalls: import_zod11.z.boolean().nullish(),
|
|
2453
|
+
previousResponseId: import_zod11.z.string().nullish(),
|
|
2454
|
+
store: import_zod11.z.boolean().nullish(),
|
|
2455
|
+
user: import_zod11.z.string().nullish(),
|
|
2456
|
+
reasoningEffort: import_zod11.z.string().nullish(),
|
|
2457
|
+
strictSchemas: import_zod11.z.boolean().nullish(),
|
|
2458
|
+
instructions: import_zod11.z.string().nullish(),
|
|
2459
|
+
reasoningSummary: import_zod11.z.string().nullish()
|
|
2483
2460
|
});
|
|
2484
2461
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2485
2462
|
0 && (module.exports = {
|
|
@@ -2490,7 +2467,9 @@ var openaiResponsesProviderOptionsSchema = import_zod10.z.object({
|
|
|
2490
2467
|
OpenAIResponsesLanguageModel,
|
|
2491
2468
|
OpenAISpeechModel,
|
|
2492
2469
|
OpenAITranscriptionModel,
|
|
2470
|
+
hasDefaultResponseFormat,
|
|
2493
2471
|
modelMaxImagesPerCall,
|
|
2472
|
+
openaiCompletionProviderOptions,
|
|
2494
2473
|
openaiEmbeddingProviderOptions,
|
|
2495
2474
|
openaiProviderOptions
|
|
2496
2475
|
});
|