@ai-sdk/openai 4.0.63 → 4.0.65
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 +18 -0
- package/dist/index.js +88 -26
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +9 -0
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model.ts +18 -10
- package/src/openai-batch.ts +95 -29
package/dist/internal/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// src/chat/openai-chat-language-model.ts
|
|
2
|
+
import {
|
|
3
|
+
InvalidResponseDataError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
2
5
|
import {
|
|
3
6
|
StreamingToolCallTracker,
|
|
4
7
|
combineHeaders,
|
|
@@ -1215,6 +1218,12 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
|
|
|
1215
1218
|
fetch: this.config.fetch
|
|
1216
1219
|
});
|
|
1217
1220
|
const choice = response.choices[0];
|
|
1221
|
+
if (choice == null) {
|
|
1222
|
+
throw new InvalidResponseDataError({
|
|
1223
|
+
data: rawResponse,
|
|
1224
|
+
message: "Response did not contain any choices."
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1218
1227
|
const content = [];
|
|
1219
1228
|
const text = choice.message.content;
|
|
1220
1229
|
if (text != null && text.length > 0) {
|