@ai-sdk/vue 1.2.12 → 2.0.0-alpha.1

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,63 +1,287 @@
1
1
  # @ai-sdk/vue
2
2
 
3
- ## 1.2.12
3
+ ## 2.0.0-alpha.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - b54cb59: fix (ai-sdk/vue): fix status reactivity
7
+ - Updated dependencies [b346545]
8
+ - Updated dependencies [109c0ac]
9
+ - ai@5.0.0-alpha.1
10
+ - @ai-sdk/provider-utils@3.0.0-alpha.1
8
11
 
9
- ## 1.2.11
12
+ ## 2.0.0-canary.23
10
13
 
11
14
  ### Patch Changes
12
15
 
13
- - Updated dependencies [d87b9d1]
14
- - @ai-sdk/provider-utils@2.2.8
15
- - @ai-sdk/ui-utils@1.2.11
16
+ - Updated dependencies [bedb239]
17
+ - Updated dependencies [507ac1d]
18
+ - Updated dependencies [2b9bbcd]
19
+ - Updated dependencies [f7e8bf4]
20
+ - Updated dependencies [cda32ba]
21
+ - Updated dependencies [50f0362]
22
+ - Updated dependencies [ed675de]
23
+ - Updated dependencies [faf8446]
24
+ - Updated dependencies [64f6d64]
25
+ - ai@5.0.0-canary.24
26
+ - @ai-sdk/provider-utils@3.0.0-canary.19
16
27
 
17
- ## 1.2.10
28
+ ## 2.0.0-canary.22
29
+
30
+ ### Major Changes
31
+
32
+ - 40acf9b: feat (ui): introduce ChatStore and ChatTransport
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [40acf9b]
37
+ - @ai-sdk/provider-utils@3.0.0-canary.18
38
+ - ai@5.0.0-canary.23
39
+
40
+ ## 2.0.0-canary.21
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [e7dc6c7]
45
+ - Updated dependencies [a34eb39]
46
+ - Updated dependencies [b33ed7a]
47
+ - Updated dependencies [765f1cd]
48
+ - ai@5.0.0-canary.22
49
+
50
+ ## 2.0.0-canary.20
51
+
52
+ ### Patch Changes
53
+
54
+ - cff5a9e: fix (ai-sdk/vue): fix status reactivity
55
+ - Updated dependencies [d964901]
56
+ - Updated dependencies [0560977]
57
+ - Updated dependencies [66af894]
58
+ - Updated dependencies [516be5b]
59
+ - Updated dependencies [bfbfc4c]
60
+ - Updated dependencies [ea7a7c9]
61
+ - Updated dependencies [1409e13]
62
+ - ai@5.0.0-canary.21
63
+ - @ai-sdk/provider-utils@3.0.0-canary.17
64
+
65
+ ## 2.0.0-canary.19
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies [13fef90]
70
+ - Updated dependencies [e90d45d]
71
+ - Updated dependencies [bc3109f]
72
+ - Updated dependencies [496bbc1]
73
+ - Updated dependencies [da70d79]
74
+ - Updated dependencies [bcea599]
75
+ - Updated dependencies [48d675a]
76
+ - Updated dependencies [c7710a9]
77
+ - Updated dependencies [87b828f]
78
+ - Updated dependencies [35fc02c]
79
+ - Updated dependencies [b983b51]
80
+ - ai@5.0.0-canary.20
81
+ - @ai-sdk/provider-utils@3.0.0-canary.16
82
+
83
+ ## 2.0.0-canary.18
84
+
85
+ ### Patch Changes
86
+
87
+ - Updated dependencies [2d03e19]
88
+ - Updated dependencies [319b989]
89
+ - Updated dependencies [441d042]
90
+ - Updated dependencies [dcc549b]
91
+ - Updated dependencies [cb2b53a]
92
+ - Updated dependencies [e244a78]
93
+ - ai@5.0.0-canary.19
94
+
95
+ ## 2.0.0-canary.17
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [a571d6e]
100
+ - Updated dependencies [c60f895]
101
+ - Updated dependencies [332167b]
102
+ - Updated dependencies [a8c8bd5]
103
+ - Updated dependencies [a662dea]
104
+ - Updated dependencies [41fa418]
105
+ - @ai-sdk/provider-utils@3.0.0-canary.15
106
+ - ai@5.0.0-canary.18
107
+
108
+ ## 2.0.0-canary.16
109
+
110
+ ### Patch Changes
111
+
112
+ - Updated dependencies [f04fb4a]
113
+ - Updated dependencies [fd1924b]
114
+ - Updated dependencies [957b739]
115
+ - Updated dependencies [fafc3f2]
116
+ - Updated dependencies [c9ad635]
117
+ - Updated dependencies [9bd5ab5]
118
+ - Updated dependencies [92cb0a2]
119
+ - ai@5.0.0-canary.17
120
+ - @ai-sdk/provider-utils@3.0.0-canary.14
121
+
122
+ ## 2.0.0-canary.15
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies [ec78cdc]
127
+ - Updated dependencies [9b4d074]
128
+ - Updated dependencies [8b86e99]
129
+ - Updated dependencies [28ad69e]
130
+ - Updated dependencies [2524fc7]
131
+ - Updated dependencies [ec5933d]
132
+ - Updated dependencies [175b868]
133
+ - ai@5.0.0-canary.16
134
+
135
+ ## 2.0.0-canary.14
136
+
137
+ ### Patch Changes
138
+
139
+ - Updated dependencies [d9209ca]
140
+ - Updated dependencies [ea27cc6]
141
+ - Updated dependencies [0ff02bb]
142
+ - Updated dependencies [4bfe9ec]
143
+ - Updated dependencies [2877a74]
144
+ - ai@5.0.0-canary.15
145
+ - @ai-sdk/provider-utils@3.0.0-canary.13
146
+
147
+ ## 2.0.0-canary.13
148
+
149
+ ### Patch Changes
150
+
151
+ - Updated dependencies [9bf7291]
152
+ - Updated dependencies [4617fab]
153
+ - Updated dependencies [a76a62b]
154
+ - ai@5.0.0-canary.14
155
+ - @ai-sdk/provider-utils@3.0.0-canary.12
156
+
157
+ ## 2.0.0-canary.12
158
+
159
+ ### Patch Changes
160
+
161
+ - Updated dependencies [14cb3be]
162
+ - Updated dependencies [66962ed]
163
+ - Updated dependencies [9301f86]
164
+ - ai@5.0.0-canary.13
165
+ - @ai-sdk/provider-utils@3.0.0-canary.11
166
+
167
+ ## 2.0.0-canary.11
18
168
 
19
169
  ### Patch Changes
20
170
 
21
- - Updated dependencies [6c59ae7]
22
- - @ai-sdk/ui-utils@1.2.10
171
+ - ai@5.0.0-canary.12
172
+ - @ai-sdk/provider-utils@3.0.0-canary.10
23
173
 
24
- ## 1.2.9
174
+ ## 2.0.0-canary.10
25
175
 
26
176
  ### Patch Changes
27
177
 
28
- - 77b2097: fix(append): support Message.experimental_attachments alongside ChatRequestOptions
29
- - Updated dependencies [62181ef]
30
- - @ai-sdk/ui-utils@1.2.9
178
+ - Updated dependencies [8e64e9c]
179
+ - ai@5.0.0-canary.11
180
+ - @ai-sdk/provider-utils@3.0.0-canary.9
31
181
 
32
- ## 1.2.8
182
+ ## 2.0.0-canary.9
33
183
 
34
184
  ### Patch Changes
35
185
 
36
- - @ai-sdk/provider-utils@2.2.7
37
- - @ai-sdk/ui-utils@1.2.8
186
+ - Updated dependencies [d8aeaef]
187
+ - Updated dependencies [3e10408]
188
+ - ai@5.0.0-canary.10
38
189
 
39
- ## 1.2.7
190
+ ## 2.0.0-canary.8
40
191
 
41
192
  ### Patch Changes
42
193
 
43
- - @ai-sdk/provider-utils@2.2.6
44
- - @ai-sdk/ui-utils@1.2.7
194
+ - Updated dependencies [a847c3e]
195
+ - Updated dependencies [5d142ab]
196
+ - Updated dependencies [cb9c9e4]
197
+ - Updated dependencies [8aa9e20]
198
+ - Updated dependencies [b32e192]
199
+ - ai@5.0.0-canary.9
200
+ - @ai-sdk/provider-utils@3.0.0-canary.8
45
201
 
46
- ## 1.2.6
202
+ ## 2.0.0-canary.7
47
203
 
48
204
  ### Patch Changes
49
205
 
50
- - Updated dependencies [c21fa6d]
51
- - @ai-sdk/provider-utils@2.2.5
52
- - @ai-sdk/ui-utils@1.2.6
206
+ - Updated dependencies [5d1e3ba]
207
+ - Updated dependencies [26735b5]
208
+ - Updated dependencies [14c9410]
209
+ - Updated dependencies [7827a49]
210
+ - Updated dependencies [bd8a36c]
211
+ - Updated dependencies [b6f9f3c]
212
+ - Updated dependencies [92c8e66]
213
+ - Updated dependencies [fd65bc6]
214
+ - Updated dependencies [5bdff05]
215
+ - ai@5.0.0-canary.8
216
+ - @ai-sdk/provider-utils@3.0.0-canary.7
217
+
218
+ ## 2.0.0-canary.6
219
+
220
+ ### Patch Changes
221
+
222
+ - Updated dependencies [0b78e17]
223
+ - Updated dependencies [6fba4c7]
224
+ - Updated dependencies [3e3b9df]
225
+ - Updated dependencies [1766ede]
226
+ - Updated dependencies [f10304b]
227
+ - ai@5.0.0-canary.7
228
+ - @ai-sdk/provider-utils@3.0.0-canary.6
229
+
230
+ ## 2.0.0-canary.5
231
+
232
+ ### Patch Changes
233
+
234
+ - ai@5.0.0-canary.6
235
+ - @ai-sdk/provider-utils@3.0.0-canary.5
236
+
237
+ ## 2.0.0-canary.4
238
+
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies [b71fe8d]
242
+ - Updated dependencies [d91b50d]
243
+ - ai@5.0.0-canary.5
244
+ - @ai-sdk/provider-utils@3.0.0-canary.4
245
+
246
+ ## 2.0.0-canary.3
247
+
248
+ ### Patch Changes
249
+
250
+ - Updated dependencies [a166433]
251
+ - Updated dependencies [9f95b35]
252
+ - @ai-sdk/provider-utils@3.0.0-canary.3
253
+ - @ai-sdk/ui-utils@2.0.0-canary.3
254
+
255
+ ## 2.0.0-canary.2
256
+
257
+ ### Patch Changes
258
+
259
+ - @ai-sdk/provider-utils@3.0.0-canary.2
260
+ - @ai-sdk/ui-utils@2.0.0-canary.2
261
+
262
+ ## 2.0.0-canary.1
263
+
264
+ ### Patch Changes
265
+
266
+ - Updated dependencies [060370c]
267
+ - Updated dependencies [0c0c0b3]
268
+ - Updated dependencies [63d791d]
269
+ - @ai-sdk/provider-utils@3.0.0-canary.1
270
+ - @ai-sdk/ui-utils@2.0.0-canary.1
271
+
272
+ ## 2.0.0-canary.0
273
+
274
+ ### Major Changes
53
275
 
54
- ## 1.2.5
276
+ - d5f588f: AI SDK 5
277
+ - 9477ebb: chore (ui): remove useAssistant hook (**breaking change**)
55
278
 
56
279
  ### Patch Changes
57
280
 
58
- - Updated dependencies [2c19b9a]
59
- - @ai-sdk/provider-utils@2.2.4
60
- - @ai-sdk/ui-utils@1.2.5
281
+ - Updated dependencies [d5f588f]
282
+ - Updated dependencies [9477ebb]
283
+ - @ai-sdk/provider-utils@3.0.0-canary.0
284
+ - @ai-sdk/ui-utils@2.0.0-canary.0
61
285
 
62
286
  ## 1.2.4
63
287
 
package/README.md CHANGED
@@ -4,4 +4,3 @@
4
4
 
5
5
  - [`useChat`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) composable
6
6
  - [`useCompletion`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-completion) composable
7
- - [`useAssistant`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-assistant) composable
package/dist/index.d.mts CHANGED
@@ -1,17 +1,17 @@
1
- import { UIMessage, Message, CreateMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, AssistantStatus, UseAssistantOptions } from '@ai-sdk/ui-utils';
2
- export { CreateMessage, Message, UIMessage, UseChatOptions, UseCompletionOptions } from '@ai-sdk/ui-utils';
3
- import { Ref, ComputedRef } from 'vue';
1
+ import { UIMessage, CreateUIMessage, ChatRequestOptions, FileUIPart, OriginalUseChatOptions, JSONValue, CompletionRequestOptions, UseCompletionOptions } from 'ai';
2
+ export { CreateUIMessage, UIMessage, UseChatOptions, UseCompletionOptions } from 'ai';
3
+ import { Ref } from 'vue';
4
4
 
5
- type UseChatHelpers = {
5
+ type UseChatHelpers<MESSAGE_METADATA> = {
6
6
  /** Current messages in the chat */
7
- messages: Ref<UIMessage[]>;
7
+ messages: Ref<UIMessage<MESSAGE_METADATA>[]>;
8
8
  /** The error object of the API request */
9
9
  error: Ref<undefined | Error>;
10
10
  /**
11
11
  * Append a user message to the chat list. This triggers the API call to fetch
12
12
  * the assistant's response.
13
13
  */
14
- append: (message: Message | CreateMessage, chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
14
+ append: (message: UIMessage<MESSAGE_METADATA> | CreateUIMessage<MESSAGE_METADATA>, chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
15
15
  /**
16
16
  * Reload the last AI chat response for the given chat history. If the last
17
17
  * message isn't from the assistant, it will request the API to generate a
@@ -27,19 +27,15 @@ type UseChatHelpers = {
27
27
  * edit the messages on the client, and then trigger the `reload` method
28
28
  * manually to regenerate the AI response.
29
29
  */
30
- setMessages: (messages: Message[] | ((messages: Message[]) => Message[])) => void;
30
+ setMessages: (messages: UIMessage<MESSAGE_METADATA>[] | ((messages: UIMessage<MESSAGE_METADATA>[]) => UIMessage<MESSAGE_METADATA>[])) => void;
31
31
  /** The current value of the input */
32
32
  input: Ref<string>;
33
33
  /** Form submission handler to automatically reset input and append a user message */
34
34
  handleSubmit: (event?: {
35
35
  preventDefault?: () => void;
36
- }, chatRequestOptions?: ChatRequestOptions) => void;
37
- /**
38
- * Whether the API request is in progress
39
- *
40
- * @deprecated use `status` instead
41
- */
42
- isLoading: Ref<boolean>;
36
+ }, chatRequestOptions?: ChatRequestOptions & {
37
+ files?: FileList | FileUIPart[];
38
+ }) => void;
43
39
  /**
44
40
  * Hook status:
45
41
  *
@@ -49,24 +45,14 @@ type UseChatHelpers = {
49
45
  * - `error`: An error occurred during the API request, preventing successful completion.
50
46
  */
51
47
  status: Ref<'submitted' | 'streaming' | 'ready' | 'error'>;
52
- /** Additional data added on the server via StreamData. */
53
- data: Ref<JSONValue[] | undefined>;
54
- /** Set the data of the chat. You can use this to transform or clear the chat data. */
55
- setData: (data: JSONValue[] | undefined | ((data: JSONValue[] | undefined) => JSONValue[] | undefined)) => void;
56
48
  addToolResult: ({ toolCallId, result, }: {
57
49
  toolCallId: string;
58
50
  result: any;
59
51
  }) => void;
60
52
  /** The id of the chat */
61
- id: string;
53
+ chatId: string;
62
54
  };
63
- declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, streamProtocol, onResponse, onFinish, onError, credentials, headers: metadataHeaders, body: metadataBody, generateId, onToolCall, fetch, keepLastMessageOnError, maxSteps, experimental_prepareRequestBody, }?: UseChatOptions & {
64
- /**
65
- * Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
66
- * A maximum number is required to prevent infinite loops in the case of misconfigured tools.
67
- * By default, it's set to 1, which means that only a single LLM call is made.
68
- */
69
- maxSteps?: number;
55
+ declare function useChat<MESSAGE_METADATA = unknown>({ api, chatId, initialMessages, initialInput, streamProtocol, onFinish, onError, credentials, headers: metadataHeaders, body: metadataBody, generateId, onToolCall, fetch, maxSteps, experimental_prepareRequestBody, messageMetadataSchema, }?: OriginalUseChatOptions<MESSAGE_METADATA> & {
70
56
  /**
71
57
  * Experimental (Vue only). When a function is provided, it will be used
72
58
  * to prepare the request body for the chat API. This can be useful for
@@ -78,12 +64,12 @@ declare function useChat({ api, id, initialMessages, initialInput, sendExtraMess
78
64
  * @param requestBody The request body object passed in the chat request
79
65
  */
80
66
  experimental_prepareRequestBody?: (options: {
81
- id: string;
82
- messages: UIMessage[];
67
+ chatId: string;
68
+ messages: UIMessage<MESSAGE_METADATA>[];
83
69
  requestData?: JSONValue;
84
70
  requestBody?: object;
85
71
  }) => unknown;
86
- }): UseChatHelpers;
72
+ }): UseChatHelpers<MESSAGE_METADATA>;
87
73
 
88
74
  type UseCompletionHelpers = {
89
75
  /** The current completion result */
@@ -93,7 +79,7 @@ type UseCompletionHelpers = {
93
79
  /**
94
80
  * Send a new prompt to the API endpoint and update the completion state.
95
81
  */
96
- complete: (prompt: string, options?: RequestOptions) => Promise<string | null | undefined>;
82
+ complete: (prompt: string, options?: CompletionRequestOptions) => Promise<string | null | undefined>;
97
83
  /**
98
84
  * Abort the current API request but keep the generated tokens.
99
85
  */
@@ -118,74 +104,7 @@ type UseCompletionHelpers = {
118
104
  }) => void;
119
105
  /** Whether the API request is in progress */
120
106
  isLoading: Ref<boolean | undefined>;
121
- /** Additional data added on the server via StreamData */
122
- data: Ref<JSONValue[] | undefined>;
123
- };
124
- declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, onResponse, onFinish, onError, fetch, }?: UseCompletionOptions): UseCompletionHelpers;
125
-
126
- /**
127
- * A vue.js composable function to interact with the assistant API.
128
- */
129
-
130
- type UseAssistantHelpers = {
131
- /**
132
- * The current array of chat messages.
133
- */
134
- messages: Ref<Message[]>;
135
- /**
136
- * Update the message store with a new array of messages.
137
- */
138
- setMessages: (messagesProcessor: (messages: Message[]) => Message[]) => void;
139
- /**
140
- * The current thread ID.
141
- */
142
- threadId: Ref<string | undefined>;
143
- /**
144
- * 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.
145
- */
146
- setThreadId: (threadId: string | undefined) => void;
147
- /**
148
- * The current value of the input field.
149
- */
150
- input: Ref<string>;
151
- /**
152
- * Append a user message to the chat list. This triggers the API call to fetch
153
- * the assistant's response.
154
- * @param message The message to append
155
- * @param requestOptions Additional options to pass to the API call
156
- */
157
- append: (message: Message | CreateMessage, requestOptions?: {
158
- data?: Record<string, string>;
159
- }) => Promise<void>;
160
- /**
161
- * Abort the current request immediately, keep the generated tokens if any.
162
- */
163
- stop: ComputedRef<() => void>;
164
- /**
165
- * Handler for the `onChange` event of the input field to control the input's value.
166
- */
167
- handleInputChange: (e: Event & {
168
- target: HTMLInputElement;
169
- }) => void;
170
- /**
171
- * Handler for the `onSubmit` event of the form to append a user message and reset the input.
172
- */
173
- handleSubmit: (e: Event & {
174
- target: HTMLFormElement;
175
- }) => void;
176
- /**
177
- * Whether the assistant is currently sending a message.
178
- */
179
- isSending: ComputedRef<boolean>;
180
- /**
181
- * The current status of the assistant.
182
- */
183
- status: Ref<AssistantStatus>;
184
- /**
185
- * The current error, if any.
186
- */
187
- error: Ref<Error | undefined>;
188
107
  };
189
- declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, }: UseAssistantOptions): UseAssistantHelpers;
108
+ declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, onFinish, onError, fetch, }?: UseCompletionOptions): UseCompletionHelpers;
190
109
 
191
- export { UseAssistantHelpers, UseChatHelpers, UseCompletionHelpers, useAssistant, useChat, useCompletion };
110
+ export { UseChatHelpers, UseCompletionHelpers, useChat, useCompletion };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { UIMessage, Message, CreateMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, AssistantStatus, UseAssistantOptions } from '@ai-sdk/ui-utils';
2
- export { CreateMessage, Message, UIMessage, UseChatOptions, UseCompletionOptions } from '@ai-sdk/ui-utils';
3
- import { Ref, ComputedRef } from 'vue';
1
+ import { UIMessage, CreateUIMessage, ChatRequestOptions, FileUIPart, OriginalUseChatOptions, JSONValue, CompletionRequestOptions, UseCompletionOptions } from 'ai';
2
+ export { CreateUIMessage, UIMessage, UseChatOptions, UseCompletionOptions } from 'ai';
3
+ import { Ref } from 'vue';
4
4
 
5
- type UseChatHelpers = {
5
+ type UseChatHelpers<MESSAGE_METADATA> = {
6
6
  /** Current messages in the chat */
7
- messages: Ref<UIMessage[]>;
7
+ messages: Ref<UIMessage<MESSAGE_METADATA>[]>;
8
8
  /** The error object of the API request */
9
9
  error: Ref<undefined | Error>;
10
10
  /**
11
11
  * Append a user message to the chat list. This triggers the API call to fetch
12
12
  * the assistant's response.
13
13
  */
14
- append: (message: Message | CreateMessage, chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
14
+ append: (message: UIMessage<MESSAGE_METADATA> | CreateUIMessage<MESSAGE_METADATA>, chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
15
15
  /**
16
16
  * Reload the last AI chat response for the given chat history. If the last
17
17
  * message isn't from the assistant, it will request the API to generate a
@@ -27,19 +27,15 @@ type UseChatHelpers = {
27
27
  * edit the messages on the client, and then trigger the `reload` method
28
28
  * manually to regenerate the AI response.
29
29
  */
30
- setMessages: (messages: Message[] | ((messages: Message[]) => Message[])) => void;
30
+ setMessages: (messages: UIMessage<MESSAGE_METADATA>[] | ((messages: UIMessage<MESSAGE_METADATA>[]) => UIMessage<MESSAGE_METADATA>[])) => void;
31
31
  /** The current value of the input */
32
32
  input: Ref<string>;
33
33
  /** Form submission handler to automatically reset input and append a user message */
34
34
  handleSubmit: (event?: {
35
35
  preventDefault?: () => void;
36
- }, chatRequestOptions?: ChatRequestOptions) => void;
37
- /**
38
- * Whether the API request is in progress
39
- *
40
- * @deprecated use `status` instead
41
- */
42
- isLoading: Ref<boolean>;
36
+ }, chatRequestOptions?: ChatRequestOptions & {
37
+ files?: FileList | FileUIPart[];
38
+ }) => void;
43
39
  /**
44
40
  * Hook status:
45
41
  *
@@ -49,24 +45,14 @@ type UseChatHelpers = {
49
45
  * - `error`: An error occurred during the API request, preventing successful completion.
50
46
  */
51
47
  status: Ref<'submitted' | 'streaming' | 'ready' | 'error'>;
52
- /** Additional data added on the server via StreamData. */
53
- data: Ref<JSONValue[] | undefined>;
54
- /** Set the data of the chat. You can use this to transform or clear the chat data. */
55
- setData: (data: JSONValue[] | undefined | ((data: JSONValue[] | undefined) => JSONValue[] | undefined)) => void;
56
48
  addToolResult: ({ toolCallId, result, }: {
57
49
  toolCallId: string;
58
50
  result: any;
59
51
  }) => void;
60
52
  /** The id of the chat */
61
- id: string;
53
+ chatId: string;
62
54
  };
63
- declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, streamProtocol, onResponse, onFinish, onError, credentials, headers: metadataHeaders, body: metadataBody, generateId, onToolCall, fetch, keepLastMessageOnError, maxSteps, experimental_prepareRequestBody, }?: UseChatOptions & {
64
- /**
65
- * Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
66
- * A maximum number is required to prevent infinite loops in the case of misconfigured tools.
67
- * By default, it's set to 1, which means that only a single LLM call is made.
68
- */
69
- maxSteps?: number;
55
+ declare function useChat<MESSAGE_METADATA = unknown>({ api, chatId, initialMessages, initialInput, streamProtocol, onFinish, onError, credentials, headers: metadataHeaders, body: metadataBody, generateId, onToolCall, fetch, maxSteps, experimental_prepareRequestBody, messageMetadataSchema, }?: OriginalUseChatOptions<MESSAGE_METADATA> & {
70
56
  /**
71
57
  * Experimental (Vue only). When a function is provided, it will be used
72
58
  * to prepare the request body for the chat API. This can be useful for
@@ -78,12 +64,12 @@ declare function useChat({ api, id, initialMessages, initialInput, sendExtraMess
78
64
  * @param requestBody The request body object passed in the chat request
79
65
  */
80
66
  experimental_prepareRequestBody?: (options: {
81
- id: string;
82
- messages: UIMessage[];
67
+ chatId: string;
68
+ messages: UIMessage<MESSAGE_METADATA>[];
83
69
  requestData?: JSONValue;
84
70
  requestBody?: object;
85
71
  }) => unknown;
86
- }): UseChatHelpers;
72
+ }): UseChatHelpers<MESSAGE_METADATA>;
87
73
 
88
74
  type UseCompletionHelpers = {
89
75
  /** The current completion result */
@@ -93,7 +79,7 @@ type UseCompletionHelpers = {
93
79
  /**
94
80
  * Send a new prompt to the API endpoint and update the completion state.
95
81
  */
96
- complete: (prompt: string, options?: RequestOptions) => Promise<string | null | undefined>;
82
+ complete: (prompt: string, options?: CompletionRequestOptions) => Promise<string | null | undefined>;
97
83
  /**
98
84
  * Abort the current API request but keep the generated tokens.
99
85
  */
@@ -118,74 +104,7 @@ type UseCompletionHelpers = {
118
104
  }) => void;
119
105
  /** Whether the API request is in progress */
120
106
  isLoading: Ref<boolean | undefined>;
121
- /** Additional data added on the server via StreamData */
122
- data: Ref<JSONValue[] | undefined>;
123
- };
124
- declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, onResponse, onFinish, onError, fetch, }?: UseCompletionOptions): UseCompletionHelpers;
125
-
126
- /**
127
- * A vue.js composable function to interact with the assistant API.
128
- */
129
-
130
- type UseAssistantHelpers = {
131
- /**
132
- * The current array of chat messages.
133
- */
134
- messages: Ref<Message[]>;
135
- /**
136
- * Update the message store with a new array of messages.
137
- */
138
- setMessages: (messagesProcessor: (messages: Message[]) => Message[]) => void;
139
- /**
140
- * The current thread ID.
141
- */
142
- threadId: Ref<string | undefined>;
143
- /**
144
- * 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.
145
- */
146
- setThreadId: (threadId: string | undefined) => void;
147
- /**
148
- * The current value of the input field.
149
- */
150
- input: Ref<string>;
151
- /**
152
- * Append a user message to the chat list. This triggers the API call to fetch
153
- * the assistant's response.
154
- * @param message The message to append
155
- * @param requestOptions Additional options to pass to the API call
156
- */
157
- append: (message: Message | CreateMessage, requestOptions?: {
158
- data?: Record<string, string>;
159
- }) => Promise<void>;
160
- /**
161
- * Abort the current request immediately, keep the generated tokens if any.
162
- */
163
- stop: ComputedRef<() => void>;
164
- /**
165
- * Handler for the `onChange` event of the input field to control the input's value.
166
- */
167
- handleInputChange: (e: Event & {
168
- target: HTMLInputElement;
169
- }) => void;
170
- /**
171
- * Handler for the `onSubmit` event of the form to append a user message and reset the input.
172
- */
173
- handleSubmit: (e: Event & {
174
- target: HTMLFormElement;
175
- }) => void;
176
- /**
177
- * Whether the assistant is currently sending a message.
178
- */
179
- isSending: ComputedRef<boolean>;
180
- /**
181
- * The current status of the assistant.
182
- */
183
- status: Ref<AssistantStatus>;
184
- /**
185
- * The current error, if any.
186
- */
187
- error: Ref<Error | undefined>;
188
107
  };
189
- declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, }: UseAssistantOptions): UseAssistantHelpers;
108
+ declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, onFinish, onError, fetch, }?: UseCompletionOptions): UseCompletionHelpers;
190
109
 
191
- export { UseAssistantHelpers, UseChatHelpers, UseCompletionHelpers, useAssistant, useChat, useCompletion };
110
+ export { UseChatHelpers, UseCompletionHelpers, useChat, useCompletion };