@ai-sdk/openai 2.0.0-canary.16 → 2.0.0-canary.17
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 +8 -0
- package/dist/index.d.mts +1 -8
- package/dist/index.d.ts +1 -8
- package/dist/index.js +9 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +0 -2
- package/dist/internal/index.d.ts +0 -2
- package/dist/internal/index.js +6 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +6 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 2.0.0-canary.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 52ce942: chore(providers/openai): remove & enable strict compatibility by default
|
|
8
|
+
- Updated dependencies [87b828f]
|
|
9
|
+
- @ai-sdk/provider-utils@3.0.0-canary.16
|
|
10
|
+
|
|
3
11
|
## 2.0.0-canary.16
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -8,7 +8,6 @@ type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
|
|
|
8
8
|
|
|
9
9
|
type OpenAICompletionConfig = {
|
|
10
10
|
provider: string;
|
|
11
|
-
compatibility: 'strict' | 'compatible';
|
|
12
11
|
headers: () => Record<string, string | undefined>;
|
|
13
12
|
url: (options: {
|
|
14
13
|
modelId: string;
|
|
@@ -143,12 +142,6 @@ interface OpenAIProviderSettings {
|
|
|
143
142
|
*/
|
|
144
143
|
headers?: Record<string, string>;
|
|
145
144
|
/**
|
|
146
|
-
OpenAI compatibility mode. Should be set to `strict` when using the OpenAI API,
|
|
147
|
-
and `compatible` when using 3rd party providers. In `compatible` mode, newer
|
|
148
|
-
information such as streamOptions are not being sent. Defaults to 'compatible'.
|
|
149
|
-
*/
|
|
150
|
-
compatibility?: 'strict' | 'compatible';
|
|
151
|
-
/**
|
|
152
145
|
Provider name. Overrides the `openai` default name for 3rd party providers.
|
|
153
146
|
*/
|
|
154
147
|
name?: string;
|
|
@@ -163,7 +156,7 @@ Create an OpenAI provider instance.
|
|
|
163
156
|
*/
|
|
164
157
|
declare function createOpenAI(options?: OpenAIProviderSettings): OpenAIProvider;
|
|
165
158
|
/**
|
|
166
|
-
Default OpenAI provider instance.
|
|
159
|
+
Default OpenAI provider instance.
|
|
167
160
|
*/
|
|
168
161
|
declare const openai: OpenAIProvider;
|
|
169
162
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
|
|
|
8
8
|
|
|
9
9
|
type OpenAICompletionConfig = {
|
|
10
10
|
provider: string;
|
|
11
|
-
compatibility: 'strict' | 'compatible';
|
|
12
11
|
headers: () => Record<string, string | undefined>;
|
|
13
12
|
url: (options: {
|
|
14
13
|
modelId: string;
|
|
@@ -143,12 +142,6 @@ interface OpenAIProviderSettings {
|
|
|
143
142
|
*/
|
|
144
143
|
headers?: Record<string, string>;
|
|
145
144
|
/**
|
|
146
|
-
OpenAI compatibility mode. Should be set to `strict` when using the OpenAI API,
|
|
147
|
-
and `compatible` when using 3rd party providers. In `compatible` mode, newer
|
|
148
|
-
information such as streamOptions are not being sent. Defaults to 'compatible'.
|
|
149
|
-
*/
|
|
150
|
-
compatibility?: 'strict' | 'compatible';
|
|
151
|
-
/**
|
|
152
145
|
Provider name. Overrides the `openai` default name for 3rd party providers.
|
|
153
146
|
*/
|
|
154
147
|
name?: string;
|
|
@@ -163,7 +156,7 @@ Create an OpenAI provider instance.
|
|
|
163
156
|
*/
|
|
164
157
|
declare function createOpenAI(options?: OpenAIProviderSettings): OpenAIProvider;
|
|
165
158
|
/**
|
|
166
|
-
Default OpenAI provider instance.
|
|
159
|
+
Default OpenAI provider instance.
|
|
167
160
|
*/
|
|
168
161
|
declare const openai: OpenAIProvider;
|
|
169
162
|
|
package/dist/index.js
CHANGED
|
@@ -617,8 +617,9 @@ var OpenAIChatLanguageModel = class {
|
|
|
617
617
|
const body = {
|
|
618
618
|
...args,
|
|
619
619
|
stream: true,
|
|
620
|
-
|
|
621
|
-
|
|
620
|
+
stream_options: {
|
|
621
|
+
include_usage: true
|
|
622
|
+
}
|
|
622
623
|
};
|
|
623
624
|
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
|
|
624
625
|
url: this.config.url({
|
|
@@ -1194,8 +1195,9 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1194
1195
|
const body = {
|
|
1195
1196
|
...args,
|
|
1196
1197
|
stream: true,
|
|
1197
|
-
|
|
1198
|
-
|
|
1198
|
+
stream_options: {
|
|
1199
|
+
include_usage: true
|
|
1200
|
+
}
|
|
1199
1201
|
};
|
|
1200
1202
|
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
1201
1203
|
url: this.config.url({
|
|
@@ -2586,10 +2588,9 @@ var OpenAISpeechModel = class {
|
|
|
2586
2588
|
|
|
2587
2589
|
// src/openai-provider.ts
|
|
2588
2590
|
function createOpenAI(options = {}) {
|
|
2589
|
-
var _a, _b
|
|
2591
|
+
var _a, _b;
|
|
2590
2592
|
const baseURL = (_a = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
|
|
2591
|
-
const
|
|
2592
|
-
const providerName = (_c = options.name) != null ? _c : "openai";
|
|
2593
|
+
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
2593
2594
|
const getHeaders = () => ({
|
|
2594
2595
|
Authorization: `Bearer ${(0, import_provider_utils10.loadApiKey)({
|
|
2595
2596
|
apiKey: options.apiKey,
|
|
@@ -2604,14 +2605,12 @@ function createOpenAI(options = {}) {
|
|
|
2604
2605
|
provider: `${providerName}.chat`,
|
|
2605
2606
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2606
2607
|
headers: getHeaders,
|
|
2607
|
-
compatibility,
|
|
2608
2608
|
fetch: options.fetch
|
|
2609
2609
|
});
|
|
2610
2610
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
2611
2611
|
provider: `${providerName}.completion`,
|
|
2612
2612
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2613
2613
|
headers: getHeaders,
|
|
2614
|
-
compatibility,
|
|
2615
2614
|
fetch: options.fetch
|
|
2616
2615
|
});
|
|
2617
2616
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
@@ -2676,10 +2675,7 @@ function createOpenAI(options = {}) {
|
|
|
2676
2675
|
provider.tools = openaiTools;
|
|
2677
2676
|
return provider;
|
|
2678
2677
|
}
|
|
2679
|
-
var openai = createOpenAI(
|
|
2680
|
-
compatibility: "strict"
|
|
2681
|
-
// strict for OpenAI API
|
|
2682
|
-
});
|
|
2678
|
+
var openai = createOpenAI();
|
|
2683
2679
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2684
2680
|
0 && (module.exports = {
|
|
2685
2681
|
createOpenAI,
|