@ai-sdk/openai 4.0.84 → 4.0.86
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 +36 -0
- package/dist/index.d.ts +56 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +216 -19
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +39 -10
- package/package.json +5 -5
- package/src/files/openai-files.ts +1 -1
- package/src/index.ts +2 -0
- package/src/openai-batch.ts +2 -0
- package/src/openai-decision-model-options.ts +19 -0
- package/src/openai-decision-model.ts +285 -0
- package/src/openai-provider.ts +20 -7
- package/src/skills/openai-skills.ts +5 -1
- package/src/transcription/openai-transcription-model.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.86
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d3bcad9: feat(provider): report decision refusals as refusal answers
|
|
8
|
+
- Updated dependencies [d3bcad9]
|
|
9
|
+
- @ai-sdk/provider@4.0.24
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.56
|
|
11
|
+
|
|
12
|
+
## 4.0.85
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- fc1e19e: fix: limit jsonl rows to 64mb during batch result downloads
|
|
17
|
+
- 99bdcd2: Replace the OpenAI structured-output wrapper for `decide` with the native Decisions API. Only `gpt-6-luna` is currently supported by this endpoint; other Responses models no longer work with `openai.decisionModel()` or its deprecated `evaluationModel()` alias.
|
|
18
|
+
|
|
19
|
+
Responses API options, such as `reasoningEffort`, are no longer applied and produce unsupported-option warnings. The Decisions API supports `providerOptions.openai.safetyIdentifier`. Native token usage and confidence values are preserved, and per-question refusals fail the decision call.
|
|
20
|
+
|
|
21
|
+
- 268225c: feat(provider): add a portable `max` reasoning level with native provider mappings, compatibility coercions, and budget-based fallback support.
|
|
22
|
+
|
|
23
|
+
Compatibility notes:
|
|
24
|
+
|
|
25
|
+
- **TypeScript source compatibility:** Adding `max` widens `LanguageModelV4CallOptions['reasoning']` and the derived `ReasoningLevel` type. Third-party providers and consumers with exhaustive switches or `Record<ReasoningLevel, ...>` mappings must handle `max` before upgrading. Ordinary calls using existing reasoning levels remain accepted.
|
|
26
|
+
- **Amazon Bedrock:** Existing Nova 2 calls using portable `reasoning: 'xhigh'` now send `maxReasoningEffort: 'high'` instead of the unsupported `'max'`, and return a compatibility warning. Anthropic and OpenAI Bedrock effort mappings retain their existing `xhigh` behavior. Partial Bedrock reasoning configurations continue to preserve explicit values and derive missing fields; explicit effort/budget overrides and disabled thinking no longer emit warnings for portable mappings that are not sent.
|
|
27
|
+
- **Fireworks:** Existing portable `minimal` and `xhigh` calls keep their request mappings to `low` and `high`, respectively, and now return compatibility warnings in generation and streaming results. Portable `max` maps to `high` with the same warning behavior.
|
|
28
|
+
|
|
29
|
+
**Release classification:** This remains a patch changeset under the repository's explicit release policy, which uses patch releases for both fixes and features. The TypeScript source-compatibility caveat for exhaustive consumers is disclosed above. Maintainers can override this classification with a `major` label if they decide to align the provider-spec addition with a future AI SDK major release.
|
|
30
|
+
|
|
31
|
+
- 0af2f7c: chore: upgrade to TypeScript 6
|
|
32
|
+
- Updated dependencies [fc1e19e]
|
|
33
|
+
- Updated dependencies [5094ebd]
|
|
34
|
+
- Updated dependencies [268225c]
|
|
35
|
+
- Updated dependencies [0af2f7c]
|
|
36
|
+
- @ai-sdk/provider-utils@5.0.55
|
|
37
|
+
- @ai-sdk/provider@4.0.23
|
|
38
|
+
|
|
3
39
|
## 4.0.84
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { FetchFunction, InferSchema, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConstructor } from "@ai-sdk/provider-utils";
|
|
2
2
|
import { EmbeddingModelV4, Experimental_BatchV4, Experimental_DecisionModelV4, Experimental_RealtimeFactoryV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4SessionConfig, Experimental_SpeechTranslationModelV4, Experimental_SpeechTranslationModelV4StreamOptions, FilesV4, ImageModelV4, JSONObject, JSONValue, LanguageModelV4, ProviderV4, SkillsV4, SpeechModelV4, TranscriptionModelV4 } from "@ai-sdk/provider";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
|
+
//#region src/openai-config.d.ts
|
|
5
|
+
type OpenAIHeaders = Record<string, string | undefined>;
|
|
6
|
+
type OpenAIConfig = {
|
|
7
|
+
provider: string;
|
|
8
|
+
baseURL?: string;
|
|
9
|
+
url: (options: {
|
|
10
|
+
modelId: string;
|
|
11
|
+
path: string;
|
|
12
|
+
}) => string;
|
|
13
|
+
headers?: () => OpenAIHeaders;
|
|
14
|
+
fetch?: FetchFunction;
|
|
15
|
+
webSocket?: WebSocketConstructor;
|
|
16
|
+
generateId?: () => string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether Responses API message input items must include an explicit
|
|
19
|
+
* `type: 'message'` discriminator.
|
|
20
|
+
*
|
|
21
|
+
* @see https://github.com/vercel/ai/issues/20180
|
|
22
|
+
*/
|
|
23
|
+
explicitMessageItemType?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the provider supports the
|
|
26
|
+
* `web_search_call.action.sources` Responses API include value.
|
|
27
|
+
*
|
|
28
|
+
* Defaults to `true`.
|
|
29
|
+
*/
|
|
30
|
+
supportsWebSearchSourcesInclude?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
|
|
33
|
+
* in file part data instead. File ID prefixes used to identify file IDs
|
|
34
|
+
* in Responses API. When undefined, all string file data is treated as
|
|
35
|
+
* base64 content.
|
|
36
|
+
*
|
|
37
|
+
* TODO: remove in v8
|
|
38
|
+
*/
|
|
39
|
+
fileIdPrefixes?: readonly string[];
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/openai-decision-model.d.ts
|
|
43
|
+
type OpenAIDecisionModelId = 'gpt-6-luna' | (string & {});
|
|
44
|
+
//#endregion
|
|
4
45
|
//#region src/chat/openai-chat-language-model-options.d.ts
|
|
5
46
|
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | '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-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
|
|
6
47
|
declare const openaiLanguageModelChatOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
@@ -1594,10 +1635,10 @@ type OpenAISpeechTranslationModelOptions = InferSchema<typeof openAISpeechTransl
|
|
|
1594
1635
|
//#region src/openai-provider.d.ts
|
|
1595
1636
|
interface OpenAIProvider extends ProviderV4 {
|
|
1596
1637
|
(modelId: OpenAIResponsesModelId): LanguageModelV4;
|
|
1597
|
-
/** Creates an experimental Choice/Score/Boolean decision model using the
|
|
1598
|
-
decisionModel(modelId:
|
|
1638
|
+
/** Creates an experimental Choice/Score/Boolean decision model using the Decisions API. */
|
|
1639
|
+
decisionModel(modelId: OpenAIDecisionModelId): Experimental_DecisionModelV4;
|
|
1599
1640
|
/** @deprecated Use `decisionModel` instead. */
|
|
1600
|
-
evaluationModel(modelId:
|
|
1641
|
+
evaluationModel(modelId: OpenAIDecisionModelId): Experimental_DecisionModelV4 & {
|
|
1601
1642
|
doEvaluate: Experimental_DecisionModelV4['doDecide'];
|
|
1602
1643
|
};
|
|
1603
1644
|
/**
|
|
@@ -1681,6 +1722,11 @@ interface OpenAIProvider extends ProviderV4 {
|
|
|
1681
1722
|
tools: typeof openaiTools;
|
|
1682
1723
|
}
|
|
1683
1724
|
interface OpenAIProviderSettings {
|
|
1725
|
+
/** Settings for downloading JSON Lines batch results. */
|
|
1726
|
+
batchResultDownloads?: {
|
|
1727
|
+
/** Maximum UTF-8 bytes per row, excluding LF. Defaults to 64 MiB. */
|
|
1728
|
+
maxLineBytes?: number;
|
|
1729
|
+
};
|
|
1684
1730
|
/**
|
|
1685
1731
|
* Base URL for the OpenAI API calls.
|
|
1686
1732
|
*/
|
|
@@ -1741,44 +1787,6 @@ type OpenAIToolOptions = {
|
|
|
1741
1787
|
};
|
|
1742
1788
|
};
|
|
1743
1789
|
//#endregion
|
|
1744
|
-
//#region src/openai-config.d.ts
|
|
1745
|
-
type OpenAIHeaders = Record<string, string | undefined>;
|
|
1746
|
-
type OpenAIConfig = {
|
|
1747
|
-
provider: string;
|
|
1748
|
-
baseURL?: string;
|
|
1749
|
-
url: (options: {
|
|
1750
|
-
modelId: string;
|
|
1751
|
-
path: string;
|
|
1752
|
-
}) => string;
|
|
1753
|
-
headers?: () => OpenAIHeaders;
|
|
1754
|
-
fetch?: FetchFunction;
|
|
1755
|
-
webSocket?: WebSocketConstructor;
|
|
1756
|
-
generateId?: () => string;
|
|
1757
|
-
/**
|
|
1758
|
-
* Whether Responses API message input items must include an explicit
|
|
1759
|
-
* `type: 'message'` discriminator.
|
|
1760
|
-
*
|
|
1761
|
-
* @see https://github.com/vercel/ai/issues/20180
|
|
1762
|
-
*/
|
|
1763
|
-
explicitMessageItemType?: boolean;
|
|
1764
|
-
/**
|
|
1765
|
-
* Whether the provider supports the
|
|
1766
|
-
* `web_search_call.action.sources` Responses API include value.
|
|
1767
|
-
*
|
|
1768
|
-
* Defaults to `true`.
|
|
1769
|
-
*/
|
|
1770
|
-
supportsWebSearchSourcesInclude?: boolean;
|
|
1771
|
-
/**
|
|
1772
|
-
* This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
|
|
1773
|
-
* in file part data instead. File ID prefixes used to identify file IDs
|
|
1774
|
-
* in Responses API. When undefined, all string file data is treated as
|
|
1775
|
-
* base64 content.
|
|
1776
|
-
*
|
|
1777
|
-
* TODO: remove in v8
|
|
1778
|
-
*/
|
|
1779
|
-
fileIdPrefixes?: readonly string[];
|
|
1780
|
-
};
|
|
1781
|
-
//#endregion
|
|
1782
1790
|
//#region src/speech-translation/openai-speech-translation-model.d.ts
|
|
1783
1791
|
interface OpenAISpeechTranslationModelConfig extends OpenAIConfig {
|
|
1784
1792
|
_internal?: {
|
|
@@ -1936,5 +1944,11 @@ type OpenaiResponsesSourceDocumentProviderMetadata = {
|
|
|
1936
1944
|
//#region src/version.d.ts
|
|
1937
1945
|
export declare const VERSION: string;
|
|
1938
1946
|
//#endregion
|
|
1939
|
-
|
|
1947
|
+
//#region src/openai-decision-model-options.d.ts
|
|
1948
|
+
declare const openaiDecisionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
1949
|
+
safetyIdentifier?: string | undefined;
|
|
1950
|
+
}>;
|
|
1951
|
+
type OpenAIDecisionModelOptions = InferSchema<typeof openaiDecisionModelOptions>;
|
|
1952
|
+
//#endregion
|
|
1953
|
+
export { type OpenAIRealtimeFactory as Experimental_OpenAIRealtimeFactory, OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig, OpenAIRealtimeModelLive as Experimental_OpenAIRealtimeModelLive, type OpenAIRealtimeModelLiveConfig as Experimental_OpenAIRealtimeModelLiveConfig, type OpenAIRealtimeModelLiveId as Experimental_OpenAIRealtimeModelLiveId, type OpenAIRealtimeModelLiveOptions as Experimental_OpenAIRealtimeModelLiveOptions, type OpenAIRealtimeOptions as Experimental_OpenAIRealtimeOptions, OpenAISpeechTranslationModel as Experimental_OpenAISpeechTranslationModel, OpenAISpeechTranslationModel as Experimental_OpenAITranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAISpeechTranslationModelId, type OpenAISpeechTranslationModelId as Experimental_OpenAITranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAISpeechTranslationModelOptions, type OpenAISpeechTranslationModelOptions as Experimental_OpenAITranslationModelOptions, type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAILanguageModelChatOptions, type OpenAIComputerAction, type OpenAIComputerSafetyCheck, type OpenAIDecisionModelId, type OpenAIDecisionModelOptions, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesSystemMessageOptions, type OpenAISpeechModelOptions, type OpenAIToolOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type OpenaiResponsesToolCallProviderMetadata };
|
|
1940
1954
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__tool_apply_patch0.ApplyPatchOperation","_$__tool_custom0.customToolFactory","_$_0.OpenAIComputerAction","_$_0.OpenAIComputerSafetyCheck","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolComparisonFilter","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolCompoundFilter","_$__tool_web_search0.webSearchToolFactory","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4SessionConfig","RealtimeModelV4","RealtimeModelV4SessionConfig","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4","RealtimeFactoryV4","DecisionModelV4","SpeechTranslationModelV4","BatchV4","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/chat/openai-chat-language-model-options.ts","../src/completion/openai-completion-language-model-options.ts","../src/embedding/openai-embedding-model-options.ts","../src/image/openai-image-model-options.ts","../src/tool/apply-patch.ts","../src/tool/custom.ts","../src/responses/openai-responses-api.ts","../src/tool/web-search.ts","../src/openai-tools.ts","../src/live/openai-realtime-model-live-options.ts","../src/realtime/openai-realtime-model.ts","../src/live/openai-realtime-model-live.ts","../src/realtime/openai-realtime-factory.ts","../src/responses/openai-responses-language-model-options.ts","../src/speech/openai-speech-model-options.ts","../src/transcription/openai-transcription-model-options.ts","../src/speech-translation/openai-speech-translation-model-options.ts","../src/openai-provider.ts","../src/responses/openai-responses-prepare-tools.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__tool_apply_patch0.ApplyPatchOperation","_$__tool_custom0.customToolFactory","_$_0.OpenAIComputerAction","_$_0.OpenAIComputerSafetyCheck","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolComparisonFilter","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolCompoundFilter","_$__tool_web_search0.webSearchToolFactory","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4SessionConfig","RealtimeModelV4","RealtimeModelV4SessionConfig","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4","RealtimeFactoryV4","DecisionModelV4","SpeechTranslationModelV4","BatchV4","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/openai-config.ts","../src/openai-decision-model.ts","../src/chat/openai-chat-language-model-options.ts","../src/completion/openai-completion-language-model-options.ts","../src/embedding/openai-embedding-model-options.ts","../src/image/openai-image-model-options.ts","../src/tool/apply-patch.ts","../src/tool/custom.ts","../src/responses/openai-responses-api.ts","../src/tool/web-search.ts","../src/openai-tools.ts","../src/live/openai-realtime-model-live-options.ts","../src/realtime/openai-realtime-model.ts","../src/live/openai-realtime-model-live.ts","../src/realtime/openai-realtime-factory.ts","../src/responses/openai-responses-language-model-options.ts","../src/speech/openai-speech-model-options.ts","../src/transcription/openai-transcription-model-options.ts","../src/speech-translation/openai-speech-translation-model-options.ts","../src/openai-provider.ts","../src/responses/openai-responses-prepare-tools.ts","../src/speech-translation/openai-speech-translation-model.ts","../src/files/openai-files-options.ts","../src/tool/computer.ts","../src/responses/openai-responses-provider-metadata.ts","../src/version.ts","../src/openai-decision-model-options.ts"],"mappings":";;;;KAKK,gBAAgB;KAMT;EACV;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;KClBU;;;KCfA;cAsEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;KAwJ/B,iCAAiC,mBACpC;;;KC/NG;cAKC,uEAAoC;;cAApC;;;;;KAiDD,uCAAuC,mBAC1C;;;KCxDG;cAMC,8DAA2B;;;;KAkB5B,8BAA8B,mBACjC;;;KCzBG;cAiFC,0DAAuB;;;;;;;KAIxB,0BAA0B,mBAC7B;cAGI,oEAAiC;;;;;;;;;KAmBlC,oCAAoC,mBACvC;cAGI,8DAA2B;;;;;;;;KAW5B,8BAA8B,mBACjC;;;;;;KCzEG;EAEN;;;;EAIA;;;;EAIA;;EAGA;;;;EAIA;;EAGA;;;;EAIA;;;;EAIA;;;;cCxDO,oDAAiB;;;;EAMZ;;;;;EAMN;;;;;EAOJ;IACE;IACA;IACA;;IAGA;;;;;;;;KC4bE;;;;EAIV;;;;EAKA;;;;EAKA;;;;;KAMU;;;;EAIV;;;;EAKA,SAAS,MACL,gDACA;;cAkVO,6DAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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YAAY;;;;;wBAME,aACd,UAAS,yBACR;;;;qBAmMU,QAAM;;;KC3XP;EACV,iBAAiB;;;;;EAKjB;EACA;EACA,eAAe;EACf;IACE;IACA;;;;;UCZM,2CAA2C;EACnD;IACE,oBAAoB;;;cAIX,wCAAwCE;WAsBxC,SAAS;mBACD;WAtBV;UAED,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKO,YAAA,SAAS,gCACD,QAAQ;EAGrB,SACJ,SAASD,qDACR,QAAQ,QAAQ,WAAWC;;;;cC5DnB,2DAAwB;;;;KAczB,qBAAqB,mBAAmB;;;cCd9C,mBAAiB,EAAA;;;;GAIrB,EAAA,KAAA;cAEI,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CxB,EAAA,KAAA;KAkCU,uBAAuB,EAAE,aAAa;KACtC,4BAA4B,EAAE,aAAa;;;KCzFlD,uBAAuB,mBAAmB;KAE1C,gDAAgD,QACnD;EACE;;KAGQ;EACV;EACA,WAAW,MAAM;EACjB;EACA;;KAGU;EACV;EACA;;KAGU;EACV,QAAQ;;KAGE;EACV,QAAQ;;KAGE;EACV;EACA;EACA;EACA;IACM;;IAEA;IACA;;;KAII;EACV,QAAQ;;KAGE;EACV;EACA;EACA;;KAGU;EACV,QAAQ;;KAGE;EACV;EACA;EACA,cAAc,MAAM;;KAGV;EACV,QAAQ;;KAGE;EAEN;EACA;EACA;;EAGA;EACA;EACA;;EAGA;EACA;EACA;;KAGM;EACV,QAAQ;;;;qBCrFG;;;cCKA,6DAA0B;EAAA;;KAS3B,6BAA6B,mBAChC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, createBinaryResponseHandler, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, deleteFromApi, downloadBlob, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mediaTypeToExtension, normalizeBatchRequestCounts, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, postMultipartStreamToApi, postToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateBaseURL, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
-
import { Experimental_DecisionLanguageModel } from "@ai-sdk/provider-utils/experimental-decision";
|
|
3
2
|
import { APICallError, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError, isJSONObject } from "@ai-sdk/provider";
|
|
4
3
|
import { z } from "zod/v4";
|
|
4
|
+
//#region src/openai-config.ts
|
|
5
|
+
function prepareOpenAIConfigForWorkflowDeserialize(config) {
|
|
6
|
+
if (config.provider == null) throw new Error("OpenAI model is missing provider after workflow deserialization.");
|
|
7
|
+
return {
|
|
8
|
+
...config,
|
|
9
|
+
provider: config.provider,
|
|
10
|
+
url: typeof config.url === "function" ? config.url : ({ path }) => {
|
|
11
|
+
if (config.baseURL == null) throw new Error("OpenAI model is missing baseURL after workflow deserialization.");
|
|
12
|
+
return `${config.baseURL}${path}`;
|
|
13
|
+
},
|
|
14
|
+
headers: typeof config.headers === "function" ? config.headers : config.headers == null ? void 0 : () => config.headers
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
5
18
|
//#region src/openai-error.ts
|
|
6
19
|
const openaiErrorDataSchema = z.object({ error: z.object({
|
|
7
20
|
message: z.string(),
|
|
@@ -14,6 +27,200 @@ const openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
14
27
|
errorToMessage: (data) => data.error.message
|
|
15
28
|
});
|
|
16
29
|
//#endregion
|
|
30
|
+
//#region src/openai-decision-model-options.ts
|
|
31
|
+
const openaiDecisionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
32
|
+
/** An opaque end-user identifier for safety monitoring, up to 128 characters. */
|
|
33
|
+
safetyIdentifier: z.string().max(128).optional() })));
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/openai-decision-model.ts
|
|
36
|
+
const probability = z.number().min(0).max(1);
|
|
37
|
+
const responseSchema = z.object({
|
|
38
|
+
model: z.string().nullish(),
|
|
39
|
+
usage: z.object({
|
|
40
|
+
input_tokens: z.number().nullish(),
|
|
41
|
+
input_tokens_details: z.object({
|
|
42
|
+
cached_tokens: z.number().nullish(),
|
|
43
|
+
cache_write_tokens: z.number().nullish()
|
|
44
|
+
}).nullish(),
|
|
45
|
+
output_tokens: z.number().nullish(),
|
|
46
|
+
output_tokens_details: z.object({ reasoning_tokens: z.number().nullish() }).nullish(),
|
|
47
|
+
total_tokens: z.number().nullish()
|
|
48
|
+
}).nullish(),
|
|
49
|
+
answers: z.array(z.discriminatedUnion("type", [
|
|
50
|
+
z.object({
|
|
51
|
+
type: z.literal("refusal"),
|
|
52
|
+
name: z.string().nullable()
|
|
53
|
+
}),
|
|
54
|
+
z.object({
|
|
55
|
+
type: z.literal("predicate"),
|
|
56
|
+
name: z.string(),
|
|
57
|
+
probability
|
|
58
|
+
}),
|
|
59
|
+
z.object({
|
|
60
|
+
type: z.literal("choice"),
|
|
61
|
+
name: z.string(),
|
|
62
|
+
choice: z.string(),
|
|
63
|
+
confidence: probability.nullish(),
|
|
64
|
+
probabilities: z.array(z.object({
|
|
65
|
+
value: z.string(),
|
|
66
|
+
probability
|
|
67
|
+
}))
|
|
68
|
+
}),
|
|
69
|
+
z.object({
|
|
70
|
+
type: z.literal("score"),
|
|
71
|
+
name: z.string(),
|
|
72
|
+
score: z.number(),
|
|
73
|
+
confidence: probability.nullish(),
|
|
74
|
+
probabilities: z.array(z.object({
|
|
75
|
+
value: z.number().int().nonnegative(),
|
|
76
|
+
probability
|
|
77
|
+
}))
|
|
78
|
+
})
|
|
79
|
+
]))
|
|
80
|
+
});
|
|
81
|
+
function toText(input) {
|
|
82
|
+
return typeof input === "string" ? input : JSON.stringify(input);
|
|
83
|
+
}
|
|
84
|
+
var DecisionOpenAIModel = class DecisionOpenAIModel {
|
|
85
|
+
constructor(modelId, config) {
|
|
86
|
+
this.modelId = modelId;
|
|
87
|
+
this.config = config;
|
|
88
|
+
this.specificationVersion = "v4";
|
|
89
|
+
this.supportedQuestionTypes = [
|
|
90
|
+
"choice",
|
|
91
|
+
"score",
|
|
92
|
+
"boolean"
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
get provider() {
|
|
96
|
+
return this.config.provider;
|
|
97
|
+
}
|
|
98
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
99
|
+
return serializeModelOptions({
|
|
100
|
+
modelId: model.modelId,
|
|
101
|
+
config: model.config
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
105
|
+
return new DecisionOpenAIModel(options.modelId, prepareOpenAIConfigForWorkflowDeserialize(options.config));
|
|
106
|
+
}
|
|
107
|
+
/** @deprecated Use `doDecide` instead. */
|
|
108
|
+
doEvaluate(options) {
|
|
109
|
+
return this.doDecide(options);
|
|
110
|
+
}
|
|
111
|
+
async doDecide({ state, questions, headers, abortSignal, providerOptions }) {
|
|
112
|
+
const openaiOptions = await parseProviderOptions({
|
|
113
|
+
provider: "openai",
|
|
114
|
+
providerOptions,
|
|
115
|
+
schema: openaiDecisionModelOptions
|
|
116
|
+
});
|
|
117
|
+
const { value: response, rawValue, responseHeaders } = await postJsonToApi({
|
|
118
|
+
url: this.config.url({
|
|
119
|
+
path: "/decisions",
|
|
120
|
+
modelId: this.modelId
|
|
121
|
+
}),
|
|
122
|
+
headers: combineHeaders(this.config.headers?.(), headers),
|
|
123
|
+
body: {
|
|
124
|
+
model: this.modelId,
|
|
125
|
+
safety_identifier: openaiOptions?.safetyIdentifier,
|
|
126
|
+
input: toText(state),
|
|
127
|
+
questions: Object.entries(questions).map(([name, question]) => {
|
|
128
|
+
const instructions = toText(question.instructions);
|
|
129
|
+
switch (question.type) {
|
|
130
|
+
case "boolean": return {
|
|
131
|
+
type: "predicate",
|
|
132
|
+
name,
|
|
133
|
+
instructions: [
|
|
134
|
+
instructions,
|
|
135
|
+
question.criteria?.true == null ? void 0 : `Criteria for true:\n${toText(question.criteria.true)}`,
|
|
136
|
+
question.criteria?.false == null ? void 0 : `Criteria for false:\n${toText(question.criteria.false)}`
|
|
137
|
+
].filter((part) => part !== void 0).join("\n\n")
|
|
138
|
+
};
|
|
139
|
+
case "choice": return {
|
|
140
|
+
type: "choice",
|
|
141
|
+
name,
|
|
142
|
+
instructions,
|
|
143
|
+
choices: Object.entries(question.criteria).map(([value, description]) => ({
|
|
144
|
+
value,
|
|
145
|
+
...description == null ? {} : { description: toText(description) }
|
|
146
|
+
}))
|
|
147
|
+
};
|
|
148
|
+
case "score": return {
|
|
149
|
+
type: "score",
|
|
150
|
+
name,
|
|
151
|
+
instructions,
|
|
152
|
+
levels: question.criteria.map((description, index) => ({
|
|
153
|
+
label: String(index),
|
|
154
|
+
...description == null ? {} : { description: toText(description) }
|
|
155
|
+
}))
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
abortSignal,
|
|
161
|
+
fetch: this.config.fetch,
|
|
162
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
163
|
+
successfulResponseHandler: createJsonResponseHandler(responseSchema)
|
|
164
|
+
});
|
|
165
|
+
const answers = Object.fromEntries(response.answers.map((answer) => {
|
|
166
|
+
if (answer.type === "refusal") {
|
|
167
|
+
if (answer.name === null) throw new InvalidResponseDataError({
|
|
168
|
+
data: rawValue,
|
|
169
|
+
message: "OpenAI Decisions refused an unnamed question."
|
|
170
|
+
});
|
|
171
|
+
return [answer.name, { type: "refusal" }];
|
|
172
|
+
}
|
|
173
|
+
if (answer.type === "predicate") return [answer.name, {
|
|
174
|
+
type: "boolean",
|
|
175
|
+
probability: answer.probability
|
|
176
|
+
}];
|
|
177
|
+
const probabilities = Object.fromEntries(answer.probabilities.map(({ value, probability }) => [value, probability]));
|
|
178
|
+
if (Object.keys(probabilities).length !== answer.probabilities.length) throw new InvalidResponseDataError({
|
|
179
|
+
data: rawValue,
|
|
180
|
+
message: "Decisions returned duplicate probability values."
|
|
181
|
+
});
|
|
182
|
+
return [answer.name, answer.type === "choice" ? {
|
|
183
|
+
type: "choice",
|
|
184
|
+
choice: answer.choice,
|
|
185
|
+
probabilities
|
|
186
|
+
} : {
|
|
187
|
+
type: "score",
|
|
188
|
+
score: answer.score,
|
|
189
|
+
probabilities
|
|
190
|
+
}];
|
|
191
|
+
}));
|
|
192
|
+
const names = response.answers.map((answer) => answer.name);
|
|
193
|
+
if (names.length !== Object.keys(questions).length || new Set(names).size !== names.length || names.some((name) => typeof name !== "string" || !Object.prototype.hasOwnProperty.call(questions, name))) throw new InvalidResponseDataError({
|
|
194
|
+
data: rawValue,
|
|
195
|
+
message: "Decisions must return exactly one answer for every question."
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
answers,
|
|
199
|
+
usage: response.usage == null ? void 0 : {
|
|
200
|
+
inputTokens: response.usage.input_tokens ?? void 0,
|
|
201
|
+
outputTokens: response.usage.output_tokens ?? void 0
|
|
202
|
+
},
|
|
203
|
+
rounding: {
|
|
204
|
+
probabilityDecimals: 2,
|
|
205
|
+
scoreDecimals: 2
|
|
206
|
+
},
|
|
207
|
+
warnings: Object.keys(providerOptions?.openai ?? {}).filter((option) => option !== "safetyIdentifier").map((option) => ({
|
|
208
|
+
type: "unsupported",
|
|
209
|
+
feature: `providerOptions.openai.${option}`
|
|
210
|
+
})),
|
|
211
|
+
providerMetadata: { openai: {
|
|
212
|
+
...response.usage == null ? {} : { usage: response.usage },
|
|
213
|
+
confidence: Object.fromEntries(response.answers.flatMap((answer) => (answer.type === "choice" || answer.type === "score") && answer.confidence != null ? [[answer.name, answer.confidence]] : []))
|
|
214
|
+
} },
|
|
215
|
+
response: {
|
|
216
|
+
modelId: response.model ?? this.modelId,
|
|
217
|
+
headers: responseHeaders,
|
|
218
|
+
body: rawValue
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
//#endregion
|
|
17
224
|
//#region src/openai-language-model-capabilities.ts
|
|
18
225
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
19
226
|
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
@@ -4016,20 +4223,6 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
4016
4223
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
4017
4224
|
usage: openaiResponsesUsageSchema.nullish()
|
|
4018
4225
|
})));
|
|
4019
|
-
//#endregion
|
|
4020
|
-
//#region src/openai-config.ts
|
|
4021
|
-
function prepareOpenAIConfigForWorkflowDeserialize(config) {
|
|
4022
|
-
if (config.provider == null) throw new Error("OpenAI model is missing provider after workflow deserialization.");
|
|
4023
|
-
return {
|
|
4024
|
-
...config,
|
|
4025
|
-
provider: config.provider,
|
|
4026
|
-
url: typeof config.url === "function" ? config.url : ({ path }) => {
|
|
4027
|
-
if (config.baseURL == null) throw new Error("OpenAI model is missing baseURL after workflow deserialization.");
|
|
4028
|
-
return `${config.baseURL}${path}`;
|
|
4029
|
-
},
|
|
4030
|
-
headers: typeof config.headers === "function" ? config.headers : config.headers == null ? void 0 : () => config.headers
|
|
4031
|
-
};
|
|
4032
|
-
}
|
|
4033
4226
|
const openaiLanguageModelResponsesOptionsSchema = lazySchema(() => zodSchema(z.object({
|
|
4034
4227
|
/**
|
|
4035
4228
|
* The ID of the OpenAI Conversation to continue.
|
|
@@ -7884,7 +8077,7 @@ var OpenAIBatch = class {
|
|
|
7884
8077
|
url: this.getUrl(`/files/${encodeURIComponent(fileId)}/content`),
|
|
7885
8078
|
headers: combineHeaders(this.options.config.headers?.(), options.headers),
|
|
7886
8079
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
7887
|
-
successfulResponseHandler: createJsonLinesResponseHandler(openaiBatchResultLineSchema),
|
|
8080
|
+
successfulResponseHandler: createJsonLinesResponseHandler(openaiBatchResultLineSchema, { maxLineBytes: this.options.maxLineBytes }),
|
|
7888
8081
|
abortSignal: options.abortSignal,
|
|
7889
8082
|
fetch: this.options.config.fetch,
|
|
7890
8083
|
validateUrl: false
|
|
@@ -9845,7 +10038,7 @@ var OpenAISkills = class {
|
|
|
9845
10038
|
};
|
|
9846
10039
|
//#endregion
|
|
9847
10040
|
//#region src/version.ts
|
|
9848
|
-
const VERSION = "4.0.
|
|
10041
|
+
const VERSION = "4.0.86";
|
|
9849
10042
|
//#endregion
|
|
9850
10043
|
//#region src/openai-provider.ts
|
|
9851
10044
|
/**
|
|
@@ -9939,6 +10132,7 @@ function createOpenAI(options = {}) {
|
|
|
9939
10132
|
};
|
|
9940
10133
|
const createBatch = () => new OpenAIBatch({
|
|
9941
10134
|
provider: `${providerName}.batch`,
|
|
10135
|
+
maxLineBytes: options.batchResultDownloads?.maxLineBytes,
|
|
9942
10136
|
config: {
|
|
9943
10137
|
provider: `${providerName}.responses`,
|
|
9944
10138
|
baseURL,
|
|
@@ -9956,8 +10150,11 @@ function createOpenAI(options = {}) {
|
|
|
9956
10150
|
provider.chat = createChatModel;
|
|
9957
10151
|
provider.completion = createCompletionModel;
|
|
9958
10152
|
provider.responses = createResponsesModel;
|
|
9959
|
-
provider.decisionModel = (modelId) => new
|
|
9960
|
-
|
|
10153
|
+
provider.decisionModel = (modelId) => new DecisionOpenAIModel(modelId, {
|
|
10154
|
+
baseURL,
|
|
10155
|
+
url: ({ path }) => `${baseURL}${path}`,
|
|
10156
|
+
headers: getHeaders,
|
|
10157
|
+
fetch: options.fetch,
|
|
9961
10158
|
provider: `${providerName}.decision`
|
|
9962
10159
|
});
|
|
9963
10160
|
provider.evaluationModel = provider.decisionModel;
|