@ai-sdk/openai 2.0.38 → 2.1.0-beta.1
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 +11 -43
- package/dist/index.d.mts +1 -34
- package/dist/index.d.ts +1 -34
- package/dist/index.js +33 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -55
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +3 -214
- package/dist/internal/index.d.ts +3 -214
- package/dist/internal/index.js +27 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +25 -49
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// src/openai-provider.ts
|
|
2
2
|
import {
|
|
3
3
|
loadApiKey,
|
|
4
|
-
withoutTrailingSlash
|
|
5
|
-
withUserAgentSuffix
|
|
4
|
+
withoutTrailingSlash
|
|
6
5
|
} from "@ai-sdk/provider-utils";
|
|
7
6
|
|
|
8
7
|
// src/chat/openai-chat-language-model.ts
|
|
@@ -251,7 +250,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
251
250
|
|
|
252
251
|
// src/chat/openai-chat-options.ts
|
|
253
252
|
import { z as z2 } from "zod/v4";
|
|
254
|
-
var
|
|
253
|
+
var openaiProviderOptions = z2.object({
|
|
255
254
|
/**
|
|
256
255
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
257
256
|
*
|
|
@@ -435,7 +434,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
435
434
|
const openaiOptions = (_a = await parseProviderOptions({
|
|
436
435
|
provider: "openai",
|
|
437
436
|
providerOptions,
|
|
438
|
-
schema:
|
|
437
|
+
schema: openaiProviderOptions
|
|
439
438
|
})) != null ? _a : {};
|
|
440
439
|
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
441
440
|
if (topK != null) {
|
|
@@ -2089,6 +2088,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2089
2088
|
});
|
|
2090
2089
|
break;
|
|
2091
2090
|
}
|
|
2091
|
+
// assistant tool result parts are from provider-executed tools:
|
|
2092
2092
|
case "tool-result": {
|
|
2093
2093
|
if (store) {
|
|
2094
2094
|
input.push({ type: "item_reference", id: part.toolCallId });
|
|
@@ -2108,40 +2108,26 @@ async function convertToOpenAIResponsesInput({
|
|
|
2108
2108
|
});
|
|
2109
2109
|
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2110
2110
|
if (reasoningId != null) {
|
|
2111
|
-
const
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2111
|
+
const existingReasoningMessage = reasoningMessages[reasoningId];
|
|
2112
|
+
const summaryParts = [];
|
|
2113
|
+
if (part.text.length > 0) {
|
|
2114
|
+
summaryParts.push({ type: "summary_text", text: part.text });
|
|
2115
|
+
} else if (existingReasoningMessage !== void 0) {
|
|
2116
|
+
warnings.push({
|
|
2117
|
+
type: "other",
|
|
2118
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
if (existingReasoningMessage === void 0) {
|
|
2122
|
+
reasoningMessages[reasoningId] = {
|
|
2123
|
+
type: "reasoning",
|
|
2124
|
+
id: reasoningId,
|
|
2125
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2126
|
+
summary: summaryParts
|
|
2127
|
+
};
|
|
2128
|
+
input.push(reasoningMessages[reasoningId]);
|
|
2121
2129
|
} else {
|
|
2122
|
-
|
|
2123
|
-
if (part.text.length > 0) {
|
|
2124
|
-
summaryParts.push({
|
|
2125
|
-
type: "summary_text",
|
|
2126
|
-
text: part.text
|
|
2127
|
-
});
|
|
2128
|
-
} else if (reasoningMessage !== void 0) {
|
|
2129
|
-
warnings.push({
|
|
2130
|
-
type: "other",
|
|
2131
|
-
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
2132
|
-
});
|
|
2133
|
-
}
|
|
2134
|
-
if (reasoningMessage === void 0) {
|
|
2135
|
-
reasoningMessages[reasoningId] = {
|
|
2136
|
-
type: "reasoning",
|
|
2137
|
-
id: reasoningId,
|
|
2138
|
-
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2139
|
-
summary: summaryParts
|
|
2140
|
-
};
|
|
2141
|
-
input.push(reasoningMessages[reasoningId]);
|
|
2142
|
-
} else {
|
|
2143
|
-
reasoningMessage.summary.push(...summaryParts);
|
|
2144
|
-
}
|
|
2130
|
+
existingReasoningMessage.summary.push(...summaryParts);
|
|
2145
2131
|
}
|
|
2146
2132
|
} else {
|
|
2147
2133
|
warnings.push({
|
|
@@ -2695,7 +2681,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2695
2681
|
])
|
|
2696
2682
|
),
|
|
2697
2683
|
service_tier: z15.string().nullish(),
|
|
2698
|
-
incomplete_details: z15.object({ reason: z15.string() }).
|
|
2684
|
+
incomplete_details: z15.object({ reason: z15.string() }).nullable(),
|
|
2699
2685
|
usage: usageSchema2
|
|
2700
2686
|
})
|
|
2701
2687
|
),
|
|
@@ -3917,27 +3903,21 @@ var openaiTranscriptionResponseSchema = z18.object({
|
|
|
3917
3903
|
).nullish()
|
|
3918
3904
|
});
|
|
3919
3905
|
|
|
3920
|
-
// src/version.ts
|
|
3921
|
-
var VERSION = true ? "2.0.38" : "0.0.0-test";
|
|
3922
|
-
|
|
3923
3906
|
// src/openai-provider.ts
|
|
3924
3907
|
function createOpenAI(options = {}) {
|
|
3925
3908
|
var _a, _b;
|
|
3926
3909
|
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
|
|
3927
3910
|
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
3928
|
-
const getHeaders = () =>
|
|
3929
|
-
{
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
},
|
|
3939
|
-
`ai-sdk/openai/${VERSION}`
|
|
3940
|
-
);
|
|
3911
|
+
const getHeaders = () => ({
|
|
3912
|
+
Authorization: `Bearer ${loadApiKey({
|
|
3913
|
+
apiKey: options.apiKey,
|
|
3914
|
+
environmentVariableName: "OPENAI_API_KEY",
|
|
3915
|
+
description: "OpenAI"
|
|
3916
|
+
})}`,
|
|
3917
|
+
"OpenAI-Organization": options.organization,
|
|
3918
|
+
"OpenAI-Project": options.project,
|
|
3919
|
+
...options.headers
|
|
3920
|
+
});
|
|
3941
3921
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
3942
3922
|
provider: `${providerName}.chat`,
|
|
3943
3923
|
url: ({ path }) => `${baseURL}${path}`,
|
|
@@ -4012,7 +3992,6 @@ function createOpenAI(options = {}) {
|
|
|
4012
3992
|
}
|
|
4013
3993
|
var openai = createOpenAI();
|
|
4014
3994
|
export {
|
|
4015
|
-
VERSION,
|
|
4016
3995
|
createOpenAI,
|
|
4017
3996
|
openai
|
|
4018
3997
|
};
|