@ai-sdk/openai 3.0.77 → 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 +6 -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 +1 -1
- package/src/responses/openai-responses-language-model.ts +61 -5
package/dist/internal/index.mjs
CHANGED
|
@@ -5915,11 +5915,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5915
5915
|
providerOptionsName,
|
|
5916
5916
|
isShellProviderExecuted
|
|
5917
5917
|
} = await this.getArgs(options);
|
|
5918
|
+
const url = this.config.url({
|
|
5919
|
+
path: "/responses",
|
|
5920
|
+
modelId: this.modelId
|
|
5921
|
+
});
|
|
5918
5922
|
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
5919
|
-
url
|
|
5920
|
-
path: "/responses",
|
|
5921
|
-
modelId: this.modelId
|
|
5922
|
-
}),
|
|
5923
|
+
url,
|
|
5923
5924
|
headers: combineHeaders7(this.config.headers(), options.headers),
|
|
5924
5925
|
body: {
|
|
5925
5926
|
...body,
|
|
@@ -5961,8 +5962,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5961
5962
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
5962
5963
|
}
|
|
5963
5964
|
if (!chunk.success) {
|
|
5965
|
+
const error = isOpenAIChatCompletionChunk(chunk.rawValue) ? createOpenAIResponsesChatCompletionsMismatchError({
|
|
5966
|
+
value: chunk.rawValue,
|
|
5967
|
+
cause: chunk.error,
|
|
5968
|
+
url,
|
|
5969
|
+
requestBodyValues: body,
|
|
5970
|
+
responseHeaders
|
|
5971
|
+
}) : chunk.error;
|
|
5964
5972
|
finishReason = { unified: "error", raw: void 0 };
|
|
5965
|
-
controller.enqueue({ type: "error", error
|
|
5973
|
+
controller.enqueue({ type: "error", error });
|
|
5966
5974
|
return;
|
|
5967
5975
|
}
|
|
5968
5976
|
const value = chunk.value;
|
|
@@ -6789,6 +6797,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6789
6797
|
function isTextDeltaChunk(chunk) {
|
|
6790
6798
|
return chunk.type === "response.output_text.delta";
|
|
6791
6799
|
}
|
|
6800
|
+
function isOpenAIChatCompletionChunk(value) {
|
|
6801
|
+
const chunk = asRecord(value);
|
|
6802
|
+
return chunk != null && Array.isArray(chunk.choices) && typeof chunk.type !== "string";
|
|
6803
|
+
}
|
|
6804
|
+
function createOpenAIResponsesChatCompletionsMismatchError({
|
|
6805
|
+
value,
|
|
6806
|
+
cause,
|
|
6807
|
+
url,
|
|
6808
|
+
requestBodyValues,
|
|
6809
|
+
responseHeaders
|
|
6810
|
+
}) {
|
|
6811
|
+
return new APICallError({
|
|
6812
|
+
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.",
|
|
6813
|
+
url,
|
|
6814
|
+
requestBodyValues,
|
|
6815
|
+
responseHeaders,
|
|
6816
|
+
responseBody: JSON.stringify(value),
|
|
6817
|
+
cause,
|
|
6818
|
+
data: value,
|
|
6819
|
+
isRetryable: false
|
|
6820
|
+
});
|
|
6821
|
+
}
|
|
6822
|
+
function asRecord(value) {
|
|
6823
|
+
return typeof value === "object" && value != null ? value : void 0;
|
|
6824
|
+
}
|
|
6792
6825
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
6793
6826
|
return chunk.type === "response.output_item.done";
|
|
6794
6827
|
}
|