ai 4.0.21 → 4.0.23

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,21 @@
1
1
  # ai
2
2
 
3
+ ## 4.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - bc4cd19: feat (ai/core): consolidate whitespace in smooth stream
8
+
9
+ ## 4.0.22
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [5ed5e45]
14
+ - @ai-sdk/provider-utils@2.0.5
15
+ - @ai-sdk/provider@1.0.3
16
+ - @ai-sdk/react@1.0.7
17
+ - @ai-sdk/ui-utils@1.0.6
18
+
3
19
  ## 4.0.21
4
20
 
5
21
  ### Patch Changes
package/dist/index.js CHANGED
@@ -5232,11 +5232,11 @@ function smoothStream({
5232
5232
  return;
5233
5233
  }
5234
5234
  buffer += chunk.textDelta;
5235
- while (buffer.match(/\s/)) {
5236
- const whitespaceIndex = buffer.search(/\s/);
5237
- const word = buffer.slice(0, whitespaceIndex + 1);
5238
- controller.enqueue({ type: "text-delta", textDelta: word });
5239
- buffer = buffer.slice(whitespaceIndex + 1);
5235
+ const regexp = /\s*\S+\s+/m;
5236
+ while (regexp.test(buffer)) {
5237
+ const chunk2 = buffer.match(regexp)[0];
5238
+ controller.enqueue({ type: "text-delta", textDelta: chunk2 });
5239
+ buffer = buffer.slice(chunk2.length);
5240
5240
  if (delayInMs > 0) {
5241
5241
  await delay2(delayInMs);
5242
5242
  }