@ai-sdk/llamaindex 3.0.0-beta.11 → 3.0.0-beta.112

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,721 @@
1
1
  # @ai-sdk/llamaindex
2
2
 
3
+ ## 3.0.0-beta.112
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5f3749c]
8
+ - Updated dependencies [0a51f7d]
9
+ - Updated dependencies [71d3022]
10
+ - Updated dependencies [67df0a0]
11
+ - Updated dependencies [4181cfe]
12
+ - Updated dependencies [51ce232]
13
+ - Updated dependencies [cf93359]
14
+ - Updated dependencies [befb78c]
15
+ - Updated dependencies [29d8cf4]
16
+ - Updated dependencies [58a2ad7]
17
+ - Updated dependencies [37d69b2]
18
+ - Updated dependencies [1043274]
19
+ - Updated dependencies [7f59f04]
20
+ - Updated dependencies [7677c1e]
21
+ - Updated dependencies [116c89f]
22
+ - Updated dependencies [f58f9bc]
23
+ - Updated dependencies [e1bfb9c]
24
+ - Updated dependencies [e87d71b]
25
+ - Updated dependencies [9d486aa]
26
+ - Updated dependencies [9b0bc8a]
27
+ - Updated dependencies [fc92055]
28
+ - Updated dependencies [4e095b0]
29
+ - ai@7.0.0-beta.112
30
+
31
+ ## 3.0.0-beta.111
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [f319fde]
36
+ - Updated dependencies [1949571]
37
+ - Updated dependencies [511902c]
38
+ - Updated dependencies [6542d93]
39
+ - Updated dependencies [2e98477]
40
+ - Updated dependencies [876fd3e]
41
+ - Updated dependencies [f32c750]
42
+ - ai@7.0.0-beta.111
43
+
44
+ ## 3.0.0-beta.110
45
+
46
+ ### Patch Changes
47
+
48
+ - Updated dependencies [72cb801]
49
+ - ai@7.0.0-beta.110
50
+
51
+ ## 3.0.0-beta.109
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies [ec98264]
56
+ - Updated dependencies [eea8d98]
57
+ - Updated dependencies [75ef93e]
58
+ - ai@7.0.0-beta.109
59
+
60
+ ## 3.0.0-beta.108
61
+
62
+ ### Patch Changes
63
+
64
+ - ai@7.0.0-beta.108
65
+
66
+ ## 3.0.0-beta.107
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [350ea38]
71
+ - ai@7.0.0-beta.107
72
+
73
+ ## 3.0.0-beta.106
74
+
75
+ ### Patch Changes
76
+
77
+ - ai@7.0.0-beta.106
78
+
79
+ ## 3.0.0-beta.105
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [33d099c]
84
+ - ai@7.0.0-beta.105
85
+
86
+ ## 3.0.0-beta.104
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [2a74d43]
91
+ - ai@7.0.0-beta.104
92
+
93
+ ## 3.0.0-beta.103
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [382d53b]
98
+ - Updated dependencies [7bf7d7f]
99
+ - Updated dependencies [c3d4019]
100
+ - Updated dependencies [083947b]
101
+ - ai@7.0.0-beta.103
102
+
103
+ ## 3.0.0-beta.102
104
+
105
+ ### Patch Changes
106
+
107
+ - ai@7.0.0-beta.102
108
+
109
+ ## 3.0.0-beta.101
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [4873966]
114
+ - ai@7.0.0-beta.101
115
+
116
+ ## 3.0.0-beta.100
117
+
118
+ ### Patch Changes
119
+
120
+ - Updated dependencies [add1126]
121
+ - ai@7.0.0-beta.100
122
+
123
+ ## 3.0.0-beta.99
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [2a9c144]
128
+ - ai@7.0.0-beta.99
129
+
130
+ ## 3.0.0-beta.98
131
+
132
+ ### Patch Changes
133
+
134
+ - ai@7.0.0-beta.98
135
+
136
+ ## 3.0.0-beta.97
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [208d045]
141
+ - ai@7.0.0-beta.97
142
+
143
+ ## 3.0.0-beta.96
144
+
145
+ ### Patch Changes
146
+
147
+ - ai@7.0.0-beta.96
148
+
149
+ ## 3.0.0-beta.95
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [c4f4b5f]
154
+ - ai@7.0.0-beta.95
155
+
156
+ ## 3.0.0-beta.94
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies [1582efa]
161
+ - ai@7.0.0-beta.94
162
+
163
+ ## 3.0.0-beta.93
164
+
165
+ ### Patch Changes
166
+
167
+ - Updated dependencies [bc47739]
168
+ - ai@7.0.0-beta.93
169
+
170
+ ## 3.0.0-beta.92
171
+
172
+ ### Patch Changes
173
+
174
+ - ai@7.0.0-beta.92
175
+
176
+ ## 3.0.0-beta.91
177
+
178
+ ### Patch Changes
179
+
180
+ - ai@7.0.0-beta.91
181
+
182
+ ## 3.0.0-beta.90
183
+
184
+ ### Patch Changes
185
+
186
+ - Updated dependencies [1db29c8]
187
+ - ai@7.0.0-beta.90
188
+
189
+ ## 3.0.0-beta.89
190
+
191
+ ### Patch Changes
192
+
193
+ - Updated dependencies [ff5eba1]
194
+ - ai@7.0.0-beta.89
195
+
196
+ ## 3.0.0-beta.88
197
+
198
+ ### Major Changes
199
+
200
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
201
+
202
+ ### Patch Changes
203
+
204
+ - Updated dependencies [ef992f8]
205
+ - ai@7.0.0-beta.88
206
+
207
+ ## 3.0.0-beta.87
208
+
209
+ ### Patch Changes
210
+
211
+ - ai@7.0.0-beta.87
212
+
213
+ ## 3.0.0-beta.86
214
+
215
+ ### Patch Changes
216
+
217
+ - Updated dependencies [5a6f514]
218
+ - ai@7.0.0-beta.86
219
+
220
+ ## 3.0.0-beta.85
221
+
222
+ ### Patch Changes
223
+
224
+ - Updated dependencies [57bf606]
225
+ - ai@7.0.0-beta.85
226
+
227
+ ## 3.0.0-beta.84
228
+
229
+ ### Patch Changes
230
+
231
+ - Updated dependencies [90e2d8a]
232
+ - ai@7.0.0-beta.84
233
+
234
+ ## 3.0.0-beta.83
235
+
236
+ ### Patch Changes
237
+
238
+ - ai@7.0.0-beta.83
239
+
240
+ ## 3.0.0-beta.82
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies [e27ed76]
245
+ - ai@7.0.0-beta.82
246
+
247
+ ## 3.0.0-beta.81
248
+
249
+ ### Patch Changes
250
+
251
+ - Updated dependencies [2fe1099]
252
+ - Updated dependencies [f04adcb]
253
+ - ai@7.0.0-beta.81
254
+
255
+ ## 3.0.0-beta.80
256
+
257
+ ### Patch Changes
258
+
259
+ - Updated dependencies [3ae1786]
260
+ - ai@7.0.0-beta.80
261
+
262
+ ## 3.0.0-beta.79
263
+
264
+ ### Patch Changes
265
+
266
+ - Updated dependencies [6866afe]
267
+ - ai@7.0.0-beta.79
268
+
269
+ ## 3.0.0-beta.78
270
+
271
+ ### Patch Changes
272
+
273
+ - Updated dependencies [f372547]
274
+ - ai@7.0.0-beta.78
275
+
276
+ ## 3.0.0-beta.77
277
+
278
+ ### Patch Changes
279
+
280
+ - Updated dependencies [2add429]
281
+ - ai@7.0.0-beta.77
282
+
283
+ ## 3.0.0-beta.76
284
+
285
+ ### Patch Changes
286
+
287
+ - Updated dependencies [fcc6869]
288
+ - ai@7.0.0-beta.76
289
+
290
+ ## 3.0.0-beta.75
291
+
292
+ ### Patch Changes
293
+
294
+ - Updated dependencies [176466a]
295
+ - ai@7.0.0-beta.75
296
+
297
+ ## 3.0.0-beta.74
298
+
299
+ ### Patch Changes
300
+
301
+ - Updated dependencies [e311194]
302
+ - ai@7.0.0-beta.74
303
+
304
+ ## 3.0.0-beta.73
305
+
306
+ ### Patch Changes
307
+
308
+ - ai@7.0.0-beta.73
309
+
310
+ ## 3.0.0-beta.72
311
+
312
+ ### Patch Changes
313
+
314
+ - Updated dependencies [664a0eb]
315
+ - ai@7.0.0-beta.72
316
+
317
+ ## 3.0.0-beta.71
318
+
319
+ ### Patch Changes
320
+
321
+ - Updated dependencies [e68be55]
322
+ - ai@7.0.0-beta.71
323
+
324
+ ## 3.0.0-beta.70
325
+
326
+ ### Patch Changes
327
+
328
+ - ai@7.0.0-beta.70
329
+
330
+ ## 3.0.0-beta.69
331
+
332
+ ### Patch Changes
333
+
334
+ - Updated dependencies [34bd95d]
335
+ - Updated dependencies [008271d]
336
+ - Updated dependencies [72223e7]
337
+ - ai@7.0.0-beta.69
338
+
339
+ ## 3.0.0-beta.68
340
+
341
+ ### Patch Changes
342
+
343
+ - Updated dependencies [b0c2869]
344
+ - Updated dependencies [7e26e81]
345
+ - ai@7.0.0-beta.68
346
+
347
+ ## 3.0.0-beta.67
348
+
349
+ ### Patch Changes
350
+
351
+ - Updated dependencies [d1a8bed]
352
+ - ai@7.0.0-beta.67
353
+
354
+ ## 3.0.0-beta.66
355
+
356
+ ### Patch Changes
357
+
358
+ - ai@7.0.0-beta.66
359
+
360
+ ## 3.0.0-beta.65
361
+
362
+ ### Patch Changes
363
+
364
+ - ai@7.0.0-beta.65
365
+
366
+ ## 3.0.0-beta.64
367
+
368
+ ### Patch Changes
369
+
370
+ - ai@7.0.0-beta.64
371
+
372
+ ## 3.0.0-beta.63
373
+
374
+ ### Patch Changes
375
+
376
+ - Updated dependencies [6fd51c0]
377
+ - ai@7.0.0-beta.63
378
+
379
+ ## 3.0.0-beta.62
380
+
381
+ ### Patch Changes
382
+
383
+ - ai@7.0.0-beta.62
384
+
385
+ ## 3.0.0-beta.61
386
+
387
+ ### Patch Changes
388
+
389
+ - Updated dependencies [c29a26f]
390
+ - ai@7.0.0-beta.61
391
+
392
+ ## 3.0.0-beta.60
393
+
394
+ ### Patch Changes
395
+
396
+ - Updated dependencies [38fc777]
397
+ - ai@7.0.0-beta.60
398
+
399
+ ## 3.0.0-beta.59
400
+
401
+ ### Patch Changes
402
+
403
+ - ai@7.0.0-beta.59
404
+
405
+ ## 3.0.0-beta.58
406
+
407
+ ### Patch Changes
408
+
409
+ - Updated dependencies [2e17091]
410
+ - ai@7.0.0-beta.58
411
+
412
+ ## 3.0.0-beta.57
413
+
414
+ ### Patch Changes
415
+
416
+ - Updated dependencies [986c6fd]
417
+ - Updated dependencies [493295c]
418
+ - ai@7.0.0-beta.57
419
+
420
+ ## 3.0.0-beta.56
421
+
422
+ ### Patch Changes
423
+
424
+ - ai@7.0.0-beta.56
425
+
426
+ ## 3.0.0-beta.55
427
+
428
+ ### Patch Changes
429
+
430
+ - Updated dependencies [b3c9f6a]
431
+ - ai@7.0.0-beta.55
432
+
433
+ ## 3.0.0-beta.54
434
+
435
+ ### Patch Changes
436
+
437
+ - Updated dependencies [5d0f18e]
438
+ - ai@7.0.0-beta.54
439
+
440
+ ## 3.0.0-beta.53
441
+
442
+ ### Patch Changes
443
+
444
+ - Updated dependencies [9b47dea]
445
+ - ai@7.0.0-beta.53
446
+
447
+ ## 3.0.0-beta.52
448
+
449
+ ### Patch Changes
450
+
451
+ - Updated dependencies [b56301c]
452
+ - ai@7.0.0-beta.52
453
+
454
+ ## 3.0.0-beta.51
455
+
456
+ ### Patch Changes
457
+
458
+ - Updated dependencies [6abd098]
459
+ - ai@7.0.0-beta.51
460
+
461
+ ## 3.0.0-beta.50
462
+
463
+ ### Patch Changes
464
+
465
+ - Updated dependencies [3debdb7]
466
+ - ai@7.0.0-beta.50
467
+
468
+ ## 3.0.0-beta.49
469
+
470
+ ### Patch Changes
471
+
472
+ - ai@7.0.0-beta.49
473
+
474
+ ## 3.0.0-beta.48
475
+
476
+ ### Patch Changes
477
+
478
+ - Updated dependencies [5c4d910]
479
+ - ai@7.0.0-beta.48
480
+
481
+ ## 3.0.0-beta.47
482
+
483
+ ### Patch Changes
484
+
485
+ - Updated dependencies [bc67b4f]
486
+ - ai@7.0.0-beta.47
487
+
488
+ ## 3.0.0-beta.46
489
+
490
+ ### Patch Changes
491
+
492
+ - Updated dependencies [31ee822]
493
+ - ai@7.0.0-beta.46
494
+
495
+ ## 3.0.0-beta.45
496
+
497
+ ### Patch Changes
498
+
499
+ - ai@7.0.0-beta.45
500
+
501
+ ## 3.0.0-beta.44
502
+
503
+ ### Patch Changes
504
+
505
+ - ai@7.0.0-beta.44
506
+
507
+ ## 3.0.0-beta.43
508
+
509
+ ### Patch Changes
510
+
511
+ - ai@7.0.0-beta.43
512
+
513
+ ## 3.0.0-beta.42
514
+
515
+ ### Patch Changes
516
+
517
+ - Updated dependencies [a3fd75b]
518
+ - ai@7.0.0-beta.42
519
+
520
+ ## 3.0.0-beta.41
521
+
522
+ ### Patch Changes
523
+
524
+ - ai@7.0.0-beta.41
525
+
526
+ ## 3.0.0-beta.40
527
+
528
+ ### Patch Changes
529
+
530
+ - Updated dependencies [989d3d2]
531
+ - ai@7.0.0-beta.40
532
+
533
+ ## 3.0.0-beta.39
534
+
535
+ ### Patch Changes
536
+
537
+ - Updated dependencies [f4cfccd]
538
+ - ai@7.0.0-beta.39
539
+
540
+ ## 3.0.0-beta.38
541
+
542
+ ### Patch Changes
543
+
544
+ - Updated dependencies [1f509d4]
545
+ - ai@7.0.0-beta.38
546
+
547
+ ## 3.0.0-beta.37
548
+
549
+ ### Patch Changes
550
+
551
+ - ai@7.0.0-beta.37
552
+
553
+ ## 3.0.0-beta.36
554
+
555
+ ### Patch Changes
556
+
557
+ - Updated dependencies [118b953]
558
+ - ai@7.0.0-beta.36
559
+
560
+ ## 3.0.0-beta.35
561
+
562
+ ### Patch Changes
563
+
564
+ - Updated dependencies [99bf941]
565
+ - ai@7.0.0-beta.35
566
+
567
+ ## 3.0.0-beta.34
568
+
569
+ ### Patch Changes
570
+
571
+ - ai@7.0.0-beta.34
572
+
573
+ ## 3.0.0-beta.33
574
+
575
+ ### Patch Changes
576
+
577
+ - Updated dependencies [caf1b6f]
578
+ - ai@7.0.0-beta.33
579
+
580
+ ## 3.0.0-beta.32
581
+
582
+ ### Patch Changes
583
+
584
+ - Updated dependencies [4b46062]
585
+ - ai@7.0.0-beta.32
586
+
587
+ ## 3.0.0-beta.31
588
+
589
+ ### Patch Changes
590
+
591
+ - Updated dependencies [e79e644]
592
+ - ai@7.0.0-beta.31
593
+
594
+ ## 3.0.0-beta.30
595
+
596
+ ### Patch Changes
597
+
598
+ - Updated dependencies [f5a6f89]
599
+ - ai@7.0.0-beta.30
600
+
601
+ ## 3.0.0-beta.29
602
+
603
+ ### Patch Changes
604
+
605
+ - Updated dependencies [877bf12]
606
+ - ai@7.0.0-beta.29
607
+
608
+ ## 3.0.0-beta.28
609
+
610
+ ### Patch Changes
611
+
612
+ - Updated dependencies [b9cf502]
613
+ - ai@7.0.0-beta.28
614
+
615
+ ## 3.0.0-beta.27
616
+
617
+ ### Patch Changes
618
+
619
+ - Updated dependencies [3887c70]
620
+ - ai@7.0.0-beta.27
621
+
622
+ ## 3.0.0-beta.26
623
+
624
+ ### Patch Changes
625
+
626
+ - Updated dependencies [f0b0b20]
627
+ - ai@7.0.0-beta.26
628
+
629
+ ## 3.0.0-beta.25
630
+
631
+ ### Patch Changes
632
+
633
+ - Updated dependencies [ff9ce30]
634
+ - ai@7.0.0-beta.25
635
+
636
+ ## 3.0.0-beta.24
637
+
638
+ ### Patch Changes
639
+
640
+ - Updated dependencies [776b617]
641
+ - ai@7.0.0-beta.24
642
+
643
+ ## 3.0.0-beta.23
644
+
645
+ ### Patch Changes
646
+
647
+ - Updated dependencies [80d4dde]
648
+ - ai@7.0.0-beta.23
649
+
650
+ ## 3.0.0-beta.22
651
+
652
+ ### Patch Changes
653
+
654
+ - ai@7.0.0-beta.22
655
+
656
+ ## 3.0.0-beta.21
657
+
658
+ ### Patch Changes
659
+
660
+ - Updated dependencies [34fd051]
661
+ - ai@7.0.0-beta.21
662
+
663
+ ## 3.0.0-beta.20
664
+
665
+ ### Patch Changes
666
+
667
+ - ai@7.0.0-beta.20
668
+
669
+ ## 3.0.0-beta.19
670
+
671
+ ### Patch Changes
672
+
673
+ - ai@7.0.0-beta.19
674
+
675
+ ## 3.0.0-beta.18
676
+
677
+ ### Patch Changes
678
+
679
+ - ai@7.0.0-beta.18
680
+
681
+ ## 3.0.0-beta.17
682
+
683
+ ### Patch Changes
684
+
685
+ - ai@7.0.0-beta.17
686
+
687
+ ## 3.0.0-beta.16
688
+
689
+ ### Patch Changes
690
+
691
+ - Updated dependencies [5b8c58f]
692
+ - ai@7.0.0-beta.16
693
+
694
+ ## 3.0.0-beta.15
695
+
696
+ ### Patch Changes
697
+
698
+ - ai@7.0.0-beta.15
699
+
700
+ ## 3.0.0-beta.14
701
+
702
+ ### Patch Changes
703
+
704
+ - ai@7.0.0-beta.14
705
+
706
+ ## 3.0.0-beta.13
707
+
708
+ ### Patch Changes
709
+
710
+ - Updated dependencies [c26ca8d]
711
+ - ai@7.0.0-beta.13
712
+
713
+ ## 3.0.0-beta.12
714
+
715
+ ### Patch Changes
716
+
717
+ - ai@7.0.0-beta.12
718
+
3
719
  ## 3.0.0-beta.11
4
720
 
5
721
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,31 +1,5 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- toUIMessageStream: () => toUIMessageStream
24
- });
25
- module.exports = __toCommonJS(src_exports);
26
-
27
1
  // src/llamaindex-adapter.ts
28
- var import_internal = require("ai/internal");
2
+ import { convertAsyncIteratorToReadableStream } from "ai/internal";
29
3
 
30
4
  // src/stream-callbacks.ts
31
5
  function createCallbacksTransformer(callbacks = {}) {
@@ -53,7 +27,7 @@ function createCallbacksTransformer(callbacks = {}) {
53
27
  // src/llamaindex-adapter.ts
54
28
  function toUIMessageStream(stream, callbacks) {
55
29
  const trimStart = trimStartOfStream();
56
- return (0, import_internal.convertAsyncIteratorToReadableStream)(stream[Symbol.asyncIterator]()).pipeThrough(
30
+ return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]()).pipeThrough(
57
31
  new TransformStream({
58
32
  async transform(message, controller) {
59
33
  controller.enqueue(trimStart(message.delta));
@@ -83,8 +57,7 @@ function trimStartOfStream() {
83
57
  return text;
84
58
  };
85
59
  }
86
- // Annotate the CommonJS export names for ESM import in node:
87
- 0 && (module.exports = {
60
+ export {
88
61
  toUIMessageStream
89
- });
62
+ };
90
63
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/llamaindex-adapter.ts","../src/stream-callbacks.ts"],"sourcesContent":["export * from './llamaindex-adapter';\n","import { UIMessageChunk } from 'ai';\nimport { convertAsyncIteratorToReadableStream } from 'ai/internal';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype EngineResponse = {\n delta: string;\n};\n\nexport function toUIMessageStream(\n stream: AsyncIterable<EngineResponse>,\n callbacks?: StreamCallbacks,\n) {\n const trimStart = trimStartOfStream();\n\n return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]())\n .pipeThrough(\n new TransformStream({\n async transform(message, controller): Promise<void> {\n controller.enqueue(trimStart(message.delta));\n },\n }),\n )\n .pipeThrough(createCallbacksTransformer(callbacks))\n .pipeThrough(\n new TransformStream<string, UIMessageChunk>({\n start: async controller => {\n controller.enqueue({ type: 'text-start', id: '1' });\n },\n transform: async (chunk, controller) => {\n controller.enqueue({ type: 'text-delta', delta: chunk, id: '1' });\n },\n flush: async controller => {\n controller.enqueue({ type: 'text-end', id: '1' });\n },\n }),\n );\n}\n\nfunction trimStartOfStream(): (text: string) => string {\n let isStreamStart = true;\n\n return (text: string): string => {\n if (isStreamStart) {\n text = text.trimStart();\n if (text) isStreamStart = false;\n }\n return text;\n };\n}\n","/**\n * Configuration options and helper callback methods for stream lifecycle events.\n */\nexport interface StreamCallbacks {\n /** `onStart`: Called once when the stream is initialized. */\n onStart?: () => Promise<void> | void;\n\n /** `onFinal`: Called once when the stream is closed with the final completion message. */\n onFinal?: (completion: string) => Promise<void> | void;\n\n /** `onToken`: Called for each tokenized message. */\n onToken?: (token: string) => Promise<void> | void;\n\n /** `onText`: Called for each text chunk. */\n onText?: (text: string) => Promise<void> | void;\n}\n\n/**\n * Creates a transform stream that encodes input messages and invokes optional callback functions.\n * The transform stream uses the provided callbacks to execute custom logic at different stages of the stream's lifecycle.\n * - `onStart`: Called once when the stream is initialized.\n * - `onToken`: Called for each tokenized message.\n * - `onFinal`: Called once when the stream is closed with the final completion message.\n *\n * This function is useful when you want to process a stream of messages and perform specific actions during the stream's lifecycle.\n *\n * @param {StreamCallbacks} [callbacks] - An object containing the callback functions.\n * @return {TransformStream<string, Uint8Array>} A transform stream that encodes input messages as Uint8Array and allows the execution of custom logic through callbacks.\n *\n * @example\n * const callbacks = {\n * onStart: async () => console.log('Stream started'),\n * onToken: async (token) => console.log(`Token: ${token}`),\n * onFinal: async () => data.close()\n * };\n * const transformer = createCallbacksTransformer(callbacks);\n */\nexport function createCallbacksTransformer(\n callbacks: StreamCallbacks | undefined = {},\n): TransformStream<string, string> {\n let aggregatedResponse = '';\n\n return new TransformStream({\n async start(): Promise<void> {\n if (callbacks.onStart) await callbacks.onStart();\n },\n\n async transform(message, controller): Promise<void> {\n controller.enqueue(message);\n\n aggregatedResponse += message;\n\n if (callbacks.onToken) await callbacks.onToken(message);\n if (callbacks.onText && typeof message === 'string') {\n await callbacks.onText(message);\n }\n },\n\n async flush(): Promise<void> {\n if (callbac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B,mBAAW,QAAQ,EAAE,MAAM,YAAY,IAAI,IAAI,CAAC;AAAA,MAClD;AAAA,IACF,CAAC;AAAA,EACH;AACJ;AAEA,SAAS,oBAA8C;AACrD,MAAI,gBAAgB;AAEpB,SAAO,CAAC,SAAyB;AAC/B,QAAI,eAAe;AACjB,aAAO,KAAK,UAAU;AACtB,UAAI,KAAM,iBAAgB;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/llamaindex-adapter.ts","../src/stream-callbacks.ts"],"sourcesContent":["import { UIMessageChunk } from 'ai';\nimport { convertAsyncIteratorToReadableStream } from 'ai/internal';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype EngineResponse = {\n delta: string;\n};\n\nexport function toUIMessageStream(\n stream: AsyncIterable<EngineResponse>,\n callbacks?: StreamCallbacks,\n) {\n const trimStart = trimStartOfStream();\n\n return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]())\n .pipeThrough(\n new TransformStream({\n async transform(message, controller): Promise<void> {\n controller.enqueue(trimStart(message.delta));\n },\n }),\n )\n .pipeThrough(createCallbacksTransformer(callbacks))\n .pipeThrough(\n new TransformStream<string, UIMessageChunk>({\n start: async controller => {\n controller.enqueue({ type: 'text-start', id: '1' });\n },\n transform: async (chunk, controller) => {\n controller.enqueue({ type: 'text-delta', delta: chunk, id: '1' });\n },\n flush: async controller => {\n controller.enqueue({ type: 'text-end', id: '1' });\n },\n }),\n );\n}\n\nfunction trimStartOfStream(): (text: string) => string {\n let isStreamStart = true;\n\n return (text: string): string => {\n if (isStreamStart) {\n text = text.trimStart();\n if (text) isStreamStart = false;\n }\n return text;\n };\n}\n","/**\n * Configuration options and helper callback methods for stream lifecycle events.\n */\nexport interface StreamCallbacks {\n /** `onStart`: Called once when the stream is initialized. */\n onStart?: () => Promise<void> | void;\n\n /** `onFinal`: Called once when the stream is closed with the final completion message. */\n onFinal?: (completion: string) => Promise<void> | void;\n\n /** `onToken`: Called for each tokenized message. */\n onToken?: (token: string) => Promise<void> | void;\n\n /** `onText`: Called for each text chunk. */\n onText?: (text: string) => Promise<void> | void;\n}\n\n/**\n * Creates a transform stream that encodes input messages and invokes optional callback functions.\n * The transform stream uses the provided callbacks to execute custom logic at different stages of the stream's lifecycle.\n * - `onStart`: Called once when the stream is initialized.\n * - `onToken`: Called for each tokenized message.\n * - `onFinal`: Called once when the stream is closed with the final completion message.\n *\n * This function is useful when you want to process a stream of messages and perform specific actions during the stream's lifecycle.\n *\n * @param {StreamCallbacks} [callbacks] - An object containing the callback functions.\n * @return {TransformStream<string, Uint8Array>} A transform stream that encodes input messages as Uint8Array and allows the execution of custom logic through callbacks.\n *\n * @example\n * const callbacks = {\n * onStart: async () => console.log('Stream started'),\n * onToken: async (token) => console.log(`Token: ${token}`),\n * onFinal: async () => data.close()\n * };\n * const transformer = createCallbacksTransformer(callbacks);\n */\nexport function createCallbacksTransformer(\n callbacks: StreamCallbacks | undefined = {},\n): TransformStream<string, string> {\n let aggregatedResponse = '';\n\n return new TransformStream({\n async start(): Promise<void> {\n if (callbacks.onStart) await callbacks.onStart();\n },\n\n async transform(message, controller): Promise<void> {\n controller.enqueue(message);\n\n aggregatedResponse += message;\n\n if (callbacks.onToken) await callbacks.onToken(message);\n if (callbacks.onText && typeof message === 'string') {\n await callbacks.onText(message);\n }\n },\n\n async flush(): Promise<void> {\n if (callbacks.onFinal) {\n await callbacks.onFinal(aggregatedResponse);\n }\n },\n });\n}\n"],"mappings":";AACA,SAAS,4CAA4C;;;ACoC9C,SAAS,2BACd,YAAyC,CAAC,GACT;AACjC,MAAI,qBAAqB;AAEzB,SAAO,IAAI,gBAAgB;AAAA,IACzB,MAAM,QAAuB;AAC3B,UAAI,UAAU,QAAS,OAAM,UAAU,QAAQ;AAAA,IACjD;AAAA,IAEA,MAAM,UAAU,SAAS,YAA2B;AAClD,iBAAW,QAAQ,OAAO;AAE1B,4BAAsB;AAEtB,UAAI,UAAU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4
+ "type": "module",
4
5
  "license": "Apache-2.0",
5
6
  "sideEffects": false,
6
7
  "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
@@ -20,12 +20,12 @@
20
20
  "./package.json": "./package.json",
21
21
  ".": {
22
22
  "types": "./dist/index.d.ts",
23
- "import": "./dist/index.mjs",
24
- "require": "./dist/index.js"
23
+ "import": "./dist/index.js",
24
+ "default": "./dist/index.js"
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "ai": "7.0.0-beta.11"
28
+ "ai": "7.0.0-beta.112"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "20.17.24",
@@ -37,7 +37,8 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "publishConfig": {
40
- "access": "public"
40
+ "access": "public",
41
+ "provenance": true
41
42
  },
42
43
  "homepage": "https://ai-sdk.dev/docs",
43
44
  "repository": {
@@ -54,9 +55,7 @@
54
55
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
55
56
  "build:watch": "pnpm clean && tsup --watch",
56
57
  "clean": "del-cli dist *.tsbuildinfo",
57
- "lint": "eslint \"./**/*.ts*\"",
58
58
  "type-check": "tsc --build",
59
- "prettier-check": "prettier --check \"./**/*.ts*\"",
60
59
  "test": "pnpm test:node && pnpm test:edge",
61
60
  "test:update": "pnpm test:node -u",
62
61
  "test:watch": "vitest --config vitest.node.config.js",
package/dist/index.d.mts DELETED
@@ -1,22 +0,0 @@
1
- import { UIMessageChunk } from 'ai';
2
-
3
- /**
4
- * Configuration options and helper callback methods for stream lifecycle events.
5
- */
6
- interface StreamCallbacks {
7
- /** `onStart`: Called once when the stream is initialized. */
8
- onStart?: () => Promise<void> | void;
9
- /** `onFinal`: Called once when the stream is closed with the final completion message. */
10
- onFinal?: (completion: string) => Promise<void> | void;
11
- /** `onToken`: Called for each tokenized message. */
12
- onToken?: (token: string) => Promise<void> | void;
13
- /** `onText`: Called for each text chunk. */
14
- onText?: (text: string) => Promise<void> | void;
15
- }
16
-
17
- type EngineResponse = {
18
- delta: string;
19
- };
20
- declare function toUIMessageStream(stream: AsyncIterable<EngineResponse>, callbacks?: StreamCallbacks): ReadableStream<UIMessageChunk>;
21
-
22
- export { toUIMessageStream };
package/dist/index.mjs DELETED
@@ -1,63 +0,0 @@
1
- // src/llamaindex-adapter.ts
2
- import { convertAsyncIteratorToReadableStream } from "ai/internal";
3
-
4
- // src/stream-callbacks.ts
5
- function createCallbacksTransformer(callbacks = {}) {
6
- let aggregatedResponse = "";
7
- return new TransformStream({
8
- async start() {
9
- if (callbacks.onStart) await callbacks.onStart();
10
- },
11
- async transform(message, controller) {
12
- controller.enqueue(message);
13
- aggregatedResponse += message;
14
- if (callbacks.onToken) await callbacks.onToken(message);
15
- if (callbacks.onText && typeof message === "string") {
16
- await callbacks.onText(message);
17
- }
18
- },
19
- async flush() {
20
- if (callbacks.onFinal) {
21
- await callbacks.onFinal(aggregatedResponse);
22
- }
23
- }
24
- });
25
- }
26
-
27
- // src/llamaindex-adapter.ts
28
- function toUIMessageStream(stream, callbacks) {
29
- const trimStart = trimStartOfStream();
30
- return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]()).pipeThrough(
31
- new TransformStream({
32
- async transform(message, controller) {
33
- controller.enqueue(trimStart(message.delta));
34
- }
35
- })
36
- ).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(
37
- new TransformStream({
38
- start: async (controller) => {
39
- controller.enqueue({ type: "text-start", id: "1" });
40
- },
41
- transform: async (chunk, controller) => {
42
- controller.enqueue({ type: "text-delta", delta: chunk, id: "1" });
43
- },
44
- flush: async (controller) => {
45
- controller.enqueue({ type: "text-end", id: "1" });
46
- }
47
- })
48
- );
49
- }
50
- function trimStartOfStream() {
51
- let isStreamStart = true;
52
- return (text) => {
53
- if (isStreamStart) {
54
- text = text.trimStart();
55
- if (text) isStreamStart = false;
56
- }
57
- return text;
58
- };
59
- }
60
- export {
61
- toUIMessageStream
62
- };
63
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/llamaindex-adapter.ts","../src/stream-callbacks.ts"],"sourcesContent":["import { UIMessageChunk } from 'ai';\nimport { convertAsyncIteratorToReadableStream } from 'ai/internal';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype EngineResponse = {\n delta: string;\n};\n\nexport function toUIMessageStream(\n stream: AsyncIterable<EngineResponse>,\n callbacks?: StreamCallbacks,\n) {\n const trimStart = trimStartOfStream();\n\n return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]())\n .pipeThrough(\n new TransformStream({\n async transform(message, controller): Promise<void> {\n controller.enqueue(trimStart(message.delta));\n },\n }),\n )\n .pipeThrough(createCallbacksTransformer(callbacks))\n .pipeThrough(\n new TransformStream<string, UIMessageChunk>({\n start: async controller => {\n controller.enqueue({ type: 'text-start', id: '1' });\n },\n transform: async (chunk, controller) => {\n controller.enqueue({ type: 'text-delta', delta: chunk, id: '1' });\n },\n flush: async controller => {\n controller.enqueue({ type: 'text-end', id: '1' });\n },\n }),\n );\n}\n\nfunction trimStartOfStream(): (text: string) => string {\n let isStreamStart = true;\n\n return (text: string): string => {\n if (isStreamStart) {\n text = text.trimStart();\n if (text) isStreamStart = false;\n }\n return text;\n };\n}\n","/**\n * Configuration options and helper callback methods for stream lifecycle events.\n */\nexport interface StreamCallbacks {\n /** `onStart`: Called once when the stream is initialized. */\n onStart?: () => Promise<void> | void;\n\n /** `onFinal`: Called once when the stream is closed with the final completion message. */\n onFinal?: (completion: string) => Promise<void> | void;\n\n /** `onToken`: Called for each tokenized message. */\n onToken?: (token: string) => Promise<void> | void;\n\n /** `onText`: Called for each text chunk. */\n onText?: (text: string) => Promise<void> | void;\n}\n\n/**\n * Creates a transform stream that encodes input messages and invokes optional callback functions.\n * The transform stream uses the provided callbacks to execute custom logic at different stages of the stream's lifecycle.\n * - `onStart`: Called once when the stream is initialized.\n * - `onToken`: Called for each tokenized message.\n * - `onFinal`: Called once when the stream is closed with the final completion message.\n *\n * This function is useful when you want to process a stream of messages and perform specific actions during the stream's lifecycle.\n *\n * @param {StreamCallbacks} [callbacks] - An object containing the callback functions.\n * @return {TransformStream<string, Uint8Array>} A transform stream that encodes input messages as Uint8Array and allows the execution of custom logic through callbacks.\n *\n * @example\n * const callbacks = {\n * onStart: async () => console.log('Stream started'),\n * onToken: async (token) => console.log(`Token: ${token}`),\n * onFinal: async () => data.close()\n * };\n * const transformer = createCallbacksTransformer(callbacks);\n */\nexport function createCallbacksTransformer(\n callbacks: StreamCallbacks | undefined = {},\n): TransformStream<string, string> {\n let aggregatedResponse = '';\n\n return new TransformStream({\n async start(): Promise<void> {\n if (callbacks.onStart) await callbacks.onStart();\n },\n\n async transform(message, controller): Promise<void> {\n controller.enqueue(message);\n\n aggregatedResponse += message;\n\n if (callbacks.onToken) await callbacks.onToken(message);\n if (callbacks.onText && typeof message === 'string') {\n await callbacks.onText(message);\n }\n },\n\n async flush(): Promise<void> {\n if (callbacks.onFinal) {\n await callbacks.onFinal(aggregatedResponse);\n }\n },\n });\n}\n"],"mappings":";AACA,SAAS,4CAA4C;;;ACoC9C,SAAS,2BACd,YAAyC,CAAC,GACT;AACjC,MAAI,qBAAqB;AAEzB,SAAO,IAAI,gBAAgB;AAAA,IACzB,MAAM,QAAuB;AAC3B,UAAI,UAAU,QAAS,OAAM,UAAU,QAAQ;AAAA,IACjD;AAAA,IAEA,MAAM,UAAU,SAAS,YAA2B;AAClD,iBAAW,QAAQ,OAAO;AAE1B,4BAAsB;AAEtB,UAAI,UAAU,QAAS,OAAM,UAAU,QAAQ,OAAO;AACtD,UAAI,UAAU,UAAU,OAAO,YAAY,UAAU;AACnD,cAAM,UAAU,OAAO,OAAO;AAAA,MAChC;AAAA,IACF;AAAA,IAEA,MAAM,QAAuB;AAC3B,UAAI,UAAU,SAAS;AACrB,cAAM,UAAU,QAAQ,kBAAkB;AAAA,MAC5C;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