ai 7.0.0-beta.59 → 7.0.0-beta.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 +52 -4
- package/dist/index.d.ts +52 -4
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/03-ai-sdk-core/25-settings.mdx +33 -1
- package/package.json +1 -1
- package/src/generate-text/core-events.ts +2 -2
- package/src/generate-text/stream-model-call.ts +48 -4
- package/src/generate-text/stream-text.ts +0 -1
- package/src/prompt/call-settings.ts +2 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -643,6 +643,8 @@ type PartialObject<ObjectType extends object> = {
|
|
|
643
643
|
* - An object with `totalMs` property for the total timeout in milliseconds
|
|
644
644
|
* - An object with `stepMs` property for the timeout of each step in milliseconds
|
|
645
645
|
* - An object with `chunkMs` property for the timeout between stream chunks (streaming only)
|
|
646
|
+
* - An object with `toolMs` property for the default timeout for all tool executions
|
|
647
|
+
* - An object with `tools` property for per-tool timeout overrides using `{toolName}Ms` keys
|
|
646
648
|
*/
|
|
647
649
|
type TimeoutConfiguration<TOOLS extends ToolSet> = number | {
|
|
648
650
|
totalMs?: number;
|
|
@@ -1450,12 +1452,58 @@ type ModelCallStreamPart<TOOLS extends ToolSet = ToolSet> = Exclude<TextStreamPa
|
|
|
1450
1452
|
*/
|
|
1451
1453
|
modelId?: string;
|
|
1452
1454
|
};
|
|
1453
|
-
|
|
1455
|
+
/**
|
|
1456
|
+
* Streams a single language model call after standardizing the prompt and tools.
|
|
1457
|
+
*
|
|
1458
|
+
* The returned stream emits model call parts together with request and response
|
|
1459
|
+
* metadata when available.
|
|
1460
|
+
*
|
|
1461
|
+
* @param model - The language model to use.
|
|
1462
|
+
* @param tools - Tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
|
1463
|
+
* @param output - Output configuration that controls the response format requested from the model.
|
|
1464
|
+
* @param toolChoice - The tool choice strategy for the model call.
|
|
1465
|
+
*
|
|
1466
|
+
* @param system - A system message that will be part of the prompt.
|
|
1467
|
+
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
1468
|
+
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
1469
|
+
*
|
|
1470
|
+
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
1471
|
+
* @param temperature - Temperature setting.
|
|
1472
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1473
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
1474
|
+
* @param topP - Nucleus sampling.
|
|
1475
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1476
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
1477
|
+
* @param topK - Only sample from the top K options for each subsequent token.
|
|
1478
|
+
* Used to remove "long tail" low probability responses.
|
|
1479
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
1480
|
+
* @param presencePenalty - Presence penalty setting.
|
|
1481
|
+
* It affects the likelihood of the model to repeat information that is already in the prompt.
|
|
1482
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1483
|
+
* @param frequencyPenalty - Frequency penalty setting.
|
|
1484
|
+
* It affects the likelihood of the model to repeatedly use the same words or phrases.
|
|
1485
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1486
|
+
* @param stopSequences - Stop sequences.
|
|
1487
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
1488
|
+
* @param seed - The seed (integer) to use for random sampling.
|
|
1489
|
+
* If set and supported by the model, calls will generate deterministic results.
|
|
1490
|
+
* @param reasoning - Reasoning configuration for the model call.
|
|
1491
|
+
*
|
|
1492
|
+
* @param download - A function that downloads URLs as part of prompt conversion.
|
|
1493
|
+
* @param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
1494
|
+
* @param headers - Additional HTTP headers to be sent with the request.
|
|
1495
|
+
* @param includeRawChunks - Whether to include raw provider stream chunks in the model stream.
|
|
1496
|
+
* @param providerOptions - Additional provider-specific options.
|
|
1497
|
+
* @param repairToolCall - A function that can repair invalid tool calls before they are emitted.
|
|
1498
|
+
* @param onStart - A callback that receives the fully converted prompt before the model call starts.
|
|
1499
|
+
*
|
|
1500
|
+
* @returns A stream of model call parts together with request and response metadata when available.
|
|
1501
|
+
*/
|
|
1502
|
+
declare function streamModelCall<TOOLS extends ToolSet, OUTPUT extends Output = Output>({ model, tools, output, toolChoice, prompt, system, messages, download, abortSignal, headers, includeRawChunks, providerOptions, repairToolCall, onStart, ...callSettings }: {
|
|
1454
1503
|
model: LanguageModel;
|
|
1455
1504
|
tools?: TOOLS;
|
|
1456
1505
|
output?: OUTPUT;
|
|
1457
1506
|
toolChoice?: ToolChoice<TOOLS>;
|
|
1458
|
-
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
|
1459
1507
|
download?: DownloadFunction;
|
|
1460
1508
|
headers?: Record<string, string | undefined>;
|
|
1461
1509
|
includeRawChunks?: boolean;
|
|
@@ -2687,7 +2735,7 @@ interface OnStartEvent<TOOLS extends ToolSet = ToolSet, CONTEXT extends Generati
|
|
|
2687
2735
|
readonly maxRetries: number;
|
|
2688
2736
|
/**
|
|
2689
2737
|
* Timeout configuration for the generation.
|
|
2690
|
-
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
2738
|
+
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs, toolMs, and per-tool overrides via tools.
|
|
2691
2739
|
*/
|
|
2692
2740
|
readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
|
|
2693
2741
|
/** Additional HTTP headers sent with the request. */
|
|
@@ -2763,7 +2811,7 @@ interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, CONTEXT extends Gene
|
|
|
2763
2811
|
readonly providerOptions: ProviderOptions | undefined;
|
|
2764
2812
|
/**
|
|
2765
2813
|
* Timeout configuration for the generation.
|
|
2766
|
-
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
2814
|
+
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs, toolMs, and per-tool overrides via tools.
|
|
2767
2815
|
*/
|
|
2768
2816
|
readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
|
|
2769
2817
|
/** Additional HTTP headers sent with the request. */
|
package/dist/index.d.ts
CHANGED
|
@@ -643,6 +643,8 @@ type PartialObject<ObjectType extends object> = {
|
|
|
643
643
|
* - An object with `totalMs` property for the total timeout in milliseconds
|
|
644
644
|
* - An object with `stepMs` property for the timeout of each step in milliseconds
|
|
645
645
|
* - An object with `chunkMs` property for the timeout between stream chunks (streaming only)
|
|
646
|
+
* - An object with `toolMs` property for the default timeout for all tool executions
|
|
647
|
+
* - An object with `tools` property for per-tool timeout overrides using `{toolName}Ms` keys
|
|
646
648
|
*/
|
|
647
649
|
type TimeoutConfiguration<TOOLS extends ToolSet> = number | {
|
|
648
650
|
totalMs?: number;
|
|
@@ -1450,12 +1452,58 @@ type ModelCallStreamPart<TOOLS extends ToolSet = ToolSet> = Exclude<TextStreamPa
|
|
|
1450
1452
|
*/
|
|
1451
1453
|
modelId?: string;
|
|
1452
1454
|
};
|
|
1453
|
-
|
|
1455
|
+
/**
|
|
1456
|
+
* Streams a single language model call after standardizing the prompt and tools.
|
|
1457
|
+
*
|
|
1458
|
+
* The returned stream emits model call parts together with request and response
|
|
1459
|
+
* metadata when available.
|
|
1460
|
+
*
|
|
1461
|
+
* @param model - The language model to use.
|
|
1462
|
+
* @param tools - Tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
|
1463
|
+
* @param output - Output configuration that controls the response format requested from the model.
|
|
1464
|
+
* @param toolChoice - The tool choice strategy for the model call.
|
|
1465
|
+
*
|
|
1466
|
+
* @param system - A system message that will be part of the prompt.
|
|
1467
|
+
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
1468
|
+
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
1469
|
+
*
|
|
1470
|
+
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
1471
|
+
* @param temperature - Temperature setting.
|
|
1472
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1473
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
1474
|
+
* @param topP - Nucleus sampling.
|
|
1475
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1476
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
1477
|
+
* @param topK - Only sample from the top K options for each subsequent token.
|
|
1478
|
+
* Used to remove "long tail" low probability responses.
|
|
1479
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
1480
|
+
* @param presencePenalty - Presence penalty setting.
|
|
1481
|
+
* It affects the likelihood of the model to repeat information that is already in the prompt.
|
|
1482
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1483
|
+
* @param frequencyPenalty - Frequency penalty setting.
|
|
1484
|
+
* It affects the likelihood of the model to repeatedly use the same words or phrases.
|
|
1485
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
1486
|
+
* @param stopSequences - Stop sequences.
|
|
1487
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
1488
|
+
* @param seed - The seed (integer) to use for random sampling.
|
|
1489
|
+
* If set and supported by the model, calls will generate deterministic results.
|
|
1490
|
+
* @param reasoning - Reasoning configuration for the model call.
|
|
1491
|
+
*
|
|
1492
|
+
* @param download - A function that downloads URLs as part of prompt conversion.
|
|
1493
|
+
* @param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
1494
|
+
* @param headers - Additional HTTP headers to be sent with the request.
|
|
1495
|
+
* @param includeRawChunks - Whether to include raw provider stream chunks in the model stream.
|
|
1496
|
+
* @param providerOptions - Additional provider-specific options.
|
|
1497
|
+
* @param repairToolCall - A function that can repair invalid tool calls before they are emitted.
|
|
1498
|
+
* @param onStart - A callback that receives the fully converted prompt before the model call starts.
|
|
1499
|
+
*
|
|
1500
|
+
* @returns A stream of model call parts together with request and response metadata when available.
|
|
1501
|
+
*/
|
|
1502
|
+
declare function streamModelCall<TOOLS extends ToolSet, OUTPUT extends Output = Output>({ model, tools, output, toolChoice, prompt, system, messages, download, abortSignal, headers, includeRawChunks, providerOptions, repairToolCall, onStart, ...callSettings }: {
|
|
1454
1503
|
model: LanguageModel;
|
|
1455
1504
|
tools?: TOOLS;
|
|
1456
1505
|
output?: OUTPUT;
|
|
1457
1506
|
toolChoice?: ToolChoice<TOOLS>;
|
|
1458
|
-
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
|
1459
1507
|
download?: DownloadFunction;
|
|
1460
1508
|
headers?: Record<string, string | undefined>;
|
|
1461
1509
|
includeRawChunks?: boolean;
|
|
@@ -2687,7 +2735,7 @@ interface OnStartEvent<TOOLS extends ToolSet = ToolSet, CONTEXT extends Generati
|
|
|
2687
2735
|
readonly maxRetries: number;
|
|
2688
2736
|
/**
|
|
2689
2737
|
* Timeout configuration for the generation.
|
|
2690
|
-
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
2738
|
+
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs, toolMs, and per-tool overrides via tools.
|
|
2691
2739
|
*/
|
|
2692
2740
|
readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
|
|
2693
2741
|
/** Additional HTTP headers sent with the request. */
|
|
@@ -2763,7 +2811,7 @@ interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, CONTEXT extends Gene
|
|
|
2763
2811
|
readonly providerOptions: ProviderOptions | undefined;
|
|
2764
2812
|
/**
|
|
2765
2813
|
* Timeout configuration for the generation.
|
|
2766
|
-
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
2814
|
+
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs, toolMs, and per-tool overrides via tools.
|
|
2767
2815
|
*/
|
|
2768
2816
|
readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
|
|
2769
2817
|
/** Additional HTTP headers sent with the request. */
|
package/dist/index.js
CHANGED
|
@@ -1367,7 +1367,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
|
1367
1367
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1368
1368
|
|
|
1369
1369
|
// src/version.ts
|
|
1370
|
-
var VERSION = true ? "7.0.0-beta.
|
|
1370
|
+
var VERSION = true ? "7.0.0-beta.60" : "0.0.0-test";
|
|
1371
1371
|
|
|
1372
1372
|
// src/util/download/download.ts
|
|
1373
1373
|
var download = async ({
|
|
@@ -6295,7 +6295,6 @@ async function streamModelCall({
|
|
|
6295
6295
|
tools,
|
|
6296
6296
|
output,
|
|
6297
6297
|
toolChoice,
|
|
6298
|
-
activeTools,
|
|
6299
6298
|
prompt,
|
|
6300
6299
|
system,
|
|
6301
6300
|
messages,
|
|
@@ -7286,12 +7285,11 @@ var DefaultStreamTextResult = class {
|
|
|
7286
7285
|
response
|
|
7287
7286
|
} = await retry(
|
|
7288
7287
|
async () => {
|
|
7289
|
-
var _a22, _b2
|
|
7288
|
+
var _a22, _b2;
|
|
7290
7289
|
return streamModelCall({
|
|
7291
7290
|
model: (_a22 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a22 : model,
|
|
7292
7291
|
tools: stepActiveTools,
|
|
7293
|
-
|
|
7294
|
-
toolChoice: (_c2 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _c2 : toolChoice,
|
|
7292
|
+
toolChoice: (_b2 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _b2 : toolChoice,
|
|
7295
7293
|
system: stepSystem,
|
|
7296
7294
|
messages: stepMessages,
|
|
7297
7295
|
repairToolCall,
|