ai 5.1.0-beta.24 → 5.1.0-beta.25
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 +6 -0
- package/dist/index.d.mts +25 -8
- package/dist/index.d.ts +25 -8
- package/dist/index.js +38 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -15
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -716,7 +716,7 @@ import {
|
|
|
716
716
|
} from "@ai-sdk/provider-utils";
|
|
717
717
|
|
|
718
718
|
// src/version.ts
|
|
719
|
-
var VERSION = true ? "5.1.0-beta.
|
|
719
|
+
var VERSION = true ? "5.1.0-beta.25" : "0.0.0-test";
|
|
720
720
|
|
|
721
721
|
// src/util/download/download.ts
|
|
722
722
|
var download = async ({ url }) => {
|
|
@@ -2381,6 +2381,7 @@ async function generateText({
|
|
|
2381
2381
|
currentDate = () => /* @__PURE__ */ new Date()
|
|
2382
2382
|
} = {},
|
|
2383
2383
|
onStepFinish,
|
|
2384
|
+
onFinish,
|
|
2384
2385
|
...settings
|
|
2385
2386
|
}) {
|
|
2386
2387
|
const model = resolveLanguageModel(modelArg);
|
|
@@ -2722,8 +2723,43 @@ async function generateText({
|
|
|
2722
2723
|
})
|
|
2723
2724
|
);
|
|
2724
2725
|
const lastStep = steps[steps.length - 1];
|
|
2726
|
+
const totalUsage = steps.reduce(
|
|
2727
|
+
(totalUsage2, step) => {
|
|
2728
|
+
return addLanguageModelUsage(totalUsage2, step.usage);
|
|
2729
|
+
},
|
|
2730
|
+
{
|
|
2731
|
+
inputTokens: void 0,
|
|
2732
|
+
outputTokens: void 0,
|
|
2733
|
+
totalTokens: void 0,
|
|
2734
|
+
reasoningTokens: void 0,
|
|
2735
|
+
cachedInputTokens: void 0
|
|
2736
|
+
}
|
|
2737
|
+
);
|
|
2738
|
+
await (onFinish == null ? void 0 : onFinish({
|
|
2739
|
+
finishReason: lastStep.finishReason,
|
|
2740
|
+
usage: lastStep.usage,
|
|
2741
|
+
content: lastStep.content,
|
|
2742
|
+
text: lastStep.text,
|
|
2743
|
+
reasoningText: lastStep.reasoningText,
|
|
2744
|
+
reasoning: lastStep.reasoning,
|
|
2745
|
+
files: lastStep.files,
|
|
2746
|
+
sources: lastStep.sources,
|
|
2747
|
+
toolCalls: lastStep.toolCalls,
|
|
2748
|
+
staticToolCalls: lastStep.staticToolCalls,
|
|
2749
|
+
dynamicToolCalls: lastStep.dynamicToolCalls,
|
|
2750
|
+
toolResults: lastStep.toolResults,
|
|
2751
|
+
staticToolResults: lastStep.staticToolResults,
|
|
2752
|
+
dynamicToolResults: lastStep.dynamicToolResults,
|
|
2753
|
+
request: lastStep.request,
|
|
2754
|
+
response: lastStep.response,
|
|
2755
|
+
warnings: lastStep.warnings,
|
|
2756
|
+
providerMetadata: lastStep.providerMetadata,
|
|
2757
|
+
steps,
|
|
2758
|
+
totalUsage
|
|
2759
|
+
}));
|
|
2725
2760
|
return new DefaultGenerateTextResult({
|
|
2726
2761
|
steps,
|
|
2762
|
+
totalUsage,
|
|
2727
2763
|
resolvedOutput: await (output == null ? void 0 : output.parseOutput(
|
|
2728
2764
|
{ text: lastStep.text },
|
|
2729
2765
|
{
|
|
@@ -2769,6 +2805,7 @@ var DefaultGenerateTextResult = class {
|
|
|
2769
2805
|
constructor(options) {
|
|
2770
2806
|
this.steps = options.steps;
|
|
2771
2807
|
this.resolvedOutput = options.resolvedOutput;
|
|
2808
|
+
this.totalUsage = options.totalUsage;
|
|
2772
2809
|
}
|
|
2773
2810
|
get finalStep() {
|
|
2774
2811
|
return this.steps[this.steps.length - 1];
|
|
@@ -2827,20 +2864,6 @@ var DefaultGenerateTextResult = class {
|
|
|
2827
2864
|
get usage() {
|
|
2828
2865
|
return this.finalStep.usage;
|
|
2829
2866
|
}
|
|
2830
|
-
get totalUsage() {
|
|
2831
|
-
return this.steps.reduce(
|
|
2832
|
-
(totalUsage, step) => {
|
|
2833
|
-
return addLanguageModelUsage(totalUsage, step.usage);
|
|
2834
|
-
},
|
|
2835
|
-
{
|
|
2836
|
-
inputTokens: void 0,
|
|
2837
|
-
outputTokens: void 0,
|
|
2838
|
-
totalTokens: void 0,
|
|
2839
|
-
reasoningTokens: void 0,
|
|
2840
|
-
cachedInputTokens: void 0
|
|
2841
|
-
}
|
|
2842
|
-
);
|
|
2843
|
-
}
|
|
2844
2867
|
get experimental_output() {
|
|
2845
2868
|
if (this.resolvedOutput == null) {
|
|
2846
2869
|
throw new NoOutputSpecifiedError();
|