ai 3.3.34 → 3.3.36
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 +27 -0
- package/dist/index.d.mts +106 -66
- package/dist/index.d.ts +106 -66
- package/dist/index.js +283 -224
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +286 -227
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/rsc/dist/index.d.ts +0 -4
- package/rsc/dist/rsc-server.d.mts +0 -4
- package/rsc/dist/rsc-server.mjs +11 -0
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/svelte/dist/index.d.mts +13 -16
- package/svelte/dist/index.d.ts +13 -16
- package/svelte/dist/index.js +5 -4
- package/svelte/dist/index.js.map +1 -1
- package/svelte/dist/index.mjs +5 -4
- package/svelte/dist/index.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 3.3.36
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- a3882f5: feat (ai/core): add steps property to streamText result and onFinish callback
|
8
|
+
- 1f590ef: chore (ai): rename roundtrips to steps
|
9
|
+
- 7e82d36: fix (ai/core): pass topK to providers
|
10
|
+
- Updated dependencies [54862e4]
|
11
|
+
- Updated dependencies [1f590ef]
|
12
|
+
- @ai-sdk/react@0.0.58
|
13
|
+
- @ai-sdk/ui-utils@0.0.43
|
14
|
+
- @ai-sdk/solid@0.0.46
|
15
|
+
- @ai-sdk/svelte@0.0.48
|
16
|
+
- @ai-sdk/vue@0.0.48
|
17
|
+
|
18
|
+
## 3.3.35
|
19
|
+
|
20
|
+
### Patch Changes
|
21
|
+
|
22
|
+
- 14210d5: feat (ai/core): add sendUsage information to streamText data stream methods
|
23
|
+
- Updated dependencies [14210d5]
|
24
|
+
- @ai-sdk/ui-utils@0.0.42
|
25
|
+
- @ai-sdk/react@0.0.57
|
26
|
+
- @ai-sdk/solid@0.0.45
|
27
|
+
- @ai-sdk/svelte@0.0.47
|
28
|
+
- @ai-sdk/vue@0.0.47
|
29
|
+
|
3
30
|
## 3.3.34
|
4
31
|
|
5
32
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -355,8 +355,6 @@ type CallSettings = {
|
|
355
355
|
|
356
356
|
The presence penalty is a number between -1 (increase repetition)
|
357
357
|
and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
358
|
-
|
359
|
-
@default 0
|
360
358
|
*/
|
361
359
|
presencePenalty?: number;
|
362
360
|
/**
|
@@ -365,8 +363,6 @@ type CallSettings = {
|
|
365
363
|
|
366
364
|
The frequency penalty is a number between -1 (increase repetition)
|
367
365
|
and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
368
|
-
|
369
|
-
@default 0
|
370
366
|
*/
|
371
367
|
frequencyPenalty?: number;
|
372
368
|
/**
|
@@ -1315,6 +1311,53 @@ type ToToolResultObject<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
|
1315
1311
|
type ToToolResult<TOOLS extends Record<string, CoreTool>> = ToToolResultObject<ToToolsWithDefinedExecute<ToToolsWithExecute<TOOLS>>>;
|
1316
1312
|
type ToToolResultArray<TOOLS extends Record<string, CoreTool>> = Array<ToToolResult<TOOLS>>;
|
1317
1313
|
|
1314
|
+
type StepResult<TOOLS extends Record<string, CoreTool>> = {
|
1315
|
+
/**
|
1316
|
+
The generated text.
|
1317
|
+
*/
|
1318
|
+
readonly text: string;
|
1319
|
+
/**
|
1320
|
+
The tool calls that were made during the generation.
|
1321
|
+
*/
|
1322
|
+
readonly toolCalls: ToToolCallArray<TOOLS>;
|
1323
|
+
/**
|
1324
|
+
The results of the tool calls.
|
1325
|
+
*/
|
1326
|
+
readonly toolResults: ToToolResultArray<TOOLS>;
|
1327
|
+
/**
|
1328
|
+
The reason why the generation finished.
|
1329
|
+
*/
|
1330
|
+
readonly finishReason: FinishReason;
|
1331
|
+
/**
|
1332
|
+
The token usage of the generated text.
|
1333
|
+
*/
|
1334
|
+
readonly usage: LanguageModelUsage$1;
|
1335
|
+
/**
|
1336
|
+
Warnings from the model provider (e.g. unsupported settings)
|
1337
|
+
*/
|
1338
|
+
readonly warnings: CallWarning[] | undefined;
|
1339
|
+
/**
|
1340
|
+
Logprobs for the completion.
|
1341
|
+
`undefined` if the mode does not support logprobs or if was not enabled.
|
1342
|
+
*/
|
1343
|
+
readonly logprobs: LogProbs | undefined;
|
1344
|
+
/**
|
1345
|
+
Optional raw response data.
|
1346
|
+
|
1347
|
+
@deprecated Use `response.headers` instead.
|
1348
|
+
*/
|
1349
|
+
readonly rawResponse?: {
|
1350
|
+
/**
|
1351
|
+
Response headers.
|
1352
|
+
*/
|
1353
|
+
readonly headers?: Record<string, string>;
|
1354
|
+
};
|
1355
|
+
/**
|
1356
|
+
Additional response information.
|
1357
|
+
*/
|
1358
|
+
readonly response: LanguageModelResponseMetadataWithHeaders;
|
1359
|
+
};
|
1360
|
+
|
1318
1361
|
/**
|
1319
1362
|
The result of a `generateText` call.
|
1320
1363
|
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
@@ -1353,55 +1396,18 @@ interface GenerateTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1353
1396
|
*/
|
1354
1397
|
readonly responseMessages: Array<CoreAssistantMessage | CoreToolMessage>;
|
1355
1398
|
/**
|
1356
|
-
|
1357
|
-
|
1399
|
+
Response information for every roundtrip.
|
1400
|
+
You can use this to get information about intermediate steps, such as the tool calls or the response headers.
|
1401
|
+
|
1402
|
+
@deprecated use `steps` instead.
|
1358
1403
|
*/
|
1359
|
-
readonly roundtrips: Array<
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
/**
|
1365
|
-
The tool calls that were made during the generation.
|
1366
|
-
*/
|
1367
|
-
readonly toolCalls: ToToolCallArray<TOOLS>;
|
1368
|
-
/**
|
1369
|
-
The results of the tool calls.
|
1370
|
-
*/
|
1371
|
-
readonly toolResults: ToToolResultArray<TOOLS>;
|
1372
|
-
/**
|
1373
|
-
The reason why the generation finished.
|
1374
|
-
*/
|
1375
|
-
readonly finishReason: FinishReason;
|
1376
|
-
/**
|
1377
|
-
The token usage of the generated text.
|
1378
|
-
*/
|
1379
|
-
readonly usage: LanguageModelUsage$1;
|
1380
|
-
/**
|
1381
|
-
Warnings from the model provider (e.g. unsupported settings)
|
1382
|
-
*/
|
1383
|
-
readonly warnings: CallWarning[] | undefined;
|
1384
|
-
/**
|
1385
|
-
Logprobs for the completion.
|
1386
|
-
`undefined` if the mode does not support logprobs or if was not enabled.
|
1387
|
-
*/
|
1388
|
-
readonly logprobs: LogProbs | undefined;
|
1389
|
-
/**
|
1390
|
-
Optional raw response data.
|
1391
|
-
|
1392
|
-
@deprecated Use `response.headers` instead.
|
1393
|
-
*/
|
1394
|
-
readonly rawResponse?: {
|
1395
|
-
/**
|
1396
|
-
Response headers.
|
1397
|
-
*/
|
1398
|
-
readonly headers?: Record<string, string>;
|
1399
|
-
};
|
1400
|
-
/**
|
1401
|
-
Additional response information.
|
1404
|
+
readonly roundtrips: Array<StepResult<TOOLS>>;
|
1405
|
+
/**
|
1406
|
+
Details for all steps.
|
1407
|
+
You can use this to get information about intermediate steps,
|
1408
|
+
such as the tool calls or the response headers.
|
1402
1409
|
*/
|
1403
|
-
|
1404
|
-
}>;
|
1410
|
+
readonly steps: Array<StepResult<TOOLS>>;
|
1405
1411
|
/**
|
1406
1412
|
Optional raw response data.
|
1407
1413
|
|
@@ -1419,7 +1425,7 @@ interface GenerateTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1419
1425
|
readonly response: LanguageModelResponseMetadataWithHeaders;
|
1420
1426
|
/**
|
1421
1427
|
Logprobs for the completion.
|
1422
|
-
`undefined` if the mode does not support logprobs or if was not enabled.
|
1428
|
+
`undefined` if the mode does not support logprobs or if it was not enabled.
|
1423
1429
|
|
1424
1430
|
@deprecated Will become a provider extension in the future.
|
1425
1431
|
*/
|
@@ -1471,12 +1477,12 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1471
1477
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1472
1478
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1473
1479
|
|
1474
|
-
@param
|
1480
|
+
@param maxSteps - Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
|
1475
1481
|
|
1476
1482
|
@returns
|
1477
1483
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
1478
1484
|
*/
|
1479
|
-
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, _internal: { generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1485
|
+
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, maxSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, _internal: { generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1480
1486
|
/**
|
1481
1487
|
The language model to use.
|
1482
1488
|
*/
|
@@ -1494,7 +1500,7 @@ The tool choice strategy. Default: 'auto'.
|
|
1494
1500
|
*/
|
1495
1501
|
maxAutomaticRoundtrips?: number;
|
1496
1502
|
/**
|
1497
|
-
|
1503
|
+
Maximum number of automatic roundtrips for tool calls.
|
1498
1504
|
|
1499
1505
|
An automatic tool call roundtrip is another LLM call with the
|
1500
1506
|
tool call results when all tool calls of the last assistant
|
@@ -1504,9 +1510,19 @@ A maximum number is required to prevent infinite loops in the
|
|
1504
1510
|
case of misconfigured tools.
|
1505
1511
|
|
1506
1512
|
By default, it's set to 0, which will disable the feature.
|
1513
|
+
|
1514
|
+
@deprecated Use `maxSteps` instead (which is `maxToolRoundtrips` + 1).
|
1507
1515
|
*/
|
1508
1516
|
maxToolRoundtrips?: number;
|
1509
1517
|
/**
|
1518
|
+
Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
|
1519
|
+
|
1520
|
+
A maximum number is required to prevent infinite loops in the case of misconfigured tools.
|
1521
|
+
|
1522
|
+
By default, it's set to 1, which means that only a single LLM call is made.
|
1523
|
+
*/
|
1524
|
+
maxSteps?: number;
|
1525
|
+
/**
|
1510
1526
|
* Optional telemetry configuration (experimental).
|
1511
1527
|
*/
|
1512
1528
|
experimental_telemetry?: TelemetrySettings;
|
@@ -1534,42 +1550,42 @@ A result object for accessing different stream types and additional information.
|
|
1534
1550
|
*/
|
1535
1551
|
interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
1536
1552
|
/**
|
1537
|
-
Warnings from the model provider (e.g. unsupported settings) for the first
|
1553
|
+
Warnings from the model provider (e.g. unsupported settings) for the first step.
|
1538
1554
|
*/
|
1539
1555
|
readonly warnings: CallWarning[] | undefined;
|
1540
1556
|
/**
|
1541
1557
|
The total token usage of the generated response.
|
1542
|
-
When there are multiple
|
1558
|
+
When there are multiple steps, the usage is the sum of all step usages.
|
1543
1559
|
|
1544
1560
|
Resolved when the response is finished.
|
1545
1561
|
*/
|
1546
1562
|
readonly usage: Promise<LanguageModelUsage$1>;
|
1547
1563
|
/**
|
1548
|
-
The reason why the generation finished. Taken from the last
|
1564
|
+
The reason why the generation finished. Taken from the last step.
|
1549
1565
|
|
1550
1566
|
Resolved when the response is finished.
|
1551
1567
|
*/
|
1552
1568
|
readonly finishReason: Promise<FinishReason>;
|
1553
1569
|
/**
|
1554
|
-
Additional provider-specific metadata from the last
|
1570
|
+
Additional provider-specific metadata from the last step.
|
1555
1571
|
Metadata is passed through from the provider to the AI SDK and
|
1556
1572
|
enables provider-specific results that can be fully encapsulated in the provider.
|
1557
1573
|
*/
|
1558
1574
|
readonly experimental_providerMetadata: Promise<ProviderMetadata | undefined>;
|
1559
1575
|
/**
|
1560
|
-
The full text that has been generated by the last
|
1576
|
+
The full text that has been generated by the last step.
|
1561
1577
|
|
1562
1578
|
Resolved when the response is finished.
|
1563
1579
|
*/
|
1564
1580
|
readonly text: Promise<string>;
|
1565
1581
|
/**
|
1566
|
-
The tool calls that have been executed in the last
|
1582
|
+
The tool calls that have been executed in the last step.
|
1567
1583
|
|
1568
1584
|
Resolved when the response is finished.
|
1569
1585
|
*/
|
1570
1586
|
readonly toolCalls: Promise<ToToolCall<TOOLS>[]>;
|
1571
1587
|
/**
|
1572
|
-
The tool results that have been generated in the last
|
1588
|
+
The tool results that have been generated in the last step.
|
1573
1589
|
|
1574
1590
|
Resolved when the all tool executions are finished.
|
1575
1591
|
*/
|
@@ -1586,6 +1602,12 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1586
1602
|
headers?: Record<string, string>;
|
1587
1603
|
};
|
1588
1604
|
/**
|
1605
|
+
Details for all steps.
|
1606
|
+
You can use this to get information about intermediate steps,
|
1607
|
+
such as the tool calls or the response headers.
|
1608
|
+
*/
|
1609
|
+
readonly steps: Promise<Array<StepResult<TOOLS>>>;
|
1610
|
+
/**
|
1589
1611
|
Additional response information.
|
1590
1612
|
*/
|
1591
1613
|
readonly response: Promise<LanguageModelResponseMetadataWithHeaders>;
|
@@ -1619,12 +1641,14 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1619
1641
|
|
1620
1642
|
@param data an optional StreamData object that will be merged into the stream.
|
1621
1643
|
@param getErrorMessage an optional function that converts an error to an error message.
|
1644
|
+
@param sendUsage whether to send the usage information to the client. Defaults to true.
|
1622
1645
|
|
1623
1646
|
@return A data stream.
|
1624
1647
|
*/
|
1625
1648
|
toDataStream(options?: {
|
1626
1649
|
data?: StreamData;
|
1627
1650
|
getErrorMessage?: (error: unknown) => string;
|
1651
|
+
sendUsage?: boolean;
|
1628
1652
|
}): ReadableStream<Uint8Array>;
|
1629
1653
|
/**
|
1630
1654
|
Writes stream data output to a Node.js response-like object.
|
@@ -1651,6 +1675,7 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1651
1675
|
init?: ResponseInit;
|
1652
1676
|
data?: StreamData;
|
1653
1677
|
getErrorMessage?: (error: unknown) => string;
|
1678
|
+
sendUsage?: boolean;
|
1654
1679
|
}): void;
|
1655
1680
|
/**
|
1656
1681
|
Writes text delta output to a Node.js response-like object.
|
@@ -1689,6 +1714,7 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1689
1714
|
init?: ResponseInit;
|
1690
1715
|
data?: StreamData;
|
1691
1716
|
getErrorMessage?: (error: unknown) => string;
|
1717
|
+
sendUsage?: boolean;
|
1692
1718
|
}): Response;
|
1693
1719
|
/**
|
1694
1720
|
Creates a simple text stream response.
|
@@ -1716,7 +1742,7 @@ type TextStreamPart<TOOLS extends Record<string, CoreTool>> = {
|
|
1716
1742
|
} | ({
|
1717
1743
|
type: 'tool-result';
|
1718
1744
|
} & ToToolResult<TOOLS>) | {
|
1719
|
-
type: '
|
1745
|
+
type: 'step-finish';
|
1720
1746
|
finishReason: FinishReason;
|
1721
1747
|
logprobs?: LogProbs;
|
1722
1748
|
usage: LanguageModelUsage$1;
|
@@ -1771,7 +1797,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1771
1797
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1772
1798
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1773
1799
|
|
1774
|
-
@param
|
1800
|
+
@param maxSteps - Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
|
1775
1801
|
|
1776
1802
|
@param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
1777
1803
|
@param onFinish - Callback that is called when the LLM response and all request tool executions
|
@@ -1780,7 +1806,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1780
1806
|
@return
|
1781
1807
|
A result object for accessing different stream types and additional information.
|
1782
1808
|
*/
|
1783
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxToolRoundtrips, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_toolCallStreaming: toolCallStreaming, onChunk, onFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1809
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxToolRoundtrips, maxSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_toolCallStreaming: toolCallStreaming, onChunk, onFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
1784
1810
|
/**
|
1785
1811
|
The language model to use.
|
1786
1812
|
*/
|
@@ -1794,7 +1820,7 @@ The tool choice strategy. Default: 'auto'.
|
|
1794
1820
|
*/
|
1795
1821
|
toolChoice?: CoreToolChoice<TOOLS>;
|
1796
1822
|
/**
|
1797
|
-
|
1823
|
+
Maximum number of automatic roundtrips for tool calls.
|
1798
1824
|
|
1799
1825
|
An automatic tool call roundtrip is another LLM call with the
|
1800
1826
|
tool call results when all tool calls of the last assistant
|
@@ -1804,9 +1830,19 @@ A maximum number is required to prevent infinite loops in the
|
|
1804
1830
|
case of misconfigured tools.
|
1805
1831
|
|
1806
1832
|
By default, it's set to 0, which will disable the feature.
|
1833
|
+
|
1834
|
+
@deprecated Use `maxSteps` instead (which is `maxToolRoundtrips` + 1).
|
1807
1835
|
*/
|
1808
1836
|
maxToolRoundtrips?: number;
|
1809
1837
|
/**
|
1838
|
+
Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
|
1839
|
+
|
1840
|
+
A maximum number is required to prevent infinite loops in the case of misconfigured tools.
|
1841
|
+
|
1842
|
+
By default, it's set to 1, which means that only a single LLM call is made.
|
1843
|
+
*/
|
1844
|
+
maxSteps?: number;
|
1845
|
+
/**
|
1810
1846
|
Optional telemetry configuration (experimental).
|
1811
1847
|
*/
|
1812
1848
|
experimental_telemetry?: TelemetrySettings;
|
@@ -1869,6 +1905,10 @@ Callback that is called when the LLM response and all request tool executions
|
|
1869
1905
|
*/
|
1870
1906
|
response: LanguageModelResponseMetadataWithHeaders;
|
1871
1907
|
/**
|
1908
|
+
Details for all steps.
|
1909
|
+
*/
|
1910
|
+
steps: StepResult<TOOLS>[];
|
1911
|
+
/**
|
1872
1912
|
Warnings from the model provider (e.g. unsupported settings).
|
1873
1913
|
*/
|
1874
1914
|
warnings?: CallWarning[];
|