@ai-sdk/openai 1.3.9 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -17
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +16 -16
- package/internal/dist/index.d.ts +16 -16
- package/internal/dist/index.js +21 -17
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +21 -17
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { LanguageModelV1, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1Ca
|
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
5
|
+
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
6
6
|
interface OpenAIChatSettings {
|
|
7
7
|
/**
|
|
8
8
|
Modify the likelihood of specified tokens appearing in the completion.
|
|
@@ -271,23 +271,23 @@ type OpenAITranscriptionModelOptions = {
|
|
|
271
271
|
};
|
|
272
272
|
|
|
273
273
|
declare const OpenAIProviderOptionsSchema: z.ZodObject<{
|
|
274
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString, "many"
|
|
275
|
-
language: z.ZodOptional<z.ZodString
|
|
276
|
-
prompt: z.ZodOptional<z.ZodString
|
|
277
|
-
temperature: z.ZodDefault<z.ZodOptional<z.ZodNumber
|
|
278
|
-
timestampGranularities: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodEnum<["word", "segment"]>, "many"
|
|
274
|
+
include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
275
|
+
language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
276
|
+
prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
277
|
+
temperature: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
|
278
|
+
timestampGranularities: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<["word", "segment"]>, "many">>>>;
|
|
279
279
|
}, "strip", z.ZodTypeAny, {
|
|
280
|
-
temperature: number;
|
|
281
|
-
timestampGranularities: ("word" | "segment")[];
|
|
282
|
-
prompt?: string | undefined;
|
|
283
|
-
include?: string[] | undefined;
|
|
284
|
-
language?: string | undefined;
|
|
280
|
+
temperature: number | null;
|
|
281
|
+
timestampGranularities: ("word" | "segment")[] | null;
|
|
282
|
+
prompt?: string | null | undefined;
|
|
283
|
+
include?: string[] | null | undefined;
|
|
284
|
+
language?: string | null | undefined;
|
|
285
285
|
}, {
|
|
286
|
-
prompt?: string | undefined;
|
|
287
|
-
temperature?: number | undefined;
|
|
288
|
-
include?: string[] | undefined;
|
|
289
|
-
language?: string | undefined;
|
|
290
|
-
timestampGranularities?: ("word" | "segment")[] | undefined;
|
|
286
|
+
prompt?: string | null | undefined;
|
|
287
|
+
temperature?: number | null | undefined;
|
|
288
|
+
include?: string[] | null | undefined;
|
|
289
|
+
language?: string | null | undefined;
|
|
290
|
+
timestampGranularities?: ("word" | "segment")[] | null | undefined;
|
|
291
291
|
}>;
|
|
292
292
|
type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV1CallOptions, 'providerOptions'> & {
|
|
293
293
|
providerOptions?: {
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV1, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1Ca
|
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
5
|
+
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
6
6
|
interface OpenAIChatSettings {
|
|
7
7
|
/**
|
|
8
8
|
Modify the likelihood of specified tokens appearing in the completion.
|
|
@@ -271,23 +271,23 @@ type OpenAITranscriptionModelOptions = {
|
|
|
271
271
|
};
|
|
272
272
|
|
|
273
273
|
declare const OpenAIProviderOptionsSchema: z.ZodObject<{
|
|
274
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString, "many"
|
|
275
|
-
language: z.ZodOptional<z.ZodString
|
|
276
|
-
prompt: z.ZodOptional<z.ZodString
|
|
277
|
-
temperature: z.ZodDefault<z.ZodOptional<z.ZodNumber
|
|
278
|
-
timestampGranularities: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodEnum<["word", "segment"]>, "many"
|
|
274
|
+
include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
275
|
+
language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
276
|
+
prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
277
|
+
temperature: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
|
278
|
+
timestampGranularities: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<["word", "segment"]>, "many">>>>;
|
|
279
279
|
}, "strip", z.ZodTypeAny, {
|
|
280
|
-
temperature: number;
|
|
281
|
-
timestampGranularities: ("word" | "segment")[];
|
|
282
|
-
prompt?: string | undefined;
|
|
283
|
-
include?: string[] | undefined;
|
|
284
|
-
language?: string | undefined;
|
|
280
|
+
temperature: number | null;
|
|
281
|
+
timestampGranularities: ("word" | "segment")[] | null;
|
|
282
|
+
prompt?: string | null | undefined;
|
|
283
|
+
include?: string[] | null | undefined;
|
|
284
|
+
language?: string | null | undefined;
|
|
285
285
|
}, {
|
|
286
|
-
prompt?: string | undefined;
|
|
287
|
-
temperature?: number | undefined;
|
|
288
|
-
include?: string[] | undefined;
|
|
289
|
-
language?: string | undefined;
|
|
290
|
-
timestampGranularities?: ("word" | "segment")[] | undefined;
|
|
286
|
+
prompt?: string | null | undefined;
|
|
287
|
+
temperature?: number | null | undefined;
|
|
288
|
+
include?: string[] | null | undefined;
|
|
289
|
+
language?: string | null | undefined;
|
|
290
|
+
timestampGranularities?: ("word" | "segment")[] | null | undefined;
|
|
291
291
|
}>;
|
|
292
292
|
type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV1CallOptions, 'providerOptions'> & {
|
|
293
293
|
providerOptions?: {
|
package/internal/dist/index.js
CHANGED
|
@@ -538,6 +538,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
538
538
|
}
|
|
539
539
|
baseArgs.max_tokens = void 0;
|
|
540
540
|
}
|
|
541
|
+
} else if (this.modelId.startsWith("gpt-4o-search-preview")) {
|
|
542
|
+
if (baseArgs.temperature != null) {
|
|
543
|
+
baseArgs.temperature = void 0;
|
|
544
|
+
warnings.push({
|
|
545
|
+
type: "unsupported-setting",
|
|
546
|
+
setting: "temperature",
|
|
547
|
+
details: "temperature is not supported for the gpt-4o-search-preview model and has been removed."
|
|
548
|
+
});
|
|
549
|
+
}
|
|
541
550
|
}
|
|
542
551
|
switch (type) {
|
|
543
552
|
case "regular": {
|
|
@@ -1607,17 +1616,11 @@ var openaiImageResponseSchema = import_zod5.z.object({
|
|
|
1607
1616
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1608
1617
|
var import_zod6 = require("zod");
|
|
1609
1618
|
var OpenAIProviderOptionsSchema = import_zod6.z.object({
|
|
1610
|
-
include: import_zod6.z.array(import_zod6.z.string()).
|
|
1611
|
-
|
|
1612
|
-
),
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
"An optional text to guide the model's style or continue a previous audio segment."
|
|
1616
|
-
),
|
|
1617
|
-
temperature: import_zod6.z.number().min(0).max(1).optional().default(0).describe("The sampling temperature, between 0 and 1."),
|
|
1618
|
-
timestampGranularities: import_zod6.z.array(import_zod6.z.enum(["word", "segment"])).optional().default(["segment"]).describe(
|
|
1619
|
-
"The timestamp granularities to populate for this transcription."
|
|
1620
|
-
)
|
|
1619
|
+
include: import_zod6.z.array(import_zod6.z.string()).nullish(),
|
|
1620
|
+
language: import_zod6.z.string().nullish(),
|
|
1621
|
+
prompt: import_zod6.z.string().nullish(),
|
|
1622
|
+
temperature: import_zod6.z.number().min(0).max(1).nullish().default(0),
|
|
1623
|
+
timestampGranularities: import_zod6.z.array(import_zod6.z.enum(["word", "segment"])).nullish().default(["segment"])
|
|
1621
1624
|
});
|
|
1622
1625
|
var languageMap = {
|
|
1623
1626
|
afrikaans: "af",
|
|
@@ -1692,6 +1695,7 @@ var OpenAITranscriptionModel = class {
|
|
|
1692
1695
|
mediaType,
|
|
1693
1696
|
providerOptions
|
|
1694
1697
|
}) {
|
|
1698
|
+
var _a, _b, _c, _d, _e;
|
|
1695
1699
|
const warnings = [];
|
|
1696
1700
|
const openAIOptions = (0, import_provider_utils7.parseProviderOptions)({
|
|
1697
1701
|
provider: "openai",
|
|
@@ -1704,16 +1708,16 @@ var OpenAITranscriptionModel = class {
|
|
|
1704
1708
|
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
1705
1709
|
if (openAIOptions) {
|
|
1706
1710
|
const transcriptionModelOptions = {
|
|
1707
|
-
include: openAIOptions.include,
|
|
1708
|
-
language: openAIOptions.language,
|
|
1709
|
-
prompt: openAIOptions.prompt,
|
|
1710
|
-
temperature: openAIOptions.temperature,
|
|
1711
|
-
timestamp_granularities: openAIOptions.timestampGranularities
|
|
1711
|
+
include: (_a = openAIOptions.include) != null ? _a : void 0,
|
|
1712
|
+
language: (_b = openAIOptions.language) != null ? _b : void 0,
|
|
1713
|
+
prompt: (_c = openAIOptions.prompt) != null ? _c : void 0,
|
|
1714
|
+
temperature: (_d = openAIOptions.temperature) != null ? _d : void 0,
|
|
1715
|
+
timestamp_granularities: (_e = openAIOptions.timestampGranularities) != null ? _e : void 0
|
|
1712
1716
|
};
|
|
1713
1717
|
for (const key in transcriptionModelOptions) {
|
|
1714
1718
|
const value = transcriptionModelOptions[key];
|
|
1715
1719
|
if (value !== void 0) {
|
|
1716
|
-
formData.append(key, value);
|
|
1720
|
+
formData.append(key, String(value));
|
|
1717
1721
|
}
|
|
1718
1722
|
}
|
|
1719
1723
|
}
|