@ai-sdk/react 2.0.0-canary.21 → 2.0.0-canary.23
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 +28 -0
- package/dist/index.d.mts +7 -21
- package/dist/index.d.ts +7 -21
- package/dist/index.js +146 -277
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -266
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @ai-sdk/react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-canary.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [bedb239]
|
|
8
|
+
- Updated dependencies [507ac1d]
|
|
9
|
+
- Updated dependencies [2b9bbcd]
|
|
10
|
+
- Updated dependencies [f7e8bf4]
|
|
11
|
+
- Updated dependencies [cda32ba]
|
|
12
|
+
- Updated dependencies [50f0362]
|
|
13
|
+
- Updated dependencies [ed675de]
|
|
14
|
+
- Updated dependencies [faf8446]
|
|
15
|
+
- Updated dependencies [64f6d64]
|
|
16
|
+
- ai@5.0.0-canary.24
|
|
17
|
+
- @ai-sdk/provider-utils@3.0.0-canary.19
|
|
18
|
+
|
|
19
|
+
## 2.0.0-canary.22
|
|
20
|
+
|
|
21
|
+
### Major Changes
|
|
22
|
+
|
|
23
|
+
- 40acf9b: feat (ui): introduce ChatStore and ChatTransport
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [40acf9b]
|
|
28
|
+
- @ai-sdk/provider-utils@3.0.0-canary.18
|
|
29
|
+
- ai@5.0.0-canary.23
|
|
30
|
+
|
|
3
31
|
## 2.0.0-canary.21
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { UIMessage, CreateUIMessage, ChatRequestOptions, FileUIPart, UseChatOptions, CompletionRequestOptions, UseCompletionOptions, Schema, DeepPartial } from 'ai';
|
|
1
|
+
import { UIDataTypes, UIMessage, CreateUIMessage, ChatRequestOptions, FileUIPart, UseChatOptions, CompletionRequestOptions, UseCompletionOptions, Schema, DeepPartial } from 'ai';
|
|
2
2
|
export { CreateUIMessage, UIMessage, UseChatOptions, UseCompletionOptions } from 'ai';
|
|
3
3
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
import z from 'zod';
|
|
5
5
|
|
|
6
|
-
type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
6
|
+
type UseChatHelpers<MESSAGE_METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes> = {
|
|
7
7
|
/**
|
|
8
8
|
* The id of the chat.
|
|
9
9
|
*/
|
|
@@ -18,7 +18,7 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
18
18
|
*/
|
|
19
19
|
readonly status: 'submitted' | 'streaming' | 'ready' | 'error';
|
|
20
20
|
/** Current messages in the chat */
|
|
21
|
-
readonly messages: UIMessage<MESSAGE_METADATA>[];
|
|
21
|
+
readonly messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
|
|
22
22
|
/** The error object of the API request */
|
|
23
23
|
readonly error: undefined | Error;
|
|
24
24
|
/**
|
|
@@ -28,7 +28,7 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
28
28
|
* @param message The message to append
|
|
29
29
|
* @param options Additional options to pass to the API call
|
|
30
30
|
*/
|
|
31
|
-
append: (message: CreateUIMessage<MESSAGE_METADATA>, options?: ChatRequestOptions) => Promise<void>;
|
|
31
|
+
append: (message: CreateUIMessage<MESSAGE_METADATA, DATA_TYPES>, options?: ChatRequestOptions) => Promise<void>;
|
|
32
32
|
/**
|
|
33
33
|
* Reload the last AI chat response for the given chat history. If the last
|
|
34
34
|
* message isn't from the assistant, it will request the API to generate a
|
|
@@ -48,7 +48,7 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
48
48
|
* edit the messages on the client, and then trigger the `reload` method
|
|
49
49
|
* manually to regenerate the AI response.
|
|
50
50
|
*/
|
|
51
|
-
setMessages: (messages: UIMessage<MESSAGE_METADATA>[] | ((messages: UIMessage<MESSAGE_METADATA>[]) => UIMessage<MESSAGE_METADATA>[])) => void;
|
|
51
|
+
setMessages: (messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[] | ((messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[]) => UIMessage<MESSAGE_METADATA, DATA_TYPES>[])) => void;
|
|
52
52
|
/** The current value of the input */
|
|
53
53
|
input: string;
|
|
54
54
|
/** setState-powered method to update the input value */
|
|
@@ -66,27 +66,13 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
66
66
|
result: any;
|
|
67
67
|
}) => void;
|
|
68
68
|
};
|
|
69
|
-
declare function useChat<MESSAGE_METADATA
|
|
70
|
-
/**
|
|
71
|
-
* Experimental (React only). When a function is provided, it will be used
|
|
72
|
-
* to prepare the request body for the chat API. This can be useful for
|
|
73
|
-
* customizing the request body based on the messages and data in the chat.
|
|
74
|
-
*
|
|
75
|
-
* @param id The id of the chat.
|
|
76
|
-
* @param messages The current messages in the chat.
|
|
77
|
-
* @param requestBody The request body object passed in the chat request.
|
|
78
|
-
*/
|
|
79
|
-
experimental_prepareRequestBody?: (options: {
|
|
80
|
-
id: string;
|
|
81
|
-
messages: UIMessage<MESSAGE_METADATA>[];
|
|
82
|
-
requestBody?: object;
|
|
83
|
-
}) => unknown;
|
|
69
|
+
declare function useChat<MESSAGE_METADATA = unknown, DATA_TYPES extends Record<string, unknown> = Record<string, unknown>>({ id, initialInput, onToolCall, onFinish, onError, generateId, experimental_throttle: throttleWaitMs, chatStore: chatStoreArg, }?: UseChatOptions<MESSAGE_METADATA, DATA_TYPES> & {
|
|
84
70
|
/**
|
|
85
71
|
Custom throttle wait in ms for the chat messages and data updates.
|
|
86
72
|
Default is undefined, which disables throttling.
|
|
87
73
|
*/
|
|
88
74
|
experimental_throttle?: number;
|
|
89
|
-
}): UseChatHelpers<MESSAGE_METADATA>;
|
|
75
|
+
}): UseChatHelpers<MESSAGE_METADATA, DATA_TYPES>;
|
|
90
76
|
|
|
91
77
|
type UseCompletionHelpers = {
|
|
92
78
|
/** The current completion result */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { UIMessage, CreateUIMessage, ChatRequestOptions, FileUIPart, UseChatOptions, CompletionRequestOptions, UseCompletionOptions, Schema, DeepPartial } from 'ai';
|
|
1
|
+
import { UIDataTypes, UIMessage, CreateUIMessage, ChatRequestOptions, FileUIPart, UseChatOptions, CompletionRequestOptions, UseCompletionOptions, Schema, DeepPartial } from 'ai';
|
|
2
2
|
export { CreateUIMessage, UIMessage, UseChatOptions, UseCompletionOptions } from 'ai';
|
|
3
3
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
import z from 'zod';
|
|
5
5
|
|
|
6
|
-
type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
6
|
+
type UseChatHelpers<MESSAGE_METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes> = {
|
|
7
7
|
/**
|
|
8
8
|
* The id of the chat.
|
|
9
9
|
*/
|
|
@@ -18,7 +18,7 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
18
18
|
*/
|
|
19
19
|
readonly status: 'submitted' | 'streaming' | 'ready' | 'error';
|
|
20
20
|
/** Current messages in the chat */
|
|
21
|
-
readonly messages: UIMessage<MESSAGE_METADATA>[];
|
|
21
|
+
readonly messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
|
|
22
22
|
/** The error object of the API request */
|
|
23
23
|
readonly error: undefined | Error;
|
|
24
24
|
/**
|
|
@@ -28,7 +28,7 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
28
28
|
* @param message The message to append
|
|
29
29
|
* @param options Additional options to pass to the API call
|
|
30
30
|
*/
|
|
31
|
-
append: (message: CreateUIMessage<MESSAGE_METADATA>, options?: ChatRequestOptions) => Promise<void>;
|
|
31
|
+
append: (message: CreateUIMessage<MESSAGE_METADATA, DATA_TYPES>, options?: ChatRequestOptions) => Promise<void>;
|
|
32
32
|
/**
|
|
33
33
|
* Reload the last AI chat response for the given chat history. If the last
|
|
34
34
|
* message isn't from the assistant, it will request the API to generate a
|
|
@@ -48,7 +48,7 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
48
48
|
* edit the messages on the client, and then trigger the `reload` method
|
|
49
49
|
* manually to regenerate the AI response.
|
|
50
50
|
*/
|
|
51
|
-
setMessages: (messages: UIMessage<MESSAGE_METADATA>[] | ((messages: UIMessage<MESSAGE_METADATA>[]) => UIMessage<MESSAGE_METADATA>[])) => void;
|
|
51
|
+
setMessages: (messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[] | ((messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[]) => UIMessage<MESSAGE_METADATA, DATA_TYPES>[])) => void;
|
|
52
52
|
/** The current value of the input */
|
|
53
53
|
input: string;
|
|
54
54
|
/** setState-powered method to update the input value */
|
|
@@ -66,27 +66,13 @@ type UseChatHelpers<MESSAGE_METADATA = unknown> = {
|
|
|
66
66
|
result: any;
|
|
67
67
|
}) => void;
|
|
68
68
|
};
|
|
69
|
-
declare function useChat<MESSAGE_METADATA
|
|
70
|
-
/**
|
|
71
|
-
* Experimental (React only). When a function is provided, it will be used
|
|
72
|
-
* to prepare the request body for the chat API. This can be useful for
|
|
73
|
-
* customizing the request body based on the messages and data in the chat.
|
|
74
|
-
*
|
|
75
|
-
* @param id The id of the chat.
|
|
76
|
-
* @param messages The current messages in the chat.
|
|
77
|
-
* @param requestBody The request body object passed in the chat request.
|
|
78
|
-
*/
|
|
79
|
-
experimental_prepareRequestBody?: (options: {
|
|
80
|
-
id: string;
|
|
81
|
-
messages: UIMessage<MESSAGE_METADATA>[];
|
|
82
|
-
requestBody?: object;
|
|
83
|
-
}) => unknown;
|
|
69
|
+
declare function useChat<MESSAGE_METADATA = unknown, DATA_TYPES extends Record<string, unknown> = Record<string, unknown>>({ id, initialInput, onToolCall, onFinish, onError, generateId, experimental_throttle: throttleWaitMs, chatStore: chatStoreArg, }?: UseChatOptions<MESSAGE_METADATA, DATA_TYPES> & {
|
|
84
70
|
/**
|
|
85
71
|
Custom throttle wait in ms for the chat messages and data updates.
|
|
86
72
|
Default is undefined, which disables throttling.
|
|
87
73
|
*/
|
|
88
74
|
experimental_throttle?: number;
|
|
89
|
-
}): UseChatHelpers<MESSAGE_METADATA>;
|
|
75
|
+
}): UseChatHelpers<MESSAGE_METADATA, DATA_TYPES>;
|
|
90
76
|
|
|
91
77
|
type UseCompletionHelpers = {
|
|
92
78
|
/** The current completion result */
|