ai 6.0.0-beta.140 → 6.0.0-beta.142
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 +13 -0
- package/dist/index.d.mts +36 -9
- package/dist/index.d.ts +36 -9
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.0-beta.142
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7169511: feat(agent): support context in onFinish callback
|
|
8
|
+
- bbdcb81: Add experimental_context parameter to prepareStep callback
|
|
9
|
+
|
|
10
|
+
## 6.0.0-beta.141
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- b1405bf: feat(ai): send context into streamText / generateText onFinish callbacks
|
|
15
|
+
|
|
3
16
|
## 6.0.0-beta.140
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1057,6 +1057,8 @@ Function that you can use to provide different settings for a step.
|
|
|
1057
1057
|
@param options.steps - The steps that have been executed so far.
|
|
1058
1058
|
@param options.stepNumber - The number of the step that is being executed.
|
|
1059
1059
|
@param options.model - The model that is being used.
|
|
1060
|
+
@param options.messages - The messages that will be sent to the model for the current step.
|
|
1061
|
+
@param options.experimental_context - The context passed via the experimental_context setting (experimental).
|
|
1060
1062
|
|
|
1061
1063
|
@returns An object that contains the settings for the step.
|
|
1062
1064
|
If you return undefined (or for undefined settings), the settings from the outer level will be used.
|
|
@@ -1066,6 +1068,7 @@ type PrepareStepFunction<TOOLS extends Record<string, Tool> = Record<string, Too
|
|
|
1066
1068
|
stepNumber: number;
|
|
1067
1069
|
model: LanguageModel;
|
|
1068
1070
|
messages: Array<ModelMessage>;
|
|
1071
|
+
experimental_context?: unknown;
|
|
1069
1072
|
}) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;
|
|
1070
1073
|
type PrepareStepResult<TOOLS extends Record<string, Tool> = Record<string, Tool>> = {
|
|
1071
1074
|
model?: LanguageModel;
|
|
@@ -1151,13 +1154,21 @@ Callback that is set using the `onFinish` option.
|
|
|
1151
1154
|
*/
|
|
1152
1155
|
type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
|
|
1153
1156
|
/**
|
|
1154
|
-
Details for all steps.
|
|
1155
|
-
|
|
1157
|
+
* Details for all steps.
|
|
1158
|
+
*/
|
|
1156
1159
|
readonly steps: StepResult<TOOLS>[];
|
|
1157
1160
|
/**
|
|
1158
|
-
Total usage for all steps. This is the sum of the usage of all steps.
|
|
1161
|
+
* Total usage for all steps. This is the sum of the usage of all steps.
|
|
1159
1162
|
*/
|
|
1160
1163
|
readonly totalUsage: LanguageModelUsage;
|
|
1164
|
+
/**
|
|
1165
|
+
* Context that is passed into tool execution.
|
|
1166
|
+
*
|
|
1167
|
+
* Experimental (can break in patch releases).
|
|
1168
|
+
*
|
|
1169
|
+
* @default undefined
|
|
1170
|
+
*/
|
|
1171
|
+
experimental_context: unknown;
|
|
1161
1172
|
}) => PromiseLike<void> | void;
|
|
1162
1173
|
/**
|
|
1163
1174
|
Generate a text and call tools for a given prompt using a language model.
|
|
@@ -2389,13 +2400,21 @@ Callback that is set using the `onFinish` option.
|
|
|
2389
2400
|
*/
|
|
2390
2401
|
type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
|
|
2391
2402
|
/**
|
|
2392
|
-
Details for all steps.
|
|
2393
|
-
|
|
2403
|
+
* Details for all steps.
|
|
2404
|
+
*/
|
|
2394
2405
|
readonly steps: StepResult<TOOLS>[];
|
|
2395
2406
|
/**
|
|
2396
|
-
Total usage for all steps. This is the sum of the usage of all steps.
|
|
2407
|
+
* Total usage for all steps. This is the sum of the usage of all steps.
|
|
2397
2408
|
*/
|
|
2398
2409
|
readonly totalUsage: LanguageModelUsage;
|
|
2410
|
+
/**
|
|
2411
|
+
* Context that is passed into tool execution.
|
|
2412
|
+
*
|
|
2413
|
+
* Experimental (can break in patch releases).
|
|
2414
|
+
*
|
|
2415
|
+
* @default undefined
|
|
2416
|
+
*/
|
|
2417
|
+
experimental_context: unknown;
|
|
2399
2418
|
}) => PromiseLike<void> | void;
|
|
2400
2419
|
/**
|
|
2401
2420
|
Callback that is set using the `onAbort` option.
|
|
@@ -2666,13 +2685,21 @@ Callback that is set using the `onFinish` option.
|
|
|
2666
2685
|
*/
|
|
2667
2686
|
type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
|
|
2668
2687
|
/**
|
|
2669
|
-
Details for all steps.
|
|
2670
|
-
|
|
2688
|
+
* Details for all steps.
|
|
2689
|
+
*/
|
|
2671
2690
|
readonly steps: StepResult<TOOLS>[];
|
|
2672
2691
|
/**
|
|
2673
|
-
Total usage for all steps. This is the sum of the usage of all steps.
|
|
2692
|
+
* Total usage for all steps. This is the sum of the usage of all steps.
|
|
2674
2693
|
*/
|
|
2675
2694
|
readonly totalUsage: LanguageModelUsage;
|
|
2695
|
+
/**
|
|
2696
|
+
* Context that is passed into tool calls.
|
|
2697
|
+
*
|
|
2698
|
+
* Experimental (can break in patch releases).
|
|
2699
|
+
*
|
|
2700
|
+
* @default undefined
|
|
2701
|
+
*/
|
|
2702
|
+
experimental_context?: unknown;
|
|
2676
2703
|
}) => PromiseLike<void> | void;
|
|
2677
2704
|
|
|
2678
2705
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1057,6 +1057,8 @@ Function that you can use to provide different settings for a step.
|
|
|
1057
1057
|
@param options.steps - The steps that have been executed so far.
|
|
1058
1058
|
@param options.stepNumber - The number of the step that is being executed.
|
|
1059
1059
|
@param options.model - The model that is being used.
|
|
1060
|
+
@param options.messages - The messages that will be sent to the model for the current step.
|
|
1061
|
+
@param options.experimental_context - The context passed via the experimental_context setting (experimental).
|
|
1060
1062
|
|
|
1061
1063
|
@returns An object that contains the settings for the step.
|
|
1062
1064
|
If you return undefined (or for undefined settings), the settings from the outer level will be used.
|
|
@@ -1066,6 +1068,7 @@ type PrepareStepFunction<TOOLS extends Record<string, Tool> = Record<string, Too
|
|
|
1066
1068
|
stepNumber: number;
|
|
1067
1069
|
model: LanguageModel;
|
|
1068
1070
|
messages: Array<ModelMessage>;
|
|
1071
|
+
experimental_context?: unknown;
|
|
1069
1072
|
}) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;
|
|
1070
1073
|
type PrepareStepResult<TOOLS extends Record<string, Tool> = Record<string, Tool>> = {
|
|
1071
1074
|
model?: LanguageModel;
|
|
@@ -1151,13 +1154,21 @@ Callback that is set using the `onFinish` option.
|
|
|
1151
1154
|
*/
|
|
1152
1155
|
type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
|
|
1153
1156
|
/**
|
|
1154
|
-
Details for all steps.
|
|
1155
|
-
|
|
1157
|
+
* Details for all steps.
|
|
1158
|
+
*/
|
|
1156
1159
|
readonly steps: StepResult<TOOLS>[];
|
|
1157
1160
|
/**
|
|
1158
|
-
Total usage for all steps. This is the sum of the usage of all steps.
|
|
1161
|
+
* Total usage for all steps. This is the sum of the usage of all steps.
|
|
1159
1162
|
*/
|
|
1160
1163
|
readonly totalUsage: LanguageModelUsage;
|
|
1164
|
+
/**
|
|
1165
|
+
* Context that is passed into tool execution.
|
|
1166
|
+
*
|
|
1167
|
+
* Experimental (can break in patch releases).
|
|
1168
|
+
*
|
|
1169
|
+
* @default undefined
|
|
1170
|
+
*/
|
|
1171
|
+
experimental_context: unknown;
|
|
1161
1172
|
}) => PromiseLike<void> | void;
|
|
1162
1173
|
/**
|
|
1163
1174
|
Generate a text and call tools for a given prompt using a language model.
|
|
@@ -2389,13 +2400,21 @@ Callback that is set using the `onFinish` option.
|
|
|
2389
2400
|
*/
|
|
2390
2401
|
type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
|
|
2391
2402
|
/**
|
|
2392
|
-
Details for all steps.
|
|
2393
|
-
|
|
2403
|
+
* Details for all steps.
|
|
2404
|
+
*/
|
|
2394
2405
|
readonly steps: StepResult<TOOLS>[];
|
|
2395
2406
|
/**
|
|
2396
|
-
Total usage for all steps. This is the sum of the usage of all steps.
|
|
2407
|
+
* Total usage for all steps. This is the sum of the usage of all steps.
|
|
2397
2408
|
*/
|
|
2398
2409
|
readonly totalUsage: LanguageModelUsage;
|
|
2410
|
+
/**
|
|
2411
|
+
* Context that is passed into tool execution.
|
|
2412
|
+
*
|
|
2413
|
+
* Experimental (can break in patch releases).
|
|
2414
|
+
*
|
|
2415
|
+
* @default undefined
|
|
2416
|
+
*/
|
|
2417
|
+
experimental_context: unknown;
|
|
2399
2418
|
}) => PromiseLike<void> | void;
|
|
2400
2419
|
/**
|
|
2401
2420
|
Callback that is set using the `onAbort` option.
|
|
@@ -2666,13 +2685,21 @@ Callback that is set using the `onFinish` option.
|
|
|
2666
2685
|
*/
|
|
2667
2686
|
type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
|
|
2668
2687
|
/**
|
|
2669
|
-
Details for all steps.
|
|
2670
|
-
|
|
2688
|
+
* Details for all steps.
|
|
2689
|
+
*/
|
|
2671
2690
|
readonly steps: StepResult<TOOLS>[];
|
|
2672
2691
|
/**
|
|
2673
|
-
Total usage for all steps. This is the sum of the usage of all steps.
|
|
2692
|
+
* Total usage for all steps. This is the sum of the usage of all steps.
|
|
2674
2693
|
*/
|
|
2675
2694
|
readonly totalUsage: LanguageModelUsage;
|
|
2695
|
+
/**
|
|
2696
|
+
* Context that is passed into tool calls.
|
|
2697
|
+
*
|
|
2698
|
+
* Experimental (can break in patch releases).
|
|
2699
|
+
*
|
|
2700
|
+
* @default undefined
|
|
2701
|
+
*/
|
|
2702
|
+
experimental_context?: unknown;
|
|
2676
2703
|
}) => PromiseLike<void> | void;
|
|
2677
2704
|
|
|
2678
2705
|
/**
|
package/dist/index.js
CHANGED
|
@@ -962,7 +962,7 @@ function detectMediaType({
|
|
|
962
962
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
963
963
|
|
|
964
964
|
// src/version.ts
|
|
965
|
-
var VERSION = true ? "6.0.0-beta.
|
|
965
|
+
var VERSION = true ? "6.0.0-beta.142" : "0.0.0-test";
|
|
966
966
|
|
|
967
967
|
// src/util/download/download.ts
|
|
968
968
|
var download = async ({ url }) => {
|
|
@@ -3549,7 +3549,8 @@ async function generateText({
|
|
|
3549
3549
|
model,
|
|
3550
3550
|
steps,
|
|
3551
3551
|
stepNumber: steps.length,
|
|
3552
|
-
messages: stepInputMessages
|
|
3552
|
+
messages: stepInputMessages,
|
|
3553
|
+
experimental_context
|
|
3553
3554
|
}));
|
|
3554
3555
|
const stepModel = resolveLanguageModel(
|
|
3555
3556
|
(_a15 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a15 : model
|
|
@@ -3833,7 +3834,8 @@ async function generateText({
|
|
|
3833
3834
|
warnings: lastStep.warnings,
|
|
3834
3835
|
providerMetadata: lastStep.providerMetadata,
|
|
3835
3836
|
steps,
|
|
3836
|
-
totalUsage
|
|
3837
|
+
totalUsage,
|
|
3838
|
+
experimental_context
|
|
3837
3839
|
}));
|
|
3838
3840
|
let resolvedOutput;
|
|
3839
3841
|
if (lastStep.finishReason === "stop") {
|
|
@@ -5742,7 +5744,8 @@ var DefaultStreamTextResult = class {
|
|
|
5742
5744
|
response: finalStep.response,
|
|
5743
5745
|
warnings: finalStep.warnings,
|
|
5744
5746
|
providerMetadata: finalStep.providerMetadata,
|
|
5745
|
-
steps: recordedSteps
|
|
5747
|
+
steps: recordedSteps,
|
|
5748
|
+
experimental_context
|
|
5746
5749
|
}));
|
|
5747
5750
|
rootSpan.setAttributes(
|
|
5748
5751
|
await selectTelemetryAttributes({
|
|
@@ -5941,7 +5944,8 @@ var DefaultStreamTextResult = class {
|
|
|
5941
5944
|
model,
|
|
5942
5945
|
steps: recordedSteps,
|
|
5943
5946
|
stepNumber: recordedSteps.length,
|
|
5944
|
-
messages: stepInputMessages
|
|
5947
|
+
messages: stepInputMessages,
|
|
5948
|
+
experimental_context
|
|
5945
5949
|
}));
|
|
5946
5950
|
const stepModel = resolveLanguageModel(
|
|
5947
5951
|
(_a15 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a15 : model
|