ai 3.1.30 → 3.1.32

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.
Files changed (40) hide show
  1. package/dist/index.d.mts +4 -563
  2. package/dist/index.d.ts +4 -563
  3. package/dist/index.js +31 -508
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +33 -496
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +19 -34
  8. package/prompts/dist/index.d.mts +2 -129
  9. package/prompts/dist/index.d.ts +2 -129
  10. package/prompts/dist/index.js.map +1 -1
  11. package/prompts/dist/index.mjs.map +1 -1
  12. package/react/dist/index.d.mts +9 -648
  13. package/react/dist/index.d.ts +9 -648
  14. package/react/dist/index.js +4 -1441
  15. package/react/dist/index.js.map +1 -1
  16. package/react/dist/index.mjs +9 -1429
  17. package/react/dist/index.mjs.map +1 -1
  18. package/rsc/dist/rsc-server.mjs +44 -298
  19. package/rsc/dist/rsc-server.mjs.map +1 -1
  20. package/rsc/dist/rsc-shared.d.mts +5 -1
  21. package/rsc/dist/rsc-shared.mjs +69 -44
  22. package/rsc/dist/rsc-shared.mjs.map +1 -1
  23. package/solid/dist/index.d.mts +7 -465
  24. package/solid/dist/index.d.ts +7 -465
  25. package/solid/dist/index.js +3 -1057
  26. package/solid/dist/index.js.map +1 -1
  27. package/solid/dist/index.mjs +7 -1056
  28. package/solid/dist/index.mjs.map +1 -1
  29. package/svelte/dist/index.d.mts +12 -422
  30. package/svelte/dist/index.d.ts +12 -422
  31. package/svelte/dist/index.js +12 -768
  32. package/svelte/dist/index.js.map +1 -1
  33. package/svelte/dist/index.mjs +10 -762
  34. package/svelte/dist/index.mjs.map +1 -1
  35. package/vue/dist/index.d.mts +7 -459
  36. package/vue/dist/index.d.ts +7 -459
  37. package/vue/dist/index.js +3 -1057
  38. package/vue/dist/index.js.map +1 -1
  39. package/vue/dist/index.mjs +7 -1046
  40. package/vue/dist/index.mjs.map +1 -1
package/dist/index.d.mts CHANGED
@@ -1,3 +1,6 @@
1
+ import { JSONValue, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
2
+ export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, parseComplexResponse, parseStreamPart, readDataStream } from '@ai-sdk/ui-utils';
3
+ export { generateId, generateId as nanoid } from '@ai-sdk/provider-utils';
1
4
  import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning } from '@ai-sdk/provider';
2
5
  export { APICallError, EmptyResponseBodyError, InvalidArgumentError, InvalidDataContentError, InvalidPromptError, InvalidResponseDataError, InvalidToolArgumentsError, JSONParseError, LoadAPIKeyError, NoObjectGeneratedError, NoSuchToolError, RetryError, ToolCallParseError, TypeValidationError, UnsupportedFunctionalityError, UnsupportedJSONSchemaError } from '@ai-sdk/provider';
3
6
  import { z } from 'zod';
@@ -832,24 +835,6 @@ declare function convertToCoreMessages(messages: Array<{
832
835
  toolInvocations?: Array<ToolResult<string, unknown, unknown>>;
833
836
  }>): CoreMessage[];
834
837
 
835
- /**
836
- Typed tool call that is returned by generateText and streamText.
837
- It contains the tool call ID, the tool name, and the tool arguments.
838
- */
839
- interface ToolCall$1<NAME extends string, ARGS> {
840
- /**
841
- ID of the tool call. This ID is used to match the tool call with the tool result.
842
- */
843
- toolCallId: string;
844
- /**
845
- Name of the tool that is being called.
846
- */
847
- toolName: NAME;
848
- /**
849
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
850
- */
851
- args: ARGS;
852
- }
853
838
  type ToToolCall<TOOLS extends Record<string, CoreTool>> = ValueOf<{
854
839
  [NAME in keyof TOOLS]: {
855
840
  type: 'tool-call';
@@ -1235,513 +1220,6 @@ declare class StreamTextResult<TOOLS extends Record<string, CoreTool>> {
1235
1220
  */
1236
1221
  declare const experimental_streamText: typeof streamText;
1237
1222
 
1238
- type AssistantStatus = 'in_progress' | 'awaiting_message';
1239
- type UseAssistantOptions = {
1240
- /**
1241
- * The API endpoint that accepts a `{ threadId: string | null; message: string; }` object and returns an `AssistantResponse` stream.
1242
- * The threadId refers to an existing thread with messages (or is `null` to create a new thread).
1243
- * The message is the next message that should be appended to the thread and sent to the assistant.
1244
- */
1245
- api: string;
1246
- /**
1247
- * An optional string that represents the ID of an existing thread.
1248
- * If not provided, a new thread will be created.
1249
- */
1250
- threadId?: string;
1251
- /**
1252
- * An optional literal that sets the mode of credentials to be used on the request.
1253
- * Defaults to "same-origin".
1254
- */
1255
- credentials?: RequestCredentials;
1256
- /**
1257
- * An optional object of headers to be passed to the API endpoint.
1258
- */
1259
- headers?: Record<string, string> | Headers;
1260
- /**
1261
- * An optional, additional body object to be passed to the API endpoint.
1262
- */
1263
- body?: object;
1264
- /**
1265
- * An optional callback that will be called when the assistant encounters an error.
1266
- */
1267
- onError?: (error: Error) => void;
1268
- };
1269
-
1270
- /**
1271
- * @deprecated use AI SDK 3.1 CoreTool / ToolResult instead
1272
- */
1273
- interface FunctionCall$1 {
1274
- /**
1275
- * The arguments to call the function with, as generated by the model in JSON
1276
- * format. Note that the model does not always generate valid JSON, and may
1277
- * hallucinate parameters not defined by your function schema. Validate the
1278
- * arguments in your code before calling your function.
1279
- */
1280
- arguments?: string;
1281
- /**
1282
- * The name of the function to call.
1283
- */
1284
- name?: string;
1285
- }
1286
- /**
1287
- * @deprecated use AI SDK 3.1 CoreTool / ToolResult instead
1288
- *
1289
- * The tool calls generated by the model, such as function calls.
1290
- */
1291
- interface ToolCall {
1292
- id: string;
1293
- type: string;
1294
- function: {
1295
- name: string;
1296
- arguments: string;
1297
- };
1298
- }
1299
- /**
1300
- * @deprecated use AI SDK 3.1 CoreTool / ToolChoice instead
1301
- *
1302
- * Controls which (if any) function is called by the model.
1303
- * - none means the model will not call a function and instead generates a message.
1304
- * - auto means the model can pick between generating a message or calling a function.
1305
- * - Specifying a particular function via {"type: "function", "function": {"name": "my_function"}} forces the model to call that function.
1306
- * none is the default when no functions are present. auto is the default if functions are present.
1307
- */
1308
- type ToolChoice = 'none' | 'auto' | {
1309
- type: 'function';
1310
- function: {
1311
- name: string;
1312
- };
1313
- };
1314
- /**
1315
- * @deprecated use AI SDK 3.1 CoreTool instead
1316
- *
1317
- * A list of tools the model may call. Currently, only functions are supported as a tool.
1318
- * Use this to provide a list of functions the model may generate JSON inputs for.
1319
- */
1320
- interface Tool {
1321
- type: 'function';
1322
- function: Function;
1323
- }
1324
- /**
1325
- * @deprecated use AI SDK 3.1 CoreTool instead
1326
- */
1327
- interface Function {
1328
- /**
1329
- * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
1330
- * underscores and dashes, with a maximum length of 64.
1331
- */
1332
- name: string;
1333
- /**
1334
- * The parameters the functions accepts, described as a JSON Schema object. See the
1335
- * [guide](/docs/guides/gpt/function-calling) for examples, and the
1336
- * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
1337
- * documentation about the format.
1338
- *
1339
- * To describe a function that accepts no parameters, provide the value
1340
- * `{"type": "object", "properties": {}}`.
1341
- */
1342
- parameters: Record<string, unknown>;
1343
- /**
1344
- * A description of what the function does, used by the model to choose when and
1345
- * how to call the function.
1346
- */
1347
- description?: string;
1348
- }
1349
- type IdGenerator = () => string;
1350
- /**
1351
- Tool invocations are either tool calls or tool results. For each assistant tool call,
1352
- there is one tool invocation. While the call is in progress, the invocation is a tool call.
1353
- Once the call is complete, the invocation is a tool result.
1354
- */
1355
- type ToolInvocation = ToolCall$1<string, any> | ToolResult<string, any, any>;
1356
- /**
1357
- * AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
1358
- */
1359
- interface Message$1 {
1360
- id: string;
1361
- createdAt?: Date;
1362
- content: string;
1363
- tool_call_id?: string;
1364
- /**
1365
- @deprecated Use AI SDK RSC instead: https://sdk.vercel.ai/docs/ai-sdk-rsc
1366
- */
1367
- ui?: string | JSX.Element | JSX.Element[] | null | undefined;
1368
- /**
1369
- * `function` and `tool` roles are deprecated.
1370
- */
1371
- role: 'system' | 'user' | 'assistant' | 'function' | 'data' | 'tool';
1372
- /**
1373
- *
1374
- * If the message has a role of `function`, the `name` field is the name of the function.
1375
- * Otherwise, the name field should not be set.
1376
- */
1377
- name?: string;
1378
- /**
1379
- * @deprecated Use AI SDK 3.1 `toolInvocations` instead.
1380
- *
1381
- * If the assistant role makes a function call, the `function_call` field
1382
- * contains the function call name and arguments. Otherwise, the field should
1383
- * not be set. (Deprecated and replaced by tool_calls.)
1384
- */
1385
- function_call?: string | FunctionCall$1;
1386
- data?: JSONValue;
1387
- /**
1388
- * @deprecated Use AI SDK 3.1 `toolInvocations` instead.
1389
- *
1390
- * If the assistant role makes a tool call, the `tool_calls` field contains
1391
- * the tool call name and arguments. Otherwise, the field should not be set.
1392
- */
1393
- tool_calls?: string | ToolCall[];
1394
- /**
1395
- * Additional message-specific information added on the server via StreamData
1396
- */
1397
- annotations?: JSONValue[] | undefined;
1398
- /**
1399
- Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
1400
- that the assistant made as part of this message.
1401
- */
1402
- toolInvocations?: Array<ToolInvocation>;
1403
- }
1404
- type CreateMessage = Omit<Message$1, 'id'> & {
1405
- id?: Message$1['id'];
1406
- };
1407
- type ChatRequest = {
1408
- messages: Message$1[];
1409
- options?: RequestOptions;
1410
- functions?: Array<Function>;
1411
- function_call?: FunctionCall$1;
1412
- data?: Record<string, string>;
1413
- tools?: Array<Tool>;
1414
- tool_choice?: ToolChoice;
1415
- };
1416
- /**
1417
- * @deprecated Use AI SDK 3.1 `streamText` and `onToolCall` instead.
1418
- */
1419
- type FunctionCallHandler = (chatMessages: Message$1[], functionCall: FunctionCall$1) => Promise<ChatRequest | void>;
1420
- /**
1421
- * @deprecated Use AI SDK 3.1 `streamText` and `onToolCall` instead.
1422
- */
1423
- type ToolCallHandler = (chatMessages: Message$1[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
1424
- type RequestOptions = {
1425
- /**
1426
- An optional object of headers to be passed to the API endpoint.
1427
- */
1428
- headers?: Record<string, string> | Headers;
1429
- /**
1430
- An optional object to be passed to the API endpoint.
1431
- */
1432
- body?: object;
1433
- };
1434
- type ChatRequestOptions = {
1435
- /**
1436
- The options to be passed to the fetch call.
1437
- */
1438
- options?: RequestOptions;
1439
- /**
1440
- @deprecated
1441
- */
1442
- functions?: Array<Function>;
1443
- /**
1444
- @deprecated
1445
- */
1446
- function_call?: FunctionCall$1;
1447
- /**
1448
- @deprecated
1449
- */
1450
- tools?: Array<Tool>;
1451
- /**
1452
- @deprecated
1453
- */
1454
- tool_choice?: ToolChoice;
1455
- /**
1456
- Additional data to be sent to the server.
1457
- */
1458
- data?: Record<string, string>;
1459
- };
1460
- type UseChatOptions = {
1461
- /**
1462
- * The API endpoint that accepts a `{ messages: Message[] }` object and returns
1463
- * a stream of tokens of the AI chat response. Defaults to `/api/chat`.
1464
- */
1465
- api?: string;
1466
- /**
1467
- * A unique identifier for the chat. If not provided, a random one will be
1468
- * generated. When provided, the `useChat` hook with the same `id` will
1469
- * have shared states across components.
1470
- */
1471
- id?: string;
1472
- /**
1473
- * Initial messages of the chat. Useful to load an existing chat history.
1474
- */
1475
- initialMessages?: Message$1[];
1476
- /**
1477
- * Initial input of the chat.
1478
- */
1479
- initialInput?: string;
1480
- /**
1481
- * @deprecated Use AI SDK 3.1 `streamText` and `onToolCall` instead.
1482
- *
1483
- * Callback function to be called when a function call is received.
1484
- * If the function returns a `ChatRequest` object, the request will be sent
1485
- * automatically to the API and will be used to update the chat.
1486
- */
1487
- experimental_onFunctionCall?: FunctionCallHandler;
1488
- /**
1489
- * @deprecated Use AI SDK 3.1 `streamText` and `onToolCall` instead.
1490
- *
1491
- * Callback function to be called when a tool call is received.
1492
- * If the function returns a `ChatRequest` object, the request will be sent
1493
- * automatically to the API and will be used to update the chat.
1494
- */
1495
- experimental_onToolCall?: ToolCallHandler;
1496
- /**
1497
- Optional callback function that is invoked when a tool call is received.
1498
- Intended for automatic client-side tool execution.
1499
-
1500
- You can optionally return a result for the tool call,
1501
- either synchronously or asynchronously.
1502
- */
1503
- onToolCall?: ({ toolCall, }: {
1504
- toolCall: ToolCall$1<string, unknown>;
1505
- }) => void | Promise<unknown> | unknown;
1506
- /**
1507
- * Callback function to be called when the API response is received.
1508
- */
1509
- onResponse?: (response: Response) => void | Promise<void>;
1510
- /**
1511
- * Callback function to be called when the chat is finished streaming.
1512
- */
1513
- onFinish?: (message: Message$1) => void;
1514
- /**
1515
- * Callback function to be called when an error is encountered.
1516
- */
1517
- onError?: (error: Error) => void;
1518
- /**
1519
- * A way to provide a function that is going to be used for ids for messages.
1520
- * If not provided nanoid is used by default.
1521
- */
1522
- generateId?: IdGenerator;
1523
- /**
1524
- * The credentials mode to be used for the fetch request.
1525
- * Possible values are: 'omit', 'same-origin', 'include'.
1526
- * Defaults to 'same-origin'.
1527
- */
1528
- credentials?: RequestCredentials;
1529
- /**
1530
- * HTTP headers to be sent with the API request.
1531
- */
1532
- headers?: Record<string, string> | Headers;
1533
- /**
1534
- * Extra body object to be sent with the API request.
1535
- * @example
1536
- * Send a `sessionId` to the API along with the messages.
1537
- * ```js
1538
- * useChat({
1539
- * body: {
1540
- * sessionId: '123',
1541
- * }
1542
- * })
1543
- * ```
1544
- */
1545
- body?: object;
1546
- /**
1547
- * Whether to send extra message fields such as `message.id` and `message.createdAt` to the API.
1548
- * Defaults to `false`. When set to `true`, the API endpoint might need to
1549
- * handle the extra fields before forwarding the request to the AI service.
1550
- */
1551
- sendExtraMessageFields?: boolean;
1552
- /** Stream mode (default to "stream-data") */
1553
- streamMode?: 'stream-data' | 'text';
1554
- };
1555
- type UseCompletionOptions = {
1556
- /**
1557
- * The API endpoint that accepts a `{ prompt: string }` object and returns
1558
- * a stream of tokens of the AI completion response. Defaults to `/api/completion`.
1559
- */
1560
- api?: string;
1561
- /**
1562
- * An unique identifier for the chat. If not provided, a random one will be
1563
- * generated. When provided, the `useChat` hook with the same `id` will
1564
- * have shared states across components.
1565
- */
1566
- id?: string;
1567
- /**
1568
- * Initial prompt input of the completion.
1569
- */
1570
- initialInput?: string;
1571
- /**
1572
- * Initial completion result. Useful to load an existing history.
1573
- */
1574
- initialCompletion?: string;
1575
- /**
1576
- * Callback function to be called when the API response is received.
1577
- */
1578
- onResponse?: (response: Response) => void | Promise<void>;
1579
- /**
1580
- * Callback function to be called when the completion is finished streaming.
1581
- */
1582
- onFinish?: (prompt: string, completion: string) => void;
1583
- /**
1584
- * Callback function to be called when an error is encountered.
1585
- */
1586
- onError?: (error: Error) => void;
1587
- /**
1588
- * The credentials mode to be used for the fetch request.
1589
- * Possible values are: 'omit', 'same-origin', 'include'.
1590
- * Defaults to 'same-origin'.
1591
- */
1592
- credentials?: RequestCredentials;
1593
- /**
1594
- * HTTP headers to be sent with the API request.
1595
- */
1596
- headers?: Record<string, string> | Headers;
1597
- /**
1598
- * Extra body object to be sent with the API request.
1599
- * @example
1600
- * Send a `sessionId` to the API along with the prompt.
1601
- * ```js
1602
- * useChat({
1603
- * body: {
1604
- * sessionId: '123',
1605
- * }
1606
- * })
1607
- * ```
1608
- */
1609
- body?: object;
1610
- /** Stream mode (default to "stream-data") */
1611
- streamMode?: 'stream-data' | 'text';
1612
- };
1613
- type JSONValue = null | string | number | boolean | {
1614
- [x: string]: JSONValue;
1615
- } | Array<JSONValue>;
1616
- type AssistantMessage = {
1617
- id: string;
1618
- role: 'assistant';
1619
- content: Array<{
1620
- type: 'text';
1621
- text: {
1622
- value: string;
1623
- };
1624
- }>;
1625
- };
1626
- type DataMessage = {
1627
- id?: string;
1628
- role: 'data';
1629
- data: JSONValue;
1630
- };
1631
-
1632
- interface StreamPart<CODE extends string, NAME extends string, TYPE> {
1633
- code: CODE;
1634
- name: NAME;
1635
- parse: (value: JSONValue) => {
1636
- type: NAME;
1637
- value: TYPE;
1638
- };
1639
- }
1640
- declare const textStreamPart: StreamPart<'0', 'text', string>;
1641
- declare const functionCallStreamPart: StreamPart<'1', 'function_call', {
1642
- function_call: FunctionCall$1;
1643
- }>;
1644
- declare const dataStreamPart: StreamPart<'2', 'data', Array<JSONValue>>;
1645
- declare const errorStreamPart: StreamPart<'3', 'error', string>;
1646
- declare const assistantMessageStreamPart: StreamPart<'4', 'assistant_message', AssistantMessage>;
1647
- declare const assistantControlDataStreamPart: StreamPart<'5', 'assistant_control_data', {
1648
- threadId: string;
1649
- messageId: string;
1650
- }>;
1651
- declare const dataMessageStreamPart: StreamPart<'6', 'data_message', DataMessage>;
1652
- declare const toolCallsStreamPart: StreamPart<'7', 'tool_calls', {
1653
- tool_calls: ToolCall[];
1654
- }>;
1655
- declare const messageAnnotationsStreamPart: StreamPart<'8', 'message_annotations', Array<JSONValue>>;
1656
- declare const toolCallStreamPart: StreamPart<'9', 'tool_call', ToolCall$1<string, any>>;
1657
- declare const toolResultStreamPart: StreamPart<'a', 'tool_result', ToolResult<string, any, any>>;
1658
- type StreamParts = typeof textStreamPart | typeof functionCallStreamPart | typeof dataStreamPart | typeof errorStreamPart | typeof assistantMessageStreamPart | typeof assistantControlDataStreamPart | typeof dataMessageStreamPart | typeof toolCallsStreamPart | typeof messageAnnotationsStreamPart | typeof toolCallStreamPart | typeof toolResultStreamPart;
1659
- /**
1660
- * Maps the type of a stream part to its value type.
1661
- */
1662
- type StreamPartValueType = {
1663
- [P in StreamParts as P['name']]: ReturnType<P['parse']>['value'];
1664
- };
1665
- type StreamPartType = ReturnType<typeof textStreamPart.parse> | ReturnType<typeof functionCallStreamPart.parse> | ReturnType<typeof dataStreamPart.parse> | ReturnType<typeof errorStreamPart.parse> | ReturnType<typeof assistantMessageStreamPart.parse> | ReturnType<typeof assistantControlDataStreamPart.parse> | ReturnType<typeof dataMessageStreamPart.parse> | ReturnType<typeof toolCallsStreamPart.parse> | ReturnType<typeof messageAnnotationsStreamPart.parse> | ReturnType<typeof toolCallStreamPart.parse> | ReturnType<typeof toolResultStreamPart.parse>;
1666
- /**
1667
- * The map of prefixes for data in the stream
1668
- *
1669
- * - 0: Text from the LLM response
1670
- * - 1: (OpenAI) function_call responses
1671
- * - 2: custom JSON added by the user using `Data`
1672
- * - 6: (OpenAI) tool_call responses
1673
- *
1674
- * Example:
1675
- * ```
1676
- * 0:Vercel
1677
- * 0:'s
1678
- * 0: AI
1679
- * 0: AI
1680
- * 0: SDK
1681
- * 0: is great
1682
- * 0:!
1683
- * 2: { "someJson": "value" }
1684
- * 1: {"function_call": {"name": "get_current_weather", "arguments": "{\\n\\"location\\": \\"Charlottesville, Virginia\\",\\n\\"format\\": \\"celsius\\"\\n}"}}
1685
- * 6: {"tool_call": {"id": "tool_0", "type": "function", "function": {"name": "get_current_weather", "arguments": "{\\n\\"location\\": \\"Charlottesville, Virginia\\",\\n\\"format\\": \\"celsius\\"\\n}"}}}
1686
- *```
1687
- */
1688
- declare const StreamStringPrefixes: {
1689
- readonly text: "0";
1690
- readonly function_call: "1";
1691
- readonly data: "2";
1692
- readonly error: "3";
1693
- readonly assistant_message: "4";
1694
- readonly assistant_control_data: "5";
1695
- readonly data_message: "6";
1696
- readonly tool_calls: "7";
1697
- readonly message_annotations: "8";
1698
- readonly tool_call: "9";
1699
- readonly tool_result: "a";
1700
- };
1701
- /**
1702
- Parses a stream part from a string.
1703
-
1704
- @param line The string to parse.
1705
- @returns The parsed stream part.
1706
- @throws An error if the string cannot be parsed.
1707
- */
1708
- declare const parseStreamPart: (line: string) => StreamPartType;
1709
- /**
1710
- Prepends a string with a prefix from the `StreamChunkPrefixes`, JSON-ifies it,
1711
- and appends a new line.
1712
-
1713
- It ensures type-safety for the part type and value.
1714
- */
1715
- declare function formatStreamPart<T extends keyof StreamPartValueType>(type: T, value: StreamPartValueType[T]): StreamString;
1716
-
1717
- /**
1718
- * Generates a 7-character random string to use for IDs. Not secure.
1719
- */
1720
- declare const generateId: (size?: number | undefined) => string;
1721
-
1722
- /**
1723
- Converts a ReadableStreamDefaultReader into an async generator that yields
1724
- StreamPart objects.
1725
-
1726
- @param reader
1727
- Reader for the stream to read from.
1728
- @param isAborted
1729
- Optional function that returns true if the request has been aborted.
1730
- If the function returns true, the generator will stop reading the stream.
1731
- If the function is not provided, the generator will not stop reading the stream.
1732
- */
1733
- declare function readDataStream(reader: ReadableStreamDefaultReader<Uint8Array>, { isAborted, }?: {
1734
- isAborted?: () => boolean;
1735
- }): AsyncGenerator<StreamPartType>;
1736
-
1737
- declare function createChunkDecoder(): (chunk: Uint8Array | undefined) => string;
1738
- declare function createChunkDecoder(complex: false): (chunk: Uint8Array | undefined) => string;
1739
- declare function createChunkDecoder(complex: true): (chunk: Uint8Array | undefined) => StreamPartType[];
1740
- declare function createChunkDecoder(complex?: boolean): (chunk: Uint8Array | undefined) => StreamPartType[] | string;
1741
-
1742
- declare const isStreamStringEqualToType: (type: keyof typeof StreamStringPrefixes, value: string) => value is `0:${string}\n` | `1:${string}\n` | `2:${string}\n` | `3:${string}\n` | `4:${string}\n` | `5:${string}\n` | `6:${string}\n` | `7:${string}\n` | `8:${string}\n` | `9:${string}\n` | `a:${string}\n`;
1743
- type StreamString = `${(typeof StreamStringPrefixes)[keyof typeof StreamStringPrefixes]}:${string}\n`;
1744
-
1745
1223
  declare interface AzureChatCompletions {
1746
1224
  id: string;
1747
1225
  created: Date;
@@ -2457,43 +1935,6 @@ declare function streamToResponse(res: ReadableStream, response: ServerResponse,
2457
1935
  status?: number;
2458
1936
  }, data?: StreamData): void;
2459
1937
 
2460
- /**
2461
- * This is a naive implementation of the streaming React response API.
2462
- * Currently, it can carry the original raw content, data payload and a special
2463
- * UI payload and stream them via "rows" (nested promises).
2464
- * It must be used inside Server Actions so Flight can encode the React elements.
2465
- *
2466
- * It is naive as unlike the StreamingTextResponse, it does not send the diff
2467
- * between the rows, but flushing the full payload on each row.
2468
- */
2469
-
2470
- type UINode = string | JSX.Element | JSX.Element[] | null | undefined;
2471
- type Payload = {
2472
- ui: UINode | Promise<UINode>;
2473
- content: string;
2474
- };
2475
- /**
2476
- @deprecated Use AI SDK RSC instead: https://sdk.vercel.ai/docs/ai-sdk-rsc
2477
- */
2478
- type ReactResponseRow = Payload & {
2479
- next: null | Promise<ReactResponseRow>;
2480
- };
2481
- /**
2482
- A utility class for streaming React responses.
2483
-
2484
- @deprecated Use AI SDK RSC instead: https://sdk.vercel.ai/docs/ai-sdk-rsc
2485
- */
2486
- declare class experimental_StreamingReactResponse {
2487
- constructor(res: ReadableStream, options?: {
2488
- ui?: (message: {
2489
- content: string;
2490
- data?: JSONValue[];
2491
- }) => UINode | Promise<UINode>;
2492
- data?: StreamData;
2493
- generateId?: IdGenerator;
2494
- });
2495
- }
2496
-
2497
1938
  /**
2498
1939
  * A utility class for streaming text responses.
2499
1940
  */
@@ -2501,4 +1942,4 @@ declare class StreamingTextResponse extends Response {
2501
1942
  constructor(res: ReadableStream, init?: ResponseInit, data?: StreamData);
2502
1943
  }
2503
1944
 
2504
- export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantMessage, AssistantResponse, AssistantStatus, CallWarning, ChatRequest, ChatRequestOptions, CohereStream, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, CreateMessage, DataContent, DataMessage, DeepPartial, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, Function, FunctionCall$1 as FunctionCall, FunctionCallHandler, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, IdGenerator, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, JSONValue, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, Message$1 as Message, MistralStream, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReactResponseRow, ReplicateStream, RequestOptions, StreamData, StreamObjectResult, StreamPart, StreamString, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, Tool, ToolCall, ToolCallHandler, ToolCallPart, ToolCallPayload, ToolChoice, ToolContent, ToolInvocation, ToolResultPart, UseAssistantOptions, UseChatOptions, UseCompletionOptions, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, createCallbacksTransformer, createChunkDecoder, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_StreamData, experimental_StreamingReactResponse, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, formatStreamPart, generateId, generateObject, generateText, isStreamStringEqualToType, generateId as nanoid, parseStreamPart, readDataStream, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
1945
+ export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DeepPartial, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_StreamData, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateObject, generateText, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };