@ai-sdk/openai 4.0.0-beta.12 → 4.0.0-beta.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 +9 -0
- package/dist/index.js +26 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +25 -21
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +27 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model.ts +10 -2
- package/src/responses/openai-responses-language-model.ts +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
|
|
8
|
+
- Updated dependencies [3887c70]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
10
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
11
|
+
|
|
3
12
|
## 4.0.0-beta.12
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -671,9 +671,10 @@ var OpenAIChatLanguageModel = class {
|
|
|
671
671
|
seed,
|
|
672
672
|
tools,
|
|
673
673
|
toolChoice,
|
|
674
|
+
reasoning,
|
|
674
675
|
providerOptions
|
|
675
676
|
}) {
|
|
676
|
-
var _a, _b, _c, _d, _e;
|
|
677
|
+
var _a, _b, _c, _d, _e, _f;
|
|
677
678
|
const warnings = [];
|
|
678
679
|
const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
679
680
|
provider: "openai",
|
|
@@ -681,18 +682,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
681
682
|
schema: openaiLanguageModelChatOptions
|
|
682
683
|
})) != null ? _a : {};
|
|
683
684
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
684
|
-
const
|
|
685
|
+
const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : (0, import_provider_utils5.isCustomReasoning)(reasoning) ? reasoning : void 0;
|
|
686
|
+
const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
|
|
685
687
|
if (topK != null) {
|
|
686
688
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
687
689
|
}
|
|
688
690
|
const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
|
|
689
691
|
{
|
|
690
692
|
prompt,
|
|
691
|
-
systemMessageMode: (
|
|
693
|
+
systemMessageMode: (_d = openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
|
|
692
694
|
}
|
|
693
695
|
);
|
|
694
696
|
warnings.push(...messageWarnings);
|
|
695
|
-
const strictJsonSchema = (
|
|
697
|
+
const strictJsonSchema = (_e = openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
696
698
|
const baseArgs = {
|
|
697
699
|
// model id:
|
|
698
700
|
model: this.modelId,
|
|
@@ -713,7 +715,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
713
715
|
json_schema: {
|
|
714
716
|
schema: responseFormat.schema,
|
|
715
717
|
strict: strictJsonSchema,
|
|
716
|
-
name: (
|
|
718
|
+
name: (_f = responseFormat.name) != null ? _f : "response",
|
|
717
719
|
description: responseFormat.description
|
|
718
720
|
}
|
|
719
721
|
} : { type: "json_object" } : void 0,
|
|
@@ -726,7 +728,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
726
728
|
store: openaiOptions.store,
|
|
727
729
|
metadata: openaiOptions.metadata,
|
|
728
730
|
prediction: openaiOptions.prediction,
|
|
729
|
-
reasoning_effort:
|
|
731
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
730
732
|
service_tier: openaiOptions.serviceTier,
|
|
731
733
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
732
734
|
prompt_cache_retention: openaiOptions.promptCacheRetention,
|
|
@@ -735,7 +737,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
735
737
|
messages
|
|
736
738
|
};
|
|
737
739
|
if (isReasoningModel) {
|
|
738
|
-
if (
|
|
740
|
+
if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
739
741
|
if (baseArgs.temperature != null) {
|
|
740
742
|
baseArgs.temperature = void 0;
|
|
741
743
|
warnings.push({
|
|
@@ -4654,12 +4656,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4654
4656
|
frequencyPenalty,
|
|
4655
4657
|
seed,
|
|
4656
4658
|
prompt,
|
|
4659
|
+
reasoning,
|
|
4657
4660
|
providerOptions,
|
|
4658
4661
|
tools,
|
|
4659
4662
|
toolChoice,
|
|
4660
4663
|
responseFormat
|
|
4661
4664
|
}) {
|
|
4662
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4665
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4663
4666
|
const warnings = [];
|
|
4664
4667
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4665
4668
|
if (topK != null) {
|
|
@@ -4690,7 +4693,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4690
4693
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
4691
4694
|
});
|
|
4692
4695
|
}
|
|
4693
|
-
const
|
|
4696
|
+
const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : (0, import_provider_utils29.isCustomReasoning)(reasoning) ? reasoning : void 0;
|
|
4697
|
+
const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
4694
4698
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
4695
4699
|
warnings.push({
|
|
4696
4700
|
type: "unsupported",
|
|
@@ -4727,10 +4731,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4727
4731
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
4728
4732
|
prompt,
|
|
4729
4733
|
toolNameMapping,
|
|
4730
|
-
systemMessageMode: (
|
|
4734
|
+
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
4731
4735
|
providerOptionsName,
|
|
4732
4736
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
4733
|
-
store: (
|
|
4737
|
+
store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
|
|
4734
4738
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
4735
4739
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
4736
4740
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -4738,7 +4742,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4738
4742
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
4739
4743
|
});
|
|
4740
4744
|
warnings.push(...inputWarnings);
|
|
4741
|
-
const strictJsonSchema = (
|
|
4745
|
+
const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
4742
4746
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4743
4747
|
function addInclude(key) {
|
|
4744
4748
|
if (include == null) {
|
|
@@ -4754,9 +4758,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4754
4758
|
if (topLogprobs) {
|
|
4755
4759
|
addInclude("message.output_text.logprobs");
|
|
4756
4760
|
}
|
|
4757
|
-
const webSearchToolName = (
|
|
4761
|
+
const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
|
|
4758
4762
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4759
|
-
)) == null ? void 0 :
|
|
4763
|
+
)) == null ? void 0 : _f.name;
|
|
4760
4764
|
if (webSearchToolName) {
|
|
4761
4765
|
addInclude("web_search_call.action.sources");
|
|
4762
4766
|
}
|
|
@@ -4779,7 +4783,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4779
4783
|
format: responseFormat.schema != null ? {
|
|
4780
4784
|
type: "json_schema",
|
|
4781
4785
|
strict: strictJsonSchema,
|
|
4782
|
-
name: (
|
|
4786
|
+
name: (_g = responseFormat.name) != null ? _g : "response",
|
|
4783
4787
|
description: responseFormat.description,
|
|
4784
4788
|
schema: responseFormat.schema
|
|
4785
4789
|
} : { type: "json_object" }
|
|
@@ -4813,10 +4817,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4813
4817
|
}))
|
|
4814
4818
|
},
|
|
4815
4819
|
// model-specific settings:
|
|
4816
|
-
...isReasoningModel && (
|
|
4820
|
+
...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
4817
4821
|
reasoning: {
|
|
4818
|
-
...
|
|
4819
|
-
effort:
|
|
4822
|
+
...resolvedReasoningEffort != null && {
|
|
4823
|
+
effort: resolvedReasoningEffort
|
|
4820
4824
|
},
|
|
4821
4825
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
4822
4826
|
summary: openaiOptions.reasoningSummary
|
|
@@ -4825,7 +4829,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4825
4829
|
}
|
|
4826
4830
|
};
|
|
4827
4831
|
if (isReasoningModel) {
|
|
4828
|
-
if (!(
|
|
4832
|
+
if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
4829
4833
|
if (baseArgs.temperature != null) {
|
|
4830
4834
|
baseArgs.temperature = void 0;
|
|
4831
4835
|
warnings.push({
|
|
@@ -4875,9 +4879,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4875
4879
|
});
|
|
4876
4880
|
delete baseArgs.service_tier;
|
|
4877
4881
|
}
|
|
4878
|
-
const shellToolEnvType = (
|
|
4882
|
+
const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
|
|
4879
4883
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
4880
|
-
)) == null ? void 0 :
|
|
4884
|
+
)) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
|
|
4881
4885
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
4882
4886
|
return {
|
|
4883
4887
|
webSearchToolName,
|
|
@@ -6678,7 +6682,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6678
6682
|
};
|
|
6679
6683
|
|
|
6680
6684
|
// src/version.ts
|
|
6681
|
-
var VERSION = true ? "4.0.0-beta.
|
|
6685
|
+
var VERSION = true ? "4.0.0-beta.13" : "0.0.0-test";
|
|
6682
6686
|
|
|
6683
6687
|
// src/openai-provider.ts
|
|
6684
6688
|
function createOpenAI(options = {}) {
|