@ai-sdk/openai 2.0.126 → 2.0.127

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.127
4
+
5
+ ### Patch Changes
6
+
7
+ - fd889a3: fix(openai): return an AI SDK error for empty chat completion choices
8
+ - Updated dependencies [c2089a9]
9
+ - Updated dependencies [ab3990f]
10
+ - @ai-sdk/provider@2.0.4
11
+ - @ai-sdk/provider-utils@3.0.37
12
+
3
13
  ## 2.0.126
4
14
 
5
15
  ### Patch Changes
package/dist/index.js CHANGED
@@ -945,6 +945,12 @@ var OpenAIChatLanguageModel = class {
945
945
  fetch: this.config.fetch
946
946
  });
947
947
  const choice = response.choices[0];
948
+ if (choice == null) {
949
+ throw new import_provider3.InvalidResponseDataError({
950
+ data: rawResponse,
951
+ message: "Response did not contain any choices."
952
+ });
953
+ }
948
954
  const content = [];
949
955
  const text = choice.message.content;
950
956
  if (text != null && text.length > 0) {
@@ -5131,7 +5137,7 @@ var OpenAITranscriptionModel = class {
5131
5137
  };
5132
5138
 
5133
5139
  // src/version.ts
5134
- var VERSION = true ? "2.0.126" : "0.0.0-test";
5140
+ var VERSION = true ? "2.0.127" : "0.0.0-test";
5135
5141
 
5136
5142
  // src/openai-provider.ts
5137
5143
  function createOpenAI(options = {}) {