ai 3.3.40 → 3.3.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5335,6 +5335,48 @@ function forwardAIMessageChunk(chunk, controller) {
5335
5335
  }
5336
5336
  }
5337
5337
 
5338
+ // streams/llamaindex-adapter.ts
5339
+ var llamaindex_adapter_exports = {};
5340
+ __export(llamaindex_adapter_exports, {
5341
+ toDataStream: () => toDataStream2,
5342
+ toDataStreamResponse: () => toDataStreamResponse2
5343
+ });
5344
+ function toDataStream2(stream, callbacks) {
5345
+ return toReadableStream(stream).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(createStreamDataTransformer());
5346
+ }
5347
+ function toDataStreamResponse2(stream, options = {}) {
5348
+ var _a11;
5349
+ const { init, data, callbacks } = options;
5350
+ const dataStream = toDataStream2(stream, callbacks);
5351
+ const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
5352
+ return new Response(responseStream, {
5353
+ status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
5354
+ statusText: init == null ? void 0 : init.statusText,
5355
+ headers: prepareResponseHeaders(init, {
5356
+ contentType: "text/plain; charset=utf-8",
5357
+ dataStreamVersion: "v1"
5358
+ })
5359
+ });
5360
+ }
5361
+ function toReadableStream(res) {
5362
+ const it = res[Symbol.asyncIterator]();
5363
+ const trimStartOfStream = trimStartOfStreamHelper();
5364
+ return new ReadableStream({
5365
+ async pull(controller) {
5366
+ var _a11;
5367
+ const { value, done } = await it.next();
5368
+ if (done) {
5369
+ controller.close();
5370
+ return;
5371
+ }
5372
+ const text = trimStartOfStream((_a11 = value.delta) != null ? _a11 : "");
5373
+ if (text) {
5374
+ controller.enqueue(text);
5375
+ }
5376
+ }
5377
+ });
5378
+ }
5379
+
5338
5380
  // streams/langchain-stream.ts
5339
5381
  function LangChainStream(callbacks) {
5340
5382
  const stream = new TransformStream();
@@ -5825,6 +5867,7 @@ export {
5825
5867
  JSONParseError,
5826
5868
  langchain_adapter_exports as LangChainAdapter,
5827
5869
  LangChainStream,
5870
+ llamaindex_adapter_exports as LlamaIndexAdapter,
5828
5871
  LoadAPIKeyError,
5829
5872
  MessageConversionError,
5830
5873
  MistralStream,