@zenning/openai 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +134 -122
- package/dist/index.d.ts +134 -122
- package/dist/index.js +807 -358
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +797 -366
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.js +730 -268
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +720 -276
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/internal/dist/index.mjs
CHANGED
|
@@ -1,8 +1,164 @@
|
|
|
1
|
+
// ../provider/dist/index.mjs
|
|
2
|
+
var marker = "vercel.ai.error";
|
|
3
|
+
var symbol = Symbol.for(marker);
|
|
4
|
+
var _a;
|
|
5
|
+
var _AISDKError = class _AISDKError2 extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* Creates an AI SDK Error.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} params - The parameters for creating the error.
|
|
10
|
+
* @param {string} params.name - The name of the error.
|
|
11
|
+
* @param {string} params.message - The error message.
|
|
12
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
13
|
+
*/
|
|
14
|
+
constructor({
|
|
15
|
+
name: name14,
|
|
16
|
+
message,
|
|
17
|
+
cause
|
|
18
|
+
}) {
|
|
19
|
+
super(message);
|
|
20
|
+
this[_a] = true;
|
|
21
|
+
this.name = name14;
|
|
22
|
+
this.cause = cause;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the given error is an AI SDK Error.
|
|
26
|
+
* @param {unknown} error - The error to check.
|
|
27
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
static isInstance(error) {
|
|
30
|
+
return _AISDKError2.hasMarker(error, marker);
|
|
31
|
+
}
|
|
32
|
+
static hasMarker(error, marker15) {
|
|
33
|
+
const markerSymbol = Symbol.for(marker15);
|
|
34
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
_a = symbol;
|
|
38
|
+
var AISDKError = _AISDKError;
|
|
39
|
+
var name = "AI_APICallError";
|
|
40
|
+
var marker2 = `vercel.ai.error.${name}`;
|
|
41
|
+
var symbol2 = Symbol.for(marker2);
|
|
42
|
+
var _a2;
|
|
43
|
+
_a2 = symbol2;
|
|
44
|
+
var name2 = "AI_EmptyResponseBodyError";
|
|
45
|
+
var marker3 = `vercel.ai.error.${name2}`;
|
|
46
|
+
var symbol3 = Symbol.for(marker3);
|
|
47
|
+
var _a3;
|
|
48
|
+
_a3 = symbol3;
|
|
49
|
+
var name3 = "AI_InvalidArgumentError";
|
|
50
|
+
var marker4 = `vercel.ai.error.${name3}`;
|
|
51
|
+
var symbol4 = Symbol.for(marker4);
|
|
52
|
+
var _a4;
|
|
53
|
+
_a4 = symbol4;
|
|
54
|
+
var name4 = "AI_InvalidPromptError";
|
|
55
|
+
var marker5 = `vercel.ai.error.${name4}`;
|
|
56
|
+
var symbol5 = Symbol.for(marker5);
|
|
57
|
+
var _a5;
|
|
58
|
+
var InvalidPromptError = class extends AISDKError {
|
|
59
|
+
constructor({
|
|
60
|
+
prompt,
|
|
61
|
+
message,
|
|
62
|
+
cause
|
|
63
|
+
}) {
|
|
64
|
+
super({ name: name4, message: `Invalid prompt: ${message}`, cause });
|
|
65
|
+
this[_a5] = true;
|
|
66
|
+
this.prompt = prompt;
|
|
67
|
+
}
|
|
68
|
+
static isInstance(error) {
|
|
69
|
+
return AISDKError.hasMarker(error, marker5);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
_a5 = symbol5;
|
|
73
|
+
var name5 = "AI_InvalidResponseDataError";
|
|
74
|
+
var marker6 = `vercel.ai.error.${name5}`;
|
|
75
|
+
var symbol6 = Symbol.for(marker6);
|
|
76
|
+
var _a6;
|
|
77
|
+
var InvalidResponseDataError = class extends AISDKError {
|
|
78
|
+
constructor({
|
|
79
|
+
data,
|
|
80
|
+
message = `Invalid response data: ${JSON.stringify(data)}.`
|
|
81
|
+
}) {
|
|
82
|
+
super({ name: name5, message });
|
|
83
|
+
this[_a6] = true;
|
|
84
|
+
this.data = data;
|
|
85
|
+
}
|
|
86
|
+
static isInstance(error) {
|
|
87
|
+
return AISDKError.hasMarker(error, marker6);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
_a6 = symbol6;
|
|
91
|
+
var name6 = "AI_JSONParseError";
|
|
92
|
+
var marker7 = `vercel.ai.error.${name6}`;
|
|
93
|
+
var symbol7 = Symbol.for(marker7);
|
|
94
|
+
var _a7;
|
|
95
|
+
_a7 = symbol7;
|
|
96
|
+
var name7 = "AI_LoadAPIKeyError";
|
|
97
|
+
var marker8 = `vercel.ai.error.${name7}`;
|
|
98
|
+
var symbol8 = Symbol.for(marker8);
|
|
99
|
+
var _a8;
|
|
100
|
+
_a8 = symbol8;
|
|
101
|
+
var name8 = "AI_LoadSettingError";
|
|
102
|
+
var marker9 = `vercel.ai.error.${name8}`;
|
|
103
|
+
var symbol9 = Symbol.for(marker9);
|
|
104
|
+
var _a9;
|
|
105
|
+
_a9 = symbol9;
|
|
106
|
+
var name9 = "AI_NoContentGeneratedError";
|
|
107
|
+
var marker10 = `vercel.ai.error.${name9}`;
|
|
108
|
+
var symbol10 = Symbol.for(marker10);
|
|
109
|
+
var _a10;
|
|
110
|
+
_a10 = symbol10;
|
|
111
|
+
var name10 = "AI_NoSuchModelError";
|
|
112
|
+
var marker11 = `vercel.ai.error.${name10}`;
|
|
113
|
+
var symbol11 = Symbol.for(marker11);
|
|
114
|
+
var _a11;
|
|
115
|
+
_a11 = symbol11;
|
|
116
|
+
var name11 = "AI_TooManyEmbeddingValuesForCallError";
|
|
117
|
+
var marker12 = `vercel.ai.error.${name11}`;
|
|
118
|
+
var symbol12 = Symbol.for(marker12);
|
|
119
|
+
var _a12;
|
|
120
|
+
var TooManyEmbeddingValuesForCallError = class extends AISDKError {
|
|
121
|
+
constructor(options) {
|
|
122
|
+
super({
|
|
123
|
+
name: name11,
|
|
124
|
+
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
125
|
+
});
|
|
126
|
+
this[_a12] = true;
|
|
127
|
+
this.provider = options.provider;
|
|
128
|
+
this.modelId = options.modelId;
|
|
129
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
130
|
+
this.values = options.values;
|
|
131
|
+
}
|
|
132
|
+
static isInstance(error) {
|
|
133
|
+
return AISDKError.hasMarker(error, marker12);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
_a12 = symbol12;
|
|
137
|
+
var name12 = "AI_TypeValidationError";
|
|
138
|
+
var marker13 = `vercel.ai.error.${name12}`;
|
|
139
|
+
var symbol13 = Symbol.for(marker13);
|
|
140
|
+
var _a13;
|
|
141
|
+
_a13 = symbol13;
|
|
142
|
+
var name13 = "AI_UnsupportedFunctionalityError";
|
|
143
|
+
var marker14 = `vercel.ai.error.${name13}`;
|
|
144
|
+
var symbol14 = Symbol.for(marker14);
|
|
145
|
+
var _a14;
|
|
146
|
+
var UnsupportedFunctionalityError = class extends AISDKError {
|
|
147
|
+
constructor({
|
|
148
|
+
functionality,
|
|
149
|
+
message = `'${functionality}' functionality not supported.`
|
|
150
|
+
}) {
|
|
151
|
+
super({ name: name13, message });
|
|
152
|
+
this[_a14] = true;
|
|
153
|
+
this.functionality = functionality;
|
|
154
|
+
}
|
|
155
|
+
static isInstance(error) {
|
|
156
|
+
return AISDKError.hasMarker(error, marker14);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
_a14 = symbol14;
|
|
160
|
+
|
|
1
161
|
// src/openai-chat-language-model.ts
|
|
2
|
-
import {
|
|
3
|
-
InvalidResponseDataError,
|
|
4
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
5
|
-
} from "@ai-sdk/provider";
|
|
6
162
|
import {
|
|
7
163
|
combineHeaders,
|
|
8
164
|
createEventSourceResponseHandler,
|
|
@@ -14,9 +170,6 @@ import {
|
|
|
14
170
|
import { z as z2 } from "zod";
|
|
15
171
|
|
|
16
172
|
// src/convert-to-openai-chat-messages.ts
|
|
17
|
-
import {
|
|
18
|
-
UnsupportedFunctionalityError
|
|
19
|
-
} from "@ai-sdk/provider";
|
|
20
173
|
import { convertUint8ArrayToBase64 } from "@ai-sdk/provider-utils";
|
|
21
174
|
function convertToOpenAIChatMessages({
|
|
22
175
|
prompt,
|
|
@@ -61,7 +214,7 @@ function convertToOpenAIChatMessages({
|
|
|
61
214
|
messages.push({
|
|
62
215
|
role: "user",
|
|
63
216
|
content: content.map((part, index) => {
|
|
64
|
-
var
|
|
217
|
+
var _a15, _b, _c, _d;
|
|
65
218
|
switch (part.type) {
|
|
66
219
|
case "text": {
|
|
67
220
|
return { type: "text", text: part.text };
|
|
@@ -70,7 +223,7 @@ function convertToOpenAIChatMessages({
|
|
|
70
223
|
return {
|
|
71
224
|
type: "image_url",
|
|
72
225
|
image_url: {
|
|
73
|
-
url: part.image instanceof URL ? part.image.toString() : `data:${(
|
|
226
|
+
url: part.image instanceof URL ? part.image.toString() : `data:${(_a15 = part.mimeType) != null ? _a15 : "image/jpeg"};base64,${convertUint8ArrayToBase64(part.image)}`,
|
|
74
227
|
// OpenAI specific extension: image detail
|
|
75
228
|
detail: (_c = (_b = part.providerMetadata) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
|
|
76
229
|
}
|
|
@@ -188,8 +341,8 @@ function convertToOpenAIChatMessages({
|
|
|
188
341
|
|
|
189
342
|
// src/map-openai-chat-logprobs.ts
|
|
190
343
|
function mapOpenAIChatLogProbsOutput(logprobs) {
|
|
191
|
-
var
|
|
192
|
-
return (_b = (
|
|
344
|
+
var _a15, _b;
|
|
345
|
+
return (_b = (_a15 = logprobs == null ? void 0 : logprobs.content) == null ? void 0 : _a15.map(({ token, logprob, top_logprobs }) => ({
|
|
193
346
|
token,
|
|
194
347
|
logprob,
|
|
195
348
|
topLogprobs: top_logprobs ? top_logprobs.map(({ token: token2, logprob: logprob2 }) => ({
|
|
@@ -249,16 +402,13 @@ function getResponseMetadata({
|
|
|
249
402
|
}
|
|
250
403
|
|
|
251
404
|
// src/openai-prepare-tools.ts
|
|
252
|
-
import {
|
|
253
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
254
|
-
} from "@ai-sdk/provider";
|
|
255
405
|
function prepareTools({
|
|
256
406
|
mode,
|
|
257
407
|
useLegacyFunctionCalling = false,
|
|
258
408
|
structuredOutputs
|
|
259
409
|
}) {
|
|
260
|
-
var
|
|
261
|
-
const tools = ((
|
|
410
|
+
var _a15;
|
|
411
|
+
const tools = ((_a15 = mode.tools) == null ? void 0 : _a15.length) ? mode.tools : void 0;
|
|
262
412
|
const toolWarnings = [];
|
|
263
413
|
if (tools == null) {
|
|
264
414
|
return { tools: void 0, tool_choice: void 0, toolWarnings };
|
|
@@ -295,7 +445,7 @@ function prepareTools({
|
|
|
295
445
|
toolWarnings
|
|
296
446
|
};
|
|
297
447
|
case "required":
|
|
298
|
-
throw new
|
|
448
|
+
throw new UnsupportedFunctionalityError({
|
|
299
449
|
functionality: "useLegacyFunctionCalling and toolChoice: required"
|
|
300
450
|
});
|
|
301
451
|
default:
|
|
@@ -344,7 +494,7 @@ function prepareTools({
|
|
|
344
494
|
};
|
|
345
495
|
default: {
|
|
346
496
|
const _exhaustiveCheck = type;
|
|
347
|
-
throw new
|
|
497
|
+
throw new UnsupportedFunctionalityError({
|
|
348
498
|
functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
|
|
349
499
|
});
|
|
350
500
|
}
|
|
@@ -360,8 +510,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
360
510
|
this.config = config;
|
|
361
511
|
}
|
|
362
512
|
get supportsStructuredOutputs() {
|
|
363
|
-
var
|
|
364
|
-
return (
|
|
513
|
+
var _a15;
|
|
514
|
+
return (_a15 = this.settings.structuredOutputs) != null ? _a15 : isReasoningModel(this.modelId);
|
|
365
515
|
}
|
|
366
516
|
get defaultObjectGenerationMode() {
|
|
367
517
|
if (isAudioModel(this.modelId)) {
|
|
@@ -389,7 +539,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
389
539
|
seed,
|
|
390
540
|
providerMetadata
|
|
391
541
|
}) {
|
|
392
|
-
var
|
|
542
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h;
|
|
393
543
|
const type = mode.type;
|
|
394
544
|
const warnings = [];
|
|
395
545
|
if (topK != null) {
|
|
@@ -407,12 +557,12 @@ var OpenAIChatLanguageModel = class {
|
|
|
407
557
|
}
|
|
408
558
|
const useLegacyFunctionCalling = this.settings.useLegacyFunctionCalling;
|
|
409
559
|
if (useLegacyFunctionCalling && this.settings.parallelToolCalls === true) {
|
|
410
|
-
throw new
|
|
560
|
+
throw new UnsupportedFunctionalityError({
|
|
411
561
|
functionality: "useLegacyFunctionCalling with parallelToolCalls"
|
|
412
562
|
});
|
|
413
563
|
}
|
|
414
564
|
if (useLegacyFunctionCalling && this.supportsStructuredOutputs) {
|
|
415
|
-
throw new
|
|
565
|
+
throw new UnsupportedFunctionalityError({
|
|
416
566
|
functionality: "structuredOutputs with useLegacyFunctionCalling"
|
|
417
567
|
});
|
|
418
568
|
}
|
|
@@ -444,7 +594,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
444
594
|
json_schema: {
|
|
445
595
|
schema: responseFormat.schema,
|
|
446
596
|
strict: true,
|
|
447
|
-
name: (
|
|
597
|
+
name: (_a15 = responseFormat.name) != null ? _a15 : "response",
|
|
448
598
|
description: responseFormat.description
|
|
449
599
|
}
|
|
450
600
|
} : { type: "json_object" } : void 0,
|
|
@@ -607,7 +757,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
607
757
|
}
|
|
608
758
|
}
|
|
609
759
|
async doGenerate(options) {
|
|
610
|
-
var
|
|
760
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h;
|
|
611
761
|
const { args: body, warnings } = this.getArgs(options);
|
|
612
762
|
const {
|
|
613
763
|
responseHeaders,
|
|
@@ -629,7 +779,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
629
779
|
});
|
|
630
780
|
const { messages: rawPrompt, ...rawSettings } = body;
|
|
631
781
|
const choice = response.choices[0];
|
|
632
|
-
const completionTokenDetails = (
|
|
782
|
+
const completionTokenDetails = (_a15 = response.usage) == null ? void 0 : _a15.completion_tokens_details;
|
|
633
783
|
const promptTokenDetails = (_b = response.usage) == null ? void 0 : _b.prompt_tokens_details;
|
|
634
784
|
const providerMetadata = { openai: {} };
|
|
635
785
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null) {
|
|
@@ -654,10 +804,10 @@ var OpenAIChatLanguageModel = class {
|
|
|
654
804
|
args: choice.message.function_call.arguments
|
|
655
805
|
}
|
|
656
806
|
] : (_d = choice.message.tool_calls) == null ? void 0 : _d.map((toolCall) => {
|
|
657
|
-
var
|
|
807
|
+
var _a16;
|
|
658
808
|
return {
|
|
659
809
|
toolCallType: "function",
|
|
660
|
-
toolCallId: (
|
|
810
|
+
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|
|
661
811
|
toolName: toolCall.function.name,
|
|
662
812
|
args: toolCall.function.arguments
|
|
663
813
|
};
|
|
@@ -756,7 +906,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
756
906
|
stream: response.pipeThrough(
|
|
757
907
|
new TransformStream({
|
|
758
908
|
transform(chunk, controller) {
|
|
759
|
-
var
|
|
909
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
760
910
|
if (!chunk.success) {
|
|
761
911
|
finishReason = "error";
|
|
762
912
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
@@ -844,7 +994,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
844
994
|
message: `Expected 'id' to be a string.`
|
|
845
995
|
});
|
|
846
996
|
}
|
|
847
|
-
if (((
|
|
997
|
+
if (((_a15 = toolCallDelta.function) == null ? void 0 : _a15.name) == null) {
|
|
848
998
|
throw new InvalidResponseDataError({
|
|
849
999
|
data: toolCallDelta,
|
|
850
1000
|
message: `Expected 'function.name' to be a string.`
|
|
@@ -911,13 +1061,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
911
1061
|
}
|
|
912
1062
|
},
|
|
913
1063
|
flush(controller) {
|
|
914
|
-
var
|
|
1064
|
+
var _a15, _b;
|
|
915
1065
|
controller.enqueue({
|
|
916
1066
|
type: "finish",
|
|
917
1067
|
finishReason,
|
|
918
1068
|
logprobs,
|
|
919
1069
|
usage: {
|
|
920
|
-
promptTokens: (
|
|
1070
|
+
promptTokens: (_a15 = usage.promptTokens) != null ? _a15 : NaN,
|
|
921
1071
|
completionTokens: (_b = usage.completionTokens) != null ? _b : NaN
|
|
922
1072
|
},
|
|
923
1073
|
...providerMetadata != null ? { providerMetadata } : {}
|
|
@@ -1043,11 +1193,11 @@ function isAudioModel(modelId) {
|
|
|
1043
1193
|
return modelId.startsWith("gpt-4o-audio-preview");
|
|
1044
1194
|
}
|
|
1045
1195
|
function getSystemMessageMode(modelId) {
|
|
1046
|
-
var
|
|
1196
|
+
var _a15, _b;
|
|
1047
1197
|
if (!isReasoningModel(modelId)) {
|
|
1048
1198
|
return "system";
|
|
1049
1199
|
}
|
|
1050
|
-
return (_b = (
|
|
1200
|
+
return (_b = (_a15 = reasoningModels[modelId]) == null ? void 0 : _a15.systemMessageMode) != null ? _b : "developer";
|
|
1051
1201
|
}
|
|
1052
1202
|
var reasoningModels = {
|
|
1053
1203
|
"o1-mini": {
|
|
@@ -1083,9 +1233,6 @@ var reasoningModels = {
|
|
|
1083
1233
|
};
|
|
1084
1234
|
|
|
1085
1235
|
// src/openai-completion-language-model.ts
|
|
1086
|
-
import {
|
|
1087
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
1088
|
-
} from "@ai-sdk/provider";
|
|
1089
1236
|
import {
|
|
1090
1237
|
combineHeaders as combineHeaders2,
|
|
1091
1238
|
createEventSourceResponseHandler as createEventSourceResponseHandler2,
|
|
@@ -1095,10 +1242,6 @@ import {
|
|
|
1095
1242
|
import { z as z3 } from "zod";
|
|
1096
1243
|
|
|
1097
1244
|
// src/convert-to-openai-completion-prompt.ts
|
|
1098
|
-
import {
|
|
1099
|
-
InvalidPromptError,
|
|
1100
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
1101
|
-
} from "@ai-sdk/provider";
|
|
1102
1245
|
function convertToOpenAICompletionPrompt({
|
|
1103
1246
|
prompt,
|
|
1104
1247
|
inputFormat,
|
|
@@ -1130,7 +1273,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
1130
1273
|
return part.text;
|
|
1131
1274
|
}
|
|
1132
1275
|
case "image": {
|
|
1133
|
-
throw new
|
|
1276
|
+
throw new UnsupportedFunctionalityError({
|
|
1134
1277
|
functionality: "images"
|
|
1135
1278
|
});
|
|
1136
1279
|
}
|
|
@@ -1149,7 +1292,7 @@ ${userMessage}
|
|
|
1149
1292
|
return part.text;
|
|
1150
1293
|
}
|
|
1151
1294
|
case "tool-call": {
|
|
1152
|
-
throw new
|
|
1295
|
+
throw new UnsupportedFunctionalityError({
|
|
1153
1296
|
functionality: "tool-call messages"
|
|
1154
1297
|
});
|
|
1155
1298
|
}
|
|
@@ -1162,7 +1305,7 @@ ${assistantMessage}
|
|
|
1162
1305
|
break;
|
|
1163
1306
|
}
|
|
1164
1307
|
case "tool": {
|
|
1165
|
-
throw new
|
|
1308
|
+
throw new UnsupportedFunctionalityError({
|
|
1166
1309
|
functionality: "tool messages"
|
|
1167
1310
|
});
|
|
1168
1311
|
}
|
|
@@ -1221,7 +1364,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1221
1364
|
responseFormat,
|
|
1222
1365
|
seed
|
|
1223
1366
|
}) {
|
|
1224
|
-
var
|
|
1367
|
+
var _a15;
|
|
1225
1368
|
const type = mode.type;
|
|
1226
1369
|
const warnings = [];
|
|
1227
1370
|
if (topK != null) {
|
|
@@ -1262,25 +1405,25 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1262
1405
|
};
|
|
1263
1406
|
switch (type) {
|
|
1264
1407
|
case "regular": {
|
|
1265
|
-
if ((
|
|
1266
|
-
throw new
|
|
1408
|
+
if ((_a15 = mode.tools) == null ? void 0 : _a15.length) {
|
|
1409
|
+
throw new UnsupportedFunctionalityError({
|
|
1267
1410
|
functionality: "tools"
|
|
1268
1411
|
});
|
|
1269
1412
|
}
|
|
1270
1413
|
if (mode.toolChoice) {
|
|
1271
|
-
throw new
|
|
1414
|
+
throw new UnsupportedFunctionalityError({
|
|
1272
1415
|
functionality: "toolChoice"
|
|
1273
1416
|
});
|
|
1274
1417
|
}
|
|
1275
1418
|
return { args: baseArgs, warnings };
|
|
1276
1419
|
}
|
|
1277
1420
|
case "object-json": {
|
|
1278
|
-
throw new
|
|
1421
|
+
throw new UnsupportedFunctionalityError({
|
|
1279
1422
|
functionality: "object-json mode"
|
|
1280
1423
|
});
|
|
1281
1424
|
}
|
|
1282
1425
|
case "object-tool": {
|
|
1283
|
-
throw new
|
|
1426
|
+
throw new UnsupportedFunctionalityError({
|
|
1284
1427
|
functionality: "object-tool mode"
|
|
1285
1428
|
});
|
|
1286
1429
|
}
|
|
@@ -1466,9 +1609,6 @@ var openaiCompletionChunkSchema = z3.union([
|
|
|
1466
1609
|
]);
|
|
1467
1610
|
|
|
1468
1611
|
// src/openai-embedding-model.ts
|
|
1469
|
-
import {
|
|
1470
|
-
TooManyEmbeddingValuesForCallError
|
|
1471
|
-
} from "@ai-sdk/provider";
|
|
1472
1612
|
import {
|
|
1473
1613
|
combineHeaders as combineHeaders3,
|
|
1474
1614
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
@@ -1486,12 +1626,12 @@ var OpenAIEmbeddingModel = class {
|
|
|
1486
1626
|
return this.config.provider;
|
|
1487
1627
|
}
|
|
1488
1628
|
get maxEmbeddingsPerCall() {
|
|
1489
|
-
var
|
|
1490
|
-
return (
|
|
1629
|
+
var _a15;
|
|
1630
|
+
return (_a15 = this.settings.maxEmbeddingsPerCall) != null ? _a15 : 2048;
|
|
1491
1631
|
}
|
|
1492
1632
|
get supportsParallelCalls() {
|
|
1493
|
-
var
|
|
1494
|
-
return (
|
|
1633
|
+
var _a15;
|
|
1634
|
+
return (_a15 = this.settings.supportsParallelCalls) != null ? _a15 : true;
|
|
1495
1635
|
}
|
|
1496
1636
|
async doEmbed({
|
|
1497
1637
|
values,
|
|
@@ -1563,8 +1703,8 @@ var OpenAIImageModel = class {
|
|
|
1563
1703
|
this.specificationVersion = "v1";
|
|
1564
1704
|
}
|
|
1565
1705
|
get maxImagesPerCall() {
|
|
1566
|
-
var
|
|
1567
|
-
return (_b = (
|
|
1706
|
+
var _a15, _b;
|
|
1707
|
+
return (_b = (_a15 = this.settings.maxImagesPerCall) != null ? _a15 : modelMaxImagesPerCall[this.modelId]) != null ? _b : 1;
|
|
1568
1708
|
}
|
|
1569
1709
|
get provider() {
|
|
1570
1710
|
return this.config.provider;
|
|
@@ -1579,7 +1719,7 @@ var OpenAIImageModel = class {
|
|
|
1579
1719
|
headers,
|
|
1580
1720
|
abortSignal
|
|
1581
1721
|
}) {
|
|
1582
|
-
var
|
|
1722
|
+
var _a15, _b, _c, _d;
|
|
1583
1723
|
const warnings = [];
|
|
1584
1724
|
if (aspectRatio != null) {
|
|
1585
1725
|
warnings.push({
|
|
@@ -1591,7 +1731,7 @@ var OpenAIImageModel = class {
|
|
|
1591
1731
|
if (seed != null) {
|
|
1592
1732
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
1593
1733
|
}
|
|
1594
|
-
const currentDate = (_c = (_b = (
|
|
1734
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1595
1735
|
const { value: response, responseHeaders } = await postJsonToApi4({
|
|
1596
1736
|
url: this.config.url({
|
|
1597
1737
|
path: "/images/generations",
|
|
@@ -1717,7 +1857,7 @@ var OpenAITranscriptionModel = class {
|
|
|
1717
1857
|
mediaType,
|
|
1718
1858
|
providerOptions
|
|
1719
1859
|
}) {
|
|
1720
|
-
var
|
|
1860
|
+
var _a15, _b, _c, _d, _e;
|
|
1721
1861
|
const warnings = [];
|
|
1722
1862
|
const openAIOptions = parseProviderOptions({
|
|
1723
1863
|
provider: "openai",
|
|
@@ -1730,7 +1870,7 @@ var OpenAITranscriptionModel = class {
|
|
|
1730
1870
|
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
1731
1871
|
if (openAIOptions) {
|
|
1732
1872
|
const transcriptionModelOptions = {
|
|
1733
|
-
include: (
|
|
1873
|
+
include: (_a15 = openAIOptions.include) != null ? _a15 : void 0,
|
|
1734
1874
|
language: (_b = openAIOptions.language) != null ? _b : void 0,
|
|
1735
1875
|
prompt: (_c = openAIOptions.prompt) != null ? _c : void 0,
|
|
1736
1876
|
temperature: (_d = openAIOptions.temperature) != null ? _d : void 0,
|
|
@@ -1749,8 +1889,8 @@ var OpenAITranscriptionModel = class {
|
|
|
1749
1889
|
};
|
|
1750
1890
|
}
|
|
1751
1891
|
async doGenerate(options) {
|
|
1752
|
-
var
|
|
1753
|
-
const currentDate = (_c = (_b = (
|
|
1892
|
+
var _a15, _b, _c, _d, _e, _f;
|
|
1893
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1754
1894
|
const { formData, warnings } = this.getArgs(options);
|
|
1755
1895
|
const {
|
|
1756
1896
|
value: response,
|
|
@@ -1872,8 +2012,8 @@ var OpenAISpeechModel = class {
|
|
|
1872
2012
|
};
|
|
1873
2013
|
}
|
|
1874
2014
|
async doGenerate(options) {
|
|
1875
|
-
var
|
|
1876
|
-
const currentDate = (_c = (_b = (
|
|
2015
|
+
var _a15, _b, _c;
|
|
2016
|
+
const currentDate = (_c = (_b = (_a15 = this.config._internal) == null ? void 0 : _a15.currentDate) == null ? void 0 : _b.call(_a15)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1877
2017
|
const { requestBody, warnings } = this.getArgs(options);
|
|
1878
2018
|
const {
|
|
1879
2019
|
value: audio,
|
|
@@ -1916,12 +2056,9 @@ import {
|
|
|
1916
2056
|
parseProviderOptions as parseProviderOptions3,
|
|
1917
2057
|
postJsonToApi as postJsonToApi6
|
|
1918
2058
|
} from "@ai-sdk/provider-utils";
|
|
1919
|
-
import { z as
|
|
2059
|
+
import { z as z12 } from "zod";
|
|
1920
2060
|
|
|
1921
2061
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1922
|
-
import {
|
|
1923
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError6
|
|
1924
|
-
} from "@ai-sdk/provider";
|
|
1925
2062
|
import { convertUint8ArrayToBase64 as convertUint8ArrayToBase642 } from "@ai-sdk/provider-utils";
|
|
1926
2063
|
function convertToOpenAIResponsesMessages({
|
|
1927
2064
|
prompt,
|
|
@@ -1961,7 +2098,7 @@ function convertToOpenAIResponsesMessages({
|
|
|
1961
2098
|
messages.push({
|
|
1962
2099
|
role: "user",
|
|
1963
2100
|
content: content.map((part, index) => {
|
|
1964
|
-
var
|
|
2101
|
+
var _a15, _b, _c, _d;
|
|
1965
2102
|
switch (part.type) {
|
|
1966
2103
|
case "text": {
|
|
1967
2104
|
return { type: "input_text", text: part.text };
|
|
@@ -1969,14 +2106,14 @@ function convertToOpenAIResponsesMessages({
|
|
|
1969
2106
|
case "image": {
|
|
1970
2107
|
return {
|
|
1971
2108
|
type: "input_image",
|
|
1972
|
-
image_url: part.image instanceof URL ? part.image.toString() : `data:${(
|
|
2109
|
+
image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a15 = part.mimeType) != null ? _a15 : "image/jpeg"};base64,${convertUint8ArrayToBase642(part.image)}`,
|
|
1973
2110
|
// OpenAI specific extension: image detail
|
|
1974
2111
|
detail: (_c = (_b = part.providerMetadata) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
|
|
1975
2112
|
};
|
|
1976
2113
|
}
|
|
1977
2114
|
case "file": {
|
|
1978
2115
|
if (part.data instanceof URL) {
|
|
1979
|
-
throw new
|
|
2116
|
+
throw new UnsupportedFunctionalityError({
|
|
1980
2117
|
functionality: "File URLs in user messages"
|
|
1981
2118
|
});
|
|
1982
2119
|
}
|
|
@@ -1989,7 +2126,7 @@ function convertToOpenAIResponsesMessages({
|
|
|
1989
2126
|
};
|
|
1990
2127
|
}
|
|
1991
2128
|
default: {
|
|
1992
|
-
throw new
|
|
2129
|
+
throw new UnsupportedFunctionalityError({
|
|
1993
2130
|
functionality: "Only PDF files are supported in user messages"
|
|
1994
2131
|
});
|
|
1995
2132
|
}
|
|
@@ -2060,16 +2197,76 @@ function mapOpenAIResponseFinishReason({
|
|
|
2060
2197
|
}
|
|
2061
2198
|
}
|
|
2062
2199
|
|
|
2200
|
+
// src/tool/code-interpreter.ts
|
|
2201
|
+
import { z as z8 } from "zod";
|
|
2202
|
+
var codeInterpreterArgsSchema = z8.object({
|
|
2203
|
+
container: z8.union([
|
|
2204
|
+
z8.string(),
|
|
2205
|
+
z8.object({
|
|
2206
|
+
fileIds: z8.array(z8.string()).optional()
|
|
2207
|
+
})
|
|
2208
|
+
]).optional()
|
|
2209
|
+
});
|
|
2210
|
+
|
|
2211
|
+
// src/tool/file-search.ts
|
|
2212
|
+
import { z as z9 } from "zod";
|
|
2213
|
+
var comparisonFilterSchema = z9.object({
|
|
2214
|
+
key: z9.string(),
|
|
2215
|
+
type: z9.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
2216
|
+
value: z9.union([z9.string(), z9.number(), z9.boolean()])
|
|
2217
|
+
});
|
|
2218
|
+
var compoundFilterSchema = z9.object({
|
|
2219
|
+
type: z9.enum(["and", "or"]),
|
|
2220
|
+
filters: z9.array(
|
|
2221
|
+
z9.union([comparisonFilterSchema, z9.lazy(() => compoundFilterSchema)])
|
|
2222
|
+
)
|
|
2223
|
+
});
|
|
2224
|
+
var filtersSchema = z9.union([comparisonFilterSchema, compoundFilterSchema]);
|
|
2225
|
+
var fileSearchArgsSchema = z9.object({
|
|
2226
|
+
vectorStoreIds: z9.array(z9.string()).optional(),
|
|
2227
|
+
maxNumResults: z9.number().optional(),
|
|
2228
|
+
ranking: z9.object({
|
|
2229
|
+
ranker: z9.enum(["auto", "default-2024-08-21"]).optional()
|
|
2230
|
+
}).optional(),
|
|
2231
|
+
filters: filtersSchema.optional()
|
|
2232
|
+
});
|
|
2233
|
+
|
|
2234
|
+
// src/tool/web-search.ts
|
|
2235
|
+
import { z as z10 } from "zod";
|
|
2236
|
+
var webSearchArgsSchema = z10.object({
|
|
2237
|
+
filters: z10.object({
|
|
2238
|
+
allowedDomains: z10.array(z10.string()).optional()
|
|
2239
|
+
}).optional(),
|
|
2240
|
+
searchContextSize: z10.enum(["low", "medium", "high"]).optional(),
|
|
2241
|
+
userLocation: z10.object({
|
|
2242
|
+
type: z10.literal("approximate"),
|
|
2243
|
+
country: z10.string().optional(),
|
|
2244
|
+
city: z10.string().optional(),
|
|
2245
|
+
region: z10.string().optional(),
|
|
2246
|
+
timezone: z10.string().optional()
|
|
2247
|
+
}).optional()
|
|
2248
|
+
});
|
|
2249
|
+
|
|
2250
|
+
// src/tool/web-search-preview.ts
|
|
2251
|
+
import { z as z11 } from "zod";
|
|
2252
|
+
var webSearchPreviewArgsSchema = z11.object({
|
|
2253
|
+
searchContextSize: z11.enum(["low", "medium", "high"]).optional(),
|
|
2254
|
+
userLocation: z11.object({
|
|
2255
|
+
type: z11.literal("approximate"),
|
|
2256
|
+
country: z11.string().optional(),
|
|
2257
|
+
city: z11.string().optional(),
|
|
2258
|
+
region: z11.string().optional(),
|
|
2259
|
+
timezone: z11.string().optional()
|
|
2260
|
+
}).optional()
|
|
2261
|
+
});
|
|
2262
|
+
|
|
2063
2263
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2064
|
-
import {
|
|
2065
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError7
|
|
2066
|
-
} from "@ai-sdk/provider";
|
|
2067
2264
|
function prepareResponsesTools({
|
|
2068
2265
|
mode,
|
|
2069
2266
|
strict
|
|
2070
2267
|
}) {
|
|
2071
|
-
var
|
|
2072
|
-
const tools = ((
|
|
2268
|
+
var _a15;
|
|
2269
|
+
const tools = ((_a15 = mode.tools) == null ? void 0 : _a15.length) ? mode.tools : void 0;
|
|
2073
2270
|
const toolWarnings = [];
|
|
2074
2271
|
if (tools == null) {
|
|
2075
2272
|
return { tools: void 0, tool_choice: void 0, toolWarnings };
|
|
@@ -2089,31 +2286,48 @@ function prepareResponsesTools({
|
|
|
2089
2286
|
break;
|
|
2090
2287
|
case "provider-defined":
|
|
2091
2288
|
switch (tool.id) {
|
|
2092
|
-
case "openai.file_search":
|
|
2289
|
+
case "openai.file_search": {
|
|
2290
|
+
const args = fileSearchArgsSchema.parse(tool.args);
|
|
2093
2291
|
openaiTools.push({
|
|
2094
2292
|
type: "file_search",
|
|
2095
|
-
vector_store_ids:
|
|
2096
|
-
max_num_results:
|
|
2097
|
-
ranking:
|
|
2098
|
-
filters:
|
|
2293
|
+
vector_store_ids: args.vectorStoreIds,
|
|
2294
|
+
max_num_results: args.maxNumResults,
|
|
2295
|
+
ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
|
|
2296
|
+
filters: args.filters
|
|
2099
2297
|
});
|
|
2100
2298
|
break;
|
|
2101
|
-
|
|
2299
|
+
}
|
|
2300
|
+
case "openai.web_search_preview": {
|
|
2301
|
+
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
2102
2302
|
openaiTools.push({
|
|
2103
2303
|
type: "web_search_preview",
|
|
2104
|
-
search_context_size:
|
|
2105
|
-
user_location:
|
|
2304
|
+
search_context_size: args.searchContextSize,
|
|
2305
|
+
user_location: args.userLocation
|
|
2306
|
+
});
|
|
2307
|
+
break;
|
|
2308
|
+
}
|
|
2309
|
+
case "openai.web_search": {
|
|
2310
|
+
const args = webSearchArgsSchema.parse(tool.args);
|
|
2311
|
+
openaiTools.push({
|
|
2312
|
+
type: "web_search",
|
|
2313
|
+
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
2314
|
+
search_context_size: args.searchContextSize,
|
|
2315
|
+
user_location: args.userLocation
|
|
2106
2316
|
});
|
|
2107
2317
|
break;
|
|
2108
|
-
|
|
2318
|
+
}
|
|
2319
|
+
case "openai.code_interpreter": {
|
|
2320
|
+
const args = codeInterpreterArgsSchema.parse(tool.args);
|
|
2109
2321
|
openaiTools.push({
|
|
2110
2322
|
type: "code_interpreter",
|
|
2111
|
-
container:
|
|
2323
|
+
container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
|
|
2112
2324
|
});
|
|
2113
2325
|
break;
|
|
2114
|
-
|
|
2326
|
+
}
|
|
2327
|
+
default: {
|
|
2115
2328
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
2116
2329
|
break;
|
|
2330
|
+
}
|
|
2117
2331
|
}
|
|
2118
2332
|
break;
|
|
2119
2333
|
default:
|
|
@@ -2130,37 +2344,15 @@ function prepareResponsesTools({
|
|
|
2130
2344
|
case "none":
|
|
2131
2345
|
case "required":
|
|
2132
2346
|
return { tools: openaiTools, tool_choice: type, toolWarnings };
|
|
2133
|
-
case "tool":
|
|
2134
|
-
if (toolChoice.toolName === "web_search_preview") {
|
|
2135
|
-
return {
|
|
2136
|
-
tools: openaiTools,
|
|
2137
|
-
tool_choice: {
|
|
2138
|
-
type: "web_search_preview"
|
|
2139
|
-
},
|
|
2140
|
-
toolWarnings
|
|
2141
|
-
};
|
|
2142
|
-
}
|
|
2143
|
-
if (toolChoice.toolName === "code_interpreter") {
|
|
2144
|
-
return {
|
|
2145
|
-
tools: openaiTools,
|
|
2146
|
-
tool_choice: {
|
|
2147
|
-
type: "code_interpreter"
|
|
2148
|
-
},
|
|
2149
|
-
toolWarnings
|
|
2150
|
-
};
|
|
2151
|
-
}
|
|
2347
|
+
case "tool":
|
|
2152
2348
|
return {
|
|
2153
2349
|
tools: openaiTools,
|
|
2154
|
-
tool_choice: {
|
|
2155
|
-
type: "function",
|
|
2156
|
-
name: toolChoice.toolName
|
|
2157
|
-
},
|
|
2350
|
+
tool_choice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
2158
2351
|
toolWarnings
|
|
2159
2352
|
};
|
|
2160
|
-
}
|
|
2161
2353
|
default: {
|
|
2162
2354
|
const _exhaustiveCheck = type;
|
|
2163
|
-
throw new
|
|
2355
|
+
throw new UnsupportedFunctionalityError({
|
|
2164
2356
|
functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
|
|
2165
2357
|
});
|
|
2166
2358
|
}
|
|
@@ -2193,7 +2385,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2193
2385
|
providerMetadata,
|
|
2194
2386
|
responseFormat
|
|
2195
2387
|
}) {
|
|
2196
|
-
var
|
|
2388
|
+
var _a15, _b, _c;
|
|
2197
2389
|
const warnings = [];
|
|
2198
2390
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
2199
2391
|
const type = mode.type;
|
|
@@ -2238,7 +2430,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2238
2430
|
providerOptions: providerMetadata,
|
|
2239
2431
|
schema: openaiResponsesProviderOptionsSchema
|
|
2240
2432
|
});
|
|
2241
|
-
const isStrict = (
|
|
2433
|
+
const isStrict = (_a15 = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a15 : true;
|
|
2242
2434
|
console.log("openaiOptions", JSON.stringify(openaiOptions));
|
|
2243
2435
|
const baseArgs = {
|
|
2244
2436
|
model: this.modelId,
|
|
@@ -2356,7 +2548,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2356
2548
|
}
|
|
2357
2549
|
}
|
|
2358
2550
|
async doGenerate(options) {
|
|
2359
|
-
var
|
|
2551
|
+
var _a15, _b, _c, _d, _e, _f, _g;
|
|
2360
2552
|
const { args: body, warnings } = this.getArgs(options);
|
|
2361
2553
|
const {
|
|
2362
2554
|
responseHeaders,
|
|
@@ -2371,55 +2563,107 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2371
2563
|
body,
|
|
2372
2564
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2373
2565
|
successfulResponseHandler: createJsonResponseHandler6(
|
|
2374
|
-
|
|
2375
|
-
id:
|
|
2376
|
-
created_at:
|
|
2377
|
-
model:
|
|
2378
|
-
output:
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
type:
|
|
2382
|
-
role:
|
|
2383
|
-
content:
|
|
2384
|
-
|
|
2385
|
-
type:
|
|
2386
|
-
text:
|
|
2387
|
-
annotations:
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2566
|
+
z12.object({
|
|
2567
|
+
id: z12.string(),
|
|
2568
|
+
created_at: z12.number(),
|
|
2569
|
+
model: z12.string(),
|
|
2570
|
+
output: z12.array(
|
|
2571
|
+
z12.discriminatedUnion("type", [
|
|
2572
|
+
z12.object({
|
|
2573
|
+
type: z12.literal("message"),
|
|
2574
|
+
role: z12.literal("assistant"),
|
|
2575
|
+
content: z12.array(
|
|
2576
|
+
z12.object({
|
|
2577
|
+
type: z12.literal("output_text"),
|
|
2578
|
+
text: z12.string(),
|
|
2579
|
+
annotations: z12.array(
|
|
2580
|
+
z12.discriminatedUnion("type", [
|
|
2581
|
+
z12.object({
|
|
2582
|
+
type: z12.literal("url_citation"),
|
|
2583
|
+
start_index: z12.number(),
|
|
2584
|
+
end_index: z12.number(),
|
|
2585
|
+
url: z12.string(),
|
|
2586
|
+
title: z12.string()
|
|
2587
|
+
}),
|
|
2588
|
+
z12.object({
|
|
2589
|
+
type: z12.literal("file_citation"),
|
|
2590
|
+
file_id: z12.string(),
|
|
2591
|
+
filename: z12.string().nullish(),
|
|
2592
|
+
index: z12.number().nullish(),
|
|
2593
|
+
start_index: z12.number().nullish(),
|
|
2594
|
+
end_index: z12.number().nullish(),
|
|
2595
|
+
quote: z12.string().nullish()
|
|
2596
|
+
}),
|
|
2597
|
+
z12.object({
|
|
2598
|
+
type: z12.literal("container_file_citation")
|
|
2599
|
+
})
|
|
2600
|
+
])
|
|
2395
2601
|
)
|
|
2396
2602
|
})
|
|
2397
2603
|
)
|
|
2398
2604
|
}),
|
|
2399
|
-
|
|
2400
|
-
type:
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2605
|
+
z12.object({
|
|
2606
|
+
type: z12.literal("code_interpreter_call")
|
|
2607
|
+
}),
|
|
2608
|
+
z12.object({
|
|
2609
|
+
type: z12.literal("function_call"),
|
|
2610
|
+
call_id: z12.string(),
|
|
2611
|
+
name: z12.string(),
|
|
2612
|
+
arguments: z12.string()
|
|
2404
2613
|
}),
|
|
2405
|
-
|
|
2406
|
-
type:
|
|
2614
|
+
z12.object({
|
|
2615
|
+
type: z12.literal("web_search_call"),
|
|
2616
|
+
id: z12.string(),
|
|
2617
|
+
status: z12.string().optional(),
|
|
2618
|
+
action: z12.discriminatedUnion("type", [
|
|
2619
|
+
z12.object({
|
|
2620
|
+
type: z12.literal("search"),
|
|
2621
|
+
query: z12.string().nullish()
|
|
2622
|
+
}),
|
|
2623
|
+
z12.object({
|
|
2624
|
+
type: z12.literal("open_page"),
|
|
2625
|
+
url: z12.string()
|
|
2626
|
+
}),
|
|
2627
|
+
z12.object({
|
|
2628
|
+
type: z12.literal("find"),
|
|
2629
|
+
url: z12.string(),
|
|
2630
|
+
pattern: z12.string()
|
|
2631
|
+
})
|
|
2632
|
+
]).nullish()
|
|
2407
2633
|
}),
|
|
2408
|
-
|
|
2409
|
-
type:
|
|
2634
|
+
z12.object({
|
|
2635
|
+
type: z12.literal("computer_call"),
|
|
2636
|
+
id: z12.string(),
|
|
2637
|
+
status: z12.string().optional()
|
|
2638
|
+
}),
|
|
2639
|
+
z12.object({
|
|
2640
|
+
type: z12.literal("file_search_call"),
|
|
2641
|
+
id: z12.string(),
|
|
2642
|
+
status: z12.string().optional(),
|
|
2643
|
+
queries: z12.array(z12.string()).nullish(),
|
|
2644
|
+
results: z12.array(
|
|
2645
|
+
z12.object({
|
|
2646
|
+
attributes: z12.object({
|
|
2647
|
+
file_id: z12.string(),
|
|
2648
|
+
filename: z12.string(),
|
|
2649
|
+
score: z12.number(),
|
|
2650
|
+
text: z12.string()
|
|
2651
|
+
})
|
|
2652
|
+
})
|
|
2653
|
+
).nullish()
|
|
2410
2654
|
}),
|
|
2411
|
-
|
|
2412
|
-
type:
|
|
2413
|
-
summary:
|
|
2414
|
-
|
|
2415
|
-
type:
|
|
2416
|
-
text:
|
|
2655
|
+
z12.object({
|
|
2656
|
+
type: z12.literal("reasoning"),
|
|
2657
|
+
summary: z12.array(
|
|
2658
|
+
z12.object({
|
|
2659
|
+
type: z12.literal("summary_text"),
|
|
2660
|
+
text: z12.string()
|
|
2417
2661
|
})
|
|
2418
2662
|
)
|
|
2419
2663
|
})
|
|
2420
2664
|
])
|
|
2421
2665
|
),
|
|
2422
|
-
incomplete_details:
|
|
2666
|
+
incomplete_details: z12.object({ reason: z12.string() }).nullable(),
|
|
2423
2667
|
usage: usageSchema
|
|
2424
2668
|
})
|
|
2425
2669
|
),
|
|
@@ -2427,13 +2671,39 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2427
2671
|
fetch: this.config.fetch
|
|
2428
2672
|
});
|
|
2429
2673
|
const outputTextElements = response.output.filter((output) => output.type === "message").flatMap((output) => output.content).filter((content) => content.type === "output_text");
|
|
2430
|
-
const toolCalls =
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2674
|
+
const toolCalls = [];
|
|
2675
|
+
for (const output of response.output) {
|
|
2676
|
+
if (output.type === "function_call") {
|
|
2677
|
+
toolCalls.push({
|
|
2678
|
+
toolCallType: "function",
|
|
2679
|
+
toolCallId: output.call_id,
|
|
2680
|
+
toolName: output.name,
|
|
2681
|
+
args: output.arguments
|
|
2682
|
+
});
|
|
2683
|
+
} else if (output.type === "web_search_call") {
|
|
2684
|
+
toolCalls.push({
|
|
2685
|
+
toolCallType: "function",
|
|
2686
|
+
toolCallId: output.id,
|
|
2687
|
+
toolName: "web_search_preview",
|
|
2688
|
+
args: JSON.stringify({ action: output.action })
|
|
2689
|
+
});
|
|
2690
|
+
} else if (output.type === "computer_call") {
|
|
2691
|
+
toolCalls.push({
|
|
2692
|
+
toolCallType: "function",
|
|
2693
|
+
toolCallId: output.id,
|
|
2694
|
+
toolName: "computer_use",
|
|
2695
|
+
args: ""
|
|
2696
|
+
});
|
|
2697
|
+
} else if (output.type === "file_search_call") {
|
|
2698
|
+
toolCalls.push({
|
|
2699
|
+
toolCallType: "function",
|
|
2700
|
+
toolCallId: output.id,
|
|
2701
|
+
toolName: "file_search",
|
|
2702
|
+
args: ""
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
const reasoningSummary = (_b = (_a15 = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a15.summary) != null ? _b : null;
|
|
2437
2707
|
console.log(JSON.stringify({
|
|
2438
2708
|
msg: "ai-sdk: content annotations",
|
|
2439
2709
|
annotations: outputTextElements.flatMap((content) => content.annotations)
|
|
@@ -2442,13 +2712,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2442
2712
|
text: outputTextElements.map((content) => content.text).join("\n"),
|
|
2443
2713
|
sources: outputTextElements.flatMap(
|
|
2444
2714
|
(content) => content.annotations.map((annotation) => {
|
|
2445
|
-
var
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2715
|
+
var _a16, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i;
|
|
2716
|
+
if (annotation.type === "url_citation") {
|
|
2717
|
+
return {
|
|
2718
|
+
sourceType: "url",
|
|
2719
|
+
id: (_c2 = (_b2 = (_a16 = this.config).generateId) == null ? void 0 : _b2.call(_a16)) != null ? _c2 : generateId2(),
|
|
2720
|
+
url: annotation.url,
|
|
2721
|
+
title: annotation.title
|
|
2722
|
+
};
|
|
2723
|
+
} else if (annotation.type === "file_citation") {
|
|
2724
|
+
return {
|
|
2725
|
+
sourceType: "document",
|
|
2726
|
+
id: (_f2 = (_e2 = (_d2 = this.config).generateId) == null ? void 0 : _e2.call(_d2)) != null ? _f2 : generateId2(),
|
|
2727
|
+
mediaType: "text/plain",
|
|
2728
|
+
title: annotation.quote || annotation.filename || "Document",
|
|
2729
|
+
filename: annotation.filename,
|
|
2730
|
+
quote: annotation.quote
|
|
2731
|
+
};
|
|
2732
|
+
} else {
|
|
2733
|
+
return {
|
|
2734
|
+
sourceType: "url",
|
|
2735
|
+
id: (_i = (_h = (_g2 = this.config).generateId) == null ? void 0 : _h.call(_g2)) != null ? _i : generateId2(),
|
|
2736
|
+
url: "",
|
|
2737
|
+
title: "Unknown Source"
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2452
2740
|
})
|
|
2453
2741
|
),
|
|
2454
2742
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -2522,7 +2810,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2522
2810
|
stream: response.pipeThrough(
|
|
2523
2811
|
new TransformStream({
|
|
2524
2812
|
transform(chunk, controller) {
|
|
2525
|
-
var
|
|
2813
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2526
2814
|
if (!chunk.success) {
|
|
2527
2815
|
finishReason = "error";
|
|
2528
2816
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
@@ -2542,6 +2830,42 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2542
2830
|
toolName: value.item.name,
|
|
2543
2831
|
argsTextDelta: value.item.arguments
|
|
2544
2832
|
});
|
|
2833
|
+
} else if (value.item.type === "web_search_call") {
|
|
2834
|
+
ongoingToolCalls[value.output_index] = {
|
|
2835
|
+
toolName: "web_search_preview",
|
|
2836
|
+
toolCallId: value.item.id
|
|
2837
|
+
};
|
|
2838
|
+
controller.enqueue({
|
|
2839
|
+
type: "tool-call-delta",
|
|
2840
|
+
toolCallType: "function",
|
|
2841
|
+
toolCallId: value.item.id,
|
|
2842
|
+
toolName: "web_search_preview",
|
|
2843
|
+
argsTextDelta: JSON.stringify({ action: value.item.action })
|
|
2844
|
+
});
|
|
2845
|
+
} else if (value.item.type === "computer_call") {
|
|
2846
|
+
ongoingToolCalls[value.output_index] = {
|
|
2847
|
+
toolName: "computer_use",
|
|
2848
|
+
toolCallId: value.item.id
|
|
2849
|
+
};
|
|
2850
|
+
controller.enqueue({
|
|
2851
|
+
type: "tool-call-delta",
|
|
2852
|
+
toolCallType: "function",
|
|
2853
|
+
toolCallId: value.item.id,
|
|
2854
|
+
toolName: "computer_use",
|
|
2855
|
+
argsTextDelta: ""
|
|
2856
|
+
});
|
|
2857
|
+
} else if (value.item.type === "file_search_call") {
|
|
2858
|
+
ongoingToolCalls[value.output_index] = {
|
|
2859
|
+
toolName: "file_search",
|
|
2860
|
+
toolCallId: value.item.id
|
|
2861
|
+
};
|
|
2862
|
+
controller.enqueue({
|
|
2863
|
+
type: "tool-call-delta",
|
|
2864
|
+
toolCallType: "function",
|
|
2865
|
+
toolCallId: value.item.id,
|
|
2866
|
+
toolName: "file_search",
|
|
2867
|
+
argsTextDelta: ""
|
|
2868
|
+
});
|
|
2545
2869
|
}
|
|
2546
2870
|
} else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
2547
2871
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
@@ -2572,19 +2896,54 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2572
2896
|
type: "reasoning",
|
|
2573
2897
|
textDelta: value.delta
|
|
2574
2898
|
});
|
|
2575
|
-
} else if (isResponseOutputItemDoneChunk(value)
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2899
|
+
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
2900
|
+
if (value.item.type === "function_call") {
|
|
2901
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2902
|
+
hasToolCalls = true;
|
|
2903
|
+
controller.enqueue({
|
|
2904
|
+
type: "tool-call",
|
|
2905
|
+
toolCallType: "function",
|
|
2906
|
+
toolCallId: value.item.call_id,
|
|
2907
|
+
toolName: value.item.name,
|
|
2908
|
+
args: value.item.arguments
|
|
2909
|
+
});
|
|
2910
|
+
} else if (value.item.type === "web_search_call") {
|
|
2911
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2912
|
+
hasToolCalls = true;
|
|
2913
|
+
controller.enqueue({
|
|
2914
|
+
type: "tool-call",
|
|
2915
|
+
toolCallType: "function",
|
|
2916
|
+
toolCallId: value.item.id,
|
|
2917
|
+
toolName: "web_search_preview",
|
|
2918
|
+
args: JSON.stringify({ action: value.item.action })
|
|
2919
|
+
});
|
|
2920
|
+
} else if (value.item.type === "computer_call") {
|
|
2921
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2922
|
+
hasToolCalls = true;
|
|
2923
|
+
controller.enqueue({
|
|
2924
|
+
type: "tool-call",
|
|
2925
|
+
toolCallType: "function",
|
|
2926
|
+
toolCallId: value.item.id,
|
|
2927
|
+
toolName: "computer_use",
|
|
2928
|
+
args: ""
|
|
2929
|
+
});
|
|
2930
|
+
} else if (value.item.type === "file_search_call") {
|
|
2931
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2932
|
+
hasToolCalls = true;
|
|
2933
|
+
controller.enqueue({
|
|
2934
|
+
type: "tool-call",
|
|
2935
|
+
toolCallType: "function",
|
|
2936
|
+
toolCallId: value.item.id,
|
|
2937
|
+
toolName: "file_search",
|
|
2938
|
+
args: JSON.stringify({
|
|
2939
|
+
queries: value.item.queries,
|
|
2940
|
+
results: value.item.results
|
|
2941
|
+
})
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2585
2944
|
} else if (isResponseFinishedChunk(value)) {
|
|
2586
2945
|
finishReason = mapOpenAIResponseFinishReason({
|
|
2587
|
-
finishReason: (
|
|
2946
|
+
finishReason: (_a15 = value.response.incomplete_details) == null ? void 0 : _a15.reason,
|
|
2588
2947
|
hasToolCalls
|
|
2589
2948
|
});
|
|
2590
2949
|
promptTokens = value.response.usage.input_tokens;
|
|
@@ -2596,21 +2955,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2596
2955
|
msg: "ai-sdk: source (stream)",
|
|
2597
2956
|
source: value.annotation
|
|
2598
2957
|
}));
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2958
|
+
if (value.annotation.type === "url_citation") {
|
|
2959
|
+
controller.enqueue({
|
|
2960
|
+
type: "source",
|
|
2961
|
+
source: {
|
|
2962
|
+
sourceType: "url",
|
|
2963
|
+
id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : generateId2(),
|
|
2964
|
+
url: value.annotation.url,
|
|
2965
|
+
title: value.annotation.title
|
|
2966
|
+
}
|
|
2967
|
+
});
|
|
2968
|
+
} else if (value.annotation.type === "file_citation") {
|
|
2969
|
+
controller.enqueue({
|
|
2970
|
+
type: "source",
|
|
2971
|
+
source: {
|
|
2972
|
+
sourceType: "document",
|
|
2973
|
+
id: (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId2(),
|
|
2974
|
+
mediaType: "text/plain",
|
|
2975
|
+
title: value.annotation.quote || value.annotation.filename || "Document",
|
|
2607
2976
|
filename: value.annotation.filename,
|
|
2608
|
-
|
|
2609
|
-
}
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
}
|
|
2613
|
-
});
|
|
2977
|
+
quote: value.annotation.quote
|
|
2978
|
+
}
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2614
2981
|
}
|
|
2615
2982
|
},
|
|
2616
2983
|
flush(controller) {
|
|
@@ -2641,91 +3008,168 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2641
3008
|
};
|
|
2642
3009
|
}
|
|
2643
3010
|
};
|
|
2644
|
-
var usageSchema =
|
|
2645
|
-
input_tokens:
|
|
2646
|
-
input_tokens_details:
|
|
2647
|
-
output_tokens:
|
|
2648
|
-
output_tokens_details:
|
|
3011
|
+
var usageSchema = z12.object({
|
|
3012
|
+
input_tokens: z12.number(),
|
|
3013
|
+
input_tokens_details: z12.object({ cached_tokens: z12.number().nullish() }).nullish(),
|
|
3014
|
+
output_tokens: z12.number(),
|
|
3015
|
+
output_tokens_details: z12.object({ reasoning_tokens: z12.number().nullish() }).nullish()
|
|
2649
3016
|
});
|
|
2650
|
-
var textDeltaChunkSchema =
|
|
2651
|
-
type:
|
|
2652
|
-
delta:
|
|
3017
|
+
var textDeltaChunkSchema = z12.object({
|
|
3018
|
+
type: z12.literal("response.output_text.delta"),
|
|
3019
|
+
delta: z12.string()
|
|
2653
3020
|
});
|
|
2654
|
-
var responseFinishedChunkSchema =
|
|
2655
|
-
type:
|
|
2656
|
-
response:
|
|
2657
|
-
incomplete_details:
|
|
3021
|
+
var responseFinishedChunkSchema = z12.object({
|
|
3022
|
+
type: z12.enum(["response.completed", "response.incomplete"]),
|
|
3023
|
+
response: z12.object({
|
|
3024
|
+
incomplete_details: z12.object({ reason: z12.string() }).nullish(),
|
|
2658
3025
|
usage: usageSchema
|
|
2659
3026
|
})
|
|
2660
3027
|
});
|
|
2661
|
-
var responseCreatedChunkSchema =
|
|
2662
|
-
type:
|
|
2663
|
-
response:
|
|
2664
|
-
id:
|
|
2665
|
-
created_at:
|
|
2666
|
-
model:
|
|
3028
|
+
var responseCreatedChunkSchema = z12.object({
|
|
3029
|
+
type: z12.literal("response.created"),
|
|
3030
|
+
response: z12.object({
|
|
3031
|
+
id: z12.string(),
|
|
3032
|
+
created_at: z12.number(),
|
|
3033
|
+
model: z12.string()
|
|
2667
3034
|
})
|
|
2668
3035
|
});
|
|
2669
|
-
var responseOutputItemDoneSchema =
|
|
2670
|
-
type:
|
|
2671
|
-
output_index:
|
|
2672
|
-
item:
|
|
2673
|
-
|
|
2674
|
-
type:
|
|
3036
|
+
var responseOutputItemDoneSchema = z12.object({
|
|
3037
|
+
type: z12.literal("response.output_item.done"),
|
|
3038
|
+
output_index: z12.number(),
|
|
3039
|
+
item: z12.discriminatedUnion("type", [
|
|
3040
|
+
z12.object({
|
|
3041
|
+
type: z12.literal("message")
|
|
2675
3042
|
}),
|
|
2676
|
-
|
|
2677
|
-
type:
|
|
2678
|
-
id:
|
|
2679
|
-
call_id:
|
|
2680
|
-
name:
|
|
2681
|
-
arguments:
|
|
2682
|
-
status:
|
|
3043
|
+
z12.object({
|
|
3044
|
+
type: z12.literal("function_call"),
|
|
3045
|
+
id: z12.string(),
|
|
3046
|
+
call_id: z12.string(),
|
|
3047
|
+
name: z12.string(),
|
|
3048
|
+
arguments: z12.string(),
|
|
3049
|
+
status: z12.literal("completed")
|
|
3050
|
+
}),
|
|
3051
|
+
z12.object({
|
|
3052
|
+
type: z12.literal("web_search_call"),
|
|
3053
|
+
id: z12.string(),
|
|
3054
|
+
status: z12.string(),
|
|
3055
|
+
action: z12.discriminatedUnion("type", [
|
|
3056
|
+
z12.object({
|
|
3057
|
+
type: z12.literal("search"),
|
|
3058
|
+
query: z12.string().nullish()
|
|
3059
|
+
}),
|
|
3060
|
+
z12.object({
|
|
3061
|
+
type: z12.literal("open_page"),
|
|
3062
|
+
url: z12.string()
|
|
3063
|
+
}),
|
|
3064
|
+
z12.object({
|
|
3065
|
+
type: z12.literal("find"),
|
|
3066
|
+
url: z12.string(),
|
|
3067
|
+
pattern: z12.string()
|
|
3068
|
+
})
|
|
3069
|
+
]).nullish()
|
|
3070
|
+
}),
|
|
3071
|
+
z12.object({
|
|
3072
|
+
type: z12.literal("computer_call"),
|
|
3073
|
+
id: z12.string(),
|
|
3074
|
+
status: z12.literal("completed")
|
|
3075
|
+
}),
|
|
3076
|
+
z12.object({
|
|
3077
|
+
type: z12.literal("file_search_call"),
|
|
3078
|
+
id: z12.string(),
|
|
3079
|
+
status: z12.literal("completed"),
|
|
3080
|
+
queries: z12.array(z12.string()).nullish(),
|
|
3081
|
+
results: z12.array(
|
|
3082
|
+
z12.object({
|
|
3083
|
+
attributes: z12.object({
|
|
3084
|
+
file_id: z12.string(),
|
|
3085
|
+
filename: z12.string(),
|
|
3086
|
+
score: z12.number(),
|
|
3087
|
+
text: z12.string()
|
|
3088
|
+
})
|
|
3089
|
+
})
|
|
3090
|
+
).nullish()
|
|
2683
3091
|
})
|
|
2684
3092
|
])
|
|
2685
3093
|
});
|
|
2686
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2687
|
-
type:
|
|
2688
|
-
item_id:
|
|
2689
|
-
output_index:
|
|
2690
|
-
delta:
|
|
3094
|
+
var responseFunctionCallArgumentsDeltaSchema = z12.object({
|
|
3095
|
+
type: z12.literal("response.function_call_arguments.delta"),
|
|
3096
|
+
item_id: z12.string(),
|
|
3097
|
+
output_index: z12.number(),
|
|
3098
|
+
delta: z12.string()
|
|
2691
3099
|
});
|
|
2692
|
-
var responseOutputItemAddedSchema =
|
|
2693
|
-
type:
|
|
2694
|
-
output_index:
|
|
2695
|
-
item:
|
|
2696
|
-
|
|
2697
|
-
type:
|
|
3100
|
+
var responseOutputItemAddedSchema = z12.object({
|
|
3101
|
+
type: z12.literal("response.output_item.added"),
|
|
3102
|
+
output_index: z12.number(),
|
|
3103
|
+
item: z12.discriminatedUnion("type", [
|
|
3104
|
+
z12.object({
|
|
3105
|
+
type: z12.literal("message")
|
|
2698
3106
|
}),
|
|
2699
|
-
|
|
2700
|
-
type:
|
|
2701
|
-
id:
|
|
2702
|
-
call_id:
|
|
2703
|
-
name:
|
|
2704
|
-
arguments:
|
|
3107
|
+
z12.object({
|
|
3108
|
+
type: z12.literal("function_call"),
|
|
3109
|
+
id: z12.string(),
|
|
3110
|
+
call_id: z12.string(),
|
|
3111
|
+
name: z12.string(),
|
|
3112
|
+
arguments: z12.string()
|
|
3113
|
+
}),
|
|
3114
|
+
z12.object({
|
|
3115
|
+
type: z12.literal("web_search_call"),
|
|
3116
|
+
id: z12.string(),
|
|
3117
|
+
status: z12.string(),
|
|
3118
|
+
action: z12.object({
|
|
3119
|
+
type: z12.literal("search"),
|
|
3120
|
+
query: z12.string().optional()
|
|
3121
|
+
}).nullish()
|
|
3122
|
+
}),
|
|
3123
|
+
z12.object({
|
|
3124
|
+
type: z12.literal("computer_call"),
|
|
3125
|
+
id: z12.string(),
|
|
3126
|
+
status: z12.string()
|
|
3127
|
+
}),
|
|
3128
|
+
z12.object({
|
|
3129
|
+
type: z12.literal("file_search_call"),
|
|
3130
|
+
id: z12.string(),
|
|
3131
|
+
status: z12.string(),
|
|
3132
|
+
queries: z12.array(z12.string()).nullish(),
|
|
3133
|
+
results: z12.array(
|
|
3134
|
+
z12.object({
|
|
3135
|
+
attributes: z12.object({
|
|
3136
|
+
file_id: z12.string(),
|
|
3137
|
+
filename: z12.string(),
|
|
3138
|
+
score: z12.number(),
|
|
3139
|
+
text: z12.string()
|
|
3140
|
+
})
|
|
3141
|
+
})
|
|
3142
|
+
).optional()
|
|
2705
3143
|
})
|
|
2706
3144
|
])
|
|
2707
3145
|
});
|
|
2708
|
-
var responseAnnotationAddedSchema =
|
|
2709
|
-
type:
|
|
2710
|
-
annotation:
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
3146
|
+
var responseAnnotationAddedSchema = z12.object({
|
|
3147
|
+
type: z12.literal("response.output_text.annotation.added"),
|
|
3148
|
+
annotation: z12.discriminatedUnion("type", [
|
|
3149
|
+
z12.object({
|
|
3150
|
+
type: z12.literal("url_citation"),
|
|
3151
|
+
url: z12.string(),
|
|
3152
|
+
title: z12.string()
|
|
3153
|
+
}),
|
|
3154
|
+
z12.object({
|
|
3155
|
+
type: z12.literal("file_citation"),
|
|
3156
|
+
file_id: z12.string(),
|
|
3157
|
+
filename: z12.string().nullish(),
|
|
3158
|
+
index: z12.number().nullish(),
|
|
3159
|
+
start_index: z12.number().nullish(),
|
|
3160
|
+
end_index: z12.number().nullish(),
|
|
3161
|
+
quote: z12.string().nullish()
|
|
3162
|
+
})
|
|
3163
|
+
])
|
|
2720
3164
|
});
|
|
2721
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
2722
|
-
type:
|
|
2723
|
-
item_id:
|
|
2724
|
-
output_index:
|
|
2725
|
-
summary_index:
|
|
2726
|
-
delta:
|
|
3165
|
+
var responseReasoningSummaryTextDeltaSchema = z12.object({
|
|
3166
|
+
type: z12.literal("response.reasoning_summary_text.delta"),
|
|
3167
|
+
item_id: z12.string(),
|
|
3168
|
+
output_index: z12.number(),
|
|
3169
|
+
summary_index: z12.number(),
|
|
3170
|
+
delta: z12.string()
|
|
2727
3171
|
});
|
|
2728
|
-
var openaiResponsesChunkSchema =
|
|
3172
|
+
var openaiResponsesChunkSchema = z12.union([
|
|
2729
3173
|
textDeltaChunkSchema,
|
|
2730
3174
|
responseFinishedChunkSchema,
|
|
2731
3175
|
responseCreatedChunkSchema,
|
|
@@ -2734,7 +3178,7 @@ var openaiResponsesChunkSchema = z8.union([
|
|
|
2734
3178
|
responseOutputItemAddedSchema,
|
|
2735
3179
|
responseAnnotationAddedSchema,
|
|
2736
3180
|
responseReasoningSummaryTextDeltaSchema,
|
|
2737
|
-
|
|
3181
|
+
z12.object({ type: z12.string() }).passthrough()
|
|
2738
3182
|
// fallback for unknown chunks
|
|
2739
3183
|
]);
|
|
2740
3184
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2782,18 +3226,18 @@ function getResponsesModelConfig(modelId) {
|
|
|
2782
3226
|
requiredAutoTruncation: false
|
|
2783
3227
|
};
|
|
2784
3228
|
}
|
|
2785
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2786
|
-
metadata:
|
|
2787
|
-
parallelToolCalls:
|
|
2788
|
-
include:
|
|
2789
|
-
previousResponseId:
|
|
2790
|
-
forceNoTemperature:
|
|
2791
|
-
store:
|
|
2792
|
-
user:
|
|
2793
|
-
reasoningEffort:
|
|
2794
|
-
strictSchemas:
|
|
2795
|
-
instructions:
|
|
2796
|
-
reasoningSummary:
|
|
3229
|
+
var openaiResponsesProviderOptionsSchema = z12.object({
|
|
3230
|
+
metadata: z12.any().nullish(),
|
|
3231
|
+
parallelToolCalls: z12.boolean().nullish(),
|
|
3232
|
+
include: z12.array(z12.string()).nullish(),
|
|
3233
|
+
previousResponseId: z12.string().nullish(),
|
|
3234
|
+
forceNoTemperature: z12.boolean().nullish(),
|
|
3235
|
+
store: z12.boolean().nullish(),
|
|
3236
|
+
user: z12.string().nullish(),
|
|
3237
|
+
reasoningEffort: z12.string().nullish(),
|
|
3238
|
+
strictSchemas: z12.boolean().nullish(),
|
|
3239
|
+
instructions: z12.string().nullish(),
|
|
3240
|
+
reasoningSummary: z12.string().nullish()
|
|
2797
3241
|
});
|
|
2798
3242
|
export {
|
|
2799
3243
|
OpenAIChatLanguageModel,
|