ai 2.2.3 → 2.2.6

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/dist/index.js CHANGED
@@ -335,10 +335,10 @@ function chunkToText() {
335
335
  }
336
336
  var __internal__OpenAIFnMessagesSymbol = Symbol("internal_openai_fn_messages");
337
337
  function isChatCompletionChunk(data) {
338
- return "choices" in data && "delta" in data.choices[0];
338
+ return "choices" in data && data.choices && data.choices[0] && "delta" in data.choices[0];
339
339
  }
340
340
  function isCompletion(data) {
341
- return "choices" in data && "text" in data.choices[0];
341
+ return "choices" in data && data.choices && data.choices[0] && "text" in data.choices[0];
342
342
  }
343
343
  function OpenAIStream(res, callbacks) {
344
344
  const cb = callbacks;
package/dist/index.mjs CHANGED
@@ -290,10 +290,10 @@ function chunkToText() {
290
290
  }
291
291
  var __internal__OpenAIFnMessagesSymbol = Symbol("internal_openai_fn_messages");
292
292
  function isChatCompletionChunk(data) {
293
- return "choices" in data && "delta" in data.choices[0];
293
+ return "choices" in data && data.choices && data.choices[0] && "delta" in data.choices[0];
294
294
  }
295
295
  function isCompletion(data) {
296
- return "choices" in data && "text" in data.choices[0];
296
+ return "choices" in data && data.choices && data.choices[0] && "text" in data.choices[0];
297
297
  }
298
298
  function OpenAIStream(res, callbacks) {
299
299
  const cb = callbacks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "2.2.3",
3
+ "version": "2.2.6",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -357,7 +357,6 @@ function useChat({
357
357
  }
358
358
  }
359
359
  abortControllerRef.current = null;
360
- return null;
361
360
  }
362
361
  } catch (err) {
363
362
  if (err.name === "AbortError") {
@@ -321,7 +321,6 @@ function useChat({
321
321
  }
322
322
  }
323
323
  abortControllerRef.current = null;
324
- return null;
325
324
  }
326
325
  } catch (err) {
327
326
  if (err.name === "AbortError") {