@mastra/core
Version:
37 lines • 1.34 kB
TypeScript
import { TransformStream } from 'node:stream/web';
import type { ChunkType } from './types.js';
/**
* Detects the next complete chunk at the start of a buffered string.
*
* @experimental This API may change in a future release.
*/
export type SmoothStreamChunkDetector = (buffer: string) => string | null | undefined;
/**
* Options for {@link smoothStream}.
*
* @experimental This API may change in a future release.
*/
export interface SmoothStreamOptions {
/**
* Delay between emitted chunks in milliseconds. Set to `null` to emit chunks
* without a delay.
*
* @default 10
*/
delayInMs?: number | null;
/**
* How buffered text and reasoning are divided into chunks.
*
* @default 'word'
*/
chunking?: 'word' | 'line' | RegExp | SmoothStreamChunkDetector | Intl.Segmenter;
}
/**
* Creates a transform stream that buffers text and reasoning deltas and emits
* them in consistent, delayed chunks. Other stream parts pass through without
* modification after any buffered content has been emitted.
*
* @experimental This API may change in a future release.
*/
export declare function smoothStream<OUTPUT = undefined>({ delayInMs, chunking, }?: SmoothStreamOptions): TransformStream<ChunkType<OUTPUT>, ChunkType<OUTPUT>>;
//# sourceMappingURL=smooth-stream.d.ts.map