ai 4.0.25 → 4.0.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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
@@ -2152,10 +2152,13 @@ Details for all steps.
|
|
2152
2152
|
* Smooths text streaming output.
|
2153
2153
|
*
|
2154
2154
|
* @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms.
|
2155
|
+
* @param chunking - Controls how the text is chunked for streaming. Use "word" to stream word by word (default), or "line" to stream line by line.
|
2156
|
+
*
|
2155
2157
|
* @returns A transform stream that smooths text streaming output.
|
2156
2158
|
*/
|
2157
|
-
declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInMs, _internal: { delay }, }?: {
|
2159
|
+
declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInMs, chunking, _internal: { delay }, }?: {
|
2158
2160
|
delayInMs?: number;
|
2161
|
+
chunking?: 'word' | 'line';
|
2159
2162
|
/**
|
2160
2163
|
* Internal. For test use only. May change without notice.
|
2161
2164
|
*/
|
package/dist/index.d.ts
CHANGED
@@ -2152,10 +2152,13 @@ Details for all steps.
|
|
2152
2152
|
* Smooths text streaming output.
|
2153
2153
|
*
|
2154
2154
|
* @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms.
|
2155
|
+
* @param chunking - Controls how the text is chunked for streaming. Use "word" to stream word by word (default), or "line" to stream line by line.
|
2156
|
+
*
|
2155
2157
|
* @returns A transform stream that smooths text streaming output.
|
2156
2158
|
*/
|
2157
|
-
declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInMs, _internal: { delay }, }?: {
|
2159
|
+
declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInMs, chunking, _internal: { delay }, }?: {
|
2158
2160
|
delayInMs?: number;
|
2161
|
+
chunking?: 'word' | 'line';
|
2159
2162
|
/**
|
2160
2163
|
* Internal. For test use only. May change without notice.
|
2161
2164
|
*/
|
package/dist/index.js
CHANGED
@@ -5349,6 +5349,7 @@ var DefaultStreamTextResult = class {
|
|
5349
5349
|
// core/generate-text/smooth-stream.ts
|
5350
5350
|
function smoothStream({
|
5351
5351
|
delayInMs = 10,
|
5352
|
+
chunking = "word",
|
5352
5353
|
_internal: { delay: delay2 = delay } = {}
|
5353
5354
|
} = {}) {
|
5354
5355
|
let buffer = "";
|
@@ -5367,7 +5368,7 @@ function smoothStream({
|
|
5367
5368
|
return;
|
5368
5369
|
}
|
5369
5370
|
buffer += chunk.textDelta;
|
5370
|
-
const regexp = /\s*\S+\s+/m;
|
5371
|
+
const regexp = chunking === "line" ? /[^\n]*\n/m : /\s*\S+\s+/m;
|
5371
5372
|
while (regexp.test(buffer)) {
|
5372
5373
|
const chunk2 = buffer.match(regexp)[0];
|
5373
5374
|
controller.enqueue({ type: "text-delta", textDelta: chunk2 });
|