ai 3.3.35 → 3.3.37
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 +104 -68
- package/dist/index.d.ts +104 -68
- package/dist/index.js +265 -213
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +268 -216
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- 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.37
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies [273f696]
|
8
|
+
- @ai-sdk/provider-utils@1.0.19
|
9
|
+
- @ai-sdk/react@0.0.59
|
10
|
+
- @ai-sdk/solid@0.0.47
|
11
|
+
- @ai-sdk/svelte@0.0.49
|
12
|
+
- @ai-sdk/ui-utils@0.0.44
|
13
|
+
- @ai-sdk/vue@0.0.49
|
14
|
+
|
15
|
+
## 3.3.36
|
16
|
+
|
17
|
+
### Patch Changes
|
18
|
+
|
19
|
+
- a3882f5: feat (ai/core): add steps property to streamText result and onFinish callback
|
20
|
+
- 1f590ef: chore (ai): rename roundtrips to steps
|
21
|
+
- 7e82d36: fix (ai/core): pass topK to providers
|
22
|
+
- Updated dependencies [54862e4]
|
23
|
+
- Updated dependencies [1f590ef]
|
24
|
+
- @ai-sdk/react@0.0.58
|
25
|
+
- @ai-sdk/ui-utils@0.0.43
|
26
|
+
- @ai-sdk/solid@0.0.46
|
27
|
+
- @ai-sdk/svelte@0.0.48
|
28
|
+
- @ai-sdk/vue@0.0.48
|
29
|
+
|
3
30
|
## 3.3.35
|
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>;
|
@@ -1720,7 +1742,7 @@ type TextStreamPart<TOOLS extends Record<string, CoreTool>> = {
|
|
1720
1742
|
} | ({
|
1721
1743
|
type: 'tool-result';
|
1722
1744
|
} & ToToolResult<TOOLS>) | {
|
1723
|
-
type: '
|
1745
|
+
type: 'step-finish';
|
1724
1746
|
finishReason: FinishReason;
|
1725
1747
|
logprobs?: LogProbs;
|
1726
1748
|
usage: LanguageModelUsage$1;
|
@@ -1775,7 +1797,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1775
1797
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1776
1798
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1777
1799
|
|
1778
|
-
@param
|
1800
|
+
@param maxSteps - Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
|
1779
1801
|
|
1780
1802
|
@param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
1781
1803
|
@param onFinish - Callback that is called when the LLM response and all request tool executions
|
@@ -1784,7 +1806,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1784
1806
|
@return
|
1785
1807
|
A result object for accessing different stream types and additional information.
|
1786
1808
|
*/
|
1787
|
-
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 & {
|
1788
1810
|
/**
|
1789
1811
|
The language model to use.
|
1790
1812
|
*/
|
@@ -1798,7 +1820,7 @@ The tool choice strategy. Default: 'auto'.
|
|
1798
1820
|
*/
|
1799
1821
|
toolChoice?: CoreToolChoice<TOOLS>;
|
1800
1822
|
/**
|
1801
|
-
|
1823
|
+
Maximum number of automatic roundtrips for tool calls.
|
1802
1824
|
|
1803
1825
|
An automatic tool call roundtrip is another LLM call with the
|
1804
1826
|
tool call results when all tool calls of the last assistant
|
@@ -1808,9 +1830,19 @@ A maximum number is required to prevent infinite loops in the
|
|
1808
1830
|
case of misconfigured tools.
|
1809
1831
|
|
1810
1832
|
By default, it's set to 0, which will disable the feature.
|
1833
|
+
|
1834
|
+
@deprecated Use `maxSteps` instead (which is `maxToolRoundtrips` + 1).
|
1811
1835
|
*/
|
1812
1836
|
maxToolRoundtrips?: number;
|
1813
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
|
+
/**
|
1814
1846
|
Optional telemetry configuration (experimental).
|
1815
1847
|
*/
|
1816
1848
|
experimental_telemetry?: TelemetrySettings;
|
@@ -1873,6 +1905,10 @@ Callback that is called when the LLM response and all request tool executions
|
|
1873
1905
|
*/
|
1874
1906
|
response: LanguageModelResponseMetadataWithHeaders;
|
1875
1907
|
/**
|
1908
|
+
Details for all steps.
|
1909
|
+
*/
|
1910
|
+
steps: StepResult<TOOLS>[];
|
1911
|
+
/**
|
1876
1912
|
Warnings from the model provider (e.g. unsupported settings).
|
1877
1913
|
*/
|
1878
1914
|
warnings?: CallWarning[];
|
@@ -3071,10 +3107,10 @@ declare class StreamingTextResponse extends Response {
|
|
3071
3107
|
constructor(res: ReadableStream, init?: ResponseInit, data?: StreamData);
|
3072
3108
|
}
|
3073
3109
|
|
3074
|
-
declare const generateId: () => string;
|
3110
|
+
declare const generateId: (size?: number) => string;
|
3075
3111
|
/**
|
3076
3112
|
@deprecated Use `generateId` instead.
|
3077
3113
|
*/
|
3078
|
-
declare const nanoid: () => string;
|
3114
|
+
declare const nanoid: (size?: number) => string;
|
3079
3115
|
|
3080
3116
|
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, Experimental_LanguageModelV1Middleware, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LanguageModelResponseMetadata, LanguageModelResponseMetadataWithHeaders, LanguageModelUsage, LogProbs, MessageConversionError, MistralStream, NoObjectGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, Provider, ProviderMetadata, ReplicateStream, RetryError, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertToCoreMessages, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_Provider, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_customProvider, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, experimental_wrapLanguageModel, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|