@ai-sdk/openai 2.0.0-canary.1 → 2.0.0-canary.2
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 +9 -0
- package/dist/index.js +113 -253
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -253
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.js +113 -253
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +111 -253
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -78,7 +78,7 @@ function convertToOpenAIChatMessages({
|
|
|
78
78
|
image_url: {
|
|
79
79
|
url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase64(part.image)}`,
|
|
80
80
|
// OpenAI specific extension: image detail
|
|
81
|
-
detail: (_c = (_b = part.
|
|
81
|
+
detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
}
|
|
@@ -259,17 +259,16 @@ import {
|
|
|
259
259
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
260
260
|
} from "@ai-sdk/provider";
|
|
261
261
|
function prepareTools({
|
|
262
|
-
|
|
262
|
+
tools,
|
|
263
|
+
toolChoice,
|
|
263
264
|
useLegacyFunctionCalling = false,
|
|
264
265
|
structuredOutputs
|
|
265
266
|
}) {
|
|
266
|
-
|
|
267
|
-
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
|
|
267
|
+
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
268
268
|
const toolWarnings = [];
|
|
269
269
|
if (tools == null) {
|
|
270
|
-
return { tools: void 0,
|
|
270
|
+
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
271
271
|
}
|
|
272
|
-
const toolChoice = mode.toolChoice;
|
|
273
272
|
if (useLegacyFunctionCalling) {
|
|
274
273
|
const openaiFunctions = [];
|
|
275
274
|
for (const tool of tools) {
|
|
@@ -329,18 +328,18 @@ function prepareTools({
|
|
|
329
328
|
}
|
|
330
329
|
}
|
|
331
330
|
if (toolChoice == null) {
|
|
332
|
-
return { tools: openaiTools2,
|
|
331
|
+
return { tools: openaiTools2, toolChoice: void 0, toolWarnings };
|
|
333
332
|
}
|
|
334
333
|
const type = toolChoice.type;
|
|
335
334
|
switch (type) {
|
|
336
335
|
case "auto":
|
|
337
336
|
case "none":
|
|
338
337
|
case "required":
|
|
339
|
-
return { tools: openaiTools2,
|
|
338
|
+
return { tools: openaiTools2, toolChoice: type, toolWarnings };
|
|
340
339
|
case "tool":
|
|
341
340
|
return {
|
|
342
341
|
tools: openaiTools2,
|
|
343
|
-
|
|
342
|
+
toolChoice: {
|
|
344
343
|
type: "function",
|
|
345
344
|
function: {
|
|
346
345
|
name: toolChoice.toolName
|
|
@@ -382,7 +381,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
382
381
|
return !this.settings.downloadImages;
|
|
383
382
|
}
|
|
384
383
|
getArgs({
|
|
385
|
-
mode,
|
|
386
384
|
prompt,
|
|
387
385
|
maxTokens,
|
|
388
386
|
temperature,
|
|
@@ -393,10 +391,11 @@ var OpenAIChatLanguageModel = class {
|
|
|
393
391
|
stopSequences,
|
|
394
392
|
responseFormat,
|
|
395
393
|
seed,
|
|
396
|
-
|
|
394
|
+
tools,
|
|
395
|
+
toolChoice,
|
|
396
|
+
providerOptions
|
|
397
397
|
}) {
|
|
398
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
399
|
-
const type = mode.type;
|
|
398
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
400
399
|
const warnings = [];
|
|
401
400
|
if (topK != null) {
|
|
402
401
|
warnings.push({
|
|
@@ -445,6 +444,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
445
444
|
top_p: topP,
|
|
446
445
|
frequency_penalty: frequencyPenalty,
|
|
447
446
|
presence_penalty: presencePenalty,
|
|
447
|
+
// TODO improve below:
|
|
448
448
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? this.supportsStructuredOutputs && responseFormat.schema != null ? {
|
|
449
449
|
type: "json_schema",
|
|
450
450
|
json_schema: {
|
|
@@ -458,11 +458,11 @@ var OpenAIChatLanguageModel = class {
|
|
|
458
458
|
seed,
|
|
459
459
|
// openai specific settings:
|
|
460
460
|
// TODO remove in next major version; we auto-map maxTokens now
|
|
461
|
-
max_completion_tokens: (_b =
|
|
462
|
-
store: (_c =
|
|
463
|
-
metadata: (_d =
|
|
464
|
-
prediction: (_e =
|
|
465
|
-
reasoning_effort: (_g = (_f =
|
|
461
|
+
max_completion_tokens: (_b = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _b.maxCompletionTokens,
|
|
462
|
+
store: (_c = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _c.store,
|
|
463
|
+
metadata: (_d = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _d.metadata,
|
|
464
|
+
prediction: (_e = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _e.prediction,
|
|
465
|
+
reasoning_effort: (_g = (_f = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _f.reasoningEffort) != null ? _g : this.settings.reasoningEffort,
|
|
466
466
|
// messages:
|
|
467
467
|
messages
|
|
468
468
|
};
|
|
@@ -527,81 +527,28 @@ var OpenAIChatLanguageModel = class {
|
|
|
527
527
|
baseArgs.max_tokens = void 0;
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
response_format: this.supportsStructuredOutputs && mode.schema != null ? {
|
|
553
|
-
type: "json_schema",
|
|
554
|
-
json_schema: {
|
|
555
|
-
schema: mode.schema,
|
|
556
|
-
strict: true,
|
|
557
|
-
name: (_h = mode.name) != null ? _h : "response",
|
|
558
|
-
description: mode.description
|
|
559
|
-
}
|
|
560
|
-
} : { type: "json_object" }
|
|
561
|
-
},
|
|
562
|
-
warnings
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
case "object-tool": {
|
|
566
|
-
return {
|
|
567
|
-
args: useLegacyFunctionCalling ? {
|
|
568
|
-
...baseArgs,
|
|
569
|
-
function_call: {
|
|
570
|
-
name: mode.tool.name
|
|
571
|
-
},
|
|
572
|
-
functions: [
|
|
573
|
-
{
|
|
574
|
-
name: mode.tool.name,
|
|
575
|
-
description: mode.tool.description,
|
|
576
|
-
parameters: mode.tool.parameters
|
|
577
|
-
}
|
|
578
|
-
]
|
|
579
|
-
} : {
|
|
580
|
-
...baseArgs,
|
|
581
|
-
tool_choice: {
|
|
582
|
-
type: "function",
|
|
583
|
-
function: { name: mode.tool.name }
|
|
584
|
-
},
|
|
585
|
-
tools: [
|
|
586
|
-
{
|
|
587
|
-
type: "function",
|
|
588
|
-
function: {
|
|
589
|
-
name: mode.tool.name,
|
|
590
|
-
description: mode.tool.description,
|
|
591
|
-
parameters: mode.tool.parameters,
|
|
592
|
-
strict: this.supportsStructuredOutputs ? true : void 0
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
]
|
|
596
|
-
},
|
|
597
|
-
warnings
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
default: {
|
|
601
|
-
const _exhaustiveCheck = type;
|
|
602
|
-
throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
530
|
+
const {
|
|
531
|
+
tools: openaiTools2,
|
|
532
|
+
toolChoice: openaiToolChoice,
|
|
533
|
+
functions,
|
|
534
|
+
function_call,
|
|
535
|
+
toolWarnings
|
|
536
|
+
} = prepareTools({
|
|
537
|
+
tools,
|
|
538
|
+
toolChoice,
|
|
539
|
+
useLegacyFunctionCalling,
|
|
540
|
+
structuredOutputs: this.supportsStructuredOutputs
|
|
541
|
+
});
|
|
542
|
+
return {
|
|
543
|
+
args: {
|
|
544
|
+
...baseArgs,
|
|
545
|
+
tools: openaiTools2,
|
|
546
|
+
tool_choice: openaiToolChoice,
|
|
547
|
+
functions,
|
|
548
|
+
function_call
|
|
549
|
+
},
|
|
550
|
+
warnings: [...warnings, ...toolWarnings]
|
|
551
|
+
};
|
|
605
552
|
}
|
|
606
553
|
async doGenerate(options) {
|
|
607
554
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -1068,9 +1015,6 @@ var reasoningModels = {
|
|
|
1068
1015
|
};
|
|
1069
1016
|
|
|
1070
1017
|
// src/openai-completion-language-model.ts
|
|
1071
|
-
import {
|
|
1072
|
-
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
1073
|
-
} from "@ai-sdk/provider";
|
|
1074
1018
|
import {
|
|
1075
1019
|
combineHeaders as combineHeaders2,
|
|
1076
1020
|
createEventSourceResponseHandler as createEventSourceResponseHandler2,
|
|
@@ -1193,7 +1137,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1193
1137
|
return this.config.provider;
|
|
1194
1138
|
}
|
|
1195
1139
|
getArgs({
|
|
1196
|
-
mode,
|
|
1197
1140
|
inputFormat,
|
|
1198
1141
|
prompt,
|
|
1199
1142
|
maxTokens,
|
|
@@ -1204,16 +1147,19 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1204
1147
|
presencePenalty,
|
|
1205
1148
|
stopSequences: userStopSequences,
|
|
1206
1149
|
responseFormat,
|
|
1150
|
+
tools,
|
|
1151
|
+
toolChoice,
|
|
1207
1152
|
seed
|
|
1208
1153
|
}) {
|
|
1209
|
-
var _a;
|
|
1210
|
-
const type = mode.type;
|
|
1211
1154
|
const warnings = [];
|
|
1212
1155
|
if (topK != null) {
|
|
1213
|
-
warnings.push({
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
});
|
|
1156
|
+
warnings.push({ type: "unsupported-setting", setting: "topK" });
|
|
1157
|
+
}
|
|
1158
|
+
if (tools == null ? void 0 : tools.length) {
|
|
1159
|
+
warnings.push({ type: "unsupported-setting", setting: "tools" });
|
|
1160
|
+
}
|
|
1161
|
+
if (toolChoice != null) {
|
|
1162
|
+
warnings.push({ type: "unsupported-setting", setting: "toolChoice" });
|
|
1217
1163
|
}
|
|
1218
1164
|
if (responseFormat != null && responseFormat.type !== "text") {
|
|
1219
1165
|
warnings.push({
|
|
@@ -1224,56 +1170,30 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1224
1170
|
}
|
|
1225
1171
|
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({ prompt, inputFormat });
|
|
1226
1172
|
const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1173
|
+
return {
|
|
1174
|
+
args: {
|
|
1175
|
+
// model id:
|
|
1176
|
+
model: this.modelId,
|
|
1177
|
+
// model specific settings:
|
|
1178
|
+
echo: this.settings.echo,
|
|
1179
|
+
logit_bias: this.settings.logitBias,
|
|
1180
|
+
logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
|
|
1181
|
+
suffix: this.settings.suffix,
|
|
1182
|
+
user: this.settings.user,
|
|
1183
|
+
// standardized settings:
|
|
1184
|
+
max_tokens: maxTokens,
|
|
1185
|
+
temperature,
|
|
1186
|
+
top_p: topP,
|
|
1187
|
+
frequency_penalty: frequencyPenalty,
|
|
1188
|
+
presence_penalty: presencePenalty,
|
|
1189
|
+
seed,
|
|
1190
|
+
// prompt:
|
|
1191
|
+
prompt: completionPrompt,
|
|
1192
|
+
// stop sequences:
|
|
1193
|
+
stop: stop.length > 0 ? stop : void 0
|
|
1194
|
+
},
|
|
1195
|
+
warnings
|
|
1247
1196
|
};
|
|
1248
|
-
switch (type) {
|
|
1249
|
-
case "regular": {
|
|
1250
|
-
if ((_a = mode.tools) == null ? void 0 : _a.length) {
|
|
1251
|
-
throw new UnsupportedFunctionalityError5({
|
|
1252
|
-
functionality: "tools"
|
|
1253
|
-
});
|
|
1254
|
-
}
|
|
1255
|
-
if (mode.toolChoice) {
|
|
1256
|
-
throw new UnsupportedFunctionalityError5({
|
|
1257
|
-
functionality: "toolChoice"
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
return { args: baseArgs, warnings };
|
|
1261
|
-
}
|
|
1262
|
-
case "object-json": {
|
|
1263
|
-
throw new UnsupportedFunctionalityError5({
|
|
1264
|
-
functionality: "object-json mode"
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
case "object-tool": {
|
|
1268
|
-
throw new UnsupportedFunctionalityError5({
|
|
1269
|
-
functionality: "object-tool mode"
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
default: {
|
|
1273
|
-
const _exhaustiveCheck = type;
|
|
1274
|
-
throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
1197
|
}
|
|
1278
1198
|
async doGenerate(options) {
|
|
1279
1199
|
const { args, warnings } = this.getArgs(options);
|
|
@@ -1645,7 +1565,7 @@ import { z as z7 } from "zod";
|
|
|
1645
1565
|
|
|
1646
1566
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1647
1567
|
import {
|
|
1648
|
-
UnsupportedFunctionalityError as
|
|
1568
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
1649
1569
|
} from "@ai-sdk/provider";
|
|
1650
1570
|
import { convertUint8ArrayToBase64 as convertUint8ArrayToBase642 } from "@ai-sdk/provider-utils";
|
|
1651
1571
|
function convertToOpenAIResponsesMessages({
|
|
@@ -1696,12 +1616,12 @@ function convertToOpenAIResponsesMessages({
|
|
|
1696
1616
|
type: "input_image",
|
|
1697
1617
|
image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase642(part.image)}`,
|
|
1698
1618
|
// OpenAI specific extension: image detail
|
|
1699
|
-
detail: (_c = (_b = part.
|
|
1619
|
+
detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
|
|
1700
1620
|
};
|
|
1701
1621
|
}
|
|
1702
1622
|
case "file": {
|
|
1703
1623
|
if (part.data instanceof URL) {
|
|
1704
|
-
throw new
|
|
1624
|
+
throw new UnsupportedFunctionalityError5({
|
|
1705
1625
|
functionality: "File URLs in user messages"
|
|
1706
1626
|
});
|
|
1707
1627
|
}
|
|
@@ -1714,7 +1634,7 @@ function convertToOpenAIResponsesMessages({
|
|
|
1714
1634
|
};
|
|
1715
1635
|
}
|
|
1716
1636
|
default: {
|
|
1717
|
-
throw new
|
|
1637
|
+
throw new UnsupportedFunctionalityError5({
|
|
1718
1638
|
functionality: "Only PDF files are supported in user messages"
|
|
1719
1639
|
});
|
|
1720
1640
|
}
|
|
@@ -1787,19 +1707,18 @@ function mapOpenAIResponseFinishReason({
|
|
|
1787
1707
|
|
|
1788
1708
|
// src/responses/openai-responses-prepare-tools.ts
|
|
1789
1709
|
import {
|
|
1790
|
-
UnsupportedFunctionalityError as
|
|
1710
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError6
|
|
1791
1711
|
} from "@ai-sdk/provider";
|
|
1792
1712
|
function prepareResponsesTools({
|
|
1793
|
-
|
|
1713
|
+
tools,
|
|
1714
|
+
toolChoice,
|
|
1794
1715
|
strict
|
|
1795
1716
|
}) {
|
|
1796
|
-
|
|
1797
|
-
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
|
|
1717
|
+
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1798
1718
|
const toolWarnings = [];
|
|
1799
1719
|
if (tools == null) {
|
|
1800
|
-
return { tools: void 0,
|
|
1720
|
+
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
1801
1721
|
}
|
|
1802
|
-
const toolChoice = mode.toolChoice;
|
|
1803
1722
|
const openaiTools2 = [];
|
|
1804
1723
|
for (const tool of tools) {
|
|
1805
1724
|
switch (tool.type) {
|
|
@@ -1832,36 +1751,23 @@ function prepareResponsesTools({
|
|
|
1832
1751
|
}
|
|
1833
1752
|
}
|
|
1834
1753
|
if (toolChoice == null) {
|
|
1835
|
-
return { tools: openaiTools2,
|
|
1754
|
+
return { tools: openaiTools2, toolChoice: void 0, toolWarnings };
|
|
1836
1755
|
}
|
|
1837
1756
|
const type = toolChoice.type;
|
|
1838
1757
|
switch (type) {
|
|
1839
1758
|
case "auto":
|
|
1840
1759
|
case "none":
|
|
1841
1760
|
case "required":
|
|
1842
|
-
return { tools: openaiTools2,
|
|
1843
|
-
case "tool":
|
|
1844
|
-
if (toolChoice.toolName === "web_search_preview") {
|
|
1845
|
-
return {
|
|
1846
|
-
tools: openaiTools2,
|
|
1847
|
-
tool_choice: {
|
|
1848
|
-
type: "web_search_preview"
|
|
1849
|
-
},
|
|
1850
|
-
toolWarnings
|
|
1851
|
-
};
|
|
1852
|
-
}
|
|
1761
|
+
return { tools: openaiTools2, toolChoice: type, toolWarnings };
|
|
1762
|
+
case "tool":
|
|
1853
1763
|
return {
|
|
1854
1764
|
tools: openaiTools2,
|
|
1855
|
-
|
|
1856
|
-
type: "function",
|
|
1857
|
-
name: toolChoice.toolName
|
|
1858
|
-
},
|
|
1765
|
+
toolChoice: toolChoice.toolName === "web_search_preview" ? { type: "web_search_preview" } : { type: "function", name: toolChoice.toolName },
|
|
1859
1766
|
toolWarnings
|
|
1860
1767
|
};
|
|
1861
|
-
}
|
|
1862
1768
|
default: {
|
|
1863
1769
|
const _exhaustiveCheck = type;
|
|
1864
|
-
throw new
|
|
1770
|
+
throw new UnsupportedFunctionalityError6({
|
|
1865
1771
|
functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
|
|
1866
1772
|
});
|
|
1867
1773
|
}
|
|
@@ -1880,7 +1786,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1880
1786
|
return this.config.provider;
|
|
1881
1787
|
}
|
|
1882
1788
|
getArgs({
|
|
1883
|
-
mode,
|
|
1884
1789
|
maxTokens,
|
|
1885
1790
|
temperature,
|
|
1886
1791
|
stopSequences,
|
|
@@ -1890,24 +1795,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1890
1795
|
frequencyPenalty,
|
|
1891
1796
|
seed,
|
|
1892
1797
|
prompt,
|
|
1893
|
-
|
|
1798
|
+
providerOptions,
|
|
1799
|
+
tools,
|
|
1800
|
+
toolChoice,
|
|
1894
1801
|
responseFormat
|
|
1895
1802
|
}) {
|
|
1896
|
-
var _a, _b
|
|
1803
|
+
var _a, _b;
|
|
1897
1804
|
const warnings = [];
|
|
1898
1805
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
1899
|
-
const type = mode.type;
|
|
1900
1806
|
if (topK != null) {
|
|
1901
|
-
warnings.push({
|
|
1902
|
-
type: "unsupported-setting",
|
|
1903
|
-
setting: "topK"
|
|
1904
|
-
});
|
|
1807
|
+
warnings.push({ type: "unsupported-setting", setting: "topK" });
|
|
1905
1808
|
}
|
|
1906
1809
|
if (seed != null) {
|
|
1907
|
-
warnings.push({
|
|
1908
|
-
type: "unsupported-setting",
|
|
1909
|
-
setting: "seed"
|
|
1910
|
-
});
|
|
1810
|
+
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
1911
1811
|
}
|
|
1912
1812
|
if (presencePenalty != null) {
|
|
1913
1813
|
warnings.push({
|
|
@@ -1922,10 +1822,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1922
1822
|
});
|
|
1923
1823
|
}
|
|
1924
1824
|
if (stopSequences != null) {
|
|
1925
|
-
warnings.push({
|
|
1926
|
-
type: "unsupported-setting",
|
|
1927
|
-
setting: "stopSequences"
|
|
1928
|
-
});
|
|
1825
|
+
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
1929
1826
|
}
|
|
1930
1827
|
const { messages, warnings: messageWarnings } = convertToOpenAIResponsesMessages({
|
|
1931
1828
|
prompt,
|
|
@@ -1934,7 +1831,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1934
1831
|
warnings.push(...messageWarnings);
|
|
1935
1832
|
const openaiOptions = parseProviderOptions({
|
|
1936
1833
|
provider: "openai",
|
|
1937
|
-
providerOptions
|
|
1834
|
+
providerOptions,
|
|
1938
1835
|
schema: openaiResponsesProviderOptionsSchema
|
|
1939
1836
|
});
|
|
1940
1837
|
const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
|
|
@@ -1988,62 +1885,23 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1988
1885
|
});
|
|
1989
1886
|
}
|
|
1990
1887
|
}
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
return {
|
|
2009
|
-
args: {
|
|
2010
|
-
...baseArgs,
|
|
2011
|
-
text: {
|
|
2012
|
-
format: mode.schema != null ? {
|
|
2013
|
-
type: "json_schema",
|
|
2014
|
-
strict: isStrict,
|
|
2015
|
-
name: (_c = mode.name) != null ? _c : "response",
|
|
2016
|
-
description: mode.description,
|
|
2017
|
-
schema: mode.schema
|
|
2018
|
-
} : { type: "json_object" }
|
|
2019
|
-
}
|
|
2020
|
-
},
|
|
2021
|
-
warnings
|
|
2022
|
-
};
|
|
2023
|
-
}
|
|
2024
|
-
case "object-tool": {
|
|
2025
|
-
return {
|
|
2026
|
-
args: {
|
|
2027
|
-
...baseArgs,
|
|
2028
|
-
tool_choice: { type: "function", name: mode.tool.name },
|
|
2029
|
-
tools: [
|
|
2030
|
-
{
|
|
2031
|
-
type: "function",
|
|
2032
|
-
name: mode.tool.name,
|
|
2033
|
-
description: mode.tool.description,
|
|
2034
|
-
parameters: mode.tool.parameters,
|
|
2035
|
-
strict: isStrict
|
|
2036
|
-
}
|
|
2037
|
-
]
|
|
2038
|
-
},
|
|
2039
|
-
warnings
|
|
2040
|
-
};
|
|
2041
|
-
}
|
|
2042
|
-
default: {
|
|
2043
|
-
const _exhaustiveCheck = type;
|
|
2044
|
-
throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
1888
|
+
const {
|
|
1889
|
+
tools: openaiTools2,
|
|
1890
|
+
toolChoice: openaiToolChoice,
|
|
1891
|
+
toolWarnings
|
|
1892
|
+
} = prepareResponsesTools({
|
|
1893
|
+
tools,
|
|
1894
|
+
toolChoice,
|
|
1895
|
+
strict: isStrict
|
|
1896
|
+
});
|
|
1897
|
+
return {
|
|
1898
|
+
args: {
|
|
1899
|
+
...baseArgs,
|
|
1900
|
+
tools: openaiTools2,
|
|
1901
|
+
tool_choice: openaiToolChoice
|
|
1902
|
+
},
|
|
1903
|
+
warnings: [...warnings, ...toolWarnings]
|
|
1904
|
+
};
|
|
2047
1905
|
}
|
|
2048
1906
|
async doGenerate(options) {
|
|
2049
1907
|
var _a, _b, _c, _d, _e;
|