@ai-sdk/react 1.2.12 → 2.0.0-alpha.10
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 +358 -26
- package/README.md +1 -1
- package/dist/index.d.mts +25 -160
- package/dist/index.d.ts +25 -160
- package/dist/index.js +147 -566
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -574
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,58 +1,390 @@
|
|
|
1
1
|
# @ai-sdk/react
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.0.0-alpha.10
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 98f25e5: chore (ui): remove managed chat inputs
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [98f25e5]
|
|
12
|
+
- Updated dependencies [7bb58d4]
|
|
13
|
+
- ai@5.0.0-alpha.10
|
|
14
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.10
|
|
15
|
+
|
|
16
|
+
## 2.0.0-alpha.9
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [8255639]
|
|
21
|
+
- Updated dependencies [9ae327d]
|
|
22
|
+
- ai@5.0.0-alpha.9
|
|
23
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.9
|
|
24
|
+
|
|
25
|
+
## 2.0.0-alpha.8
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [4fef487]
|
|
30
|
+
- Updated dependencies [6b1c55c]
|
|
31
|
+
- Updated dependencies [2e4f9e4]
|
|
32
|
+
- Updated dependencies [c25cbce]
|
|
33
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.8
|
|
34
|
+
- ai@5.0.0-alpha.8
|
|
35
|
+
|
|
36
|
+
## 2.0.0-alpha.7
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [db345da]
|
|
41
|
+
- Updated dependencies [9b0da33]
|
|
42
|
+
- Updated dependencies [247ee0c]
|
|
43
|
+
- ai@5.0.0-alpha.7
|
|
44
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.7
|
|
45
|
+
|
|
46
|
+
## 2.0.0-alpha.6
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [0d2c085]
|
|
51
|
+
- Updated dependencies [48a7606]
|
|
52
|
+
- ai@5.0.0-alpha.6
|
|
53
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.6
|
|
54
|
+
|
|
55
|
+
## 2.0.0-alpha.5
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [655cf3c]
|
|
60
|
+
- Updated dependencies [1675396]
|
|
61
|
+
- Updated dependencies [cf9af6e]
|
|
62
|
+
- Updated dependencies [ef256ed]
|
|
63
|
+
- Updated dependencies [1ed0287]
|
|
64
|
+
- Updated dependencies [825e8d7]
|
|
65
|
+
- Updated dependencies [7324c21]
|
|
66
|
+
- ai@5.0.0-alpha.5
|
|
67
|
+
|
|
68
|
+
## 2.0.0-alpha.4
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- 6b14724: chore (ai/react): add experimental throttle back to useChat
|
|
73
|
+
- Updated dependencies [b32c141]
|
|
74
|
+
- Updated dependencies [72d7d72]
|
|
75
|
+
- Updated dependencies [9315076]
|
|
76
|
+
- Updated dependencies [7d97ab6]
|
|
77
|
+
- Updated dependencies [37a916d]
|
|
78
|
+
- Updated dependencies [5f2b3d4]
|
|
79
|
+
- ai@5.0.0-alpha.4
|
|
80
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.4
|
|
81
|
+
|
|
82
|
+
## 2.0.0-alpha.3
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- Updated dependencies [ab7ccef]
|
|
87
|
+
- Updated dependencies [257224b]
|
|
88
|
+
- Updated dependencies [0463011]
|
|
89
|
+
- Updated dependencies [d306260]
|
|
90
|
+
- ai@5.0.0-alpha.3
|
|
91
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.3
|
|
92
|
+
|
|
93
|
+
## 2.0.0-alpha.2
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- Updated dependencies [82aa95d]
|
|
98
|
+
- ai@5.0.0-alpha.2
|
|
99
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.2
|
|
100
|
+
|
|
101
|
+
## 2.0.0-alpha.1
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- Updated dependencies [b346545]
|
|
106
|
+
- Updated dependencies [109c0ac]
|
|
107
|
+
- ai@5.0.0-alpha.1
|
|
108
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.1
|
|
109
|
+
|
|
110
|
+
## 2.0.0-canary.23
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Updated dependencies [bedb239]
|
|
115
|
+
- Updated dependencies [507ac1d]
|
|
116
|
+
- Updated dependencies [2b9bbcd]
|
|
117
|
+
- Updated dependencies [f7e8bf4]
|
|
118
|
+
- Updated dependencies [cda32ba]
|
|
119
|
+
- Updated dependencies [50f0362]
|
|
120
|
+
- Updated dependencies [ed675de]
|
|
121
|
+
- Updated dependencies [faf8446]
|
|
122
|
+
- Updated dependencies [64f6d64]
|
|
123
|
+
- ai@5.0.0-canary.24
|
|
124
|
+
- @ai-sdk/provider-utils@3.0.0-canary.19
|
|
125
|
+
|
|
126
|
+
## 2.0.0-canary.22
|
|
127
|
+
|
|
128
|
+
### Major Changes
|
|
129
|
+
|
|
130
|
+
- 40acf9b: feat (ui): introduce ChatStore and ChatTransport
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- Updated dependencies [40acf9b]
|
|
135
|
+
- @ai-sdk/provider-utils@3.0.0-canary.18
|
|
136
|
+
- ai@5.0.0-canary.23
|
|
137
|
+
|
|
138
|
+
## 2.0.0-canary.21
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- Updated dependencies [e7dc6c7]
|
|
143
|
+
- Updated dependencies [a34eb39]
|
|
144
|
+
- Updated dependencies [b33ed7a]
|
|
145
|
+
- Updated dependencies [765f1cd]
|
|
146
|
+
- ai@5.0.0-canary.22
|
|
147
|
+
|
|
148
|
+
## 2.0.0-canary.20
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [d964901]
|
|
153
|
+
- Updated dependencies [0560977]
|
|
154
|
+
- Updated dependencies [66af894]
|
|
155
|
+
- Updated dependencies [516be5b]
|
|
156
|
+
- Updated dependencies [bfbfc4c]
|
|
157
|
+
- Updated dependencies [ea7a7c9]
|
|
158
|
+
- Updated dependencies [1409e13]
|
|
159
|
+
- ai@5.0.0-canary.21
|
|
160
|
+
- @ai-sdk/provider-utils@3.0.0-canary.17
|
|
161
|
+
|
|
162
|
+
## 2.0.0-canary.19
|
|
163
|
+
|
|
164
|
+
### Major Changes
|
|
165
|
+
|
|
166
|
+
- 496bbc1: chore (ui): inline/remove ChatRequest type
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- Updated dependencies [13fef90]
|
|
171
|
+
- Updated dependencies [e90d45d]
|
|
172
|
+
- Updated dependencies [bc3109f]
|
|
173
|
+
- Updated dependencies [496bbc1]
|
|
174
|
+
- Updated dependencies [da70d79]
|
|
175
|
+
- Updated dependencies [bcea599]
|
|
176
|
+
- Updated dependencies [48d675a]
|
|
177
|
+
- Updated dependencies [c7710a9]
|
|
178
|
+
- Updated dependencies [87b828f]
|
|
179
|
+
- Updated dependencies [35fc02c]
|
|
180
|
+
- Updated dependencies [b983b51]
|
|
181
|
+
- ai@5.0.0-canary.20
|
|
182
|
+
- @ai-sdk/provider-utils@3.0.0-canary.16
|
|
183
|
+
|
|
184
|
+
## 2.0.0-canary.18
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- Updated dependencies [2d03e19]
|
|
189
|
+
- Updated dependencies [319b989]
|
|
190
|
+
- Updated dependencies [441d042]
|
|
191
|
+
- Updated dependencies [dcc549b]
|
|
192
|
+
- Updated dependencies [cb2b53a]
|
|
193
|
+
- Updated dependencies [e244a78]
|
|
194
|
+
- ai@5.0.0-canary.19
|
|
195
|
+
|
|
196
|
+
## 2.0.0-canary.17
|
|
197
|
+
|
|
198
|
+
### Patch Changes
|
|
199
|
+
|
|
200
|
+
- Updated dependencies [a571d6e]
|
|
201
|
+
- Updated dependencies [c60f895]
|
|
202
|
+
- Updated dependencies [332167b]
|
|
203
|
+
- Updated dependencies [a8c8bd5]
|
|
204
|
+
- Updated dependencies [a662dea]
|
|
205
|
+
- Updated dependencies [41fa418]
|
|
206
|
+
- @ai-sdk/provider-utils@3.0.0-canary.15
|
|
207
|
+
- ai@5.0.0-canary.18
|
|
208
|
+
|
|
209
|
+
## 2.0.0-canary.16
|
|
210
|
+
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- c34ccd7: feat (ui/react): support resuming an ongoing stream
|
|
214
|
+
- Updated dependencies [f04fb4a]
|
|
215
|
+
- Updated dependencies [fd1924b]
|
|
216
|
+
- Updated dependencies [957b739]
|
|
217
|
+
- Updated dependencies [fafc3f2]
|
|
218
|
+
- Updated dependencies [c9ad635]
|
|
219
|
+
- Updated dependencies [9bd5ab5]
|
|
220
|
+
- Updated dependencies [92cb0a2]
|
|
221
|
+
- ai@5.0.0-canary.17
|
|
222
|
+
- @ai-sdk/provider-utils@3.0.0-canary.14
|
|
223
|
+
|
|
224
|
+
## 2.0.0-canary.15
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- 6a0ff37: fix (react): integrate addToolResult into UseChatHelpers type without intersection
|
|
229
|
+
- Updated dependencies [ec78cdc]
|
|
230
|
+
- Updated dependencies [9b4d074]
|
|
231
|
+
- Updated dependencies [8b86e99]
|
|
232
|
+
- Updated dependencies [28ad69e]
|
|
233
|
+
- Updated dependencies [2524fc7]
|
|
234
|
+
- Updated dependencies [ec5933d]
|
|
235
|
+
- Updated dependencies [175b868]
|
|
236
|
+
- ai@5.0.0-canary.16
|
|
237
|
+
|
|
238
|
+
## 2.0.0-canary.14
|
|
239
|
+
|
|
240
|
+
### Patch Changes
|
|
241
|
+
|
|
242
|
+
- Updated dependencies [d9209ca]
|
|
243
|
+
- Updated dependencies [ea27cc6]
|
|
244
|
+
- Updated dependencies [0ff02bb]
|
|
245
|
+
- Updated dependencies [4bfe9ec]
|
|
246
|
+
- Updated dependencies [2877a74]
|
|
247
|
+
- ai@5.0.0-canary.15
|
|
248
|
+
- @ai-sdk/provider-utils@3.0.0-canary.13
|
|
249
|
+
|
|
250
|
+
## 2.0.0-canary.13
|
|
251
|
+
|
|
252
|
+
### Patch Changes
|
|
253
|
+
|
|
254
|
+
- Updated dependencies [9bf7291]
|
|
255
|
+
- Updated dependencies [4617fab]
|
|
256
|
+
- Updated dependencies [a76a62b]
|
|
257
|
+
- ai@5.0.0-canary.14
|
|
258
|
+
- @ai-sdk/provider-utils@3.0.0-canary.12
|
|
259
|
+
|
|
260
|
+
## 2.0.0-canary.12
|
|
261
|
+
|
|
262
|
+
### Patch Changes
|
|
263
|
+
|
|
264
|
+
- Updated dependencies [14cb3be]
|
|
265
|
+
- Updated dependencies [66962ed]
|
|
266
|
+
- Updated dependencies [9301f86]
|
|
267
|
+
- ai@5.0.0-canary.13
|
|
268
|
+
- @ai-sdk/provider-utils@3.0.0-canary.11
|
|
269
|
+
|
|
270
|
+
## 2.0.0-canary.11
|
|
271
|
+
|
|
272
|
+
### Patch Changes
|
|
273
|
+
|
|
274
|
+
- ai@5.0.0-canary.12
|
|
275
|
+
- @ai-sdk/provider-utils@3.0.0-canary.10
|
|
276
|
+
|
|
277
|
+
## 2.0.0-canary.10
|
|
278
|
+
|
|
279
|
+
### Patch Changes
|
|
280
|
+
|
|
281
|
+
- Updated dependencies [8e64e9c]
|
|
282
|
+
- ai@5.0.0-canary.11
|
|
283
|
+
- @ai-sdk/provider-utils@3.0.0-canary.9
|
|
284
|
+
|
|
285
|
+
## 2.0.0-canary.9
|
|
4
286
|
|
|
5
287
|
### Patch Changes
|
|
6
288
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
|
|
9
|
-
-
|
|
289
|
+
- Updated dependencies [d8aeaef]
|
|
290
|
+
- Updated dependencies [3e10408]
|
|
291
|
+
- ai@5.0.0-canary.10
|
|
10
292
|
|
|
11
|
-
##
|
|
293
|
+
## 2.0.0-canary.8
|
|
12
294
|
|
|
13
295
|
### Patch Changes
|
|
14
296
|
|
|
15
|
-
-
|
|
16
|
-
- Updated dependencies [
|
|
17
|
-
|
|
297
|
+
- Updated dependencies [a847c3e]
|
|
298
|
+
- Updated dependencies [5d142ab]
|
|
299
|
+
- Updated dependencies [cb9c9e4]
|
|
300
|
+
- Updated dependencies [8aa9e20]
|
|
301
|
+
- Updated dependencies [b32e192]
|
|
302
|
+
- ai@5.0.0-canary.9
|
|
303
|
+
- @ai-sdk/provider-utils@3.0.0-canary.8
|
|
18
304
|
|
|
19
|
-
##
|
|
305
|
+
## 2.0.0-canary.7
|
|
20
306
|
|
|
21
307
|
### Patch Changes
|
|
22
308
|
|
|
23
|
-
-
|
|
24
|
-
- Updated dependencies [
|
|
25
|
-
|
|
309
|
+
- Updated dependencies [5d1e3ba]
|
|
310
|
+
- Updated dependencies [26735b5]
|
|
311
|
+
- Updated dependencies [14c9410]
|
|
312
|
+
- Updated dependencies [7827a49]
|
|
313
|
+
- Updated dependencies [bd8a36c]
|
|
314
|
+
- Updated dependencies [b6f9f3c]
|
|
315
|
+
- Updated dependencies [92c8e66]
|
|
316
|
+
- Updated dependencies [fd65bc6]
|
|
317
|
+
- Updated dependencies [5bdff05]
|
|
318
|
+
- ai@5.0.0-canary.8
|
|
319
|
+
- @ai-sdk/provider-utils@3.0.0-canary.7
|
|
26
320
|
|
|
27
|
-
##
|
|
321
|
+
## 2.0.0-canary.6
|
|
28
322
|
|
|
29
323
|
### Patch Changes
|
|
30
324
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
325
|
+
- Updated dependencies [0b78e17]
|
|
326
|
+
- Updated dependencies [6fba4c7]
|
|
327
|
+
- Updated dependencies [3e3b9df]
|
|
328
|
+
- Updated dependencies [1766ede]
|
|
329
|
+
- Updated dependencies [f10304b]
|
|
330
|
+
- ai@5.0.0-canary.7
|
|
331
|
+
- @ai-sdk/provider-utils@3.0.0-canary.6
|
|
33
332
|
|
|
34
|
-
##
|
|
333
|
+
## 2.0.0-canary.5
|
|
35
334
|
|
|
36
335
|
### Patch Changes
|
|
37
336
|
|
|
38
|
-
-
|
|
39
|
-
- @ai-sdk/
|
|
337
|
+
- ai@5.0.0-canary.6
|
|
338
|
+
- @ai-sdk/provider-utils@3.0.0-canary.5
|
|
40
339
|
|
|
41
|
-
##
|
|
340
|
+
## 2.0.0-canary.4
|
|
42
341
|
|
|
43
342
|
### Patch Changes
|
|
44
343
|
|
|
45
|
-
- Updated dependencies [
|
|
46
|
-
|
|
47
|
-
-
|
|
344
|
+
- Updated dependencies [b71fe8d]
|
|
345
|
+
- Updated dependencies [d91b50d]
|
|
346
|
+
- ai@5.0.0-canary.5
|
|
347
|
+
- @ai-sdk/provider-utils@3.0.0-canary.4
|
|
348
|
+
|
|
349
|
+
## 2.0.0-canary.3
|
|
350
|
+
|
|
351
|
+
### Patch Changes
|
|
352
|
+
|
|
353
|
+
- Updated dependencies [a166433]
|
|
354
|
+
- Updated dependencies [9f95b35]
|
|
355
|
+
- @ai-sdk/provider-utils@3.0.0-canary.3
|
|
356
|
+
- @ai-sdk/ui-utils@2.0.0-canary.3
|
|
357
|
+
|
|
358
|
+
## 2.0.0-canary.2
|
|
359
|
+
|
|
360
|
+
### Patch Changes
|
|
361
|
+
|
|
362
|
+
- @ai-sdk/provider-utils@3.0.0-canary.2
|
|
363
|
+
- @ai-sdk/ui-utils@2.0.0-canary.2
|
|
364
|
+
|
|
365
|
+
## 2.0.0-canary.1
|
|
366
|
+
|
|
367
|
+
### Patch Changes
|
|
368
|
+
|
|
369
|
+
- Updated dependencies [060370c]
|
|
370
|
+
- Updated dependencies [0c0c0b3]
|
|
371
|
+
- Updated dependencies [63d791d]
|
|
372
|
+
- @ai-sdk/provider-utils@3.0.0-canary.1
|
|
373
|
+
- @ai-sdk/ui-utils@2.0.0-canary.1
|
|
374
|
+
|
|
375
|
+
## 2.0.0-canary.0
|
|
376
|
+
|
|
377
|
+
### Major Changes
|
|
48
378
|
|
|
49
|
-
|
|
379
|
+
- d5f588f: AI SDK 5
|
|
380
|
+
- 9477ebb: chore (ui): remove useAssistant hook (**breaking change**)
|
|
50
381
|
|
|
51
382
|
### Patch Changes
|
|
52
383
|
|
|
53
|
-
- Updated dependencies [
|
|
54
|
-
|
|
55
|
-
- @ai-sdk/
|
|
384
|
+
- Updated dependencies [d5f588f]
|
|
385
|
+
- Updated dependencies [9477ebb]
|
|
386
|
+
- @ai-sdk/provider-utils@3.0.0-canary.0
|
|
387
|
+
- @ai-sdk/ui-utils@2.0.0-canary.0
|
|
56
388
|
|
|
57
389
|
## 1.2.5
|
|
58
390
|
|
package/README.md
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
- [`useChat`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) hook
|
|
6
6
|
- [`useCompletion`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-completion) hook
|
|
7
|
-
- [`
|
|
7
|
+
- [`useObject`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-object) hook
|
package/dist/index.d.mts
CHANGED
|
@@ -1,169 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
-
import
|
|
1
|
+
import { UIDataPartSchemas, AbstractChat, ChatInit, UIMessage, InferUIDataParts, CompletionRequestOptions, UseCompletionOptions, Schema, DeepPartial } from 'ai';
|
|
2
|
+
export { CreateUIMessage, UIMessage, UseCompletionOptions } from 'ai';
|
|
3
|
+
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
|
+
import * as z3 from 'zod/v3';
|
|
5
|
+
import * as z4 from 'zod/v4/core';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
7
|
+
declare class Chat<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> extends AbstractChat<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS> {
|
|
8
|
+
constructor({ messages, ...init }: ChatInit<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>);
|
|
9
|
+
}
|
|
64
10
|
|
|
65
|
-
type UseChatHelpers = {
|
|
66
|
-
/** Current messages in the chat */
|
|
67
|
-
messages: UIMessage[];
|
|
68
|
-
/** The error object of the API request */
|
|
69
|
-
error: undefined | Error;
|
|
70
|
-
/**
|
|
71
|
-
* Append a user message to the chat list. This triggers the API call to fetch
|
|
72
|
-
* the assistant's response.
|
|
73
|
-
* @param message The message to append
|
|
74
|
-
* @param options Additional options to pass to the API call
|
|
75
|
-
*/
|
|
76
|
-
append: (message: Message | CreateMessage, chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
|
|
77
|
-
/**
|
|
78
|
-
* Reload the last AI chat response for the given chat history. If the last
|
|
79
|
-
* message isn't from the assistant, it will request the API to generate a
|
|
80
|
-
* new response.
|
|
81
|
-
*/
|
|
82
|
-
reload: (chatRequestOptions?: ChatRequestOptions) => Promise<string | null | undefined>;
|
|
83
|
-
/**
|
|
84
|
-
* Abort the current request immediately, keep the generated tokens if any.
|
|
85
|
-
*/
|
|
86
|
-
stop: () => void;
|
|
11
|
+
type UseChatHelpers<MESSAGE_METADATA = unknown, DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = {
|
|
87
12
|
/**
|
|
88
|
-
*
|
|
13
|
+
* The id of the chat.
|
|
89
14
|
*/
|
|
90
|
-
|
|
15
|
+
readonly id: string;
|
|
91
16
|
/**
|
|
92
17
|
* Update the `messages` state locally. This is useful when you want to
|
|
93
18
|
* edit the messages on the client, and then trigger the `reload` method
|
|
94
19
|
* manually to regenerate the AI response.
|
|
95
20
|
*/
|
|
96
|
-
setMessages: (messages:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
handleInputChange: (e: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
103
|
-
/** Form submission handler to automatically reset input and append a user message */
|
|
104
|
-
handleSubmit: (event?: {
|
|
105
|
-
preventDefault?: () => void;
|
|
106
|
-
}, chatRequestOptions?: ChatRequestOptions) => void;
|
|
107
|
-
metadata?: Object;
|
|
108
|
-
/**
|
|
109
|
-
* Whether the API request is in progress
|
|
110
|
-
*
|
|
111
|
-
* @deprecated use `status` instead
|
|
112
|
-
*/
|
|
113
|
-
isLoading: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Hook status:
|
|
116
|
-
*
|
|
117
|
-
* - `submitted`: The message has been sent to the API and we're awaiting the start of the response stream.
|
|
118
|
-
* - `streaming`: The response is actively streaming in from the API, receiving chunks of data.
|
|
119
|
-
* - `ready`: The full response has been received and processed; a new user message can be submitted.
|
|
120
|
-
* - `error`: An error occurred during the API request, preventing successful completion.
|
|
121
|
-
*/
|
|
122
|
-
status: 'submitted' | 'streaming' | 'ready' | 'error';
|
|
123
|
-
/** Additional data added on the server via StreamData. */
|
|
124
|
-
data?: JSONValue[];
|
|
125
|
-
/** Set the data of the chat. You can use this to transform or clear the chat data. */
|
|
126
|
-
setData: (data: JSONValue[] | undefined | ((data: JSONValue[] | undefined) => JSONValue[] | undefined)) => void;
|
|
127
|
-
/** The id of the chat */
|
|
128
|
-
id: string;
|
|
129
|
-
};
|
|
130
|
-
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, onToolCall, experimental_prepareRequestBody, maxSteps, streamProtocol, onResponse, onFinish, onError, credentials, headers, body, generateId, fetch, keepLastMessageOnError, experimental_throttle: throttleWaitMs, }?: UseChatOptions & {
|
|
131
|
-
key?: string;
|
|
132
|
-
/**
|
|
133
|
-
* Experimental (React only). When a function is provided, it will be used
|
|
134
|
-
* to prepare the request body for the chat API. This can be useful for
|
|
135
|
-
* customizing the request body based on the messages and data in the chat.
|
|
136
|
-
*
|
|
137
|
-
* @param messages The current messages in the chat.
|
|
138
|
-
* @param requestData The data object passed in the chat request.
|
|
139
|
-
* @param requestBody The request body object passed in the chat request.
|
|
140
|
-
*/
|
|
141
|
-
experimental_prepareRequestBody?: (options: {
|
|
142
|
-
id: string;
|
|
143
|
-
messages: UIMessage[];
|
|
144
|
-
requestData?: JSONValue;
|
|
145
|
-
requestBody?: object;
|
|
146
|
-
}) => unknown;
|
|
21
|
+
setMessages: (messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<DATA_PART_SCHEMAS>>[] | ((messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<DATA_PART_SCHEMAS>>[]) => UIMessage<MESSAGE_METADATA, InferUIDataParts<DATA_PART_SCHEMAS>>[])) => void;
|
|
22
|
+
error: Error | undefined;
|
|
23
|
+
} & Pick<AbstractChat<MESSAGE_METADATA, DATA_PART_SCHEMAS>, 'sendMessage' | 'reload' | 'stop' | 'experimental_resume' | 'addToolResult' | 'status' | 'messages'>;
|
|
24
|
+
type UseChatOptions<MESSAGE_METADATA = unknown, DATA_TYPE_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = ({
|
|
25
|
+
chat: Chat<MESSAGE_METADATA, DATA_TYPE_SCHEMAS>;
|
|
26
|
+
} | ChatInit<MESSAGE_METADATA, DATA_TYPE_SCHEMAS>) & {
|
|
147
27
|
/**
|
|
148
28
|
Custom throttle wait in ms for the chat messages and data updates.
|
|
149
29
|
Default is undefined, which disables throttling.
|
|
150
30
|
*/
|
|
151
31
|
experimental_throttle?: number;
|
|
152
|
-
/**
|
|
153
|
-
Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
|
|
154
|
-
Must be at least 1.
|
|
155
|
-
|
|
156
|
-
A maximum number is required to prevent infinite loops in the case of misconfigured tools.
|
|
157
|
-
|
|
158
|
-
By default, it's set to 1, which means that only a single LLM call is made.
|
|
159
|
-
*/
|
|
160
|
-
maxSteps?: number;
|
|
161
|
-
}): UseChatHelpers & {
|
|
162
|
-
addToolResult: ({ toolCallId, result, }: {
|
|
163
|
-
toolCallId: string;
|
|
164
|
-
result: any;
|
|
165
|
-
}) => void;
|
|
166
32
|
};
|
|
33
|
+
declare function useChat<MESSAGE_METADATA = unknown, DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas>({ experimental_throttle: throttleWaitMs, ...options }?: UseChatOptions<MESSAGE_METADATA, DATA_PART_SCHEMAS>): UseChatHelpers<MESSAGE_METADATA, DATA_PART_SCHEMAS>;
|
|
167
34
|
|
|
168
35
|
type UseCompletionHelpers = {
|
|
169
36
|
/** The current completion result */
|
|
@@ -171,7 +38,7 @@ type UseCompletionHelpers = {
|
|
|
171
38
|
/**
|
|
172
39
|
* Send a new prompt to the API endpoint and update the completion state.
|
|
173
40
|
*/
|
|
174
|
-
complete: (prompt: string, options?:
|
|
41
|
+
complete: (prompt: string, options?: CompletionRequestOptions) => Promise<string | null | undefined>;
|
|
175
42
|
/** The error object of the API request */
|
|
176
43
|
error: undefined | Error;
|
|
177
44
|
/**
|
|
@@ -208,10 +75,8 @@ type UseCompletionHelpers = {
|
|
|
208
75
|
}) => void;
|
|
209
76
|
/** Whether the API request is in progress */
|
|
210
77
|
isLoading: boolean;
|
|
211
|
-
/** Additional data added on the server via StreamData */
|
|
212
|
-
data?: JSONValue[];
|
|
213
78
|
};
|
|
214
|
-
declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, fetch,
|
|
79
|
+
declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, fetch, onFinish, onError, experimental_throttle: throttleWaitMs, }?: UseCompletionOptions & {
|
|
215
80
|
/**
|
|
216
81
|
* Custom throttle wait in ms for the completion and data updates.
|
|
217
82
|
* Default is undefined, which disables throttling.
|
|
@@ -219,7 +84,7 @@ declare function useCompletion({ api, id, initialCompletion, initialInput, crede
|
|
|
219
84
|
experimental_throttle?: number;
|
|
220
85
|
}): UseCompletionHelpers;
|
|
221
86
|
|
|
222
|
-
type Experimental_UseObjectOptions<RESULT> = {
|
|
87
|
+
type Experimental_UseObjectOptions<SCHEMA extends z4.$ZodType | z3.Schema | Schema, RESULT> = {
|
|
223
88
|
/**
|
|
224
89
|
* The API endpoint. It should stream JSON that matches the schema as chunked text.
|
|
225
90
|
*/
|
|
@@ -227,7 +92,7 @@ type Experimental_UseObjectOptions<RESULT> = {
|
|
|
227
92
|
/**
|
|
228
93
|
* A Zod schema that defines the shape of the complete object.
|
|
229
94
|
*/
|
|
230
|
-
schema:
|
|
95
|
+
schema: SCHEMA;
|
|
231
96
|
/**
|
|
232
97
|
* An unique identifier. If not provided, a random one will be
|
|
233
98
|
* generated. When provided, the `useObject` hook with the same `id` will
|
|
@@ -294,8 +159,8 @@ type Experimental_UseObjectHelpers<RESULT, INPUT> = {
|
|
|
294
159
|
*/
|
|
295
160
|
stop: () => void;
|
|
296
161
|
};
|
|
297
|
-
declare function useObject<
|
|
298
|
-
initialValue, fetch, onError, onFinish, headers, credentials, }: Experimental_UseObjectOptions<RESULT>): Experimental_UseObjectHelpers<RESULT, INPUT>;
|
|
162
|
+
declare function useObject<SCHEMA extends z4.$ZodType | z3.Schema | Schema, RESULT = InferSchema<SCHEMA>, INPUT = any>({ api, id, schema, // required, in the future we will use it for validation
|
|
163
|
+
initialValue, fetch, onError, onFinish, headers, credentials, }: Experimental_UseObjectOptions<SCHEMA, RESULT>): Experimental_UseObjectHelpers<RESULT, INPUT>;
|
|
299
164
|
declare const experimental_useObject: typeof useObject;
|
|
300
165
|
|
|
301
|
-
export { Experimental_UseObjectHelpers, Experimental_UseObjectOptions,
|
|
166
|
+
export { Chat, Experimental_UseObjectHelpers, Experimental_UseObjectOptions, UseChatHelpers, UseChatOptions, UseCompletionHelpers, experimental_useObject, useChat, useCompletion };
|