@ai-sdk/openai 2.0.0-canary.12 → 2.0.0-canary.13
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 +14 -0
- package/dist/index.d.mts +7 -25
- package/dist/index.d.ts +7 -25
- package/dist/index.js +178 -164
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -164
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +25 -43
- package/dist/internal/index.d.ts +25 -43
- package/dist/internal/index.js +174 -158
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +173 -158
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -254,7 +254,13 @@ var openaiProviderOptions = z.object({
|
|
|
254
254
|
/**
|
|
255
255
|
* Parameters for prediction mode.
|
|
256
256
|
*/
|
|
257
|
-
prediction: z.record(z.any()).optional()
|
|
257
|
+
prediction: z.record(z.any()).optional(),
|
|
258
|
+
/**
|
|
259
|
+
* Whether to use structured outputs.
|
|
260
|
+
*
|
|
261
|
+
* @default true
|
|
262
|
+
*/
|
|
263
|
+
structuredOutputs: z.boolean().optional()
|
|
258
264
|
});
|
|
259
265
|
|
|
260
266
|
// src/openai-error.ts
|
|
@@ -337,10 +343,9 @@ function prepareTools({
|
|
|
337
343
|
|
|
338
344
|
// src/openai-chat-language-model.ts
|
|
339
345
|
var OpenAIChatLanguageModel = class {
|
|
340
|
-
constructor(modelId,
|
|
346
|
+
constructor(modelId, config) {
|
|
341
347
|
this.specificationVersion = "v2";
|
|
342
348
|
this.modelId = modelId;
|
|
343
|
-
this.settings = settings;
|
|
344
349
|
this.config = config;
|
|
345
350
|
}
|
|
346
351
|
get provider() {
|
|
@@ -373,13 +378,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
373
378
|
providerOptions,
|
|
374
379
|
schema: openaiProviderOptions
|
|
375
380
|
})) != null ? _a : {};
|
|
381
|
+
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
376
382
|
if (topK != null) {
|
|
377
383
|
warnings.push({
|
|
378
384
|
type: "unsupported-setting",
|
|
379
385
|
setting: "topK"
|
|
380
386
|
});
|
|
381
387
|
}
|
|
382
|
-
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !
|
|
388
|
+
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !structuredOutputs) {
|
|
383
389
|
warnings.push({
|
|
384
390
|
type: "unsupported-setting",
|
|
385
391
|
setting: "responseFormat",
|
|
@@ -408,12 +414,12 @@ var OpenAIChatLanguageModel = class {
|
|
|
408
414
|
presence_penalty: presencePenalty,
|
|
409
415
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? (
|
|
410
416
|
// TODO convert into provider option
|
|
411
|
-
|
|
417
|
+
structuredOutputs && responseFormat.schema != null ? {
|
|
412
418
|
type: "json_schema",
|
|
413
419
|
json_schema: {
|
|
414
420
|
schema: responseFormat.schema,
|
|
415
421
|
strict: true,
|
|
416
|
-
name: (
|
|
422
|
+
name: (_c = responseFormat.name) != null ? _c : "response",
|
|
417
423
|
description: responseFormat.description
|
|
418
424
|
}
|
|
419
425
|
} : { type: "json_object" }
|
|
@@ -493,7 +499,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
493
499
|
} = prepareTools({
|
|
494
500
|
tools,
|
|
495
501
|
toolChoice,
|
|
496
|
-
structuredOutputs
|
|
502
|
+
structuredOutputs
|
|
497
503
|
});
|
|
498
504
|
return {
|
|
499
505
|
args: {
|
|
@@ -878,13 +884,9 @@ import {
|
|
|
878
884
|
} from "@ai-sdk/provider";
|
|
879
885
|
function convertToOpenAICompletionPrompt({
|
|
880
886
|
prompt,
|
|
881
|
-
inputFormat,
|
|
882
887
|
user = "user",
|
|
883
888
|
assistant = "assistant"
|
|
884
889
|
}) {
|
|
885
|
-
if (inputFormat === "prompt" && prompt.length === 1 && prompt[0].role === "user" && prompt[0].content.length === 1 && prompt[0].content[0].type === "text") {
|
|
886
|
-
return { prompt: prompt[0].content[0].text };
|
|
887
|
-
}
|
|
888
890
|
let text = "";
|
|
889
891
|
if (prompt[0].role === "system") {
|
|
890
892
|
text += `${prompt[0].content}
|
|
@@ -1005,7 +1007,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1005
1007
|
};
|
|
1006
1008
|
}
|
|
1007
1009
|
async getArgs({
|
|
1008
|
-
inputFormat,
|
|
1009
1010
|
prompt,
|
|
1010
1011
|
maxOutputTokens,
|
|
1011
1012
|
temperature,
|
|
@@ -1049,7 +1050,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1049
1050
|
details: "JSON response format is not supported."
|
|
1050
1051
|
});
|
|
1051
1052
|
}
|
|
1052
|
-
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({ prompt
|
|
1053
|
+
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({ prompt });
|
|
1053
1054
|
const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
|
|
1054
1055
|
return {
|
|
1055
1056
|
args: {
|
|
@@ -1258,23 +1259,16 @@ var openaiEmbeddingProviderOptions = z6.object({
|
|
|
1258
1259
|
|
|
1259
1260
|
// src/openai-embedding-model.ts
|
|
1260
1261
|
var OpenAIEmbeddingModel = class {
|
|
1261
|
-
constructor(modelId,
|
|
1262
|
+
constructor(modelId, config) {
|
|
1262
1263
|
this.specificationVersion = "v2";
|
|
1264
|
+
this.maxEmbeddingsPerCall = 2048;
|
|
1265
|
+
this.supportsParallelCalls = true;
|
|
1263
1266
|
this.modelId = modelId;
|
|
1264
|
-
this.settings = settings;
|
|
1265
1267
|
this.config = config;
|
|
1266
1268
|
}
|
|
1267
1269
|
get provider() {
|
|
1268
1270
|
return this.config.provider;
|
|
1269
1271
|
}
|
|
1270
|
-
get maxEmbeddingsPerCall() {
|
|
1271
|
-
var _a;
|
|
1272
|
-
return (_a = this.settings.maxEmbeddingsPerCall) != null ? _a : 2048;
|
|
1273
|
-
}
|
|
1274
|
-
get supportsParallelCalls() {
|
|
1275
|
-
var _a;
|
|
1276
|
-
return (_a = this.settings.supportsParallelCalls) != null ? _a : true;
|
|
1277
|
-
}
|
|
1278
1272
|
async doEmbed({
|
|
1279
1273
|
values,
|
|
1280
1274
|
headers,
|
|
@@ -1450,14 +1444,36 @@ import {
|
|
|
1450
1444
|
parseProviderOptions as parseProviderOptions4,
|
|
1451
1445
|
postFormDataToApi
|
|
1452
1446
|
} from "@ai-sdk/provider-utils";
|
|
1447
|
+
import { z as z11 } from "zod";
|
|
1448
|
+
|
|
1449
|
+
// src/openai-transcription-options.ts
|
|
1453
1450
|
import { z as z10 } from "zod";
|
|
1454
|
-
var
|
|
1451
|
+
var openAITranscriptionProviderOptions = z10.object({
|
|
1452
|
+
/**
|
|
1453
|
+
* Additional information to include in the transcription response.
|
|
1454
|
+
*/
|
|
1455
1455
|
include: z10.array(z10.string()).nullish(),
|
|
1456
|
+
/**
|
|
1457
|
+
* The language of the input audio in ISO-639-1 format.
|
|
1458
|
+
*/
|
|
1456
1459
|
language: z10.string().nullish(),
|
|
1460
|
+
/**
|
|
1461
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
1462
|
+
*/
|
|
1457
1463
|
prompt: z10.string().nullish(),
|
|
1458
|
-
|
|
1459
|
-
|
|
1464
|
+
/**
|
|
1465
|
+
* The sampling temperature, between 0 and 1.
|
|
1466
|
+
* @default 0
|
|
1467
|
+
*/
|
|
1468
|
+
temperature: z10.number().min(0).max(1).default(0).nullish(),
|
|
1469
|
+
/**
|
|
1470
|
+
* The timestamp granularities to populate for this transcription.
|
|
1471
|
+
* @default ['segment']
|
|
1472
|
+
*/
|
|
1473
|
+
timestampGranularities: z10.array(z10.enum(["word", "segment"])).default(["segment"]).nullish()
|
|
1460
1474
|
});
|
|
1475
|
+
|
|
1476
|
+
// src/openai-transcription-model.ts
|
|
1461
1477
|
var languageMap = {
|
|
1462
1478
|
afrikaans: "af",
|
|
1463
1479
|
arabic: "ar",
|
|
@@ -1531,12 +1547,11 @@ var OpenAITranscriptionModel = class {
|
|
|
1531
1547
|
mediaType,
|
|
1532
1548
|
providerOptions
|
|
1533
1549
|
}) {
|
|
1534
|
-
var _a, _b, _c, _d, _e;
|
|
1535
1550
|
const warnings = [];
|
|
1536
1551
|
const openAIOptions = await parseProviderOptions4({
|
|
1537
1552
|
provider: "openai",
|
|
1538
1553
|
providerOptions,
|
|
1539
|
-
schema:
|
|
1554
|
+
schema: openAITranscriptionProviderOptions
|
|
1540
1555
|
});
|
|
1541
1556
|
const formData = new FormData();
|
|
1542
1557
|
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
|
|
@@ -1544,15 +1559,14 @@ var OpenAITranscriptionModel = class {
|
|
|
1544
1559
|
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
1545
1560
|
if (openAIOptions) {
|
|
1546
1561
|
const transcriptionModelOptions = {
|
|
1547
|
-
include:
|
|
1548
|
-
language:
|
|
1549
|
-
prompt:
|
|
1550
|
-
temperature:
|
|
1551
|
-
timestamp_granularities:
|
|
1562
|
+
include: openAIOptions.include,
|
|
1563
|
+
language: openAIOptions.language,
|
|
1564
|
+
prompt: openAIOptions.prompt,
|
|
1565
|
+
temperature: openAIOptions.temperature,
|
|
1566
|
+
timestamp_granularities: openAIOptions.timestampGranularities
|
|
1552
1567
|
};
|
|
1553
|
-
for (const key
|
|
1554
|
-
|
|
1555
|
-
if (value !== void 0) {
|
|
1568
|
+
for (const [key, value] of Object.entries(transcriptionModelOptions)) {
|
|
1569
|
+
if (value != null) {
|
|
1556
1570
|
formData.append(key, String(value));
|
|
1557
1571
|
}
|
|
1558
1572
|
}
|
|
@@ -1604,15 +1618,15 @@ var OpenAITranscriptionModel = class {
|
|
|
1604
1618
|
};
|
|
1605
1619
|
}
|
|
1606
1620
|
};
|
|
1607
|
-
var openaiTranscriptionResponseSchema =
|
|
1608
|
-
text:
|
|
1609
|
-
language:
|
|
1610
|
-
duration:
|
|
1611
|
-
words:
|
|
1612
|
-
|
|
1613
|
-
word:
|
|
1614
|
-
start:
|
|
1615
|
-
end:
|
|
1621
|
+
var openaiTranscriptionResponseSchema = z11.object({
|
|
1622
|
+
text: z11.string(),
|
|
1623
|
+
language: z11.string().nullish(),
|
|
1624
|
+
duration: z11.number().nullish(),
|
|
1625
|
+
words: z11.array(
|
|
1626
|
+
z11.object({
|
|
1627
|
+
word: z11.string(),
|
|
1628
|
+
start: z11.number(),
|
|
1629
|
+
end: z11.number()
|
|
1616
1630
|
})
|
|
1617
1631
|
).nullish()
|
|
1618
1632
|
});
|
|
@@ -1626,7 +1640,7 @@ import {
|
|
|
1626
1640
|
parseProviderOptions as parseProviderOptions5,
|
|
1627
1641
|
postJsonToApi as postJsonToApi5
|
|
1628
1642
|
} from "@ai-sdk/provider-utils";
|
|
1629
|
-
import { z as
|
|
1643
|
+
import { z as z12 } from "zod";
|
|
1630
1644
|
|
|
1631
1645
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1632
1646
|
import {
|
|
@@ -1991,55 +2005,55 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1991
2005
|
body,
|
|
1992
2006
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1993
2007
|
successfulResponseHandler: createJsonResponseHandler6(
|
|
1994
|
-
|
|
1995
|
-
id:
|
|
1996
|
-
created_at:
|
|
1997
|
-
model:
|
|
1998
|
-
output:
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
type:
|
|
2002
|
-
role:
|
|
2003
|
-
content:
|
|
2004
|
-
|
|
2005
|
-
type:
|
|
2006
|
-
text:
|
|
2007
|
-
annotations:
|
|
2008
|
-
|
|
2009
|
-
type:
|
|
2010
|
-
start_index:
|
|
2011
|
-
end_index:
|
|
2012
|
-
url:
|
|
2013
|
-
title:
|
|
2008
|
+
z12.object({
|
|
2009
|
+
id: z12.string(),
|
|
2010
|
+
created_at: z12.number(),
|
|
2011
|
+
model: z12.string(),
|
|
2012
|
+
output: z12.array(
|
|
2013
|
+
z12.discriminatedUnion("type", [
|
|
2014
|
+
z12.object({
|
|
2015
|
+
type: z12.literal("message"),
|
|
2016
|
+
role: z12.literal("assistant"),
|
|
2017
|
+
content: z12.array(
|
|
2018
|
+
z12.object({
|
|
2019
|
+
type: z12.literal("output_text"),
|
|
2020
|
+
text: z12.string(),
|
|
2021
|
+
annotations: z12.array(
|
|
2022
|
+
z12.object({
|
|
2023
|
+
type: z12.literal("url_citation"),
|
|
2024
|
+
start_index: z12.number(),
|
|
2025
|
+
end_index: z12.number(),
|
|
2026
|
+
url: z12.string(),
|
|
2027
|
+
title: z12.string()
|
|
2014
2028
|
})
|
|
2015
2029
|
)
|
|
2016
2030
|
})
|
|
2017
2031
|
)
|
|
2018
2032
|
}),
|
|
2019
|
-
|
|
2020
|
-
type:
|
|
2021
|
-
call_id:
|
|
2022
|
-
name:
|
|
2023
|
-
arguments:
|
|
2033
|
+
z12.object({
|
|
2034
|
+
type: z12.literal("function_call"),
|
|
2035
|
+
call_id: z12.string(),
|
|
2036
|
+
name: z12.string(),
|
|
2037
|
+
arguments: z12.string()
|
|
2024
2038
|
}),
|
|
2025
|
-
|
|
2026
|
-
type:
|
|
2039
|
+
z12.object({
|
|
2040
|
+
type: z12.literal("web_search_call")
|
|
2027
2041
|
}),
|
|
2028
|
-
|
|
2029
|
-
type:
|
|
2042
|
+
z12.object({
|
|
2043
|
+
type: z12.literal("computer_call")
|
|
2030
2044
|
}),
|
|
2031
|
-
|
|
2032
|
-
type:
|
|
2033
|
-
summary:
|
|
2034
|
-
|
|
2035
|
-
type:
|
|
2036
|
-
text:
|
|
2045
|
+
z12.object({
|
|
2046
|
+
type: z12.literal("reasoning"),
|
|
2047
|
+
summary: z12.array(
|
|
2048
|
+
z12.object({
|
|
2049
|
+
type: z12.literal("summary_text"),
|
|
2050
|
+
text: z12.string()
|
|
2037
2051
|
})
|
|
2038
2052
|
)
|
|
2039
2053
|
})
|
|
2040
2054
|
])
|
|
2041
2055
|
),
|
|
2042
|
-
incomplete_details:
|
|
2056
|
+
incomplete_details: z12.object({ reason: z12.string() }).nullable(),
|
|
2043
2057
|
usage: usageSchema
|
|
2044
2058
|
})
|
|
2045
2059
|
),
|
|
@@ -2253,86 +2267,86 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2253
2267
|
};
|
|
2254
2268
|
}
|
|
2255
2269
|
};
|
|
2256
|
-
var usageSchema =
|
|
2257
|
-
input_tokens:
|
|
2258
|
-
input_tokens_details:
|
|
2259
|
-
output_tokens:
|
|
2260
|
-
output_tokens_details:
|
|
2270
|
+
var usageSchema = z12.object({
|
|
2271
|
+
input_tokens: z12.number(),
|
|
2272
|
+
input_tokens_details: z12.object({ cached_tokens: z12.number().nullish() }).nullish(),
|
|
2273
|
+
output_tokens: z12.number(),
|
|
2274
|
+
output_tokens_details: z12.object({ reasoning_tokens: z12.number().nullish() }).nullish()
|
|
2261
2275
|
});
|
|
2262
|
-
var textDeltaChunkSchema =
|
|
2263
|
-
type:
|
|
2264
|
-
delta:
|
|
2276
|
+
var textDeltaChunkSchema = z12.object({
|
|
2277
|
+
type: z12.literal("response.output_text.delta"),
|
|
2278
|
+
delta: z12.string()
|
|
2265
2279
|
});
|
|
2266
|
-
var responseFinishedChunkSchema =
|
|
2267
|
-
type:
|
|
2268
|
-
response:
|
|
2269
|
-
incomplete_details:
|
|
2280
|
+
var responseFinishedChunkSchema = z12.object({
|
|
2281
|
+
type: z12.enum(["response.completed", "response.incomplete"]),
|
|
2282
|
+
response: z12.object({
|
|
2283
|
+
incomplete_details: z12.object({ reason: z12.string() }).nullish(),
|
|
2270
2284
|
usage: usageSchema
|
|
2271
2285
|
})
|
|
2272
2286
|
});
|
|
2273
|
-
var responseCreatedChunkSchema =
|
|
2274
|
-
type:
|
|
2275
|
-
response:
|
|
2276
|
-
id:
|
|
2277
|
-
created_at:
|
|
2278
|
-
model:
|
|
2287
|
+
var responseCreatedChunkSchema = z12.object({
|
|
2288
|
+
type: z12.literal("response.created"),
|
|
2289
|
+
response: z12.object({
|
|
2290
|
+
id: z12.string(),
|
|
2291
|
+
created_at: z12.number(),
|
|
2292
|
+
model: z12.string()
|
|
2279
2293
|
})
|
|
2280
2294
|
});
|
|
2281
|
-
var responseOutputItemDoneSchema =
|
|
2282
|
-
type:
|
|
2283
|
-
output_index:
|
|
2284
|
-
item:
|
|
2285
|
-
|
|
2286
|
-
type:
|
|
2295
|
+
var responseOutputItemDoneSchema = z12.object({
|
|
2296
|
+
type: z12.literal("response.output_item.done"),
|
|
2297
|
+
output_index: z12.number(),
|
|
2298
|
+
item: z12.discriminatedUnion("type", [
|
|
2299
|
+
z12.object({
|
|
2300
|
+
type: z12.literal("message")
|
|
2287
2301
|
}),
|
|
2288
|
-
|
|
2289
|
-
type:
|
|
2290
|
-
id:
|
|
2291
|
-
call_id:
|
|
2292
|
-
name:
|
|
2293
|
-
arguments:
|
|
2294
|
-
status:
|
|
2302
|
+
z12.object({
|
|
2303
|
+
type: z12.literal("function_call"),
|
|
2304
|
+
id: z12.string(),
|
|
2305
|
+
call_id: z12.string(),
|
|
2306
|
+
name: z12.string(),
|
|
2307
|
+
arguments: z12.string(),
|
|
2308
|
+
status: z12.literal("completed")
|
|
2295
2309
|
})
|
|
2296
2310
|
])
|
|
2297
2311
|
});
|
|
2298
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2299
|
-
type:
|
|
2300
|
-
item_id:
|
|
2301
|
-
output_index:
|
|
2302
|
-
delta:
|
|
2312
|
+
var responseFunctionCallArgumentsDeltaSchema = z12.object({
|
|
2313
|
+
type: z12.literal("response.function_call_arguments.delta"),
|
|
2314
|
+
item_id: z12.string(),
|
|
2315
|
+
output_index: z12.number(),
|
|
2316
|
+
delta: z12.string()
|
|
2303
2317
|
});
|
|
2304
|
-
var responseOutputItemAddedSchema =
|
|
2305
|
-
type:
|
|
2306
|
-
output_index:
|
|
2307
|
-
item:
|
|
2308
|
-
|
|
2309
|
-
type:
|
|
2318
|
+
var responseOutputItemAddedSchema = z12.object({
|
|
2319
|
+
type: z12.literal("response.output_item.added"),
|
|
2320
|
+
output_index: z12.number(),
|
|
2321
|
+
item: z12.discriminatedUnion("type", [
|
|
2322
|
+
z12.object({
|
|
2323
|
+
type: z12.literal("message")
|
|
2310
2324
|
}),
|
|
2311
|
-
|
|
2312
|
-
type:
|
|
2313
|
-
id:
|
|
2314
|
-
call_id:
|
|
2315
|
-
name:
|
|
2316
|
-
arguments:
|
|
2325
|
+
z12.object({
|
|
2326
|
+
type: z12.literal("function_call"),
|
|
2327
|
+
id: z12.string(),
|
|
2328
|
+
call_id: z12.string(),
|
|
2329
|
+
name: z12.string(),
|
|
2330
|
+
arguments: z12.string()
|
|
2317
2331
|
})
|
|
2318
2332
|
])
|
|
2319
2333
|
});
|
|
2320
|
-
var responseAnnotationAddedSchema =
|
|
2321
|
-
type:
|
|
2322
|
-
annotation:
|
|
2323
|
-
type:
|
|
2324
|
-
url:
|
|
2325
|
-
title:
|
|
2334
|
+
var responseAnnotationAddedSchema = z12.object({
|
|
2335
|
+
type: z12.literal("response.output_text.annotation.added"),
|
|
2336
|
+
annotation: z12.object({
|
|
2337
|
+
type: z12.literal("url_citation"),
|
|
2338
|
+
url: z12.string(),
|
|
2339
|
+
title: z12.string()
|
|
2326
2340
|
})
|
|
2327
2341
|
});
|
|
2328
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
2329
|
-
type:
|
|
2330
|
-
item_id:
|
|
2331
|
-
output_index:
|
|
2332
|
-
summary_index:
|
|
2333
|
-
delta:
|
|
2342
|
+
var responseReasoningSummaryTextDeltaSchema = z12.object({
|
|
2343
|
+
type: z12.literal("response.reasoning_summary_text.delta"),
|
|
2344
|
+
item_id: z12.string(),
|
|
2345
|
+
output_index: z12.number(),
|
|
2346
|
+
summary_index: z12.number(),
|
|
2347
|
+
delta: z12.string()
|
|
2334
2348
|
});
|
|
2335
|
-
var openaiResponsesChunkSchema =
|
|
2349
|
+
var openaiResponsesChunkSchema = z12.union([
|
|
2336
2350
|
textDeltaChunkSchema,
|
|
2337
2351
|
responseFinishedChunkSchema,
|
|
2338
2352
|
responseCreatedChunkSchema,
|
|
@@ -2341,7 +2355,7 @@ var openaiResponsesChunkSchema = z11.union([
|
|
|
2341
2355
|
responseOutputItemAddedSchema,
|
|
2342
2356
|
responseAnnotationAddedSchema,
|
|
2343
2357
|
responseReasoningSummaryTextDeltaSchema,
|
|
2344
|
-
|
|
2358
|
+
z12.object({ type: z12.string() }).passthrough()
|
|
2345
2359
|
// fallback for unknown chunks
|
|
2346
2360
|
]);
|
|
2347
2361
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2389,16 +2403,16 @@ function getResponsesModelConfig(modelId) {
|
|
|
2389
2403
|
requiredAutoTruncation: false
|
|
2390
2404
|
};
|
|
2391
2405
|
}
|
|
2392
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2393
|
-
metadata:
|
|
2394
|
-
parallelToolCalls:
|
|
2395
|
-
previousResponseId:
|
|
2396
|
-
store:
|
|
2397
|
-
user:
|
|
2398
|
-
reasoningEffort:
|
|
2399
|
-
strictSchemas:
|
|
2400
|
-
instructions:
|
|
2401
|
-
reasoningSummary:
|
|
2406
|
+
var openaiResponsesProviderOptionsSchema = z12.object({
|
|
2407
|
+
metadata: z12.any().nullish(),
|
|
2408
|
+
parallelToolCalls: z12.boolean().nullish(),
|
|
2409
|
+
previousResponseId: z12.string().nullish(),
|
|
2410
|
+
store: z12.boolean().nullish(),
|
|
2411
|
+
user: z12.string().nullish(),
|
|
2412
|
+
reasoningEffort: z12.string().nullish(),
|
|
2413
|
+
strictSchemas: z12.boolean().nullish(),
|
|
2414
|
+
instructions: z12.string().nullish(),
|
|
2415
|
+
reasoningSummary: z12.string().nullish()
|
|
2402
2416
|
});
|
|
2403
2417
|
|
|
2404
2418
|
// src/openai-speech-model.ts
|
|
@@ -2408,10 +2422,10 @@ import {
|
|
|
2408
2422
|
parseProviderOptions as parseProviderOptions6,
|
|
2409
2423
|
postJsonToApi as postJsonToApi6
|
|
2410
2424
|
} from "@ai-sdk/provider-utils";
|
|
2411
|
-
import { z as
|
|
2412
|
-
var OpenAIProviderOptionsSchema =
|
|
2413
|
-
instructions:
|
|
2414
|
-
speed:
|
|
2425
|
+
import { z as z13 } from "zod";
|
|
2426
|
+
var OpenAIProviderOptionsSchema = z13.object({
|
|
2427
|
+
instructions: z13.string().nullish(),
|
|
2428
|
+
speed: z13.number().min(0.25).max(4).default(1).nullish()
|
|
2415
2429
|
});
|
|
2416
2430
|
var OpenAISpeechModel = class {
|
|
2417
2431
|
constructor(modelId, config) {
|
|
@@ -2521,7 +2535,7 @@ function createOpenAI(options = {}) {
|
|
|
2521
2535
|
"OpenAI-Project": options.project,
|
|
2522
2536
|
...options.headers
|
|
2523
2537
|
});
|
|
2524
|
-
const createChatModel = (modelId
|
|
2538
|
+
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
2525
2539
|
provider: `${providerName}.chat`,
|
|
2526
2540
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2527
2541
|
headers: getHeaders,
|
|
@@ -2535,7 +2549,7 @@ function createOpenAI(options = {}) {
|
|
|
2535
2549
|
compatibility,
|
|
2536
2550
|
fetch: options.fetch
|
|
2537
2551
|
});
|
|
2538
|
-
const createEmbeddingModel = (modelId
|
|
2552
|
+
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
2539
2553
|
provider: `${providerName}.embedding`,
|
|
2540
2554
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2541
2555
|
headers: getHeaders,
|
|
@@ -2559,7 +2573,7 @@ function createOpenAI(options = {}) {
|
|
|
2559
2573
|
headers: getHeaders,
|
|
2560
2574
|
fetch: options.fetch
|
|
2561
2575
|
});
|
|
2562
|
-
const createLanguageModel = (modelId
|
|
2576
|
+
const createLanguageModel = (modelId) => {
|
|
2563
2577
|
if (new.target) {
|
|
2564
2578
|
throw new Error(
|
|
2565
2579
|
"The OpenAI model function cannot be called with the new keyword."
|
|
@@ -2568,7 +2582,7 @@ function createOpenAI(options = {}) {
|
|
|
2568
2582
|
if (modelId === "gpt-3.5-turbo-instruct") {
|
|
2569
2583
|
return createCompletionModel(modelId);
|
|
2570
2584
|
}
|
|
2571
|
-
return createChatModel(modelId
|
|
2585
|
+
return createChatModel(modelId);
|
|
2572
2586
|
};
|
|
2573
2587
|
const createResponsesModel = (modelId) => {
|
|
2574
2588
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
@@ -2578,8 +2592,8 @@ function createOpenAI(options = {}) {
|
|
|
2578
2592
|
fetch: options.fetch
|
|
2579
2593
|
});
|
|
2580
2594
|
};
|
|
2581
|
-
const provider = function(modelId
|
|
2582
|
-
return createLanguageModel(modelId
|
|
2595
|
+
const provider = function(modelId) {
|
|
2596
|
+
return createLanguageModel(modelId);
|
|
2583
2597
|
};
|
|
2584
2598
|
provider.languageModel = createLanguageModel;
|
|
2585
2599
|
provider.chat = createChatModel;
|