ai 3.1.24 → 3.1.26

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.d.mts CHANGED
@@ -2280,9 +2280,13 @@ type LangChainAIMessageChunk = {
2280
2280
  content: LangChainMessageContent;
2281
2281
  };
2282
2282
  /**
2283
- Converts the result of a LangChain Expression Language stream invocation to an AIStream.
2283
+ Converts LangChain output streams to AIStream.
2284
+
2285
+ The following streams are supported:
2286
+ - `LangChainAIMessageChunk` streams (LangChain `model.stream` output)
2287
+ - `string` streams (LangChain `StringOutputParser` output)
2284
2288
  */
2285
- declare function toAIStream(stream: ReadableStream<LangChainAIMessageChunk>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2289
+ declare function toAIStream(stream: ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2286
2290
 
2287
2291
  declare const langchainAdapter_toAIStream: typeof toAIStream;
2288
2292
  declare namespace langchainAdapter {
package/dist/index.d.ts CHANGED
@@ -2280,9 +2280,13 @@ type LangChainAIMessageChunk = {
2280
2280
  content: LangChainMessageContent;
2281
2281
  };
2282
2282
  /**
2283
- Converts the result of a LangChain Expression Language stream invocation to an AIStream.
2283
+ Converts LangChain output streams to AIStream.
2284
+
2285
+ The following streams are supported:
2286
+ - `LangChainAIMessageChunk` streams (LangChain `model.stream` output)
2287
+ - `string` streams (LangChain `StringOutputParser` output)
2284
2288
  */
2285
- declare function toAIStream(stream: ReadableStream<LangChainAIMessageChunk>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2289
+ declare function toAIStream(stream: ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2286
2290
 
2287
2291
  declare const langchainAdapter_toAIStream: typeof toAIStream;
2288
2292
  declare namespace langchainAdapter {
package/dist/index.js CHANGED
@@ -2830,7 +2830,9 @@ function toAIStream(stream, callbacks) {
2830
2830
  return stream.pipeThrough(
2831
2831
  new TransformStream({
2832
2832
  transform: async (chunk, controller) => {
2833
- if (typeof chunk.content === "string") {
2833
+ if (typeof chunk === "string") {
2834
+ controller.enqueue(chunk);
2835
+ } else if (typeof chunk.content === "string") {
2834
2836
  controller.enqueue(chunk.content);
2835
2837
  } else {
2836
2838
  const content = chunk.content;