@ai-sdk/langchain 1.0.0-canary.9 → 1.0.0

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,709 @@
1
1
  # @ai-sdk/langchain
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - bc3109f: chore (ai): push stream-callbacks into langchain/llamaindex adapters
8
+ - c9fbc57: chore(providers/langchain): extract to separate package
9
+ - Updated dependencies [e1cbf8a]
10
+ - Updated dependencies [a571d6e]
11
+ - Updated dependencies [de2d2ab]
12
+ - Updated dependencies [c22ad54]
13
+ - Updated dependencies [a847c3e]
14
+ - Updated dependencies [13fef90]
15
+ - Updated dependencies [d88455d]
16
+ - Updated dependencies [e7fcc86]
17
+ - Updated dependencies [da1e6f0]
18
+ - Updated dependencies [48378b9]
19
+ - Updated dependencies [5d1e3ba]
20
+ - Updated dependencies [d964901]
21
+ - Updated dependencies [93d53a1]
22
+ - Updated dependencies [e90d45d]
23
+ - Updated dependencies [b32c141]
24
+ - Updated dependencies [bc3109f]
25
+ - Updated dependencies [0a710d8]
26
+ - Updated dependencies [0d9583c]
27
+ - Updated dependencies [9ad0484]
28
+ - Updated dependencies [38ae5cc]
29
+ - Updated dependencies [10b21eb]
30
+ - Updated dependencies [63f9e9b]
31
+ - Updated dependencies [ab7ccef]
32
+ - Updated dependencies [d5f588f]
33
+ - Updated dependencies [9e40cbe]
34
+ - Updated dependencies [6909543]
35
+ - Updated dependencies [86cfc72]
36
+ - Updated dependencies [ec78cdc]
37
+ - Updated dependencies [377bbcf]
38
+ - Updated dependencies [6a83f7d]
39
+ - Updated dependencies [d8aeaef]
40
+ - Updated dependencies [ae77a99]
41
+ - Updated dependencies [4fef487]
42
+ - Updated dependencies [b1e3abd]
43
+ - Updated dependencies [4f3e637]
44
+ - Updated dependencies [db345da]
45
+ - Updated dependencies [496bbc1]
46
+ - Updated dependencies [14cb3be]
47
+ - Updated dependencies [1f6ce57]
48
+ - Updated dependencies [72d7d72]
49
+ - Updated dependencies [40acf9b]
50
+ - Updated dependencies [98f25e5]
51
+ - Updated dependencies [16ccfb2]
52
+ - Updated dependencies [225f087]
53
+ - Updated dependencies [ce1d1f3]
54
+ - Updated dependencies [fc0380b]
55
+ - Updated dependencies [b7eae2d]
56
+ - Updated dependencies [2d03e19]
57
+ - Updated dependencies [6622441]
58
+ - Updated dependencies [4048ce3]
59
+ - Updated dependencies [6c42e56]
60
+ - Updated dependencies [bedb239]
61
+ - Updated dependencies [da70d79]
62
+ - Updated dependencies [9b4d074]
63
+ - Updated dependencies [c60f895]
64
+ - Updated dependencies [bcea599]
65
+ - Updated dependencies [c8fce91]
66
+ - Updated dependencies [655cf3c]
67
+ - Updated dependencies [3e10408]
68
+ - Updated dependencies [d5ae088]
69
+ - Updated dependencies [ced8eee]
70
+ - Updated dependencies [c040e2f]
71
+ - Updated dependencies [d3960e3]
72
+ - Updated dependencies [0560977]
73
+ - Updated dependencies [faea29f]
74
+ - Updated dependencies [66af894]
75
+ - Updated dependencies [332167b]
76
+ - Updated dependencies [9477ebb]
77
+ - Updated dependencies [6b1c55c]
78
+ - Updated dependencies [5a975a4]
79
+ - Updated dependencies [1f55c21]
80
+ - Updated dependencies [507ac1d]
81
+ - Updated dependencies [a166433]
82
+ - Updated dependencies [e7dc6c7]
83
+ - Updated dependencies [26735b5]
84
+ - Updated dependencies [c93a8bc]
85
+ - Updated dependencies [8b86e99]
86
+ - Updated dependencies [0d2c085]
87
+ - Updated dependencies [2b9bbcd]
88
+ - Updated dependencies [04d5063]
89
+ - Updated dependencies [a8c8bd5]
90
+ - Updated dependencies [75c3396]
91
+ - Updated dependencies [cb9c9e4]
92
+ - Updated dependencies [319b989]
93
+ - Updated dependencies [14c9410]
94
+ - Updated dependencies [9bf7291]
95
+ - Updated dependencies [9b0da33]
96
+ - Updated dependencies [a34eb39]
97
+ - Updated dependencies [28ad69e]
98
+ - Updated dependencies [0b78e17]
99
+ - Updated dependencies [20398f2]
100
+ - Updated dependencies [66962ed]
101
+ - Updated dependencies [f04fb4a]
102
+ - Updated dependencies [b71fe8d]
103
+ - Updated dependencies [f7e8bf4]
104
+ - Updated dependencies [7827a49]
105
+ - Updated dependencies [48d675a]
106
+ - Updated dependencies [257224b]
107
+ - Updated dependencies [bd8a36c]
108
+ - Updated dependencies [d9209ca]
109
+ - Updated dependencies [b346545]
110
+ - Updated dependencies [05d2819]
111
+ - Updated dependencies [f2b041e]
112
+ - Updated dependencies [2a62513]
113
+ - Updated dependencies [143c55b]
114
+ - Updated dependencies [9301f86]
115
+ - Updated dependencies [904fa5e]
116
+ - Updated dependencies [fd1924b]
117
+ - Updated dependencies [0a87932]
118
+ - Updated dependencies [2524fc7]
119
+ - Updated dependencies [1675396]
120
+ - Updated dependencies [51f497d]
121
+ - Updated dependencies [cee64b2]
122
+ - Updated dependencies [6fba4c7]
123
+ - Updated dependencies [b4b4bb2]
124
+ - Updated dependencies [f04ffe4]
125
+ - Updated dependencies [bc24722]
126
+ - Updated dependencies [b6f9f3c]
127
+ - Updated dependencies [8aa9e20]
128
+ - Updated dependencies [4617fab]
129
+ - Updated dependencies [8255639]
130
+ - Updated dependencies [f81c720]
131
+ - Updated dependencies [441d042]
132
+ - Updated dependencies [cf9af6e]
133
+ - Updated dependencies [ef256ed]
134
+ - Updated dependencies [ee38081]
135
+ - Updated dependencies [2e4f9e4]
136
+ - Updated dependencies [516be5b]
137
+ - Updated dependencies [a662dea]
138
+ - Updated dependencies [d884051]
139
+ - Updated dependencies [3e3b9df]
140
+ - Updated dependencies [cda32ba]
141
+ - Updated dependencies [e8324c5]
142
+ - Updated dependencies [fafc3f2]
143
+ - Updated dependencies [48a7606]
144
+ - Updated dependencies [cb68df0]
145
+ - Updated dependencies [db64cbe]
146
+ - Updated dependencies [97c35c0]
147
+ - Updated dependencies [1ed0287]
148
+ - Updated dependencies [26695a3]
149
+ - Updated dependencies [90ac328]
150
+ - Updated dependencies [c9ad635]
151
+ - Updated dependencies [60132dd]
152
+ - Updated dependencies [c7710a9]
153
+ - Updated dependencies [4a1e0c8]
154
+ - Updated dependencies [bfbfc4c]
155
+ - Updated dependencies [c6b64a7]
156
+ - Updated dependencies [fccf75c]
157
+ - Updated dependencies [9ae327d]
158
+ - Updated dependencies [9315076]
159
+ - Updated dependencies [247ee0c]
160
+ - Updated dependencies [9121250]
161
+ - Updated dependencies [ea27cc6]
162
+ - Updated dependencies [90ca2b9]
163
+ - Updated dependencies [50f0362]
164
+ - Updated dependencies [109c0ac]
165
+ - Updated dependencies [954aa73]
166
+ - Updated dependencies [33eb499]
167
+ - Updated dependencies [825e8d7]
168
+ - Updated dependencies [901df02]
169
+ - Updated dependencies [7d97ab6]
170
+ - Updated dependencies [4892798]
171
+ - Updated dependencies [0ff02bb]
172
+ - Updated dependencies [c25cbce]
173
+ - Updated dependencies [4f3776c]
174
+ - Updated dependencies [9338f3e]
175
+ - Updated dependencies [b33ed7a]
176
+ - Updated dependencies [92c8e66]
177
+ - Updated dependencies [53569b8]
178
+ - Updated dependencies [82aa95d]
179
+ - Updated dependencies [ed675de]
180
+ - Updated dependencies [e7d2ce3]
181
+ - Updated dependencies [add5ac1]
182
+ - Updated dependencies [37a916d]
183
+ - Updated dependencies [30ac566]
184
+ - Updated dependencies [8026705]
185
+ - Updated dependencies [9bd5ab5]
186
+ - Updated dependencies [ec5933d]
187
+ - Updated dependencies [09f41ac]
188
+ - Updated dependencies [7bb58d4]
189
+ - Updated dependencies [ff1c81a]
190
+ - Updated dependencies [af1d5a5]
191
+ - Updated dependencies [cb3b9c9]
192
+ - Updated dependencies [86293e5]
193
+ - Updated dependencies [d1a034f]
194
+ - Updated dependencies [fd65bc6]
195
+ - Updated dependencies [ea7a7c9]
196
+ - Updated dependencies [d92b9a8]
197
+ - Updated dependencies [102b066]
198
+ - Updated dependencies [142576e]
199
+ - Updated dependencies [84343eb]
200
+ - Updated dependencies [0463011]
201
+ - Updated dependencies [a76a62b]
202
+ - Updated dependencies [89ba235]
203
+ - Updated dependencies [8e31d46]
204
+ - Updated dependencies [dcc549b]
205
+ - Updated dependencies [35fc02c]
206
+ - Updated dependencies [64f6d64]
207
+ - Updated dependencies [bd398e4]
208
+ - Updated dependencies [88a8ee5]
209
+ - Updated dependencies [205077b]
210
+ - Updated dependencies [d91b50d]
211
+ - Updated dependencies [e4c8647]
212
+ - Updated dependencies [c808e4d]
213
+ - Updated dependencies [175b868]
214
+ - Updated dependencies [e862b5b]
215
+ - Updated dependencies [395c85e]
216
+ - Updated dependencies [60e2c56]
217
+ - Updated dependencies [5bdff05]
218
+ - Updated dependencies [13b4f46]
219
+ - Updated dependencies [a4f3007]
220
+ - Updated dependencies [8e64e9c]
221
+ - Updated dependencies [765f1cd]
222
+ - Updated dependencies [cb2b53a]
223
+ - Updated dependencies [b983b51]
224
+ - Updated dependencies [e244a78]
225
+ - Updated dependencies [d306260]
226
+ - Updated dependencies [4bfe9ec]
227
+ - Updated dependencies [56c232b]
228
+ - Updated dependencies [1766ede]
229
+ - Updated dependencies [7324c21]
230
+ - Updated dependencies [2877a74]
231
+ - Updated dependencies [f10304b]
232
+ - Updated dependencies [dd5fd43]
233
+ - Updated dependencies [a753b3a]
234
+ - Updated dependencies [1409e13]
235
+ - Updated dependencies [383cbfa]
236
+ - Updated dependencies [27deb4d]
237
+ - Updated dependencies [5f2b3d4]
238
+ - Updated dependencies [4c8f834]
239
+ - Updated dependencies [f2c7f19]
240
+ - Updated dependencies [b32e192]
241
+ - Updated dependencies [92cb0a2]
242
+ - Updated dependencies [2b637d6]
243
+ - Updated dependencies [7bd025b]
244
+ - ai@5.0.0
245
+
246
+ ## 1.0.0-beta.34
247
+
248
+ ### Patch Changes
249
+
250
+ - Updated dependencies [53569b8]
251
+ - Updated dependencies [88a8ee5]
252
+ - Updated dependencies [f2c7f19]
253
+ - ai@5.0.0-beta.34
254
+
255
+ ## 1.0.0-beta.33
256
+
257
+ ### Patch Changes
258
+
259
+ - Updated dependencies [48378b9]
260
+ - Updated dependencies [93d53a1]
261
+ - Updated dependencies [27deb4d]
262
+ - ai@5.0.0-beta.33
263
+
264
+ ## 1.0.0-beta.32
265
+
266
+ ### Patch Changes
267
+
268
+ - Updated dependencies [bc24722]
269
+ - Updated dependencies [13b4f46]
270
+ - Updated dependencies [56c232b]
271
+ - ai@5.0.0-beta.32
272
+
273
+ ## 1.0.0-beta.31
274
+
275
+ ### Patch Changes
276
+
277
+ - Updated dependencies [6622441]
278
+ - Updated dependencies [ced8eee]
279
+ - Updated dependencies [cee64b2]
280
+ - Updated dependencies [ee38081]
281
+ - Updated dependencies [dd5fd43]
282
+ - ai@5.0.0-beta.31
283
+
284
+ ## 1.0.0-beta.30
285
+
286
+ ### Patch Changes
287
+
288
+ - ai@5.0.0-beta.30
289
+
290
+ ## 1.0.0-beta.29
291
+
292
+ ### Patch Changes
293
+
294
+ - Updated dependencies [e7fcc86]
295
+ - Updated dependencies [d92b9a8]
296
+ - ai@5.0.0-beta.29
297
+
298
+ ## 1.0.0-beta.28
299
+
300
+ ### Patch Changes
301
+
302
+ - Updated dependencies [84343eb]
303
+ - Updated dependencies [a753b3a]
304
+ - ai@5.0.0-beta.28
305
+
306
+ ## 1.0.0-beta.27
307
+
308
+ ### Patch Changes
309
+
310
+ - Updated dependencies [d5ae088]
311
+ - ai@5.0.0-beta.27
312
+
313
+ ## 1.0.0-beta.26
314
+
315
+ ### Patch Changes
316
+
317
+ - Updated dependencies [ae77a99]
318
+ - Updated dependencies [1f6ce57]
319
+ - Updated dependencies [5a975a4]
320
+ - Updated dependencies [2a62513]
321
+ - Updated dependencies [904fa5e]
322
+ - Updated dependencies [f81c720]
323
+ - ai@5.0.0-beta.26
324
+
325
+ ## 1.0.0-beta.25
326
+
327
+ ### Patch Changes
328
+
329
+ - ai@5.0.0-beta.25
330
+
331
+ ## 1.0.0-beta.24
332
+
333
+ ### Patch Changes
334
+
335
+ - Updated dependencies [add5ac1]
336
+ - Updated dependencies [ff1c81a]
337
+ - Updated dependencies [e4c8647]
338
+ - Updated dependencies [383cbfa]
339
+ - ai@5.0.0-beta.24
340
+
341
+ ## 1.0.0-beta.23
342
+
343
+ ### Patch Changes
344
+
345
+ - Updated dependencies [89ba235]
346
+ - ai@5.0.0-beta.23
347
+
348
+ ## 1.0.0-beta.22
349
+
350
+ ### Patch Changes
351
+
352
+ - Updated dependencies [de2d2ab]
353
+ - Updated dependencies [6c42e56]
354
+ - Updated dependencies [c93a8bc]
355
+ - Updated dependencies [20398f2]
356
+ - Updated dependencies [86293e5]
357
+ - Updated dependencies [205077b]
358
+ - ai@5.0.0-beta.22
359
+
360
+ ## 1.0.0-beta.21
361
+
362
+ ### Patch Changes
363
+
364
+ - Updated dependencies [38ae5cc]
365
+ - Updated dependencies [faea29f]
366
+ - Updated dependencies [90ac328]
367
+ - Updated dependencies [4a1e0c8]
368
+ - Updated dependencies [30ac566]
369
+ - ai@5.0.0-beta.21
370
+
371
+ ## 1.0.0-beta.20
372
+
373
+ ### Patch Changes
374
+
375
+ - Updated dependencies [4c8f834]
376
+ - ai@5.0.0-beta.20
377
+
378
+ ## 1.0.0-beta.19
379
+
380
+ ### Patch Changes
381
+
382
+ - Updated dependencies [10b21eb]
383
+ - Updated dependencies [75c3396]
384
+ - Updated dependencies [05d2819]
385
+ - Updated dependencies [db64cbe]
386
+ - ai@5.0.0-beta.19
387
+
388
+ ## 1.0.0-beta.18
389
+
390
+ ### Patch Changes
391
+
392
+ - Updated dependencies [d3960e3]
393
+ - Updated dependencies [9338f3e]
394
+ - ai@5.0.0-beta.18
395
+
396
+ ## 1.0.0-beta.17
397
+
398
+ ### Patch Changes
399
+
400
+ - ai@5.0.0-beta.17
401
+
402
+ ## 1.0.0-beta.16
403
+
404
+ ### Patch Changes
405
+
406
+ - ai@5.0.0-beta.16
407
+
408
+ ## 1.0.0-beta.15
409
+
410
+ ### Patch Changes
411
+
412
+ - Updated dependencies [8e31d46]
413
+ - ai@5.0.0-beta.15
414
+
415
+ ## 1.0.0-beta.14
416
+
417
+ ### Patch Changes
418
+
419
+ - ai@5.0.0-beta.14
420
+
421
+ ## 1.0.0-beta.13
422
+
423
+ ### Patch Changes
424
+
425
+ - Updated dependencies [377bbcf]
426
+ - Updated dependencies [ce1d1f3]
427
+ - Updated dependencies [c040e2f]
428
+ - Updated dependencies [c808e4d]
429
+ - ai@5.0.0-beta.13
430
+
431
+ ## 1.0.0-beta.12
432
+
433
+ ### Patch Changes
434
+
435
+ - Updated dependencies [fc0380b]
436
+ - Updated dependencies [51f497d]
437
+ - Updated dependencies [4f3776c]
438
+ - ai@5.0.0-beta.12
439
+
440
+ ## 1.0.0-beta.11
441
+
442
+ ### Patch Changes
443
+
444
+ - Updated dependencies [9e40cbe]
445
+ - ai@5.0.0-beta.11
446
+
447
+ ## 1.0.0-beta.10
448
+
449
+ ### Patch Changes
450
+
451
+ - Updated dependencies [16ccfb2]
452
+ - Updated dependencies [90ca2b9]
453
+ - Updated dependencies [af1d5a5]
454
+ - Updated dependencies [2b637d6]
455
+ - ai@5.0.0-beta.10
456
+
457
+ ## 1.0.0-beta.9
458
+
459
+ ### Patch Changes
460
+
461
+ - Updated dependencies [86cfc72]
462
+ - ai@5.0.0-beta.9
463
+
464
+ ## 1.0.0-beta.8
465
+
466
+ ### Patch Changes
467
+
468
+ - Updated dependencies [6909543]
469
+ - Updated dependencies [c8fce91]
470
+ - Updated dependencies [9121250]
471
+ - ai@5.0.0-beta.8
472
+
473
+ ## 1.0.0-beta.7
474
+
475
+ ### Patch Changes
476
+
477
+ - Updated dependencies [60132dd]
478
+ - ai@5.0.0-beta.7
479
+
480
+ ## 1.0.0-beta.6
481
+
482
+ ### Patch Changes
483
+
484
+ - Updated dependencies [143c55b]
485
+ - Updated dependencies [f04ffe4]
486
+ - Updated dependencies [97c35c0]
487
+ - Updated dependencies [fccf75c]
488
+ - ai@5.0.0-beta.6
489
+
490
+ ## 1.0.0-beta.5
491
+
492
+ ### Patch Changes
493
+
494
+ - Updated dependencies [4f3e637]
495
+ - ai@5.0.0-beta.5
496
+
497
+ ## 1.0.0-beta.4
498
+
499
+ ### Patch Changes
500
+
501
+ - Updated dependencies [09f41ac]
502
+ - ai@5.0.0-beta.4
503
+
504
+ ## 1.0.0-beta.3
505
+
506
+ ### Patch Changes
507
+
508
+ - ai@5.0.0-beta.3
509
+
510
+ ## 1.0.0-beta.2
511
+
512
+ ### Patch Changes
513
+
514
+ - Updated dependencies [0d9583c]
515
+ - Updated dependencies [c6b64a7]
516
+ - Updated dependencies [cb3b9c9]
517
+ - Updated dependencies [d1a034f]
518
+ - ai@5.0.0-beta.2
519
+
520
+ ## 1.0.0-beta.1
521
+
522
+ ### Patch Changes
523
+
524
+ - Updated dependencies [d88455d]
525
+ - Updated dependencies [9ad0484]
526
+ - Updated dependencies [4048ce3]
527
+ - Updated dependencies [f2b041e]
528
+ - Updated dependencies [cb68df0]
529
+ - Updated dependencies [26695a3]
530
+ - Updated dependencies [e7d2ce3]
531
+ - Updated dependencies [102b066]
532
+ - Updated dependencies [e862b5b]
533
+ - Updated dependencies [7bd025b]
534
+ - ai@5.0.0-beta.1
535
+
536
+ ## 1.0.0-alpha.15
537
+
538
+ ### Patch Changes
539
+
540
+ - Updated dependencies [b1e3abd]
541
+ - Updated dependencies [04d5063]
542
+ - Updated dependencies [b4b4bb2]
543
+ - Updated dependencies [d884051]
544
+ - Updated dependencies [954aa73]
545
+ - Updated dependencies [142576e]
546
+ - Updated dependencies [395c85e]
547
+ - Updated dependencies [60e2c56]
548
+ - ai@5.0.0-alpha.15
549
+
550
+ ## 1.0.0-alpha.14
551
+
552
+ ### Patch Changes
553
+
554
+ - Updated dependencies [63f9e9b]
555
+ - ai@5.0.0-alpha.14
556
+
557
+ ## 1.0.0-alpha.13
558
+
559
+ ### Patch Changes
560
+
561
+ - Updated dependencies [0a710d8]
562
+ - Updated dependencies [6a83f7d]
563
+ - Updated dependencies [1f55c21]
564
+ - Updated dependencies [33eb499]
565
+ - Updated dependencies [901df02]
566
+ - ai@5.0.0-alpha.13
567
+
568
+ ## 1.0.0-alpha.12
569
+
570
+ ### Patch Changes
571
+
572
+ - Updated dependencies [da1e6f0]
573
+ - Updated dependencies [4892798]
574
+ - ai@5.0.0-alpha.12
575
+
576
+ ## 1.0.0-alpha.11
577
+
578
+ ### Patch Changes
579
+
580
+ - Updated dependencies [e8324c5]
581
+ - ai@5.0.0-alpha.11
582
+
583
+ ## 1.0.0-alpha.10
584
+
585
+ ### Patch Changes
586
+
587
+ - Updated dependencies [98f25e5]
588
+ - Updated dependencies [7bb58d4]
589
+ - ai@5.0.0-alpha.10
590
+
591
+ ## 1.0.0-alpha.9
592
+
593
+ ### Patch Changes
594
+
595
+ - Updated dependencies [8255639]
596
+ - Updated dependencies [9ae327d]
597
+ - ai@5.0.0-alpha.9
598
+
599
+ ## 1.0.0-alpha.8
600
+
601
+ ### Patch Changes
602
+
603
+ - Updated dependencies [4fef487]
604
+ - Updated dependencies [6b1c55c]
605
+ - Updated dependencies [2e4f9e4]
606
+ - Updated dependencies [c25cbce]
607
+ - ai@5.0.0-alpha.8
608
+
609
+ ## 1.0.0-alpha.7
610
+
611
+ ### Patch Changes
612
+
613
+ - Updated dependencies [db345da]
614
+ - Updated dependencies [9b0da33]
615
+ - Updated dependencies [247ee0c]
616
+ - ai@5.0.0-alpha.7
617
+
618
+ ## 1.0.0-alpha.6
619
+
620
+ ### Patch Changes
621
+
622
+ - Updated dependencies [0d2c085]
623
+ - Updated dependencies [48a7606]
624
+ - ai@5.0.0-alpha.6
625
+
626
+ ## 1.0.0-alpha.5
627
+
628
+ ### Patch Changes
629
+
630
+ - Updated dependencies [655cf3c]
631
+ - Updated dependencies [1675396]
632
+ - Updated dependencies [cf9af6e]
633
+ - Updated dependencies [ef256ed]
634
+ - Updated dependencies [1ed0287]
635
+ - Updated dependencies [825e8d7]
636
+ - Updated dependencies [7324c21]
637
+ - ai@5.0.0-alpha.5
638
+
639
+ ## 1.0.0-alpha.4
640
+
641
+ ### Patch Changes
642
+
643
+ - Updated dependencies [b32c141]
644
+ - Updated dependencies [72d7d72]
645
+ - Updated dependencies [9315076]
646
+ - Updated dependencies [7d97ab6]
647
+ - Updated dependencies [37a916d]
648
+ - Updated dependencies [5f2b3d4]
649
+ - ai@5.0.0-alpha.4
650
+
651
+ ## 1.0.0-alpha.3
652
+
653
+ ### Patch Changes
654
+
655
+ - Updated dependencies [ab7ccef]
656
+ - Updated dependencies [257224b]
657
+ - Updated dependencies [0463011]
658
+ - Updated dependencies [d306260]
659
+ - ai@5.0.0-alpha.3
660
+
661
+ ## 1.0.0-alpha.2
662
+
663
+ ### Patch Changes
664
+
665
+ - Updated dependencies [82aa95d]
666
+ - ai@5.0.0-alpha.2
667
+
668
+ ## 1.0.0-alpha.1
669
+
670
+ ### Patch Changes
671
+
672
+ - Updated dependencies [b346545]
673
+ - Updated dependencies [109c0ac]
674
+ - ai@5.0.0-alpha.1
675
+
676
+ ## 1.0.0-canary.12
677
+
678
+ ### Patch Changes
679
+
680
+ - Updated dependencies [bedb239]
681
+ - Updated dependencies [507ac1d]
682
+ - Updated dependencies [2b9bbcd]
683
+ - Updated dependencies [f7e8bf4]
684
+ - Updated dependencies [cda32ba]
685
+ - Updated dependencies [50f0362]
686
+ - Updated dependencies [ed675de]
687
+ - Updated dependencies [64f6d64]
688
+ - ai@5.0.0-canary.24
689
+
690
+ ## 1.0.0-canary.11
691
+
692
+ ### Patch Changes
693
+
694
+ - Updated dependencies [40acf9b]
695
+ - ai@5.0.0-canary.23
696
+
697
+ ## 1.0.0-canary.10
698
+
699
+ ### Patch Changes
700
+
701
+ - Updated dependencies [e7dc6c7]
702
+ - Updated dependencies [a34eb39]
703
+ - Updated dependencies [b33ed7a]
704
+ - Updated dependencies [765f1cd]
705
+ - ai@5.0.0-canary.22
706
+
3
707
  ## 1.0.0-canary.9
4
708
 
5
709
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { UIMessageChunk } from 'ai';
2
+
1
3
  /**
2
4
  * Configuration options and helper callback methods for stream lifecycle events.
3
5
  */
@@ -44,89 +46,6 @@ The following streams are supported:
44
46
  - `LangChainAIMessageChunk` streams (LangChain `model.stream` output)
45
47
  - `string` streams (LangChain `StringOutputParser` output)
46
48
  */
47
- declare function toDataStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: StreamCallbacks): ReadableStream<{
48
- type: "text";
49
- value: string;
50
- } | {
51
- type: "error";
52
- value: string;
53
- } | {
54
- type: "tool-call";
55
- value: {
56
- toolCallId: string;
57
- toolName: string;
58
- args?: unknown;
59
- };
60
- } | {
61
- type: "tool-result";
62
- value: {
63
- toolCallId: string;
64
- result?: unknown;
65
- providerMetadata?: any;
66
- };
67
- } | {
68
- type: "tool-call-streaming-start";
69
- value: {
70
- toolCallId: string;
71
- toolName: string;
72
- };
73
- } | {
74
- type: "tool-call-delta";
75
- value: {
76
- toolCallId: string;
77
- argsTextDelta: string;
78
- };
79
- } | {
80
- type: "reasoning";
81
- value: {
82
- text: string;
83
- providerMetadata?: Record<string, any> | undefined;
84
- };
85
- } | {
86
- type: "source";
87
- value: {
88
- type: "source";
89
- sourceType: "url";
90
- url: string;
91
- id: string;
92
- providerMetadata?: any;
93
- title?: string | undefined;
94
- };
95
- } | {
96
- type: "file";
97
- value: {
98
- url: string;
99
- mediaType: string;
100
- };
101
- } | {
102
- type: "metadata";
103
- value: {
104
- metadata?: unknown;
105
- };
106
- } | {
107
- type: "start-step";
108
- value: {
109
- metadata?: unknown;
110
- };
111
- } | {
112
- type: "finish-step";
113
- value: {
114
- metadata?: unknown;
115
- };
116
- } | {
117
- type: "start";
118
- value: {
119
- metadata?: unknown;
120
- messageId?: string | undefined;
121
- };
122
- } | {
123
- type: "finish";
124
- value: {
125
- metadata?: unknown;
126
- };
127
- } | {
128
- type: "reasoning-part-finish";
129
- value: null;
130
- }>;
49
+ declare function toUIMessageStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: StreamCallbacks): ReadableStream<UIMessageChunk>;
131
50
 
132
- export { toDataStream };
51
+ export { toUIMessageStream };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { UIMessageChunk } from 'ai';
2
+
1
3
  /**
2
4
  * Configuration options and helper callback methods for stream lifecycle events.
3
5
  */
@@ -44,89 +46,6 @@ The following streams are supported:
44
46
  - `LangChainAIMessageChunk` streams (LangChain `model.stream` output)
45
47
  - `string` streams (LangChain `StringOutputParser` output)
46
48
  */
47
- declare function toDataStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: StreamCallbacks): ReadableStream<{
48
- type: "text";
49
- value: string;
50
- } | {
51
- type: "error";
52
- value: string;
53
- } | {
54
- type: "tool-call";
55
- value: {
56
- toolCallId: string;
57
- toolName: string;
58
- args?: unknown;
59
- };
60
- } | {
61
- type: "tool-result";
62
- value: {
63
- toolCallId: string;
64
- result?: unknown;
65
- providerMetadata?: any;
66
- };
67
- } | {
68
- type: "tool-call-streaming-start";
69
- value: {
70
- toolCallId: string;
71
- toolName: string;
72
- };
73
- } | {
74
- type: "tool-call-delta";
75
- value: {
76
- toolCallId: string;
77
- argsTextDelta: string;
78
- };
79
- } | {
80
- type: "reasoning";
81
- value: {
82
- text: string;
83
- providerMetadata?: Record<string, any> | undefined;
84
- };
85
- } | {
86
- type: "source";
87
- value: {
88
- type: "source";
89
- sourceType: "url";
90
- url: string;
91
- id: string;
92
- providerMetadata?: any;
93
- title?: string | undefined;
94
- };
95
- } | {
96
- type: "file";
97
- value: {
98
- url: string;
99
- mediaType: string;
100
- };
101
- } | {
102
- type: "metadata";
103
- value: {
104
- metadata?: unknown;
105
- };
106
- } | {
107
- type: "start-step";
108
- value: {
109
- metadata?: unknown;
110
- };
111
- } | {
112
- type: "finish-step";
113
- value: {
114
- metadata?: unknown;
115
- };
116
- } | {
117
- type: "start";
118
- value: {
119
- metadata?: unknown;
120
- messageId?: string | undefined;
121
- };
122
- } | {
123
- type: "finish";
124
- value: {
125
- metadata?: unknown;
126
- };
127
- } | {
128
- type: "reasoning-part-finish";
129
- value: null;
130
- }>;
49
+ declare function toUIMessageStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: StreamCallbacks): ReadableStream<UIMessageChunk>;
131
50
 
132
- export { toDataStream };
51
+ export { toUIMessageStream };
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- toDataStream: () => toDataStream
23
+ toUIMessageStream: () => toUIMessageStream
24
24
  });
25
25
  module.exports = __toCommonJS(src_exports);
26
26
 
@@ -48,7 +48,7 @@ function createCallbacksTransformer(callbacks = {}) {
48
48
  }
49
49
 
50
50
  // src/langchain-adapter.ts
51
- function toDataStream(stream, callbacks) {
51
+ function toUIMessageStream(stream, callbacks) {
52
52
  return stream.pipeThrough(
53
53
  new TransformStream({
54
54
  transform: async (value, controller) => {
@@ -71,8 +71,14 @@ function toDataStream(stream, callbacks) {
71
71
  })
72
72
  ).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(
73
73
  new TransformStream({
74
+ start: async (controller) => {
75
+ controller.enqueue({ type: "text-start", id: "1" });
76
+ },
74
77
  transform: async (chunk, controller) => {
75
- controller.enqueue({ type: "text", value: chunk });
78
+ controller.enqueue({ type: "text-delta", delta: chunk, id: "1" });
79
+ },
80
+ flush: async (controller) => {
81
+ controller.enqueue({ type: "text-end", id: "1" });
76
82
  }
77
83
  })
78
84
  );
@@ -91,6 +97,6 @@ function forwardAIMessageChunk(chunk, controller) {
91
97
  }
92
98
  // Annotate the CommonJS export names for ESM import in node:
93
99
  0 && (module.exports = {
94
- toDataStream
100
+ toUIMessageStream
95
101
  });
96
102
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/stream-callbacks.ts","../src/langchain-adapter.ts"],"sourcesContent":["export * from './langchain-adapter';\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","import { DataStreamPart } from 'ai';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype LangChainImageDetail = 'auto' | 'low' | 'high';\n\ntype LangChainMessageContentText = {\n type: 'text';\n text: string;\n};\n\ntype LangChainMessageContentImageUrl = {\n type: 'image_url';\n image_url:\n | string\n | {\n url: string;\n detail?: LangChainImageDetail;\n };\n};\n\ntype LangChainMessageContentComplex =\n | LangChainMessageContentText\n | LangChainMessageContentImageUrl\n | (Record<string, any> & {\n type?: 'text' | 'image_url' | string;\n })\n | (Record<string, any> & {\n type?: never;\n });\n\ntype LangChainMessageContent = string | LangChainMessageContentComplex[];\n\ntype LangChainAIMessageChunk = {\n content: LangChainMessageContent;\n};\n\n// LC stream event v2\ntype LangChainStreamEvent = {\n event: string;\n data: any;\n};\n\n/**\nConverts LangChain output streams to an AI SDK Data Stream.\n\nThe following streams are supported:\n- `LangChainAIMessageChunk` streams (LangChain `model.stream` output)\n- `string` streams (LangChain `StringOutputParser` output)\n */\nexport function toDataStream(\n stream:\n | ReadableStream<LangChainStreamEvent>\n | ReadableStream<LangChainAIMessageChunk>\n | ReadableStream<string>,\n callbacks?: StreamCallbacks,\n) {\n return stream\n .pipeThrough(\n new TransformStream<\n LangChainStreamEvent | LangChainAIMessageChunk | string\n >({\n transform: async (value, controller) => {\n // text stream:\n if (typeof value === 'string') {\n controller.enqueue(value);\n return;\n }\n\n // LC stream events v2:\n if ('event' in value) {\n // chunk is AIMessage Chunk for on_chat_model_stream event:\n if (value.event === 'on_chat_model_stream') {\n forwardAIMessageChunk(\n value.data?.chunk as LangChainAIMessageChunk,\n controller,\n );\n }\n return;\n }\n\n // AI Message chunk stream:\n forwardAIMessageChunk(value, controller);\n },\n }),\n )\n .pipeThrough(createCallbacksTransformer(callbacks))\n .pipeThrough(\n new TransformStream<string, DataStreamPart>({\n transform: async (chunk, controller) => {\n controller.enqueue({ type: 'text', value: chunk });\n },\n }),\n );\n}\n\nfunction forwardAIMessageChunk(\n chunk: LangChainAIMessageChunk,\n controller: TransformStreamDefaultController<any>,\n) {\n if (typeof chunk.content === 'string') {\n controller.enqueue(chunk.content);\n } else {\n const content: LangChainMessageContentComplex[] = chunk.content;\n for (const item of content) {\n if (item.type === 'text') {\n controller.enqueue(item.text);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqCO,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;;;ACZO,SAAS,aACd,QAIA,WACA;AACA,SAAO,OACJ;AAAA,IACC,IAAI,gBAEF;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AAhEhD;AAkEU,YAAI,OAAO,UAAU,UAAU;AAC7B,qBAAW,QAAQ,KAAK;AACxB;AAAA,QACF;AAGA,YAAI,WAAW,OAAO;AAEpB,cAAI,MAAM,UAAU,wBAAwB;AAC1C;AAAA,eACE,WAAM,SAAN,mBAAY;AAAA,cACZ;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAGA,8BAAsB,OAAO,UAAU;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH,EACC,YAAY,2BAA2B,SAAS,CAAC,EACjD;AAAA,IACC,IAAI,gBAAwC;AAAA,MAC1C,WAAW,OAAO,OAAO,eAAe;AACtC,mBAAW,QAAQ,EAAE,MAAM,QAAQ,OAAO,MAAM,CAAC;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AACJ;AAEA,SAAS,sBACP,OACA,YACA;AACA,MAAI,OAAO,MAAM,YAAY,UAAU;AACrC,eAAW,QAAQ,MAAM,OAAO;AAAA,EAClC,OAAO;AACL,UAAM,UAA4C,MAAM;AACxD,eAAW,QAAQ,SAAS;AAC1B,UAAI,KAAK,SAAS,QAAQ;AACxB,mBAAW,QAAQ,KAAK,IAAI;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/stream-callbacks.ts","../src/langchain-adapter.ts"],"sourcesContent":["export * from './langchain-adapter';\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","import { UIMessageChunk } from 'ai';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype LangChainImageDetail = 'auto' | 'low' | 'high';\n\ntype LangChainMessageContentText = {\n type: 'text';\n text: string;\n};\n\ntype LangChainMessageContentImageUrl = {\n type: 'image_url';\n image_url:\n | string\n | {\n url: string;\n detail?: LangChainImageDetail;\n };\n};\n\ntype LangChainMessageContentComplex =\n | LangChainMessageContentText\n | LangChainMessageContentImageUrl\n | (Record<string, any> & {\n type?: 'text' | 'image_url' | string;\n })\n | (Record<string, any> & {\n type?: never;\n });\n\ntype LangChainMessageContent = string | LangChainMessageContentComplex[];\n\ntype LangChainAIMessageChunk = {\n content: LangChainMessageContent;\n};\n\n// LC stream event v2\ntype LangChainStreamEvent = {\n event: string;\n data: any;\n};\n\n/**\nConverts LangChain output streams to an AI SDK Data Stream.\n\nThe following streams are supported:\n- `LangChainAIMessageChunk` streams (LangChain `model.stream` output)\n- `string` streams (LangChain `StringOutputParser` output)\n */\nexport function toUIMessageStream(\n stream:\n | ReadableStream<LangChainStreamEvent>\n | ReadableStream<LangChainAIMessageChunk>\n | ReadableStream<string>,\n callbacks?: StreamCallbacks,\n) {\n return stream\n .pipeThrough(\n new TransformStream<\n LangChainStreamEvent | LangChainAIMessageChunk | string\n >({\n transform: async (value, controller) => {\n // text stream:\n if (typeof value === 'string') {\n controller.enqueue(value);\n return;\n }\n\n // LC stream events v2:\n if ('event' in value) {\n // chunk is AIMessage Chunk for on_chat_model_stream event:\n if (value.event === 'on_chat_model_stream') {\n forwardAIMessageChunk(\n value.data?.chunk as LangChainAIMessageChunk,\n controller,\n );\n }\n return;\n }\n\n // AI Message chunk stream:\n forwardAIMessageChunk(value, controller);\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 forwardAIMessageChunk(\n chunk: LangChainAIMessageChunk,\n controller: TransformStreamDefaultController<any>,\n) {\n if (typeof chunk.content === 'string') {\n controller.enqueue(chunk.content);\n } else {\n const content: LangChainMessageContentComplex[] = chunk.content;\n for (const item of content) {\n if (item.type === 'text') {\n controller.enqueue(item.text);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqCO,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;;;ACZO,SAAS,kBACd,QAIA,WACA;AACA,SAAO,OACJ;AAAA,IACC,IAAI,gBAEF;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AAhEhD;AAkEU,YAAI,OAAO,UAAU,UAAU;AAC7B,qBAAW,QAAQ,KAAK;AACxB;AAAA,QACF;AAGA,YAAI,WAAW,OAAO;AAEpB,cAAI,MAAM,UAAU,wBAAwB;AAC1C;AAAA,eACE,WAAM,SAAN,mBAAY;AAAA,cACZ;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAGA,8BAAsB,OAAO,UAAU;AAAA,MACzC;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,sBACP,OACA,YACA;AACA,MAAI,OAAO,MAAM,YAAY,UAAU;AACrC,eAAW,QAAQ,MAAM,OAAO;AAAA,EAClC,OAAO;AACL,UAAM,UAA4C,MAAM;AACxD,eAAW,QAAQ,SAAS;AAC1B,UAAI,KAAK,SAAS,QAAQ;AACxB,mBAAW,QAAQ,KAAK,IAAI;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/dist/index.mjs CHANGED
@@ -22,7 +22,7 @@ function createCallbacksTransformer(callbacks = {}) {
22
22
  }
23
23
 
24
24
  // src/langchain-adapter.ts
25
- function toDataStream(stream, callbacks) {
25
+ function toUIMessageStream(stream, callbacks) {
26
26
  return stream.pipeThrough(
27
27
  new TransformStream({
28
28
  transform: async (value, controller) => {
@@ -45,8 +45,14 @@ function toDataStream(stream, callbacks) {
45
45
  })
46
46
  ).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(
47
47
  new TransformStream({
48
+ start: async (controller) => {
49
+ controller.enqueue({ type: "text-start", id: "1" });
50
+ },
48
51
  transform: async (chunk, controller) => {
49
- controller.enqueue({ type: "text", value: chunk });
52
+ controller.enqueue({ type: "text-delta", delta: chunk, id: "1" });
53
+ },
54
+ flush: async (controller) => {
55
+ controller.enqueue({ type: "text-end", id: "1" });
50
56
  }
51
57
  })
52
58
  );
@@ -64,6 +70,6 @@ function forwardAIMessageChunk(chunk, controller) {
64
70
  }
65
71
  }
66
72
  export {
67
- toDataStream
73
+ toUIMessageStream
68
74
  };
69
75
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/stream-callbacks.ts","../src/langchain-adapter.ts"],"sourcesContent":["/**\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","import { DataStreamPart } from 'ai';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype LangChainImageDetail = 'auto' | 'low' | 'high';\n\ntype LangChainMessageContentText = {\n type: 'text';\n text: string;\n};\n\ntype LangChainMessageContentImageUrl = {\n type: 'image_url';\n image_url:\n | string\n | {\n url: string;\n detail?: LangChainImageDetail;\n };\n};\n\ntype LangChainMessageContentComplex =\n | LangChainMessageContentText\n | LangChainMessageContentImageUrl\n | (Record<string, any> & {\n type?: 'text' | 'image_url' | string;\n })\n | (Record<string, any> & {\n type?: never;\n });\n\ntype LangChainMessageContent = string | LangChainMessageContentComplex[];\n\ntype LangChainAIMessageChunk = {\n content: LangChainMessageContent;\n};\n\n// LC stream event v2\ntype LangChainStreamEvent = {\n event: string;\n data: any;\n};\n\n/**\nConverts LangChain output streams to an AI SDK Data Stream.\n\nThe following streams are supported:\n- `LangChainAIMessageChunk` streams (LangChain `model.stream` output)\n- `string` streams (LangChain `StringOutputParser` output)\n */\nexport function toDataStream(\n stream:\n | ReadableStream<LangChainStreamEvent>\n | ReadableStream<LangChainAIMessageChunk>\n | ReadableStream<string>,\n callbacks?: StreamCallbacks,\n) {\n return stream\n .pipeThrough(\n new TransformStream<\n LangChainStreamEvent | LangChainAIMessageChunk | string\n >({\n transform: async (value, controller) => {\n // text stream:\n if (typeof value === 'string') {\n controller.enqueue(value);\n return;\n }\n\n // LC stream events v2:\n if ('event' in value) {\n // chunk is AIMessage Chunk for on_chat_model_stream event:\n if (value.event === 'on_chat_model_stream') {\n forwardAIMessageChunk(\n value.data?.chunk as LangChainAIMessageChunk,\n controller,\n );\n }\n return;\n }\n\n // AI Message chunk stream:\n forwardAIMessageChunk(value, controller);\n },\n }),\n )\n .pipeThrough(createCallbacksTransformer(callbacks))\n .pipeThrough(\n new TransformStream<string, DataStreamPart>({\n transform: async (chunk, controller) => {\n controller.enqueue({ type: 'text', value: chunk });\n },\n }),\n );\n}\n\nfunction forwardAIMessageChunk(\n chunk: LangChainAIMessageChunk,\n controller: TransformStreamDefaultController<any>,\n) {\n if (typeof chunk.content === 'string') {\n controller.enqueue(chunk.content);\n } else {\n const content: LangChainMessageContentComplex[] = chunk.content;\n for (const item of content) {\n if (item.type === 'text') {\n controller.enqueue(item.text);\n }\n }\n }\n}\n"],"mappings":";AAqCO,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;;;ACZO,SAAS,aACd,QAIA,WACA;AACA,SAAO,OACJ;AAAA,IACC,IAAI,gBAEF;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AAhEhD;AAkEU,YAAI,OAAO,UAAU,UAAU;AAC7B,qBAAW,QAAQ,KAAK;AACxB;AAAA,QACF;AAGA,YAAI,WAAW,OAAO;AAEpB,cAAI,MAAM,UAAU,wBAAwB;AAC1C;AAAA,eACE,WAAM,SAAN,mBAAY;AAAA,cACZ;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAGA,8BAAsB,OAAO,UAAU;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH,EACC,YAAY,2BAA2B,SAAS,CAAC,EACjD;AAAA,IACC,IAAI,gBAAwC;AAAA,MAC1C,WAAW,OAAO,OAAO,eAAe;AACtC,mBAAW,QAAQ,EAAE,MAAM,QAAQ,OAAO,MAAM,CAAC;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AACJ;AAEA,SAAS,sBACP,OACA,YACA;AACA,MAAI,OAAO,MAAM,YAAY,UAAU;AACrC,eAAW,QAAQ,MAAM,OAAO;AAAA,EAClC,OAAO;AACL,UAAM,UAA4C,MAAM;AACxD,eAAW,QAAQ,SAAS;AAC1B,UAAI,KAAK,SAAS,QAAQ;AACxB,mBAAW,QAAQ,KAAK,IAAI;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/stream-callbacks.ts","../src/langchain-adapter.ts"],"sourcesContent":["/**\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","import { UIMessageChunk } from 'ai';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype LangChainImageDetail = 'auto' | 'low' | 'high';\n\ntype LangChainMessageContentText = {\n type: 'text';\n text: string;\n};\n\ntype LangChainMessageContentImageUrl = {\n type: 'image_url';\n image_url:\n | string\n | {\n url: string;\n detail?: LangChainImageDetail;\n };\n};\n\ntype LangChainMessageContentComplex =\n | LangChainMessageContentText\n | LangChainMessageContentImageUrl\n | (Record<string, any> & {\n type?: 'text' | 'image_url' | string;\n })\n | (Record<string, any> & {\n type?: never;\n });\n\ntype LangChainMessageContent = string | LangChainMessageContentComplex[];\n\ntype LangChainAIMessageChunk = {\n content: LangChainMessageContent;\n};\n\n// LC stream event v2\ntype LangChainStreamEvent = {\n event: string;\n data: any;\n};\n\n/**\nConverts LangChain output streams to an AI SDK Data Stream.\n\nThe following streams are supported:\n- `LangChainAIMessageChunk` streams (LangChain `model.stream` output)\n- `string` streams (LangChain `StringOutputParser` output)\n */\nexport function toUIMessageStream(\n stream:\n | ReadableStream<LangChainStreamEvent>\n | ReadableStream<LangChainAIMessageChunk>\n | ReadableStream<string>,\n callbacks?: StreamCallbacks,\n) {\n return stream\n .pipeThrough(\n new TransformStream<\n LangChainStreamEvent | LangChainAIMessageChunk | string\n >({\n transform: async (value, controller) => {\n // text stream:\n if (typeof value === 'string') {\n controller.enqueue(value);\n return;\n }\n\n // LC stream events v2:\n if ('event' in value) {\n // chunk is AIMessage Chunk for on_chat_model_stream event:\n if (value.event === 'on_chat_model_stream') {\n forwardAIMessageChunk(\n value.data?.chunk as LangChainAIMessageChunk,\n controller,\n );\n }\n return;\n }\n\n // AI Message chunk stream:\n forwardAIMessageChunk(value, controller);\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 forwardAIMessageChunk(\n chunk: LangChainAIMessageChunk,\n controller: TransformStreamDefaultController<any>,\n) {\n if (typeof chunk.content === 'string') {\n controller.enqueue(chunk.content);\n } else {\n const content: LangChainMessageContentComplex[] = chunk.content;\n for (const item of content) {\n if (item.type === 'text') {\n controller.enqueue(item.text);\n }\n }\n }\n}\n"],"mappings":";AAqCO,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;;;ACZO,SAAS,kBACd,QAIA,WACA;AACA,SAAO,OACJ;AAAA,IACC,IAAI,gBAEF;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AAhEhD;AAkEU,YAAI,OAAO,UAAU,UAAU;AAC7B,qBAAW,QAAQ,KAAK;AACxB;AAAA,QACF;AAGA,YAAI,WAAW,OAAO;AAEpB,cAAI,MAAM,UAAU,wBAAwB;AAC1C;AAAA,eACE,WAAM,SAAN,mBAAY;AAAA,cACZ;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAGA,8BAAsB,OAAO,UAAU;AAAA,MACzC;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,sBACP,OACA,YACA;AACA,MAAI,OAAO,MAAM,YAAY,UAAU;AACrC,eAAW,QAAQ,MAAM,OAAO;AAAA,EAClC,OAAO;AACL,UAAM,UAA4C,MAAM;AACxD,eAAW,QAAQ,SAAS;AAC1B,UAAI,KAAK,SAAS,QAAQ;AACxB,mBAAW,QAAQ,KAAK,IAAI;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/langchain",
3
- "version": "1.0.0-canary.9",
3
+ "version": "1.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "ai": "5.0.0-canary.21"
22
+ "ai": "5.0.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "20.17.24",