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

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,693 @@
1
1
  # @ai-sdk/llamaindex
2
2
 
3
+ ## 3.0.0-beta.111
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f319fde]
8
+ - Updated dependencies [1949571]
9
+ - Updated dependencies [511902c]
10
+ - Updated dependencies [6542d93]
11
+ - Updated dependencies [2e98477]
12
+ - Updated dependencies [876fd3e]
13
+ - Updated dependencies [f32c750]
14
+ - ai@7.0.0-beta.111
15
+
16
+ ## 3.0.0-beta.110
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [72cb801]
21
+ - ai@7.0.0-beta.110
22
+
23
+ ## 3.0.0-beta.109
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [ec98264]
28
+ - Updated dependencies [eea8d98]
29
+ - Updated dependencies [75ef93e]
30
+ - ai@7.0.0-beta.109
31
+
32
+ ## 3.0.0-beta.108
33
+
34
+ ### Patch Changes
35
+
36
+ - ai@7.0.0-beta.108
37
+
38
+ ## 3.0.0-beta.107
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [350ea38]
43
+ - ai@7.0.0-beta.107
44
+
45
+ ## 3.0.0-beta.106
46
+
47
+ ### Patch Changes
48
+
49
+ - ai@7.0.0-beta.106
50
+
51
+ ## 3.0.0-beta.105
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies [33d099c]
56
+ - ai@7.0.0-beta.105
57
+
58
+ ## 3.0.0-beta.104
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [2a74d43]
63
+ - ai@7.0.0-beta.104
64
+
65
+ ## 3.0.0-beta.103
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies [382d53b]
70
+ - Updated dependencies [7bf7d7f]
71
+ - Updated dependencies [c3d4019]
72
+ - Updated dependencies [083947b]
73
+ - ai@7.0.0-beta.103
74
+
75
+ ## 3.0.0-beta.102
76
+
77
+ ### Patch Changes
78
+
79
+ - ai@7.0.0-beta.102
80
+
81
+ ## 3.0.0-beta.101
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [4873966]
86
+ - ai@7.0.0-beta.101
87
+
88
+ ## 3.0.0-beta.100
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies [add1126]
93
+ - ai@7.0.0-beta.100
94
+
95
+ ## 3.0.0-beta.99
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [2a9c144]
100
+ - ai@7.0.0-beta.99
101
+
102
+ ## 3.0.0-beta.98
103
+
104
+ ### Patch Changes
105
+
106
+ - ai@7.0.0-beta.98
107
+
108
+ ## 3.0.0-beta.97
109
+
110
+ ### Patch Changes
111
+
112
+ - Updated dependencies [208d045]
113
+ - ai@7.0.0-beta.97
114
+
115
+ ## 3.0.0-beta.96
116
+
117
+ ### Patch Changes
118
+
119
+ - ai@7.0.0-beta.96
120
+
121
+ ## 3.0.0-beta.95
122
+
123
+ ### Patch Changes
124
+
125
+ - Updated dependencies [c4f4b5f]
126
+ - ai@7.0.0-beta.95
127
+
128
+ ## 3.0.0-beta.94
129
+
130
+ ### Patch Changes
131
+
132
+ - Updated dependencies [1582efa]
133
+ - ai@7.0.0-beta.94
134
+
135
+ ## 3.0.0-beta.93
136
+
137
+ ### Patch Changes
138
+
139
+ - Updated dependencies [bc47739]
140
+ - ai@7.0.0-beta.93
141
+
142
+ ## 3.0.0-beta.92
143
+
144
+ ### Patch Changes
145
+
146
+ - ai@7.0.0-beta.92
147
+
148
+ ## 3.0.0-beta.91
149
+
150
+ ### Patch Changes
151
+
152
+ - ai@7.0.0-beta.91
153
+
154
+ ## 3.0.0-beta.90
155
+
156
+ ### Patch Changes
157
+
158
+ - Updated dependencies [1db29c8]
159
+ - ai@7.0.0-beta.90
160
+
161
+ ## 3.0.0-beta.89
162
+
163
+ ### Patch Changes
164
+
165
+ - Updated dependencies [ff5eba1]
166
+ - ai@7.0.0-beta.89
167
+
168
+ ## 3.0.0-beta.88
169
+
170
+ ### Major Changes
171
+
172
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
173
+
174
+ ### Patch Changes
175
+
176
+ - Updated dependencies [ef992f8]
177
+ - ai@7.0.0-beta.88
178
+
179
+ ## 3.0.0-beta.87
180
+
181
+ ### Patch Changes
182
+
183
+ - ai@7.0.0-beta.87
184
+
185
+ ## 3.0.0-beta.86
186
+
187
+ ### Patch Changes
188
+
189
+ - Updated dependencies [5a6f514]
190
+ - ai@7.0.0-beta.86
191
+
192
+ ## 3.0.0-beta.85
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies [57bf606]
197
+ - ai@7.0.0-beta.85
198
+
199
+ ## 3.0.0-beta.84
200
+
201
+ ### Patch Changes
202
+
203
+ - Updated dependencies [90e2d8a]
204
+ - ai@7.0.0-beta.84
205
+
206
+ ## 3.0.0-beta.83
207
+
208
+ ### Patch Changes
209
+
210
+ - ai@7.0.0-beta.83
211
+
212
+ ## 3.0.0-beta.82
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [e27ed76]
217
+ - ai@7.0.0-beta.82
218
+
219
+ ## 3.0.0-beta.81
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [2fe1099]
224
+ - Updated dependencies [f04adcb]
225
+ - ai@7.0.0-beta.81
226
+
227
+ ## 3.0.0-beta.80
228
+
229
+ ### Patch Changes
230
+
231
+ - Updated dependencies [3ae1786]
232
+ - ai@7.0.0-beta.80
233
+
234
+ ## 3.0.0-beta.79
235
+
236
+ ### Patch Changes
237
+
238
+ - Updated dependencies [6866afe]
239
+ - ai@7.0.0-beta.79
240
+
241
+ ## 3.0.0-beta.78
242
+
243
+ ### Patch Changes
244
+
245
+ - Updated dependencies [f372547]
246
+ - ai@7.0.0-beta.78
247
+
248
+ ## 3.0.0-beta.77
249
+
250
+ ### Patch Changes
251
+
252
+ - Updated dependencies [2add429]
253
+ - ai@7.0.0-beta.77
254
+
255
+ ## 3.0.0-beta.76
256
+
257
+ ### Patch Changes
258
+
259
+ - Updated dependencies [fcc6869]
260
+ - ai@7.0.0-beta.76
261
+
262
+ ## 3.0.0-beta.75
263
+
264
+ ### Patch Changes
265
+
266
+ - Updated dependencies [176466a]
267
+ - ai@7.0.0-beta.75
268
+
269
+ ## 3.0.0-beta.74
270
+
271
+ ### Patch Changes
272
+
273
+ - Updated dependencies [e311194]
274
+ - ai@7.0.0-beta.74
275
+
276
+ ## 3.0.0-beta.73
277
+
278
+ ### Patch Changes
279
+
280
+ - ai@7.0.0-beta.73
281
+
282
+ ## 3.0.0-beta.72
283
+
284
+ ### Patch Changes
285
+
286
+ - Updated dependencies [664a0eb]
287
+ - ai@7.0.0-beta.72
288
+
289
+ ## 3.0.0-beta.71
290
+
291
+ ### Patch Changes
292
+
293
+ - Updated dependencies [e68be55]
294
+ - ai@7.0.0-beta.71
295
+
296
+ ## 3.0.0-beta.70
297
+
298
+ ### Patch Changes
299
+
300
+ - ai@7.0.0-beta.70
301
+
302
+ ## 3.0.0-beta.69
303
+
304
+ ### Patch Changes
305
+
306
+ - Updated dependencies [34bd95d]
307
+ - Updated dependencies [008271d]
308
+ - Updated dependencies [72223e7]
309
+ - ai@7.0.0-beta.69
310
+
311
+ ## 3.0.0-beta.68
312
+
313
+ ### Patch Changes
314
+
315
+ - Updated dependencies [b0c2869]
316
+ - Updated dependencies [7e26e81]
317
+ - ai@7.0.0-beta.68
318
+
319
+ ## 3.0.0-beta.67
320
+
321
+ ### Patch Changes
322
+
323
+ - Updated dependencies [d1a8bed]
324
+ - ai@7.0.0-beta.67
325
+
326
+ ## 3.0.0-beta.66
327
+
328
+ ### Patch Changes
329
+
330
+ - ai@7.0.0-beta.66
331
+
332
+ ## 3.0.0-beta.65
333
+
334
+ ### Patch Changes
335
+
336
+ - ai@7.0.0-beta.65
337
+
338
+ ## 3.0.0-beta.64
339
+
340
+ ### Patch Changes
341
+
342
+ - ai@7.0.0-beta.64
343
+
344
+ ## 3.0.0-beta.63
345
+
346
+ ### Patch Changes
347
+
348
+ - Updated dependencies [6fd51c0]
349
+ - ai@7.0.0-beta.63
350
+
351
+ ## 3.0.0-beta.62
352
+
353
+ ### Patch Changes
354
+
355
+ - ai@7.0.0-beta.62
356
+
357
+ ## 3.0.0-beta.61
358
+
359
+ ### Patch Changes
360
+
361
+ - Updated dependencies [c29a26f]
362
+ - ai@7.0.0-beta.61
363
+
364
+ ## 3.0.0-beta.60
365
+
366
+ ### Patch Changes
367
+
368
+ - Updated dependencies [38fc777]
369
+ - ai@7.0.0-beta.60
370
+
371
+ ## 3.0.0-beta.59
372
+
373
+ ### Patch Changes
374
+
375
+ - ai@7.0.0-beta.59
376
+
377
+ ## 3.0.0-beta.58
378
+
379
+ ### Patch Changes
380
+
381
+ - Updated dependencies [2e17091]
382
+ - ai@7.0.0-beta.58
383
+
384
+ ## 3.0.0-beta.57
385
+
386
+ ### Patch Changes
387
+
388
+ - Updated dependencies [986c6fd]
389
+ - Updated dependencies [493295c]
390
+ - ai@7.0.0-beta.57
391
+
392
+ ## 3.0.0-beta.56
393
+
394
+ ### Patch Changes
395
+
396
+ - ai@7.0.0-beta.56
397
+
398
+ ## 3.0.0-beta.55
399
+
400
+ ### Patch Changes
401
+
402
+ - Updated dependencies [b3c9f6a]
403
+ - ai@7.0.0-beta.55
404
+
405
+ ## 3.0.0-beta.54
406
+
407
+ ### Patch Changes
408
+
409
+ - Updated dependencies [5d0f18e]
410
+ - ai@7.0.0-beta.54
411
+
412
+ ## 3.0.0-beta.53
413
+
414
+ ### Patch Changes
415
+
416
+ - Updated dependencies [9b47dea]
417
+ - ai@7.0.0-beta.53
418
+
419
+ ## 3.0.0-beta.52
420
+
421
+ ### Patch Changes
422
+
423
+ - Updated dependencies [b56301c]
424
+ - ai@7.0.0-beta.52
425
+
426
+ ## 3.0.0-beta.51
427
+
428
+ ### Patch Changes
429
+
430
+ - Updated dependencies [6abd098]
431
+ - ai@7.0.0-beta.51
432
+
433
+ ## 3.0.0-beta.50
434
+
435
+ ### Patch Changes
436
+
437
+ - Updated dependencies [3debdb7]
438
+ - ai@7.0.0-beta.50
439
+
440
+ ## 3.0.0-beta.49
441
+
442
+ ### Patch Changes
443
+
444
+ - ai@7.0.0-beta.49
445
+
446
+ ## 3.0.0-beta.48
447
+
448
+ ### Patch Changes
449
+
450
+ - Updated dependencies [5c4d910]
451
+ - ai@7.0.0-beta.48
452
+
453
+ ## 3.0.0-beta.47
454
+
455
+ ### Patch Changes
456
+
457
+ - Updated dependencies [bc67b4f]
458
+ - ai@7.0.0-beta.47
459
+
460
+ ## 3.0.0-beta.46
461
+
462
+ ### Patch Changes
463
+
464
+ - Updated dependencies [31ee822]
465
+ - ai@7.0.0-beta.46
466
+
467
+ ## 3.0.0-beta.45
468
+
469
+ ### Patch Changes
470
+
471
+ - ai@7.0.0-beta.45
472
+
473
+ ## 3.0.0-beta.44
474
+
475
+ ### Patch Changes
476
+
477
+ - ai@7.0.0-beta.44
478
+
479
+ ## 3.0.0-beta.43
480
+
481
+ ### Patch Changes
482
+
483
+ - ai@7.0.0-beta.43
484
+
485
+ ## 3.0.0-beta.42
486
+
487
+ ### Patch Changes
488
+
489
+ - Updated dependencies [a3fd75b]
490
+ - ai@7.0.0-beta.42
491
+
492
+ ## 3.0.0-beta.41
493
+
494
+ ### Patch Changes
495
+
496
+ - ai@7.0.0-beta.41
497
+
498
+ ## 3.0.0-beta.40
499
+
500
+ ### Patch Changes
501
+
502
+ - Updated dependencies [989d3d2]
503
+ - ai@7.0.0-beta.40
504
+
505
+ ## 3.0.0-beta.39
506
+
507
+ ### Patch Changes
508
+
509
+ - Updated dependencies [f4cfccd]
510
+ - ai@7.0.0-beta.39
511
+
512
+ ## 3.0.0-beta.38
513
+
514
+ ### Patch Changes
515
+
516
+ - Updated dependencies [1f509d4]
517
+ - ai@7.0.0-beta.38
518
+
519
+ ## 3.0.0-beta.37
520
+
521
+ ### Patch Changes
522
+
523
+ - ai@7.0.0-beta.37
524
+
525
+ ## 3.0.0-beta.36
526
+
527
+ ### Patch Changes
528
+
529
+ - Updated dependencies [118b953]
530
+ - ai@7.0.0-beta.36
531
+
532
+ ## 3.0.0-beta.35
533
+
534
+ ### Patch Changes
535
+
536
+ - Updated dependencies [99bf941]
537
+ - ai@7.0.0-beta.35
538
+
539
+ ## 3.0.0-beta.34
540
+
541
+ ### Patch Changes
542
+
543
+ - ai@7.0.0-beta.34
544
+
545
+ ## 3.0.0-beta.33
546
+
547
+ ### Patch Changes
548
+
549
+ - Updated dependencies [caf1b6f]
550
+ - ai@7.0.0-beta.33
551
+
552
+ ## 3.0.0-beta.32
553
+
554
+ ### Patch Changes
555
+
556
+ - Updated dependencies [4b46062]
557
+ - ai@7.0.0-beta.32
558
+
559
+ ## 3.0.0-beta.31
560
+
561
+ ### Patch Changes
562
+
563
+ - Updated dependencies [e79e644]
564
+ - ai@7.0.0-beta.31
565
+
566
+ ## 3.0.0-beta.30
567
+
568
+ ### Patch Changes
569
+
570
+ - Updated dependencies [f5a6f89]
571
+ - ai@7.0.0-beta.30
572
+
573
+ ## 3.0.0-beta.29
574
+
575
+ ### Patch Changes
576
+
577
+ - Updated dependencies [877bf12]
578
+ - ai@7.0.0-beta.29
579
+
580
+ ## 3.0.0-beta.28
581
+
582
+ ### Patch Changes
583
+
584
+ - Updated dependencies [b9cf502]
585
+ - ai@7.0.0-beta.28
586
+
587
+ ## 3.0.0-beta.27
588
+
589
+ ### Patch Changes
590
+
591
+ - Updated dependencies [3887c70]
592
+ - ai@7.0.0-beta.27
593
+
594
+ ## 3.0.0-beta.26
595
+
596
+ ### Patch Changes
597
+
598
+ - Updated dependencies [f0b0b20]
599
+ - ai@7.0.0-beta.26
600
+
601
+ ## 3.0.0-beta.25
602
+
603
+ ### Patch Changes
604
+
605
+ - Updated dependencies [ff9ce30]
606
+ - ai@7.0.0-beta.25
607
+
608
+ ## 3.0.0-beta.24
609
+
610
+ ### Patch Changes
611
+
612
+ - Updated dependencies [776b617]
613
+ - ai@7.0.0-beta.24
614
+
615
+ ## 3.0.0-beta.23
616
+
617
+ ### Patch Changes
618
+
619
+ - Updated dependencies [80d4dde]
620
+ - ai@7.0.0-beta.23
621
+
622
+ ## 3.0.0-beta.22
623
+
624
+ ### Patch Changes
625
+
626
+ - ai@7.0.0-beta.22
627
+
628
+ ## 3.0.0-beta.21
629
+
630
+ ### Patch Changes
631
+
632
+ - Updated dependencies [34fd051]
633
+ - ai@7.0.0-beta.21
634
+
635
+ ## 3.0.0-beta.20
636
+
637
+ ### Patch Changes
638
+
639
+ - ai@7.0.0-beta.20
640
+
641
+ ## 3.0.0-beta.19
642
+
643
+ ### Patch Changes
644
+
645
+ - ai@7.0.0-beta.19
646
+
647
+ ## 3.0.0-beta.18
648
+
649
+ ### Patch Changes
650
+
651
+ - ai@7.0.0-beta.18
652
+
653
+ ## 3.0.0-beta.17
654
+
655
+ ### Patch Changes
656
+
657
+ - ai@7.0.0-beta.17
658
+
659
+ ## 3.0.0-beta.16
660
+
661
+ ### Patch Changes
662
+
663
+ - Updated dependencies [5b8c58f]
664
+ - ai@7.0.0-beta.16
665
+
666
+ ## 3.0.0-beta.15
667
+
668
+ ### Patch Changes
669
+
670
+ - ai@7.0.0-beta.15
671
+
672
+ ## 3.0.0-beta.14
673
+
674
+ ### Patch Changes
675
+
676
+ - ai@7.0.0-beta.14
677
+
678
+ ## 3.0.0-beta.13
679
+
680
+ ### Patch Changes
681
+
682
+ - Updated dependencies [c26ca8d]
683
+ - ai@7.0.0-beta.13
684
+
685
+ ## 3.0.0-beta.12
686
+
687
+ ### Patch Changes
688
+
689
+ - ai@7.0.0-beta.12
690
+
3
691
  ## 3.0.0-beta.11
4
692
 
5
693
  ### 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 (callbacks.onFinal) {\n await callbacks.onFinal(aggregatedResponse);\n }\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,sBAAqD;;;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;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;ADrDO,SAAS,kBACd,QACA,WACA;AACA,QAAM,YAAY,kBAAkB;AAEpC,aAAO,sDAAqC,OAAO,OAAO,aAAa,EAAE,CAAC,EACvE;AAAA,IACC,IAAI,gBAAgB;AAAA,MAClB,MAAM,UAAU,SAAS,YAA2B;AAClD,mBAAW,QAAQ,UAAU,QAAQ,KAAK,CAAC;AAAA,MAC7C;AAAA,IACF,CAAC;AAAA,EACH,EACC,YAAY,2BAA2B,SAAS,CAAC,EACjD;AAAA,IACC,IAAI,gBAAwC;AAAA,MAC1C,OAAO,OAAM,eAAc;AACzB,mBAAW,QAAQ,EAAE,MAAM,cAAc,IAAI,IAAI,CAAC;AAAA,MACpD;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AACtC,mBAAW,QAAQ,EAAE,MAAM,cAAc,OAAO,OAAO,IAAI,IAAI,CAAC;AAAA,MAClE;AAAA,MACA,OAAO,OAAM,eAAc;AACzB,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,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;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;ADrDO,SAAS,kBACd,QACA,WACA;AACA,QAAM,YAAY,kBAAkB;AAEpC,SAAO,qCAAqC,OAAO,OAAO,aAAa,EAAE,CAAC,EACvE;AAAA,IACC,IAAI,gBAAgB;AAAA,MAClB,MAAM,UAAU,SAAS,YAA2B;AAClD,mBAAW,QAAQ,UAAU,QAAQ,KAAK,CAAC;AAAA,MAC7C;AAAA,IACF,CAAC;AAAA,EACH,EACC,YAAY,2BAA2B,SAAS,CAAC,EACjD;AAAA,IACC,IAAI,gBAAwC;AAAA,MAC1C,OAAO,OAAM,eAAc;AACzB,mBAAW,QAAQ,EAAE,MAAM,cAAc,IAAI,IAAI,CAAC;AAAA,MACpD;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AACtC,mBAAW,QAAQ,EAAE,MAAM,cAAc,OAAO,OAAO,IAAI,IAAI,CAAC;AAAA,MAClE;AAAA,MACA,OAAO,OAAM,eAAc;AACzB,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":[]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ai-sdk/llamaindex",
3
- "version": "3.0.0-beta.11",
3
+ "version": "3.0.0-beta.111",
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.111"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "20.17.24",
@@ -54,9 +54,7 @@
54
54
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
55
55
  "build:watch": "pnpm clean && tsup --watch",
56
56
  "clean": "del-cli dist *.tsbuildinfo",
57
- "lint": "eslint \"./**/*.ts*\"",
58
57
  "type-check": "tsc --build",
59
- "prettier-check": "prettier --check \"./**/*.ts*\"",
60
58
  "test": "pnpm test:node && pnpm test:edge",
61
59
  "test:update": "pnpm test:node -u",
62
60
  "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;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;ADrDO,SAAS,kBACd,QACA,WACA;AACA,QAAM,YAAY,kBAAkB;AAEpC,SAAO,qCAAqC,OAAO,OAAO,aAAa,EAAE,CAAC,EACvE;AAAA,IACC,IAAI,gBAAgB;AAAA,MAClB,MAAM,UAAU,SAAS,YAA2B;AAClD,mBAAW,QAAQ,UAAU,QAAQ,KAAK,CAAC;AAAA,MAC7C;AAAA,IACF,CAAC;AAAA,EACH,EACC,YAAY,2BAA2B,SAAS,CAAC,EACjD;AAAA,IACC,IAAI,gBAAwC;AAAA,MAC1C,OAAO,OAAM,eAAc;AACzB,mBAAW,QAAQ,EAAE,MAAM,cAAc,IAAI,IAAI,CAAC;AAAA,MACpD;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AACtC,mBAAW,QAAQ,EAAE,MAAM,cAAc,OAAO,OAAO,IAAI,IAAI,CAAC;AAAA,MAClE;AAAA,MACA,OAAO,OAAM,eAAc;AACzB,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":[]}