ai 6.0.274 → 6.0.276
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 +19 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +6 -0
- package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +1 -1
- package/package.json +2 -2
- package/src/generate-text/smooth-stream.ts +19 -4
package/dist/index.mjs
CHANGED
|
@@ -1224,7 +1224,7 @@ import {
|
|
|
1224
1224
|
} from "@ai-sdk/provider-utils";
|
|
1225
1225
|
|
|
1226
1226
|
// src/version.ts
|
|
1227
|
-
var VERSION = true ? "6.0.
|
|
1227
|
+
var VERSION = true ? "6.0.276" : "0.0.0-test";
|
|
1228
1228
|
|
|
1229
1229
|
// src/util/download/download.ts
|
|
1230
1230
|
var download = async ({
|
|
@@ -12486,6 +12486,9 @@ var CHUNKING_REGEXPS = {
|
|
|
12486
12486
|
word: /\S+\s+/m,
|
|
12487
12487
|
line: /\n+/m
|
|
12488
12488
|
};
|
|
12489
|
+
function isDocumentHidden() {
|
|
12490
|
+
return typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
12491
|
+
}
|
|
12489
12492
|
function smoothStream({
|
|
12490
12493
|
delayInMs = 10,
|
|
12491
12494
|
chunking = "word",
|
|
@@ -12539,7 +12542,7 @@ function smoothStream({
|
|
|
12539
12542
|
let type = void 0;
|
|
12540
12543
|
let providerMetadata = void 0;
|
|
12541
12544
|
function flushBuffer(controller) {
|
|
12542
|
-
if (buffer.length > 0
|
|
12545
|
+
if (type !== void 0 && (buffer.length > 0 || providerMetadata != null)) {
|
|
12543
12546
|
controller.enqueue({
|
|
12544
12547
|
type,
|
|
12545
12548
|
text: buffer,
|
|
@@ -12557,7 +12560,7 @@ function smoothStream({
|
|
|
12557
12560
|
controller.enqueue(chunk);
|
|
12558
12561
|
return;
|
|
12559
12562
|
}
|
|
12560
|
-
if ((chunk.type !== type || chunk.id !== id) && buffer.length > 0) {
|
|
12563
|
+
if ((chunk.type !== type || chunk.id !== id) && (buffer.length > 0 || providerMetadata != null)) {
|
|
12561
12564
|
flushBuffer(controller);
|
|
12562
12565
|
}
|
|
12563
12566
|
buffer += chunk.text;
|
|
@@ -12570,7 +12573,7 @@ function smoothStream({
|
|
|
12570
12573
|
while ((match = detectChunk(buffer)) != null) {
|
|
12571
12574
|
controller.enqueue({ type, text: match, id });
|
|
12572
12575
|
buffer = buffer.slice(match.length);
|
|
12573
|
-
await delay(delayInMs);
|
|
12576
|
+
await delay(isDocumentHidden() ? null : delayInMs);
|
|
12574
12577
|
}
|
|
12575
12578
|
}
|
|
12576
12579
|
});
|
|
@@ -13769,7 +13772,7 @@ async function rerank({
|
|
|
13769
13772
|
...assembleOperationName({ operationId: "ai.rerank", telemetry }),
|
|
13770
13773
|
...baseTelemetryAttributes,
|
|
13771
13774
|
"ai.documents": {
|
|
13772
|
-
input: () => documents.map((
|
|
13775
|
+
input: () => documents.map((document2) => JSON.stringify(document2))
|
|
13773
13776
|
}
|
|
13774
13777
|
}
|
|
13775
13778
|
}),
|
|
@@ -13789,7 +13792,7 @@ async function rerank({
|
|
|
13789
13792
|
...baseTelemetryAttributes,
|
|
13790
13793
|
// specific settings that only make sense on the outer level:
|
|
13791
13794
|
"ai.documents": {
|
|
13792
|
-
input: () => documents.map((
|
|
13795
|
+
input: () => documents.map((document2) => JSON.stringify(document2))
|
|
13793
13796
|
}
|
|
13794
13797
|
}
|
|
13795
13798
|
}),
|