ai 6.0.59 → 6.0.60
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 +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -13
- 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/01-generate-text.mdx +28 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +21 -0
- package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +108 -0
- package/package.json +1 -1
- package/src/generate-text/generate-text.ts +48 -7
- package/src/generate-text/stream-text.ts +26 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1074,7 +1074,7 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TO
|
|
|
1074
1074
|
* @returns
|
|
1075
1075
|
* A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1076
1076
|
*/
|
|
1077
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, _internal: { generateId }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1077
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1078
1078
|
/**
|
|
1079
1079
|
* The language model to use.
|
|
1080
1080
|
*/
|
|
@@ -1157,6 +1157,26 @@ declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Out
|
|
|
1157
1157
|
* @default undefined
|
|
1158
1158
|
*/
|
|
1159
1159
|
experimental_context?: unknown;
|
|
1160
|
+
/**
|
|
1161
|
+
* Settings for controlling what data is included in step results.
|
|
1162
|
+
* Disabling inclusion can help reduce memory usage when processing
|
|
1163
|
+
* large payloads like images.
|
|
1164
|
+
*
|
|
1165
|
+
* By default, all data is included for backwards compatibility.
|
|
1166
|
+
*/
|
|
1167
|
+
experimental_include?: {
|
|
1168
|
+
/**
|
|
1169
|
+
* Whether to retain the request body in step results.
|
|
1170
|
+
* The request body can be large when sending images or files.
|
|
1171
|
+
* @default true
|
|
1172
|
+
*/
|
|
1173
|
+
requestBody?: boolean;
|
|
1174
|
+
/**
|
|
1175
|
+
* Whether to retain the response body in step results.
|
|
1176
|
+
* @default true
|
|
1177
|
+
*/
|
|
1178
|
+
responseBody?: boolean;
|
|
1179
|
+
};
|
|
1160
1180
|
/**
|
|
1161
1181
|
* Internal. For test use only. May change without notice.
|
|
1162
1182
|
*/
|
|
@@ -2402,7 +2422,7 @@ type StreamTextOnAbortCallback<TOOLS extends ToolSet> = (event: {
|
|
|
2402
2422
|
* @returns
|
|
2403
2423
|
* A result object for accessing different stream types and additional information.
|
|
2404
2424
|
*/
|
|
2405
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2425
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2406
2426
|
/**
|
|
2407
2427
|
* The language model to use.
|
|
2408
2428
|
*/
|
|
@@ -2517,6 +2537,21 @@ declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Outpu
|
|
|
2517
2537
|
* @default undefined
|
|
2518
2538
|
*/
|
|
2519
2539
|
experimental_context?: unknown;
|
|
2540
|
+
/**
|
|
2541
|
+
* Settings for controlling what data is included in step results.
|
|
2542
|
+
* Disabling inclusion can help reduce memory usage when processing
|
|
2543
|
+
* large payloads like images.
|
|
2544
|
+
*
|
|
2545
|
+
* By default, all data is included for backwards compatibility.
|
|
2546
|
+
*/
|
|
2547
|
+
experimental_include?: {
|
|
2548
|
+
/**
|
|
2549
|
+
* Whether to retain the request body in step results.
|
|
2550
|
+
* The request body can be large when sending images or files.
|
|
2551
|
+
* @default true
|
|
2552
|
+
*/
|
|
2553
|
+
requestBody?: boolean;
|
|
2554
|
+
};
|
|
2520
2555
|
/**
|
|
2521
2556
|
* Internal. For test use only. May change without notice.
|
|
2522
2557
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1074,7 +1074,7 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TO
|
|
|
1074
1074
|
* @returns
|
|
1075
1075
|
* A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1076
1076
|
*/
|
|
1077
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, _internal: { generateId }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1077
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1078
1078
|
/**
|
|
1079
1079
|
* The language model to use.
|
|
1080
1080
|
*/
|
|
@@ -1157,6 +1157,26 @@ declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Out
|
|
|
1157
1157
|
* @default undefined
|
|
1158
1158
|
*/
|
|
1159
1159
|
experimental_context?: unknown;
|
|
1160
|
+
/**
|
|
1161
|
+
* Settings for controlling what data is included in step results.
|
|
1162
|
+
* Disabling inclusion can help reduce memory usage when processing
|
|
1163
|
+
* large payloads like images.
|
|
1164
|
+
*
|
|
1165
|
+
* By default, all data is included for backwards compatibility.
|
|
1166
|
+
*/
|
|
1167
|
+
experimental_include?: {
|
|
1168
|
+
/**
|
|
1169
|
+
* Whether to retain the request body in step results.
|
|
1170
|
+
* The request body can be large when sending images or files.
|
|
1171
|
+
* @default true
|
|
1172
|
+
*/
|
|
1173
|
+
requestBody?: boolean;
|
|
1174
|
+
/**
|
|
1175
|
+
* Whether to retain the response body in step results.
|
|
1176
|
+
* @default true
|
|
1177
|
+
*/
|
|
1178
|
+
responseBody?: boolean;
|
|
1179
|
+
};
|
|
1160
1180
|
/**
|
|
1161
1181
|
* Internal. For test use only. May change without notice.
|
|
1162
1182
|
*/
|
|
@@ -2402,7 +2422,7 @@ type StreamTextOnAbortCallback<TOOLS extends ToolSet> = (event: {
|
|
|
2402
2422
|
* @returns
|
|
2403
2423
|
* A result object for accessing different stream types and additional information.
|
|
2404
2424
|
*/
|
|
2405
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2425
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2406
2426
|
/**
|
|
2407
2427
|
* The language model to use.
|
|
2408
2428
|
*/
|
|
@@ -2517,6 +2537,21 @@ declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Outpu
|
|
|
2517
2537
|
* @default undefined
|
|
2518
2538
|
*/
|
|
2519
2539
|
experimental_context?: unknown;
|
|
2540
|
+
/**
|
|
2541
|
+
* Settings for controlling what data is included in step results.
|
|
2542
|
+
* Disabling inclusion can help reduce memory usage when processing
|
|
2543
|
+
* large payloads like images.
|
|
2544
|
+
*
|
|
2545
|
+
* By default, all data is included for backwards compatibility.
|
|
2546
|
+
*/
|
|
2547
|
+
experimental_include?: {
|
|
2548
|
+
/**
|
|
2549
|
+
* Whether to retain the request body in step results.
|
|
2550
|
+
* The request body can be large when sending images or files.
|
|
2551
|
+
* @default true
|
|
2552
|
+
*/
|
|
2553
|
+
requestBody?: boolean;
|
|
2554
|
+
};
|
|
2520
2555
|
/**
|
|
2521
2556
|
* Internal. For test use only. May change without notice.
|
|
2522
2557
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1104,7 +1104,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
|
1104
1104
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1105
1105
|
|
|
1106
1106
|
// src/version.ts
|
|
1107
|
-
var VERSION = true ? "6.0.
|
|
1107
|
+
var VERSION = true ? "6.0.60" : "0.0.0-test";
|
|
1108
1108
|
|
|
1109
1109
|
// src/util/download/download.ts
|
|
1110
1110
|
var download = async ({ url }) => {
|
|
@@ -3850,6 +3850,7 @@ async function generateText({
|
|
|
3850
3850
|
experimental_repairToolCall: repairToolCall,
|
|
3851
3851
|
experimental_download: download2,
|
|
3852
3852
|
experimental_context,
|
|
3853
|
+
experimental_include: include,
|
|
3853
3854
|
_internal: { generateId: generateId2 = originalGenerateId } = {},
|
|
3854
3855
|
onStepFinish,
|
|
3855
3856
|
onFinish,
|
|
@@ -3908,7 +3909,7 @@ async function generateText({
|
|
|
3908
3909
|
}),
|
|
3909
3910
|
tracer,
|
|
3910
3911
|
fn: async (span) => {
|
|
3911
|
-
var _a20, _b, _c, _d, _e, _f, _g, _h;
|
|
3912
|
+
var _a20, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3912
3913
|
const initialMessages = initialPrompt.messages;
|
|
3913
3914
|
const responseMessages = [];
|
|
3914
3915
|
const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
|
|
@@ -4230,6 +4231,14 @@ async function generateText({
|
|
|
4230
4231
|
tools
|
|
4231
4232
|
})
|
|
4232
4233
|
);
|
|
4234
|
+
const stepRequest = ((_g = include == null ? void 0 : include.requestBody) != null ? _g : true) ? (_h = currentModelResponse.request) != null ? _h : {} : { ...currentModelResponse.request, body: void 0 };
|
|
4235
|
+
const stepResponse = {
|
|
4236
|
+
...currentModelResponse.response,
|
|
4237
|
+
// deep clone msgs to avoid mutating past messages in multi-step:
|
|
4238
|
+
messages: structuredClone(responseMessages),
|
|
4239
|
+
// Conditionally include response body:
|
|
4240
|
+
body: ((_i = include == null ? void 0 : include.responseBody) != null ? _i : true) ? (_j = currentModelResponse.response) == null ? void 0 : _j.body : void 0
|
|
4241
|
+
};
|
|
4233
4242
|
const currentStepResult = new DefaultStepResult({
|
|
4234
4243
|
content: stepContent,
|
|
4235
4244
|
finishReason: currentModelResponse.finishReason.unified,
|
|
@@ -4237,15 +4246,11 @@ async function generateText({
|
|
|
4237
4246
|
usage: asLanguageModelUsage(currentModelResponse.usage),
|
|
4238
4247
|
warnings: currentModelResponse.warnings,
|
|
4239
4248
|
providerMetadata: currentModelResponse.providerMetadata,
|
|
4240
|
-
request:
|
|
4241
|
-
response:
|
|
4242
|
-
...currentModelResponse.response,
|
|
4243
|
-
// deep clone msgs to avoid mutating past messages in multi-step:
|
|
4244
|
-
messages: structuredClone(responseMessages)
|
|
4245
|
-
}
|
|
4249
|
+
request: stepRequest,
|
|
4250
|
+
response: stepResponse
|
|
4246
4251
|
});
|
|
4247
4252
|
logWarnings({
|
|
4248
|
-
warnings: (
|
|
4253
|
+
warnings: (_k = currentModelResponse.warnings) != null ? _k : [],
|
|
4249
4254
|
provider: stepModel.provider,
|
|
4250
4255
|
model: stepModel.modelId
|
|
4251
4256
|
});
|
|
@@ -5992,6 +5997,7 @@ function streamText({
|
|
|
5992
5997
|
onAbort,
|
|
5993
5998
|
onStepFinish,
|
|
5994
5999
|
experimental_context,
|
|
6000
|
+
experimental_include: include,
|
|
5995
6001
|
_internal: { now: now2 = now, generateId: generateId2 = originalGenerateId2 } = {},
|
|
5996
6002
|
...settings
|
|
5997
6003
|
}) {
|
|
@@ -6037,7 +6043,8 @@ function streamText({
|
|
|
6037
6043
|
now: now2,
|
|
6038
6044
|
generateId: generateId2,
|
|
6039
6045
|
experimental_context,
|
|
6040
|
-
download: download2
|
|
6046
|
+
download: download2,
|
|
6047
|
+
include
|
|
6041
6048
|
});
|
|
6042
6049
|
}
|
|
6043
6050
|
function createOutputTransformStream(output) {
|
|
@@ -6135,7 +6142,8 @@ var DefaultStreamTextResult = class {
|
|
|
6135
6142
|
onAbort,
|
|
6136
6143
|
onStepFinish,
|
|
6137
6144
|
experimental_context,
|
|
6138
|
-
download: download2
|
|
6145
|
+
download: download2,
|
|
6146
|
+
include
|
|
6139
6147
|
}) {
|
|
6140
6148
|
this._totalUsage = new import_provider_utils19.DelayedPromise();
|
|
6141
6149
|
this._finishReason = new import_provider_utils19.DelayedPromise();
|
|
@@ -6577,7 +6585,7 @@ var DefaultStreamTextResult = class {
|
|
|
6577
6585
|
responseMessages,
|
|
6578
6586
|
usage
|
|
6579
6587
|
}) {
|
|
6580
|
-
var _a20, _b, _c, _d, _e, _f;
|
|
6588
|
+
var _a20, _b, _c, _d, _e, _f, _g;
|
|
6581
6589
|
const includeRawChunks2 = self.includeRawChunks;
|
|
6582
6590
|
const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : void 0;
|
|
6583
6591
|
let chunkTimeoutId = void 0;
|
|
@@ -6707,7 +6715,7 @@ var DefaultStreamTextResult = class {
|
|
|
6707
6715
|
experimental_context,
|
|
6708
6716
|
generateId: generateId2
|
|
6709
6717
|
});
|
|
6710
|
-
const stepRequest = request != null ? request : {};
|
|
6718
|
+
const stepRequest = ((_g = include == null ? void 0 : include.requestBody) != null ? _g : true) ? request != null ? request : {} : { ...request, body: void 0 };
|
|
6711
6719
|
const stepToolCalls = [];
|
|
6712
6720
|
const stepToolOutputs = [];
|
|
6713
6721
|
let warnings;
|