ai 6.0.272 → 6.0.273
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 +8 -0
- package/dist/index.d.mts +24 -16
- package/dist/index.d.ts +24 -16
- package/dist/index.js +64 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -47
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +7 -0
- package/package.json +2 -2
- package/src/generate-text/index.ts +2 -0
- package/src/generate-text/stream-text.ts +99 -52
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.273" : "0.0.0-test";
|
|
1228
1228
|
|
|
1229
1229
|
// src/util/download/download.ts
|
|
1230
1230
|
var download = async ({
|
|
@@ -7554,40 +7554,51 @@ var DefaultStreamTextResult = class {
|
|
|
7554
7554
|
self._totalUsage.resolve(totalUsage);
|
|
7555
7555
|
self._steps.resolve(recordedSteps);
|
|
7556
7556
|
const finalStep = recordedSteps[recordedSteps.length - 1];
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7557
|
+
const onFinishEvent = {
|
|
7558
|
+
stepNumber: finalStep.stepNumber,
|
|
7559
|
+
model: finalStep.model,
|
|
7560
|
+
functionId: finalStep.functionId,
|
|
7561
|
+
metadata: finalStep.metadata,
|
|
7562
|
+
experimental_context: finalStep.experimental_context,
|
|
7563
|
+
finishReason: finalStep.finishReason,
|
|
7564
|
+
rawFinishReason: finalStep.rawFinishReason,
|
|
7565
|
+
totalUsage,
|
|
7566
|
+
usage: finalStep.usage,
|
|
7567
|
+
content: finalStep.content,
|
|
7568
|
+
text: finalStep.text,
|
|
7569
|
+
reasoningText: finalStep.reasoningText,
|
|
7570
|
+
reasoning: finalStep.reasoning,
|
|
7571
|
+
files: finalStep.files,
|
|
7572
|
+
sources: finalStep.sources,
|
|
7573
|
+
toolCalls: finalStep.toolCalls,
|
|
7574
|
+
staticToolCalls: finalStep.staticToolCalls,
|
|
7575
|
+
dynamicToolCalls: finalStep.dynamicToolCalls,
|
|
7576
|
+
toolResults: finalStep.toolResults,
|
|
7577
|
+
staticToolResults: finalStep.staticToolResults,
|
|
7578
|
+
dynamicToolResults: finalStep.dynamicToolResults,
|
|
7579
|
+
request: finalStep.request,
|
|
7580
|
+
response: finalStep.response,
|
|
7581
|
+
warnings: finalStep.warnings,
|
|
7582
|
+
providerMetadata: finalStep.providerMetadata,
|
|
7583
|
+
steps: recordedSteps
|
|
7584
|
+
};
|
|
7585
|
+
const onFinishWithOutput = onFinish == null ? void 0 : async (event) => {
|
|
7586
|
+
const parsedOutput = output == null ? void 0 : await self.getOutputPromise().catch(() => void 0);
|
|
7587
|
+
await onFinish({
|
|
7588
|
+
...event,
|
|
7589
|
+
...output != null ? { output: parsedOutput } : {}
|
|
7590
|
+
});
|
|
7591
|
+
};
|
|
7592
|
+
await Promise.all([
|
|
7593
|
+
notify({
|
|
7594
|
+
event: onFinishEvent,
|
|
7595
|
+
callbacks: onFinishWithOutput
|
|
7596
|
+
}),
|
|
7597
|
+
notify({
|
|
7598
|
+
event: onFinishEvent,
|
|
7599
|
+
callbacks: globalTelemetry.onFinish
|
|
7600
|
+
})
|
|
7601
|
+
]);
|
|
7591
7602
|
rootSpan.setAttributes(
|
|
7592
7603
|
await selectTelemetryAttributes({
|
|
7593
7604
|
telemetry,
|
|
@@ -8649,19 +8660,25 @@ var DefaultStreamTextResult = class {
|
|
|
8649
8660
|
}
|
|
8650
8661
|
return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
|
|
8651
8662
|
}
|
|
8663
|
+
getOutputPromise() {
|
|
8664
|
+
if (this.outputPromise == null) {
|
|
8665
|
+
this.outputPromise = this.finalStep.then((step) => {
|
|
8666
|
+
var _a23;
|
|
8667
|
+
const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
|
|
8668
|
+
return output.parseCompleteOutput(
|
|
8669
|
+
{ text: step.text },
|
|
8670
|
+
{
|
|
8671
|
+
response: step.response,
|
|
8672
|
+
usage: step.usage,
|
|
8673
|
+
finishReason: step.finishReason
|
|
8674
|
+
}
|
|
8675
|
+
);
|
|
8676
|
+
});
|
|
8677
|
+
}
|
|
8678
|
+
return this.outputPromise;
|
|
8679
|
+
}
|
|
8652
8680
|
get output() {
|
|
8653
|
-
return this.
|
|
8654
|
-
var _a23;
|
|
8655
|
-
const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
|
|
8656
|
-
return output.parseCompleteOutput(
|
|
8657
|
-
{ text: step.text },
|
|
8658
|
-
{
|
|
8659
|
-
response: step.response,
|
|
8660
|
-
usage: step.usage,
|
|
8661
|
-
finishReason: step.finishReason
|
|
8662
|
-
}
|
|
8663
|
-
);
|
|
8664
|
-
});
|
|
8681
|
+
return this.getOutputPromise();
|
|
8665
8682
|
}
|
|
8666
8683
|
toUIMessageStream({
|
|
8667
8684
|
originalMessages,
|