ai 3.1.0 → 3.1.2
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 +31 -4
- package/dist/index.d.ts +31 -4
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/rsc/dist/index.d.ts +7 -5
- package/rsc/dist/rsc-server.d.mts +7 -5
- package/rsc/dist/rsc-server.mjs +7 -7
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -1397,12 +1397,25 @@ var StreamTextResult = class {
|
|
1397
1397
|
this.rawResponse = rawResponse;
|
1398
1398
|
}
|
1399
1399
|
/**
|
1400
|
+
Split out a new stream from the original stream.
|
1401
|
+
The original stream is replaced to allow for further splitting,
|
1402
|
+
since we do not know how many times the stream will be split.
|
1403
|
+
|
1404
|
+
Note: this leads to buffering the stream content on the server.
|
1405
|
+
However, the LLM results are expected to be small enough to not cause issues.
|
1406
|
+
*/
|
1407
|
+
teeStream() {
|
1408
|
+
const [stream1, stream2] = this.originalStream.tee();
|
1409
|
+
this.originalStream = stream2;
|
1410
|
+
return stream1;
|
1411
|
+
}
|
1412
|
+
/**
|
1400
1413
|
A text stream that returns only the generated text deltas. You can use it
|
1401
1414
|
as either an AsyncIterable or a ReadableStream. When an error occurs, the
|
1402
1415
|
stream will throw the error.
|
1403
1416
|
*/
|
1404
1417
|
get textStream() {
|
1405
|
-
return createAsyncIterableStream(this.
|
1418
|
+
return createAsyncIterableStream(this.teeStream(), {
|
1406
1419
|
transform(chunk, controller) {
|
1407
1420
|
if (chunk.type === "text-delta") {
|
1408
1421
|
if (chunk.textDelta.length > 0) {
|
@@ -1421,7 +1434,7 @@ var StreamTextResult = class {
|
|
1421
1434
|
stream will throw the error.
|
1422
1435
|
*/
|
1423
1436
|
get fullStream() {
|
1424
|
-
return createAsyncIterableStream(this.
|
1437
|
+
return createAsyncIterableStream(this.teeStream(), {
|
1425
1438
|
transform(chunk, controller) {
|
1426
1439
|
if (chunk.type === "text-delta") {
|
1427
1440
|
if (chunk.textDelta.length > 0) {
|