@ai-sdk/openai 1.3.0 → 1.3.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 +13 -0
- package/dist/index.d.mts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +18 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -32
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +28 -1
- package/internal/dist/index.d.ts +28 -1
- package/internal/dist/index.js +18 -28
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +20 -32
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1612,16 +1612,13 @@ var openaiImageResponseSchema = z5.object({
|
|
|
1612
1612
|
});
|
|
1613
1613
|
|
|
1614
1614
|
// src/responses/openai-responses-language-model.ts
|
|
1615
|
-
import {
|
|
1616
|
-
InvalidArgumentError
|
|
1617
|
-
} from "@ai-sdk/provider";
|
|
1618
1615
|
import {
|
|
1619
1616
|
combineHeaders as combineHeaders5,
|
|
1620
1617
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
1621
1618
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
1622
1619
|
generateId as generateId2,
|
|
1623
|
-
|
|
1624
|
-
|
|
1620
|
+
parseProviderOptions,
|
|
1621
|
+
postJsonToApi as postJsonToApi5
|
|
1625
1622
|
} from "@ai-sdk/provider-utils";
|
|
1626
1623
|
import { z as z6 } from "zod";
|
|
1627
1624
|
|
|
@@ -1865,7 +1862,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1865
1862
|
providerMetadata,
|
|
1866
1863
|
responseFormat
|
|
1867
1864
|
}) {
|
|
1868
|
-
var _a, _b, _c
|
|
1865
|
+
var _a, _b, _c;
|
|
1869
1866
|
const warnings = [];
|
|
1870
1867
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
1871
1868
|
const type = mode.type;
|
|
@@ -1904,19 +1901,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1904
1901
|
systemMessageMode: modelConfig.systemMessageMode
|
|
1905
1902
|
});
|
|
1906
1903
|
warnings.push(...messageWarnings);
|
|
1907
|
-
const
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
argument: "providerOptions",
|
|
1914
|
-
message: "invalid provider options",
|
|
1915
|
-
cause: parsedProviderOptions.error
|
|
1916
|
-
});
|
|
1917
|
-
}
|
|
1918
|
-
const openaiOptions = (_a = parsedProviderOptions.value) == null ? void 0 : _a.openai;
|
|
1919
|
-
const isStrict = (_b = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _b : true;
|
|
1904
|
+
const openaiOptions = parseProviderOptions({
|
|
1905
|
+
provider: "openai",
|
|
1906
|
+
providerOptions: providerMetadata,
|
|
1907
|
+
schema: openaiResponsesProviderOptionsSchema
|
|
1908
|
+
});
|
|
1909
|
+
const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
|
|
1920
1910
|
const baseArgs = {
|
|
1921
1911
|
model: this.modelId,
|
|
1922
1912
|
input: messages,
|
|
@@ -1928,7 +1918,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1928
1918
|
format: responseFormat.schema != null ? {
|
|
1929
1919
|
type: "json_schema",
|
|
1930
1920
|
strict: isStrict,
|
|
1931
|
-
name: (
|
|
1921
|
+
name: (_b = responseFormat.name) != null ? _b : "response",
|
|
1932
1922
|
description: responseFormat.description,
|
|
1933
1923
|
schema: responseFormat.schema
|
|
1934
1924
|
} : { type: "json_object" }
|
|
@@ -1990,7 +1980,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1990
1980
|
format: mode.schema != null ? {
|
|
1991
1981
|
type: "json_schema",
|
|
1992
1982
|
strict: isStrict,
|
|
1993
|
-
name: (
|
|
1983
|
+
name: (_c = mode.name) != null ? _c : "response",
|
|
1994
1984
|
description: mode.description,
|
|
1995
1985
|
schema: mode.schema
|
|
1996
1986
|
} : { type: "json_object" }
|
|
@@ -2383,17 +2373,6 @@ function isResponseOutputItemAddedChunk(chunk) {
|
|
|
2383
2373
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
2384
2374
|
return chunk.type === "response.output_text.annotation.added";
|
|
2385
2375
|
}
|
|
2386
|
-
var providerOptionsSchema = z6.object({
|
|
2387
|
-
openai: z6.object({
|
|
2388
|
-
metadata: z6.any().nullish(),
|
|
2389
|
-
parallelToolCalls: z6.boolean().nullish(),
|
|
2390
|
-
previousResponseId: z6.string().nullish(),
|
|
2391
|
-
store: z6.boolean().nullish(),
|
|
2392
|
-
user: z6.string().nullish(),
|
|
2393
|
-
reasoningEffort: z6.string().nullish(),
|
|
2394
|
-
strictSchemas: z6.boolean().nullish()
|
|
2395
|
-
}).nullish()
|
|
2396
|
-
});
|
|
2397
2376
|
function getResponsesModelConfig(modelId) {
|
|
2398
2377
|
if (modelId.startsWith("o")) {
|
|
2399
2378
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
@@ -2415,6 +2394,15 @@ function getResponsesModelConfig(modelId) {
|
|
|
2415
2394
|
requiredAutoTruncation: false
|
|
2416
2395
|
};
|
|
2417
2396
|
}
|
|
2397
|
+
var openaiResponsesProviderOptionsSchema = z6.object({
|
|
2398
|
+
metadata: z6.any().nullish(),
|
|
2399
|
+
parallelToolCalls: z6.boolean().nullish(),
|
|
2400
|
+
previousResponseId: z6.string().nullish(),
|
|
2401
|
+
store: z6.boolean().nullish(),
|
|
2402
|
+
user: z6.string().nullish(),
|
|
2403
|
+
reasoningEffort: z6.string().nullish(),
|
|
2404
|
+
strictSchemas: z6.boolean().nullish()
|
|
2405
|
+
});
|
|
2418
2406
|
|
|
2419
2407
|
// src/openai-tools.ts
|
|
2420
2408
|
import { z as z7 } from "zod";
|