ai 6.0.0-beta.86 → 6.0.0-beta.87

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,11 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.0-beta.87
4
+
5
+ ### Patch Changes
6
+
7
+ - ca13d26: feat(ai): add output to StreamTextResult
8
+
3
9
  ## 6.0.0-beta.86
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2381,10 +2381,14 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
2381
2381
  */
2382
2382
  readonly experimental_partialOutputStream: AsyncIterableStream<InferPartialOutput<OUTPUT>>;
2383
2383
  /**
2384
- * A stream of partial outputs. It uses the `output` specification.
2384
+ * A stream of partial parsed outputs. It uses the `output` specification.
2385
2385
  */
2386
2386
  readonly partialOutputStream: AsyncIterableStream<InferPartialOutput<OUTPUT>>;
2387
2387
  /**
2388
+ * The complete parsed output. It uses the `output` specification.
2389
+ */
2390
+ readonly output: Promise<InferCompleteOutput<OUTPUT>>;
2391
+ /**
2388
2392
  Consumes the stream without processing the parts.
2389
2393
  This is useful to force the stream to finish.
2390
2394
  It effectively removes the backpressure and allows the stream to finish,
package/dist/index.d.ts CHANGED
@@ -2381,10 +2381,14 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
2381
2381
  */
2382
2382
  readonly experimental_partialOutputStream: AsyncIterableStream<InferPartialOutput<OUTPUT>>;
2383
2383
  /**
2384
- * A stream of partial outputs. It uses the `output` specification.
2384
+ * A stream of partial parsed outputs. It uses the `output` specification.
2385
2385
  */
2386
2386
  readonly partialOutputStream: AsyncIterableStream<InferPartialOutput<OUTPUT>>;
2387
2387
  /**
2388
+ * The complete parsed output. It uses the `output` specification.
2389
+ */
2390
+ readonly output: Promise<InferCompleteOutput<OUTPUT>>;
2391
+ /**
2388
2392
  Consumes the stream without processing the parts.
2389
2393
  This is useful to force the stream to finish.
2390
2394
  It effectively removes the backpressure and allows the stream to finish,
package/dist/index.js CHANGED
@@ -877,7 +877,7 @@ function detectMediaType({
877
877
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
878
878
 
879
879
  // src/version.ts
880
- var VERSION = true ? "6.0.0-beta.86" : "0.0.0-test";
880
+ var VERSION = true ? "6.0.0-beta.87" : "0.0.0-test";
881
881
 
882
882
  // src/util/download/download.ts
883
883
  var download = async ({ url }) => {
@@ -5131,7 +5131,7 @@ var DefaultStreamTextResult = class {
5131
5131
  this._totalUsage = new DelayedPromise();
5132
5132
  this._finishReason = new DelayedPromise();
5133
5133
  this._steps = new DelayedPromise();
5134
- this.output = output;
5134
+ this.outputSpecification = output;
5135
5135
  this.includeRawChunks = includeRawChunks;
5136
5136
  this.tools = tools;
5137
5137
  let stepFinish;
@@ -6033,7 +6033,7 @@ var DefaultStreamTextResult = class {
6033
6033
  return this.partialOutputStream;
6034
6034
  }
6035
6035
  get partialOutputStream() {
6036
- if (this.output == null) {
6036
+ if (this.outputSpecification == null) {
6037
6037
  throw new NoOutputSpecifiedError();
6038
6038
  }
6039
6039
  return createAsyncIterableStream(
@@ -6048,6 +6048,21 @@ var DefaultStreamTextResult = class {
6048
6048
  )
6049
6049
  );
6050
6050
  }
6051
+ get output() {
6052
+ return this.finalStep.then((step) => {
6053
+ if (this.outputSpecification == null) {
6054
+ throw new NoOutputSpecifiedError();
6055
+ }
6056
+ return this.outputSpecification.parseCompleteOutput(
6057
+ { text: step.text },
6058
+ {
6059
+ response: step.response,
6060
+ usage: step.usage,
6061
+ finishReason: step.finishReason
6062
+ }
6063
+ );
6064
+ });
6065
+ }
6051
6066
  toUIMessageStream({
6052
6067
  originalMessages,
6053
6068
  generateMessageId,