@ai-sdk/openai 3.0.76 → 3.0.78
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 +13 -0
- package/dist/index.js +39 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +38 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +38 -5
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +18 -11
- package/package.json +2 -2
- package/src/responses/openai-responses-language-model.ts +61 -5
package/dist/index.mjs
CHANGED
|
@@ -5670,11 +5670,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5670
5670
|
providerOptionsName,
|
|
5671
5671
|
isShellProviderExecuted
|
|
5672
5672
|
} = await this.getArgs(options);
|
|
5673
|
+
const url = this.config.url({
|
|
5674
|
+
path: "/responses",
|
|
5675
|
+
modelId: this.modelId
|
|
5676
|
+
});
|
|
5673
5677
|
const { responseHeaders, value: response } = await postJsonToApi5({
|
|
5674
|
-
url
|
|
5675
|
-
path: "/responses",
|
|
5676
|
-
modelId: this.modelId
|
|
5677
|
-
}),
|
|
5678
|
+
url,
|
|
5678
5679
|
headers: combineHeaders5(this.config.headers(), options.headers),
|
|
5679
5680
|
body: {
|
|
5680
5681
|
...body,
|
|
@@ -5716,8 +5717,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5716
5717
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5717
5718
|
}
|
|
5718
5719
|
if (!chunk.success) {
|
|
5720
|
+
const error = isOpenAIChatCompletionChunk(chunk.rawValue) ? createOpenAIResponsesChatCompletionsMismatchError({
|
|
5721
|
+
value: chunk.rawValue,
|
|
5722
|
+
cause: chunk.error,
|
|
5723
|
+
url,
|
|
5724
|
+
requestBodyValues: body,
|
|
5725
|
+
responseHeaders
|
|
5726
|
+
}) : chunk.error;
|
|
5719
5727
|
finishReason = { unified: "error", raw: void 0 };
|
|
5720
|
-
controller.enqueue({ type: "error", error
|
|
5728
|
+
controller.enqueue({ type: "error", error });
|
|
5721
5729
|
return;
|
|
5722
5730
|
}
|
|
5723
5731
|
const value = chunk.value;
|
|
@@ -6544,6 +6552,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6544
6552
|
function isTextDeltaChunk(chunk) {
|
|
6545
6553
|
return chunk.type === "response.output_text.delta";
|
|
6546
6554
|
}
|
|
6555
|
+
function isOpenAIChatCompletionChunk(value) {
|
|
6556
|
+
const chunk = asRecord(value);
|
|
6557
|
+
return chunk != null && Array.isArray(chunk.choices) && typeof chunk.type !== "string";
|
|
6558
|
+
}
|
|
6559
|
+
function createOpenAIResponsesChatCompletionsMismatchError({
|
|
6560
|
+
value,
|
|
6561
|
+
cause,
|
|
6562
|
+
url,
|
|
6563
|
+
requestBodyValues,
|
|
6564
|
+
responseHeaders
|
|
6565
|
+
}) {
|
|
6566
|
+
return new APICallError({
|
|
6567
|
+
message: "Received a Chat Completions stream while using the OpenAI Responses API. The default OpenAI provider model uses the Responses API. If your custom baseURL targets a Chat Completions-compatible endpoint, use openai.chat('model-id') or createOpenAI(...).chat('model-id') instead. You can also use @ai-sdk/openai-compatible for OpenAI-compatible providers.",
|
|
6568
|
+
url,
|
|
6569
|
+
requestBodyValues,
|
|
6570
|
+
responseHeaders,
|
|
6571
|
+
responseBody: JSON.stringify(value),
|
|
6572
|
+
cause,
|
|
6573
|
+
data: value,
|
|
6574
|
+
isRetryable: false
|
|
6575
|
+
});
|
|
6576
|
+
}
|
|
6577
|
+
function asRecord(value) {
|
|
6578
|
+
return typeof value === "object" && value != null ? value : void 0;
|
|
6579
|
+
}
|
|
6547
6580
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
6548
6581
|
return chunk.type === "response.output_item.done";
|
|
6549
6582
|
}
|
|
@@ -6989,7 +7022,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6989
7022
|
};
|
|
6990
7023
|
|
|
6991
7024
|
// src/version.ts
|
|
6992
|
-
var VERSION = true ? "3.0.
|
|
7025
|
+
var VERSION = true ? "3.0.78" : "0.0.0-test";
|
|
6993
7026
|
|
|
6994
7027
|
// src/openai-provider.ts
|
|
6995
7028
|
function createOpenAI(options = {}) {
|