ai 2.1.12 → 2.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -63,8 +63,8 @@
63
63
  "ts-jest": "29.0.3",
64
64
  "tsup": "^6.7.0",
65
65
  "typescript": "5.1.3",
66
- "eslint-config-vercel-ai": "0.0.0",
67
- "@vercel/ai-tsconfig": "0.0.0"
66
+ "@vercel/ai-tsconfig": "0.0.0",
67
+ "eslint-config-vercel-ai": "0.0.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.2.0",
@@ -185,8 +185,7 @@ function useChat({
185
185
  headers,
186
186
  body
187
187
  } = {}) {
188
- const hookId = (0, import_react.useId)();
189
- const chatId = id || hookId;
188
+ const chatId = id || `chat-${nanoid()}`;
190
189
  const { data, mutate } = (0, import_swr.default)([api, chatId], null, {
191
190
  fallbackData: initialMessages
192
191
  });
@@ -360,8 +359,7 @@ function useCompletion({
360
359
  onFinish,
361
360
  onError
362
361
  } = {}) {
363
- const hookId = (0, import_react2.useId)();
364
- const completionId = id || hookId;
362
+ const completionId = id || `completion-${nanoid()}`;
365
363
  const { data, mutate } = (0, import_swr2.default)([api, completionId], null, {
366
364
  fallbackData: initialCompletion
367
365
  });
@@ -37,7 +37,7 @@ var __async = (__this, __arguments, generator) => {
37
37
  };
38
38
 
39
39
  // react/use-chat.ts
40
- import { useCallback, useEffect, useId, useRef, useState } from "react";
40
+ import { useCallback, useEffect, useRef, useState } from "react";
41
41
  import useSWRMutation from "swr/mutation";
42
42
  import useSWR from "swr";
43
43
 
@@ -151,8 +151,7 @@ function useChat({
151
151
  headers,
152
152
  body
153
153
  } = {}) {
154
- const hookId = useId();
155
- const chatId = id || hookId;
154
+ const chatId = id || `chat-${nanoid()}`;
156
155
  const { data, mutate } = useSWR([api, chatId], null, {
157
156
  fallbackData: initialMessages
158
157
  });
@@ -311,7 +310,7 @@ function useChat({
311
310
  }
312
311
 
313
312
  // react/use-completion.ts
314
- import { useCallback as useCallback2, useEffect as useEffect2, useId as useId2, useRef as useRef2, useState as useState2 } from "react";
313
+ import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
315
314
  import useSWRMutation2 from "swr/mutation";
316
315
  import useSWR2 from "swr";
317
316
  function useCompletion({
@@ -326,8 +325,7 @@ function useCompletion({
326
325
  onFinish,
327
326
  onError
328
327
  } = {}) {
329
- const hookId = useId2();
330
- const completionId = id || hookId;
328
+ const completionId = id || `completion-${nanoid()}`;
331
329
  const { data, mutate } = useSWR2([api, completionId], null, {
332
330
  fallbackData: initialCompletion
333
331
  });
@@ -516,7 +516,6 @@ function createChunkDecoder() {
516
516
  }
517
517
 
518
518
  // svelte/use-chat.ts
519
- var uniqueId = 0;
520
519
  var store = {};
521
520
  function useChat({
522
521
  api = "/api/chat",
@@ -531,7 +530,7 @@ function useChat({
531
530
  headers,
532
531
  body
533
532
  } = {}) {
534
- const chatId = id || `chat-${uniqueId++}`;
533
+ const chatId = id || `chat-${nanoid()}`;
535
534
  const key = `${api}|${chatId}`;
536
535
  const { data, mutate: originalMutate } = $(key, {
537
536
  fetcher: () => store[key] || initialMessages,
@@ -686,7 +685,6 @@ function useChat({
686
685
 
687
686
  // svelte/use-completion.ts
688
687
  var import_store2 = require("svelte/store");
689
- var uniqueId2 = 0;
690
688
  var store2 = {};
691
689
  function useCompletion({
692
690
  api = "/api/completion",
@@ -700,7 +698,7 @@ function useCompletion({
700
698
  onFinish,
701
699
  onError
702
700
  } = {}) {
703
- const completionId = id || `completion-${uniqueId2++}`;
701
+ const completionId = id || `completion-${nanoid()}`;
704
702
  const key = `${api}|${completionId}`;
705
703
  const { data, mutate: originalMutate } = $(key, {
706
704
  fetcher: () => store2[key] || initialCompletion,
@@ -492,7 +492,6 @@ function createChunkDecoder() {
492
492
  }
493
493
 
494
494
  // svelte/use-chat.ts
495
- var uniqueId = 0;
496
495
  var store = {};
497
496
  function useChat({
498
497
  api = "/api/chat",
@@ -507,7 +506,7 @@ function useChat({
507
506
  headers,
508
507
  body
509
508
  } = {}) {
510
- const chatId = id || `chat-${uniqueId++}`;
509
+ const chatId = id || `chat-${nanoid()}`;
511
510
  const key = `${api}|${chatId}`;
512
511
  const { data, mutate: originalMutate } = $(key, {
513
512
  fetcher: () => store[key] || initialMessages,
@@ -662,7 +661,6 @@ function useChat({
662
661
 
663
662
  // svelte/use-completion.ts
664
663
  import { get as get2, writable as writable2 } from "svelte/store";
665
- var uniqueId2 = 0;
666
664
  var store2 = {};
667
665
  function useCompletion({
668
666
  api = "/api/completion",
@@ -676,7 +674,7 @@ function useCompletion({
676
674
  onFinish,
677
675
  onError
678
676
  } = {}) {
679
- const completionId = id || `completion-${uniqueId2++}`;
677
+ const completionId = id || `completion-${nanoid()}`;
680
678
  const key = `${api}|${completionId}`;
681
679
  const { data, mutate: originalMutate } = $(key, {
682
680
  fetcher: () => store2[key] || initialCompletion,
package/vue/dist/index.js CHANGED
@@ -89,7 +89,6 @@ function createChunkDecoder() {
89
89
  }
90
90
 
91
91
  // vue/use-chat.ts
92
- var uniqueId = 0;
93
92
  var useSWRV = import_swrv.default.default || import_swrv.default;
94
93
  var store = {};
95
94
  function useChat({
@@ -105,7 +104,7 @@ function useChat({
105
104
  headers,
106
105
  body
107
106
  } = {}) {
108
- const chatId = id || `chat-${uniqueId++}`;
107
+ const chatId = id || `chat-${nanoid()}`;
109
108
  const key = `${api}|${chatId}`;
110
109
  const { data, mutate: originalMutate } = useSWRV(
111
110
  key,
@@ -260,7 +259,6 @@ function useChat({
260
259
  // vue/use-completion.ts
261
260
  var import_swrv2 = __toESM(require("swrv"));
262
261
  var import_vue2 = require("vue");
263
- var uniqueId2 = 0;
264
262
  var useSWRV2 = import_swrv2.default.default || import_swrv2.default;
265
263
  var store2 = {};
266
264
  function useCompletion({
@@ -275,7 +273,7 @@ function useCompletion({
275
273
  onFinish,
276
274
  onError
277
275
  } = {}) {
278
- const completionId = id || `completion-${uniqueId2++}`;
276
+ const completionId = id || `completion-${nanoid()}`;
279
277
  const key = `${api}|${completionId}`;
280
278
  const { data, mutate: originalMutate } = useSWRV2(
281
279
  key,
@@ -55,7 +55,6 @@ function createChunkDecoder() {
55
55
  }
56
56
 
57
57
  // vue/use-chat.ts
58
- var uniqueId = 0;
59
58
  var useSWRV = swrv.default || swrv;
60
59
  var store = {};
61
60
  function useChat({
@@ -71,7 +70,7 @@ function useChat({
71
70
  headers,
72
71
  body
73
72
  } = {}) {
74
- const chatId = id || `chat-${uniqueId++}`;
73
+ const chatId = id || `chat-${nanoid()}`;
75
74
  const key = `${api}|${chatId}`;
76
75
  const { data, mutate: originalMutate } = useSWRV(
77
76
  key,
@@ -226,7 +225,6 @@ function useChat({
226
225
  // vue/use-completion.ts
227
226
  import swrv2 from "swrv";
228
227
  import { ref as ref2 } from "vue";
229
- var uniqueId2 = 0;
230
228
  var useSWRV2 = swrv2.default || swrv2;
231
229
  var store2 = {};
232
230
  function useCompletion({
@@ -241,7 +239,7 @@ function useCompletion({
241
239
  onFinish,
242
240
  onError
243
241
  } = {}) {
244
- const completionId = id || `completion-${uniqueId2++}`;
242
+ const completionId = id || `completion-${nanoid()}`;
245
243
  const key = `${api}|${completionId}`;
246
244
  const { data, mutate: originalMutate } = useSWRV2(
247
245
  key,