@ai-sdk/react 1.2.5 → 2.0.0-canary.0

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/react
2
2
 
3
+ ## 2.0.0-canary.0
4
+
5
+ ### Major Changes
6
+
7
+ - d5f588f: AI SDK 5
8
+ - 9477ebb: chore (ui): remove useAssistant hook (**breaking change**)
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [d5f588f]
13
+ - Updated dependencies [9477ebb]
14
+ - @ai-sdk/provider-utils@3.0.0-canary.0
15
+ - @ai-sdk/ui-utils@2.0.0-canary.0
16
+
3
17
  ## 1.2.5
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -4,4 +4,4 @@
4
4
 
5
5
  - [`useChat`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-chat) hook
6
6
  - [`useCompletion`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion) hook
7
- - [`useAssistant`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-assistant) hook
7
+ - [`useObject`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-object) hook
package/dist/index.d.mts CHANGED
@@ -1,67 +1,8 @@
1
- import { Message, CreateMessage, AssistantStatus, UseAssistantOptions, UIMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, Schema, DeepPartial } from '@ai-sdk/ui-utils';
1
+ import { UIMessage, Message, CreateMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, Schema, DeepPartial } from '@ai-sdk/ui-utils';
2
2
  export { CreateMessage, Message, UseChatOptions, UseCompletionOptions } from '@ai-sdk/ui-utils';
3
3
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
  import z from 'zod';
5
5
 
6
- type UseAssistantHelpers = {
7
- /**
8
- * The current array of chat messages.
9
- */
10
- messages: Message[];
11
- /**
12
- * Update the message store with a new array of messages.
13
- */
14
- setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
15
- /**
16
- * The current thread ID.
17
- */
18
- threadId: string | undefined;
19
- /**
20
- * Set the current thread ID. Specifying a thread ID will switch to that thread, if it exists. If set to 'undefined', a new thread will be created. For both cases, `threadId` will be updated with the new value and `messages` will be cleared.
21
- */
22
- setThreadId: (threadId: string | undefined) => void;
23
- /**
24
- * The current value of the input field.
25
- */
26
- input: string;
27
- /**
28
- * Append a user message to the chat list. This triggers the API call to fetch
29
- * the assistant's response.
30
- * @param message The message to append
31
- * @param requestOptions Additional options to pass to the API call
32
- */
33
- append: (message: Message | CreateMessage, requestOptions?: {
34
- data?: Record<string, string>;
35
- }) => Promise<void>;
36
- /**
37
- Abort the current request immediately, keep the generated tokens if any.
38
- */
39
- stop: () => void;
40
- /**
41
- * setState-powered method to update the input value.
42
- */
43
- setInput: React.Dispatch<React.SetStateAction<string>>;
44
- /**
45
- * Handler for the `onChange` event of the input field to control the input's value.
46
- */
47
- handleInputChange: (event: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => void;
48
- /**
49
- * Form submission handler that automatically resets the input field and appends a user message.
50
- */
51
- submitMessage: (event?: React.FormEvent<HTMLFormElement>, requestOptions?: {
52
- data?: Record<string, string>;
53
- }) => Promise<void>;
54
- /**
55
- * The current status of the assistant. This can be used to show a loading indicator.
56
- */
57
- status: AssistantStatus;
58
- /**
59
- * The error thrown during the assistant message processing, if any.
60
- */
61
- error: undefined | Error;
62
- };
63
- declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, fetch, }: UseAssistantOptions): UseAssistantHelpers;
64
-
65
6
  type UseChatHelpers = {
66
7
  /** Current messages in the chat */
67
8
  messages: UIMessage[];
@@ -294,4 +235,4 @@ declare function useObject<RESULT, INPUT = any>({ api, id, schema, // required,
294
235
  initialValue, fetch, onError, onFinish, headers, credentials, }: Experimental_UseObjectOptions<RESULT>): Experimental_UseObjectHelpers<RESULT, INPUT>;
295
236
  declare const experimental_useObject: typeof useObject;
296
237
 
297
- export { Experimental_UseObjectHelpers, Experimental_UseObjectOptions, UseAssistantHelpers, UseChatHelpers, UseCompletionHelpers, experimental_useObject, useAssistant, useChat, useCompletion };
238
+ export { Experimental_UseObjectHelpers, Experimental_UseObjectOptions, UseChatHelpers, UseCompletionHelpers, experimental_useObject, useChat, useCompletion };
package/dist/index.d.ts CHANGED
@@ -1,67 +1,8 @@
1
- import { Message, CreateMessage, AssistantStatus, UseAssistantOptions, UIMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, Schema, DeepPartial } from '@ai-sdk/ui-utils';
1
+ import { UIMessage, Message, CreateMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, Schema, DeepPartial } from '@ai-sdk/ui-utils';
2
2
  export { CreateMessage, Message, UseChatOptions, UseCompletionOptions } from '@ai-sdk/ui-utils';
3
3
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
  import z from 'zod';
5
5
 
6
- type UseAssistantHelpers = {
7
- /**
8
- * The current array of chat messages.
9
- */
10
- messages: Message[];
11
- /**
12
- * Update the message store with a new array of messages.
13
- */
14
- setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
15
- /**
16
- * The current thread ID.
17
- */
18
- threadId: string | undefined;
19
- /**
20
- * Set the current thread ID. Specifying a thread ID will switch to that thread, if it exists. If set to 'undefined', a new thread will be created. For both cases, `threadId` will be updated with the new value and `messages` will be cleared.
21
- */
22
- setThreadId: (threadId: string | undefined) => void;
23
- /**
24
- * The current value of the input field.
25
- */
26
- input: string;
27
- /**
28
- * Append a user message to the chat list. This triggers the API call to fetch
29
- * the assistant's response.
30
- * @param message The message to append
31
- * @param requestOptions Additional options to pass to the API call
32
- */
33
- append: (message: Message | CreateMessage, requestOptions?: {
34
- data?: Record<string, string>;
35
- }) => Promise<void>;
36
- /**
37
- Abort the current request immediately, keep the generated tokens if any.
38
- */
39
- stop: () => void;
40
- /**
41
- * setState-powered method to update the input value.
42
- */
43
- setInput: React.Dispatch<React.SetStateAction<string>>;
44
- /**
45
- * Handler for the `onChange` event of the input field to control the input's value.
46
- */
47
- handleInputChange: (event: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => void;
48
- /**
49
- * Form submission handler that automatically resets the input field and appends a user message.
50
- */
51
- submitMessage: (event?: React.FormEvent<HTMLFormElement>, requestOptions?: {
52
- data?: Record<string, string>;
53
- }) => Promise<void>;
54
- /**
55
- * The current status of the assistant. This can be used to show a loading indicator.
56
- */
57
- status: AssistantStatus;
58
- /**
59
- * The error thrown during the assistant message processing, if any.
60
- */
61
- error: undefined | Error;
62
- };
63
- declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, fetch, }: UseAssistantOptions): UseAssistantHelpers;
64
-
65
6
  type UseChatHelpers = {
66
7
  /** Current messages in the chat */
67
8
  messages: UIMessage[];
@@ -294,4 +235,4 @@ declare function useObject<RESULT, INPUT = any>({ api, id, schema, // required,
294
235
  initialValue, fetch, onError, onFinish, headers, credentials, }: Experimental_UseObjectOptions<RESULT>): Experimental_UseObjectHelpers<RESULT, INPUT>;
295
236
  declare const experimental_useObject: typeof useObject;
296
237
 
297
- export { Experimental_UseObjectHelpers, Experimental_UseObjectOptions, UseAssistantHelpers, UseChatHelpers, UseCompletionHelpers, experimental_useObject, useAssistant, useChat, useCompletion };
238
+ export { Experimental_UseObjectHelpers, Experimental_UseObjectOptions, UseChatHelpers, UseCompletionHelpers, experimental_useObject, useChat, useCompletion };