@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/dist/index.mjs
CHANGED
|
@@ -607,8 +607,9 @@ var OpenAIChatLanguageModel = class {
|
|
|
607
607
|
const body = {
|
|
608
608
|
...args,
|
|
609
609
|
stream: true,
|
|
610
|
-
|
|
611
|
-
|
|
610
|
+
stream_options: {
|
|
611
|
+
include_usage: true
|
|
612
|
+
}
|
|
612
613
|
};
|
|
613
614
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
614
615
|
url: this.config.url({
|
|
@@ -1193,8 +1194,9 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1193
1194
|
const body = {
|
|
1194
1195
|
...args,
|
|
1195
1196
|
stream: true,
|
|
1196
|
-
|
|
1197
|
-
|
|
1197
|
+
stream_options: {
|
|
1198
|
+
include_usage: true
|
|
1199
|
+
}
|
|
1198
1200
|
};
|
|
1199
1201
|
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
1200
1202
|
url: this.config.url({
|
|
@@ -2618,10 +2620,9 @@ var OpenAISpeechModel = class {
|
|
|
2618
2620
|
|
|
2619
2621
|
// src/openai-provider.ts
|
|
2620
2622
|
function createOpenAI(options = {}) {
|
|
2621
|
-
var _a, _b
|
|
2623
|
+
var _a, _b;
|
|
2622
2624
|
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
|
|
2623
|
-
const
|
|
2624
|
-
const providerName = (_c = options.name) != null ? _c : "openai";
|
|
2625
|
+
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
2625
2626
|
const getHeaders = () => ({
|
|
2626
2627
|
Authorization: `Bearer ${loadApiKey({
|
|
2627
2628
|
apiKey: options.apiKey,
|
|
@@ -2636,14 +2637,12 @@ function createOpenAI(options = {}) {
|
|
|
2636
2637
|
provider: `${providerName}.chat`,
|
|
2637
2638
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2638
2639
|
headers: getHeaders,
|
|
2639
|
-
compatibility,
|
|
2640
2640
|
fetch: options.fetch
|
|
2641
2641
|
});
|
|
2642
2642
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
2643
2643
|
provider: `${providerName}.completion`,
|
|
2644
2644
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2645
2645
|
headers: getHeaders,
|
|
2646
|
-
compatibility,
|
|
2647
2646
|
fetch: options.fetch
|
|
2648
2647
|
});
|
|
2649
2648
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
@@ -2708,10 +2707,7 @@ function createOpenAI(options = {}) {
|
|
|
2708
2707
|
provider.tools = openaiTools;
|
|
2709
2708
|
return provider;
|
|
2710
2709
|
}
|
|
2711
|
-
var openai = createOpenAI(
|
|
2712
|
-
compatibility: "strict"
|
|
2713
|
-
// strict for OpenAI API
|
|
2714
|
-
});
|
|
2710
|
+
var openai = createOpenAI();
|
|
2715
2711
|
export {
|
|
2716
2712
|
createOpenAI,
|
|
2717
2713
|
openai
|