@core-ai/openai 0.27.0 → 0.28.0
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: "supported",
|
|
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,6 +601,15 @@ function createRequest(modelId, options, stream, adapterOptions) {
|
|
|
567
601
|
};
|
|
568
602
|
}
|
|
569
603
|
function createRequestBase(modelId, options, adapterOptions) {
|
|
604
|
+
const functionCalling = getOpenAIModelCapabilities(modelId).chatCompletions.functionCalling;
|
|
605
|
+
const usingTools = options.tools !== void 0 && Object.keys(options.tools).length > 0;
|
|
606
|
+
if (usingTools && functionCalling === "unsupported") {
|
|
607
|
+
throw new ValidationError2(
|
|
608
|
+
`${adapterOptions.providerId} model "${modelId}" does not support tool calling on Chat Completions. Use the Responses API`,
|
|
609
|
+
void 0,
|
|
610
|
+
adapterOptions.providerId
|
|
611
|
+
);
|
|
612
|
+
}
|
|
570
613
|
validateReasoningConfig(
|
|
571
614
|
modelId,
|
|
572
615
|
options,
|
|
@@ -579,10 +622,6 @@ function createRequestBase(modelId, options, adapterOptions) {
|
|
|
579
622
|
modelId,
|
|
580
623
|
providerId: adapterOptions.providerId
|
|
581
624
|
});
|
|
582
|
-
const reasoningFields = mapReasoningToRequestFields(
|
|
583
|
-
options,
|
|
584
|
-
adapterOptions.capabilities
|
|
585
|
-
);
|
|
586
625
|
return {
|
|
587
626
|
model: modelId,
|
|
588
627
|
messages: convertMessages(options.messages, adapterOptions),
|
|
@@ -594,7 +633,11 @@ function createRequestBase(modelId, options, adapterOptions) {
|
|
|
594
633
|
})
|
|
595
634
|
} : {},
|
|
596
635
|
...options.toolChoice ? { tool_choice: convertToolChoice(options.toolChoice) } : {},
|
|
597
|
-
...
|
|
636
|
+
...mapReasoningToRequestFields(
|
|
637
|
+
modelId,
|
|
638
|
+
options,
|
|
639
|
+
adapterOptions.capabilities
|
|
640
|
+
),
|
|
598
641
|
...mapSamplingToRequestFields(modelId, options, adapterOptions)
|
|
599
642
|
};
|
|
600
643
|
}
|
|
@@ -884,7 +927,7 @@ async function* transformStream(stream, adapterOptions = {}) {
|
|
|
884
927
|
usage
|
|
885
928
|
};
|
|
886
929
|
}
|
|
887
|
-
function mapReasoningToRequestFields(options, capabilities) {
|
|
930
|
+
function mapReasoningToRequestFields(modelId, options, capabilities) {
|
|
888
931
|
if (!options.reasoning) {
|
|
889
932
|
return {};
|
|
890
933
|
}
|
|
@@ -896,7 +939,7 @@ function mapReasoningToRequestFields(options, capabilities) {
|
|
|
896
939
|
capabilities.reasoning.supportedEfforts
|
|
897
940
|
);
|
|
898
941
|
return {
|
|
899
|
-
reasoning_effort: toOpenAIReasoningEffort(clampedEffort)
|
|
942
|
+
reasoning_effort: toOpenAIReasoningEffort(clampedEffort, modelId)
|
|
900
943
|
};
|
|
901
944
|
}
|
|
902
945
|
function createAssistantParts(reasoning, content, toolCalls, reasoningProviderMetadataKey) {
|
|
@@ -1688,7 +1731,7 @@ function createRequestBase2(modelId, options, { capabilities, providerId }) {
|
|
|
1688
1731
|
})
|
|
1689
1732
|
} : {},
|
|
1690
1733
|
...options.toolChoice ? { tool_choice: convertResponseToolChoice(options.toolChoice) } : {},
|
|
1691
|
-
...mapReasoningToRequestFields2(options, capabilities),
|
|
1734
|
+
...mapReasoningToRequestFields2(modelId, options, capabilities),
|
|
1692
1735
|
...mapSamplingToRequestFields2(options)
|
|
1693
1736
|
};
|
|
1694
1737
|
}
|
|
@@ -2187,7 +2230,7 @@ async function* transformStream2(stream, adapterOptions = {}) {
|
|
|
2187
2230
|
function createInBandStreamError(body) {
|
|
2188
2231
|
return new APIError2(void 0, body, body.message, void 0);
|
|
2189
2232
|
}
|
|
2190
|
-
function mapReasoningToRequestFields2(options, capabilities) {
|
|
2233
|
+
function mapReasoningToRequestFields2(modelId, options, capabilities) {
|
|
2191
2234
|
if (!options.reasoning) {
|
|
2192
2235
|
return {};
|
|
2193
2236
|
}
|
|
@@ -2198,7 +2241,8 @@ function mapReasoningToRequestFields2(options, capabilities) {
|
|
|
2198
2241
|
clampReasoningEffort2(
|
|
2199
2242
|
options.reasoning.effort,
|
|
2200
2243
|
capabilities.reasoning.supportedEfforts
|
|
2201
|
-
)
|
|
2244
|
+
),
|
|
2245
|
+
modelId
|
|
2202
2246
|
);
|
|
2203
2247
|
return {
|
|
2204
2248
|
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-h4e42zh6.js';
|
|
4
|
+
export { c as OpenAICompatGenerateProviderOptions, d as OpenAICompatRequestOptions, o as openaiCompatGenerateProviderOptionsSchema, e as openaiCompatProviderOptionsSchema } from './provider-factory-h4e42zh6.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-h4e42zh6.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-h4e42zh6.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-NAZAEUX3.js";
|
|
14
14
|
|
|
15
15
|
// src/provider.ts
|
|
16
16
|
function createOpenAI(options = {}) {
|
|
@@ -2,11 +2,23 @@ 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
|
+
* `unsupported` models accept tools on the Responses API only.
|
|
9
|
+
*/
|
|
10
|
+
type OpenAIChatCompletionsFunctionCalling = 'supported' | 'unsupported';
|
|
5
11
|
type OpenAIChatCompletionsCapabilities = {
|
|
6
12
|
maxTokensParameter: 'max_tokens' | 'max_completion_tokens';
|
|
13
|
+
functionCalling: OpenAIChatCompletionsFunctionCalling;
|
|
7
14
|
};
|
|
8
15
|
type OpenAIModelCapabilities = ModelCapabilities & {
|
|
9
16
|
chatCompletions: OpenAIChatCompletionsCapabilities;
|
|
17
|
+
/**
|
|
18
|
+
* When true, core `max` is sent as OpenAI `max`. Otherwise it is sent as
|
|
19
|
+
* `xhigh`, which is the top effort on earlier reasoning models.
|
|
20
|
+
*/
|
|
21
|
+
nativeMaxEffort: boolean;
|
|
10
22
|
};
|
|
11
23
|
declare function getOpenAIModelCapabilities(modelId: string): OpenAIModelCapabilities;
|
|
12
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
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.28.0",
|
|
54
54
|
"openai": "^6.46.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|