ai 3.4.15 → 3.4.17
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 +12 -0
- package/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/rsc/dist/rsc-server.mjs +11 -3
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 3.4.17
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- e4ff512: fix (core): prevent unnecessary input/output serialization when telemetry is not enabled
|
8
|
+
|
9
|
+
## 3.4.16
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 01dcc44: feat (ai/core): add experimental activeTools option to generateText and streamText
|
14
|
+
|
3
15
|
## 3.4.15
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -1580,7 +1580,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1580
1580
|
@returns
|
1581
1581
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
1582
1582
|
*/
|
1583
|
-
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, maxSteps, experimental_continuationSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
|
1583
|
+
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, maxSteps, experimental_continuationSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_activeTools: activeTools, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
|
1584
1584
|
/**
|
1585
1585
|
The language model to use.
|
1586
1586
|
*/
|
@@ -1641,6 +1641,11 @@ functionality that can be fully encapsulated in the provider.
|
|
1641
1641
|
*/
|
1642
1642
|
experimental_providerMetadata?: ProviderMetadata;
|
1643
1643
|
/**
|
1644
|
+
Limits the tools that are available for the model to call without
|
1645
|
+
changing the tool call and result types in the result.
|
1646
|
+
*/
|
1647
|
+
experimental_activeTools?: Array<keyof TOOLS>;
|
1648
|
+
/**
|
1644
1649
|
Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
1645
1650
|
*/
|
1646
1651
|
onStepFinish?: (event: StepResult<TOOLS>) => Promise<void> | void;
|
@@ -1931,7 +1936,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1931
1936
|
@return
|
1932
1937
|
A result object for accessing different stream types and additional information.
|
1933
1938
|
*/
|
1934
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxToolRoundtrips, maxSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_toolCallStreaming: toolCallStreaming, onChunk, onFinish, onStepFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1939
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxToolRoundtrips, maxSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_toolCallStreaming: toolCallStreaming, experimental_activeTools: activeTools, onChunk, onFinish, onStepFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1935
1940
|
/**
|
1936
1941
|
The language model to use.
|
1937
1942
|
*/
|
@@ -1984,6 +1989,11 @@ functionality that can be fully encapsulated in the provider.
|
|
1984
1989
|
*/
|
1985
1990
|
experimental_providerMetadata?: ProviderMetadata;
|
1986
1991
|
/**
|
1992
|
+
Limits the tools that are available for the model to call without
|
1993
|
+
changing the tool call and result types in the result.
|
1994
|
+
*/
|
1995
|
+
experimental_activeTools?: Array<keyof TOOLS>;
|
1996
|
+
/**
|
1987
1997
|
Enable streaming of tool call deltas as they are generated. Disabled by default.
|
1988
1998
|
*/
|
1989
1999
|
experimental_toolCallStreaming?: boolean;
|
package/dist/index.d.ts
CHANGED
@@ -1580,7 +1580,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1580
1580
|
@returns
|
1581
1581
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
1582
1582
|
*/
|
1583
|
-
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, maxSteps, experimental_continuationSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
|
1583
|
+
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, maxSteps, experimental_continuationSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_activeTools: activeTools, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
|
1584
1584
|
/**
|
1585
1585
|
The language model to use.
|
1586
1586
|
*/
|
@@ -1641,6 +1641,11 @@ functionality that can be fully encapsulated in the provider.
|
|
1641
1641
|
*/
|
1642
1642
|
experimental_providerMetadata?: ProviderMetadata;
|
1643
1643
|
/**
|
1644
|
+
Limits the tools that are available for the model to call without
|
1645
|
+
changing the tool call and result types in the result.
|
1646
|
+
*/
|
1647
|
+
experimental_activeTools?: Array<keyof TOOLS>;
|
1648
|
+
/**
|
1644
1649
|
Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
1645
1650
|
*/
|
1646
1651
|
onStepFinish?: (event: StepResult<TOOLS>) => Promise<void> | void;
|
@@ -1931,7 +1936,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1931
1936
|
@return
|
1932
1937
|
A result object for accessing different stream types and additional information.
|
1933
1938
|
*/
|
1934
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxToolRoundtrips, maxSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_toolCallStreaming: toolCallStreaming, onChunk, onFinish, onStepFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1939
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxToolRoundtrips, maxSteps, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_toolCallStreaming: toolCallStreaming, experimental_activeTools: activeTools, onChunk, onFinish, onStepFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1935
1940
|
/**
|
1936
1941
|
The language model to use.
|
1937
1942
|
*/
|
@@ -1984,6 +1989,11 @@ functionality that can be fully encapsulated in the provider.
|
|
1984
1989
|
*/
|
1985
1990
|
experimental_providerMetadata?: ProviderMetadata;
|
1986
1991
|
/**
|
1992
|
+
Limits the tools that are available for the model to call without
|
1993
|
+
changing the tool call and result types in the result.
|
1994
|
+
*/
|
1995
|
+
experimental_activeTools?: Array<keyof TOOLS>;
|
1996
|
+
/**
|
1987
1997
|
Enable streaming of tool call deltas as they are generated. Disabled by default.
|
1988
1998
|
*/
|
1989
1999
|
experimental_toolCallStreaming?: boolean;
|
package/dist/index.js
CHANGED
@@ -373,6 +373,9 @@ function selectTelemetryAttributes({
|
|
373
373
|
telemetry,
|
374
374
|
attributes
|
375
375
|
}) {
|
376
|
+
if ((telemetry == null ? void 0 : telemetry.isEnabled) !== true) {
|
377
|
+
return {};
|
378
|
+
}
|
376
379
|
return Object.entries(attributes).reduce((attributes2, [key, value]) => {
|
377
380
|
if (value === void 0) {
|
378
381
|
return attributes2;
|
@@ -3067,7 +3070,8 @@ function isNonEmptyObject(object) {
|
|
3067
3070
|
// core/prompt/prepare-tools-and-tool-choice.ts
|
3068
3071
|
function prepareToolsAndToolChoice({
|
3069
3072
|
tools,
|
3070
|
-
toolChoice
|
3073
|
+
toolChoice,
|
3074
|
+
activeTools
|
3071
3075
|
}) {
|
3072
3076
|
if (!isNonEmptyObject(tools)) {
|
3073
3077
|
return {
|
@@ -3075,8 +3079,11 @@ function prepareToolsAndToolChoice({
|
|
3075
3079
|
toolChoice: void 0
|
3076
3080
|
};
|
3077
3081
|
}
|
3082
|
+
const filteredTools = activeTools != null ? Object.entries(tools).filter(
|
3083
|
+
([name11]) => activeTools.includes(name11)
|
3084
|
+
) : Object.entries(tools);
|
3078
3085
|
return {
|
3079
|
-
tools:
|
3086
|
+
tools: filteredTools.map(([name11, tool2]) => ({
|
3080
3087
|
type: "function",
|
3081
3088
|
name: name11,
|
3082
3089
|
description: tool2.description,
|
@@ -3178,6 +3185,7 @@ async function generateText({
|
|
3178
3185
|
experimental_continueSteps: continueSteps = experimental_continuationSteps != null ? experimental_continuationSteps : false,
|
3179
3186
|
experimental_telemetry: telemetry,
|
3180
3187
|
experimental_providerMetadata: providerMetadata,
|
3188
|
+
experimental_activeTools: activeTools,
|
3181
3189
|
_internal: {
|
3182
3190
|
generateId: generateId3 = originalGenerateId3,
|
3183
3191
|
currentDate = () => /* @__PURE__ */ new Date()
|
@@ -3227,7 +3235,7 @@ async function generateText({
|
|
3227
3235
|
});
|
3228
3236
|
const mode = {
|
3229
3237
|
type: "regular",
|
3230
|
-
...prepareToolsAndToolChoice({ tools, toolChoice })
|
3238
|
+
...prepareToolsAndToolChoice({ tools, toolChoice, activeTools })
|
3231
3239
|
};
|
3232
3240
|
const callSettings = prepareCallSettings(settings);
|
3233
3241
|
const promptMessages = await convertToLanguageModelPrompt({
|
@@ -3906,6 +3914,7 @@ async function streamText({
|
|
3906
3914
|
experimental_telemetry: telemetry,
|
3907
3915
|
experimental_providerMetadata: providerMetadata,
|
3908
3916
|
experimental_toolCallStreaming: toolCallStreaming = false,
|
3917
|
+
experimental_activeTools: activeTools,
|
3909
3918
|
onChunk,
|
3910
3919
|
onFinish,
|
3911
3920
|
onStepFinish,
|
@@ -3994,7 +4003,11 @@ async function streamText({
|
|
3994
4003
|
result: await model.doStream({
|
3995
4004
|
mode: {
|
3996
4005
|
type: "regular",
|
3997
|
-
...prepareToolsAndToolChoice({
|
4006
|
+
...prepareToolsAndToolChoice({
|
4007
|
+
tools,
|
4008
|
+
toolChoice,
|
4009
|
+
activeTools
|
4010
|
+
})
|
3998
4011
|
},
|
3999
4012
|
...prepareCallSettings(settings),
|
4000
4013
|
inputFormat: promptType,
|