@core-ai/openai 0.26.0 → 0.27.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.
|
@@ -40,11 +40,14 @@ function createCapabilities({
|
|
|
40
40
|
restrictsSamplingParams,
|
|
41
41
|
maxTokensParameter = "max_completion_tokens",
|
|
42
42
|
modalities = MULTIMODAL_INPUT_MODALITIES,
|
|
43
|
-
strictToolSchemas = SUPPORTED_TOOL_SCHEMA_STRICTNESS
|
|
43
|
+
strictToolSchemas = SUPPORTED_TOOL_SCHEMA_STRICTNESS,
|
|
44
|
+
reasoningMode = "optional",
|
|
45
|
+
functionCalling = "supported",
|
|
46
|
+
nativeMaxEffort = false
|
|
44
47
|
}) {
|
|
45
48
|
return {
|
|
46
49
|
reasoning: {
|
|
47
|
-
mode:
|
|
50
|
+
mode: reasoningMode,
|
|
48
51
|
supportedEfforts,
|
|
49
52
|
restrictsSamplingParams,
|
|
50
53
|
supportedToolChoices: ["auto", "none", "required", "tool"]
|
|
@@ -54,8 +57,10 @@ function createCapabilities({
|
|
|
54
57
|
strictSchemas: strictToolSchemas
|
|
55
58
|
},
|
|
56
59
|
chatCompletions: {
|
|
57
|
-
maxTokensParameter
|
|
58
|
-
|
|
60
|
+
maxTokensParameter,
|
|
61
|
+
functionCalling
|
|
62
|
+
},
|
|
63
|
+
nativeMaxEffort
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
66
|
var DEFAULT_CAPABILITIES = createCapabilities({
|
|
@@ -87,10 +92,31 @@ var GPT_5_HIGH_REASONING_CAPABILITIES = createCapabilities({
|
|
|
87
92
|
supportedEfforts: HIGH_EFFORT,
|
|
88
93
|
restrictsSamplingParams: true
|
|
89
94
|
});
|
|
95
|
+
var GPT_6_EFFORTS = [
|
|
96
|
+
"low",
|
|
97
|
+
"medium",
|
|
98
|
+
"high",
|
|
99
|
+
"max"
|
|
100
|
+
];
|
|
101
|
+
var GPT_6_ASTRA_CAPABILITIES = createCapabilities({
|
|
102
|
+
supportedEfforts: GPT_6_EFFORTS,
|
|
103
|
+
restrictsSamplingParams: true,
|
|
104
|
+
reasoningMode: "always-on",
|
|
105
|
+
functionCalling: "unsupported",
|
|
106
|
+
nativeMaxEffort: true
|
|
107
|
+
});
|
|
108
|
+
var GPT_6_SOL_LUNA_CAPABILITIES = createCapabilities({
|
|
109
|
+
supportedEfforts: GPT_6_EFFORTS,
|
|
110
|
+
restrictsSamplingParams: true,
|
|
111
|
+
reasoningMode: "always-on",
|
|
112
|
+
functionCalling: "none-only",
|
|
113
|
+
nativeMaxEffort: true
|
|
114
|
+
});
|
|
90
115
|
function createNoReasoningCapabilities({
|
|
91
116
|
maxTokensParameter,
|
|
92
117
|
modalities = MULTIMODAL_INPUT_MODALITIES,
|
|
93
|
-
strictToolSchemas = SUPPORTED_TOOL_SCHEMA_STRICTNESS
|
|
118
|
+
strictToolSchemas = SUPPORTED_TOOL_SCHEMA_STRICTNESS,
|
|
119
|
+
functionCalling = "supported"
|
|
94
120
|
}) {
|
|
95
121
|
return {
|
|
96
122
|
reasoning: {
|
|
@@ -104,8 +130,10 @@ function createNoReasoningCapabilities({
|
|
|
104
130
|
strictSchemas: strictToolSchemas
|
|
105
131
|
},
|
|
106
132
|
chatCompletions: {
|
|
107
|
-
maxTokensParameter
|
|
108
|
-
|
|
133
|
+
maxTokensParameter,
|
|
134
|
+
functionCalling
|
|
135
|
+
},
|
|
136
|
+
nativeMaxEffort: false
|
|
109
137
|
};
|
|
110
138
|
}
|
|
111
139
|
var NO_REASONING_CAPABILITIES = createNoReasoningCapabilities({
|
|
@@ -145,6 +173,9 @@ var LEGACY_NO_STRICT_TOOLS_TEXT_ONLY_CAPABILITIES = createNoReasoningCapabilitie
|
|
|
145
173
|
});
|
|
146
174
|
var OPENAI_MODEL_CAPABILITIES = {
|
|
147
175
|
"gpt-4o-2024-05-13": LEGACY_NO_STRICT_TOOLS_CAPABILITIES,
|
|
176
|
+
"gpt-6-astra": GPT_6_ASTRA_CAPABILITIES,
|
|
177
|
+
"gpt-6-sol": GPT_6_SOL_LUNA_CAPABILITIES,
|
|
178
|
+
"gpt-6-luna": GPT_6_SOL_LUNA_CAPABILITIES,
|
|
148
179
|
"gpt-5.6-sol": GPT_5_MAX_REASONING_CAPABILITIES,
|
|
149
180
|
"gpt-5.6-terra": SAMPLING_RESTRICTED_STANDARD_CAPABILITIES,
|
|
150
181
|
"gpt-5.6-luna": GPT_5_MINIMAL_REASONING_CAPABILITIES,
|
|
@@ -218,7 +249,10 @@ function toOpenAIResponsesCapabilities(capabilities) {
|
|
|
218
249
|
}
|
|
219
250
|
};
|
|
220
251
|
}
|
|
221
|
-
function toOpenAIReasoningEffort(effort) {
|
|
252
|
+
function toOpenAIReasoningEffort(effort, modelId) {
|
|
253
|
+
if (effort === "max" && modelId !== void 0 && getOpenAIModelCapabilities(modelId).nativeMaxEffort) {
|
|
254
|
+
return "max";
|
|
255
|
+
}
|
|
222
256
|
return OPENAI_REASONING_EFFORT_MAP[effort];
|
|
223
257
|
}
|
|
224
258
|
|
|
@@ -567,19 +601,39 @@ function createRequest(modelId, options, stream, adapterOptions) {
|
|
|
567
601
|
};
|
|
568
602
|
}
|
|
569
603
|
function createRequestBase(modelId, options, adapterOptions) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
604
|
+
const functionCalling = getOpenAIModelCapabilities(modelId).chatCompletions.functionCalling;
|
|
605
|
+
const usingTools = options.tools !== void 0 && Object.keys(options.tools).length > 0;
|
|
606
|
+
const disableReasoningForTools = usingTools && functionCalling === "none-only" && options.reasoning === void 0;
|
|
607
|
+
if (usingTools && functionCalling === "unsupported") {
|
|
608
|
+
throw new ValidationError2(
|
|
609
|
+
`${adapterOptions.providerId} model "${modelId}" does not support tool calling on Chat Completions. Use the Responses API`,
|
|
610
|
+
void 0,
|
|
611
|
+
adapterOptions.providerId
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
if (usingTools && functionCalling === "none-only" && options.reasoning !== void 0) {
|
|
615
|
+
throw new ValidationError2(
|
|
616
|
+
`${adapterOptions.providerId} model "${modelId}" supports Chat Completions function calling only when reasoning is disabled. Omit reasoning or use the Responses API to combine tools with reasoning`,
|
|
617
|
+
void 0,
|
|
618
|
+
adapterOptions.providerId
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
if (!disableReasoningForTools) {
|
|
622
|
+
validateReasoningConfig(
|
|
623
|
+
modelId,
|
|
624
|
+
options,
|
|
625
|
+
adapterOptions.capabilities,
|
|
626
|
+
adapterOptions.providerId
|
|
627
|
+
);
|
|
628
|
+
}
|
|
576
629
|
validateInputModalities({
|
|
577
630
|
messages: options.messages,
|
|
578
631
|
capabilities: adapterOptions.capabilities,
|
|
579
632
|
modelId,
|
|
580
633
|
providerId: adapterOptions.providerId
|
|
581
634
|
});
|
|
582
|
-
const reasoningFields = mapReasoningToRequestFields(
|
|
635
|
+
const reasoningFields = disableReasoningForTools ? { reasoning_effort: "none" } : mapReasoningToRequestFields(
|
|
636
|
+
modelId,
|
|
583
637
|
options,
|
|
584
638
|
adapterOptions.capabilities
|
|
585
639
|
);
|
|
@@ -884,7 +938,7 @@ async function* transformStream(stream, adapterOptions = {}) {
|
|
|
884
938
|
usage
|
|
885
939
|
};
|
|
886
940
|
}
|
|
887
|
-
function mapReasoningToRequestFields(options, capabilities) {
|
|
941
|
+
function mapReasoningToRequestFields(modelId, options, capabilities) {
|
|
888
942
|
if (!options.reasoning) {
|
|
889
943
|
return {};
|
|
890
944
|
}
|
|
@@ -896,7 +950,7 @@ function mapReasoningToRequestFields(options, capabilities) {
|
|
|
896
950
|
capabilities.reasoning.supportedEfforts
|
|
897
951
|
);
|
|
898
952
|
return {
|
|
899
|
-
reasoning_effort: toOpenAIReasoningEffort(clampedEffort)
|
|
953
|
+
reasoning_effort: toOpenAIReasoningEffort(clampedEffort, modelId)
|
|
900
954
|
};
|
|
901
955
|
}
|
|
902
956
|
function createAssistantParts(reasoning, content, toolCalls, reasoningProviderMetadataKey) {
|
|
@@ -1688,7 +1742,7 @@ function createRequestBase2(modelId, options, { capabilities, providerId }) {
|
|
|
1688
1742
|
})
|
|
1689
1743
|
} : {},
|
|
1690
1744
|
...options.toolChoice ? { tool_choice: convertResponseToolChoice(options.toolChoice) } : {},
|
|
1691
|
-
...mapReasoningToRequestFields2(options, capabilities),
|
|
1745
|
+
...mapReasoningToRequestFields2(modelId, options, capabilities),
|
|
1692
1746
|
...mapSamplingToRequestFields2(options)
|
|
1693
1747
|
};
|
|
1694
1748
|
}
|
|
@@ -2187,7 +2241,7 @@ async function* transformStream2(stream, adapterOptions = {}) {
|
|
|
2187
2241
|
function createInBandStreamError(body) {
|
|
2188
2242
|
return new APIError2(void 0, body, body.message, void 0);
|
|
2189
2243
|
}
|
|
2190
|
-
function mapReasoningToRequestFields2(options, capabilities) {
|
|
2244
|
+
function mapReasoningToRequestFields2(modelId, options, capabilities) {
|
|
2191
2245
|
if (!options.reasoning) {
|
|
2192
2246
|
return {};
|
|
2193
2247
|
}
|
|
@@ -2198,7 +2252,8 @@ function mapReasoningToRequestFields2(options, capabilities) {
|
|
|
2198
2252
|
clampReasoningEffort2(
|
|
2199
2253
|
options.reasoning.effort,
|
|
2200
2254
|
capabilities.reasoning.supportedEfforts
|
|
2201
|
-
)
|
|
2255
|
+
),
|
|
2256
|
+
modelId
|
|
2202
2257
|
);
|
|
2203
2258
|
return {
|
|
2204
2259
|
reasoning: {
|
package/dist/compat.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _core_ai_core_ai from '@core-ai/core-ai';
|
|
2
2
|
import { ChatModel } from '@core-ai/core-ai';
|
|
3
|
-
import { O as OpenAIChatClient, a as OpenAIProvider, b as OpenAIProviderBaseOptions } from './provider-factory-
|
|
4
|
-
export { c as OpenAICompatGenerateProviderOptions, d as OpenAICompatRequestOptions, o as openaiCompatGenerateProviderOptionsSchema, e as openaiCompatProviderOptionsSchema } from './provider-factory-
|
|
3
|
+
import { O as OpenAIChatClient, a as OpenAIProvider, b as OpenAIProviderBaseOptions } from './provider-factory-d8HgPeVi.js';
|
|
4
|
+
export { c as OpenAICompatGenerateProviderOptions, d as OpenAICompatRequestOptions, o as openaiCompatGenerateProviderOptionsSchema, e as openaiCompatProviderOptionsSchema } from './provider-factory-d8HgPeVi.js';
|
|
5
5
|
import 'openai';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
package/dist/compat.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as OpenAIProvider$1, b as OpenAIProviderBaseOptions } from './provider-factory-
|
|
2
|
-
export { O as OpenAIChatClient, f as OpenAIChatCompletionsModelOptions, g as OpenAIChatGenerateProviderOptions, h as OpenAIChatGenerateProviderOptionsConfig, i as OpenAIChatProvider, c as OpenAICompatGenerateProviderOptions, d as OpenAICompatRequestOptions, j as OpenAICompatibility, k as OpenAICompatibilityOptions, l as OpenAIEmbedProviderOptions, m as OpenAIImageProviderOptions, n as OpenAIModelCapabilities, p as OpenAIProviderFactoryOptions, q as OpenAIReasoningTokenAccounting, r as OpenAIResponsesGenerateProviderOptions, s as OpenAIResponsesGenerateProviderOptionsConfig, t as OpenAIResponsesProviderOptions, u as OpenAIStructuredOutputMode, v as createOpenAIChatCompletionsModel, w as createOpenAIProvider, x as getOpenAIModelCapabilities, y as openaiChatGenerateProviderOptionsSchema, o as openaiCompatGenerateProviderOptionsSchema, e as openaiCompatProviderOptionsSchema, z as openaiEmbedProviderOptionsSchema, A as openaiImageProviderOptionsSchema, B as openaiResponsesGenerateProviderOptionsSchema, C as openaiResponsesProviderOptionsSchema } from './provider-factory-
|
|
1
|
+
import { a as OpenAIProvider$1, b as OpenAIProviderBaseOptions } from './provider-factory-d8HgPeVi.js';
|
|
2
|
+
export { O as OpenAIChatClient, f as OpenAIChatCompletionsModelOptions, g as OpenAIChatGenerateProviderOptions, h as OpenAIChatGenerateProviderOptionsConfig, i as OpenAIChatProvider, c as OpenAICompatGenerateProviderOptions, d as OpenAICompatRequestOptions, j as OpenAICompatibility, k as OpenAICompatibilityOptions, l as OpenAIEmbedProviderOptions, m as OpenAIImageProviderOptions, n as OpenAIModelCapabilities, p as OpenAIProviderFactoryOptions, q as OpenAIReasoningTokenAccounting, r as OpenAIResponsesGenerateProviderOptions, s as OpenAIResponsesGenerateProviderOptionsConfig, t as OpenAIResponsesProviderOptions, u as OpenAIStructuredOutputMode, v as createOpenAIChatCompletionsModel, w as createOpenAIProvider, x as getOpenAIModelCapabilities, y as openaiChatGenerateProviderOptionsSchema, o as openaiCompatGenerateProviderOptionsSchema, e as openaiCompatProviderOptionsSchema, z as openaiEmbedProviderOptionsSchema, A as openaiImageProviderOptionsSchema, B as openaiResponsesGenerateProviderOptionsSchema, C as openaiResponsesProviderOptionsSchema } from './provider-factory-d8HgPeVi.js';
|
|
3
3
|
import 'openai';
|
|
4
4
|
import '@core-ai/core-ai';
|
|
5
5
|
import 'zod';
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
openaiImageProviderOptionsSchema,
|
|
11
11
|
openaiResponsesGenerateProviderOptionsSchema,
|
|
12
12
|
openaiResponsesProviderOptionsSchema
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-LEACTNS5.js";
|
|
14
14
|
|
|
15
15
|
// src/provider.ts
|
|
16
16
|
function createOpenAI(options = {}) {
|
|
@@ -2,11 +2,24 @@ import OpenAI from 'openai';
|
|
|
2
2
|
import { ModelCapabilities, ChatModel, EmbeddingModel, ImageModel, ModelCapabilitiesRegistry } from '@core-ai/core-ai';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Chat Completions function-calling support for a model.
|
|
7
|
+
*
|
|
8
|
+
* `none-only` models accept function tools only when `reasoning_effort` is
|
|
9
|
+
* `none`. `unsupported` models accept tools on the Responses API only.
|
|
10
|
+
*/
|
|
11
|
+
type OpenAIChatCompletionsFunctionCalling = 'supported' | 'none-only' | 'unsupported';
|
|
5
12
|
type OpenAIChatCompletionsCapabilities = {
|
|
6
13
|
maxTokensParameter: 'max_tokens' | 'max_completion_tokens';
|
|
14
|
+
functionCalling: OpenAIChatCompletionsFunctionCalling;
|
|
7
15
|
};
|
|
8
16
|
type OpenAIModelCapabilities = ModelCapabilities & {
|
|
9
17
|
chatCompletions: OpenAIChatCompletionsCapabilities;
|
|
18
|
+
/**
|
|
19
|
+
* When true, core `max` is sent as OpenAI `max`. Otherwise it is sent as
|
|
20
|
+
* `xhigh`, which is the top effort on earlier reasoning models.
|
|
21
|
+
*/
|
|
22
|
+
nativeMaxEffort: boolean;
|
|
10
23
|
};
|
|
11
24
|
declare function getOpenAIModelCapabilities(modelId: string): OpenAIModelCapabilities;
|
|
12
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "OpenAI provider package for @core-ai/core-ai",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Omnifact (https://omnifact.ai)",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"test:watch": "vitest"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@core-ai/core-ai": "^0.
|
|
53
|
+
"@core-ai/core-ai": "^0.27.1",
|
|
54
54
|
"openai": "^6.46.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|